I have a sensor device connected to my Ubuntu 20 machine using a serial to usb cable. I understand that to stream data from it I need to run the following commands:
sudo -I
.stty -F /dev/ttyACM0 9600 cs8 -cstopb -parenb
.echo -e "some_string" > /dev/ttyACM0
.cat < /dev/ttyACM0
.However, I cannot be sure that my device is connected as /dev/ttyACM0
. How can I set this up? Currently it has the path /dev/bus/usb/001/005
, although the last number changes every time the device is plugged in.
In response to the comment below, here is the output I get when I disconnect the device and run dmesg | tail
(I've edited some real values):
[89092.291151] usb 1-1: USB disconnect, device number 11
[89100.310893] usb 1-1: new full-speed USB device number 12 using xhci_hcd
[89100.467562] usb 1-1: New USB device found, idVendor=SOME_ID, idProduct=SOME_PRODUCT, bcdDevice=SOME_BCD_DEVICE
[89100.467565] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[89100.467567] usb 1-1: Product: SOME_PRODUCT
[89100.467569] usb 1-1: Manufacturer: SOME_MANUFACTURER
EDIT: I have just found that I can use sudo modprobe usbserial vendor=SOME_ID product=SOME_PRODUCT
to make ttyUSB0
available. However, plugging this into the above commands and running screen /dev/ttyUSB0
only returns lots of ``` characters. Note that this stops when the device is unplugged.
I managed to get this working. The commands were:
sudo -i
rmmod ftdi_sio
rmmod usbserial
modprobe ftdi-sio
echo -n VENDOR_ID PRODUCT_ID | sudo tee /sys/bus/usb-serial/drivers/ftdi_sio/new_id
stty -F /dev/ttyUSB0 9600 cs8 -cstopb -parenb
echo -e "uud1\r" > /dev/ttyUSB0
screen /dev/ttyUSB0 9600