0

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:

  1. Enter root with sudo -I.
  2. Setup a virtual COM port with stty -F /dev/ttyACM0 9600 cs8 -cstopb -parenb.
  3. Send a command to the device to initiate data streaming with echo -e "some_string" > /dev/ttyACM0.
  4. Stream data with 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.

Pyy
  • 327
  • 6
  • 23
  • Your device is most likely at `/dev/ttyUSBx` with x being a number starting by 0. If you only have one, it will be `/dev/ttyUSB0` – Eugen Rieck Jan 19 '21 at 16:12
  • Thanks for the comment! This does not seem to exist. Any idea why? – Pyy Jan 19 '21 at 16:36
  • Plug in the USB *"cable"*, and then enter the command `dmesg | tail`. Hopefully the last line will be something like `[12415. ...] usb i-j: xyz now attached to ttyXXX0`. Append the output to your post if you need more help. – sawdust Jan 19 '21 at 23:52
  • Just added this - see above. Doesn't look like I get the expected output... – Pyy Jan 20 '21 at 09:42
  • You’ll want to make a udev rule so that it shows up as the same port every time. This may help: https://stackoverflow.com/a/55581196/624483 – rm5248 Jan 20 '21 at 16:35
  • @Pyy -- Obliterating the product information from the messages negates the purpose. The messages are now useless, and convey no information. If that's all the messages, then it appears that there is no device driver available to service that USB device. When there's no device driver, there would be no need to create any device node in **/dev**, i.e there are no major & minor numbers (from the driver) to assign to the node. – sawdust Jan 20 '21 at 22:45
  • Yes that was all the message from dmesg | tail. I've just added an edit that allows me to get the device loaded as ttyUSB0 but I still can't return data. Does that give any clues about whether a driver is installed? Where might I get a driver from? – Pyy Jan 21 '21 at 09:15
  • *"Where might I get a driver from?"* -- Talk to *"SOME_MANUFACTURER"* about their *"SOME_PRODUCT"*. Or read **Documentation/usb/usb-serial.rst** – sawdust Jan 22 '21 at 22:32

1 Answers1

1

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
Pyy
  • 327
  • 6
  • 23