2

I'm trying to communicate with hardware over USB CDC and Raspberry Pi 3. When the hardware is plugged in it shows as /dev/ttyACM0 and I can open the serial port. However I am never receiving any data. The hardware is sending data and I can see it when I plug it into my PC, but when connected to the Pi nothing seems to be received.

This is a stripped down python script I've tried to use to see if any data is coming through - it will just keep waiting for data that never arrives. I've tried changing the settings and using serial.inWaiting(), but nothing seems to work.

import serial
import time

port = serial.Serial(
    port='/dev/ttyACM0',
    baudrate=9600,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS,
    timeout=None,
    )

port.setDTR(1)

while True:
    time.sleep(1)
    command = port.read()
    print command

Is there anything specific I need to do on the Pi 3 in order to receive data?

1

I'm answering myself in case it helps anyone else. It turned out this is a problem with power - the script above works just fine and I can see the data coming through when the hardware is connected to an externally powered USB hub that connects to the Pi rather than directly into the Pi 3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.