USB<>serial communication not working on linux - linux

I'm currently working on a project in which I have to communicate with a custom-made sonar board over an USB<>Serial connection with cts/rts hardware flow control at a baud rate of 4,499,456.
MATLAB code for sending and receiving data is already available and fully tested on Windows.
The problem occurs when trying to execute the MATLAB code on linux (Ubuntu 14.10/15.04). Both the commands for toggling the LED on the board (write) as well as receiving information (read) are not working.
Python ports of the MATLAB code using the pyserial and pylibftdi library do allow writing, but also hang on receiving data.
Does anyone have any idea as to why it does work on Windows but not Ubuntu? Maybe a driver issue? Or something having to do with cts/rts on Linux?
lsusb output
Bus 002 Device 004: ID 0403:6014 Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC
dmesg output
[11906.209231] usb 2-3: new high-speed USB device number 5 using ehci-pci
[11906.346701] usb 2-3: New USB device found, idVendor=0403, idProduct=6014
[11906.346713] usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[11906.346720] usb 2-3: Product: USB <-> Serial Converter
[11906.346725] usb 2-3: Manufacturer: FTDI
[11906.346730] usb 2-3: SerialNumber: FT69T4N
[11906.351716] ftdi_sio 2-3:1.0: FTDI USB Serial Device converter detected
[11906.351800] usb 2-3: Detected FT232H
[11906.352234] usb 2-3: FTDI USB Serial Device converter now attached to ttyUSB1
Edit: Just logging my progress in case somebody encounters the same issue. The problem seems to lie in the baudrate; changing it to 115200 allows reading from the device, but messes up sending data to it.

Apparently the FTDI driver doesn't work to well with very high/non-standard baudrates. I ended up solving this by using a baudrate of 3,000,000

Related

linux virtual comport driver for ARM cortex A8

I have been working on this problem for quite a while now and cannot seem to find the correct driver for Linux to interface with an STM32F407. The Linux runs on an AR drone 2.0. The STM already acts as a virtual Com-port as itself when I connect it to my computer and then I can interact with it. On the AR drone 2.0 it is not listed as a COM-port but it does detect it as a USB device when I attach it. When I telnet it, it gives me this information:
Bus 001 device 002: ID 0483:5740 SGS Thomson Microelectronics
Bus 001 device 001: ID 1d6b:0002
The first one is obviously the one I need to look at and I looked at the vendor ID on this website. http://www.linux-usb.org/usb.ids
this vendor ID gave me indeed the STM32F407, but I cannot find the Linux driver for this device. I was able to put the STM into a Linux computer and then looked at what driver it used.
It was the CDC_AMC driver. I looked it up but now I have the next problem.
it needs the virtual COM-Port driver to interact with the STM32.
The Drone runs on a busybox Linux version v1.14.0 and I have not enough experience with Linux to know what driver I have to use and where I can find it.
Does it also have something to do with what processor it uses? In that case, the drone has a: ARM Cortex A8 1 GHz 32-bit processor
The following is seen in the output of dmesg:
usb 1-1: new full speed USB device using musb_hdrc and address 2 ecc correction in bits 939,
usb 1-1: skipped 4 descriptors after interface
usb 1-1: default language 0x0409
usb 1-1: udev 2, busnum 1, minor = 1
usb 1-1: New USB device found, idVendor=0483, idProduct=5740
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: Pozyx Virtual ComPort in FS Mode
usb 1-1: Manufacturer: Pozyx Labs
usb 1-1: SerialNumber: 396D323F3336
usb 1-1: uevent

Linux OTG port screwing up my other host port

I've got a Variscite VAR-SOM-MX6 running a Linux 3.0.35 kernel, with two USB ports. The first port is an OTG port connected to an external mini-OTG jack. The second is an internal host port going to a hub chip, and then to some other devices.
If I've got an OTG cable plugged into the first port, telling it to be a host, then everything works fine. If I have a regular cable, or no cable at all, plugged in, then the second host port doesn't enumerate properly. There doesn't have to be anything at the other end of the cable, so this is a bug related only to whether the OTG is trying to be a host or a device.
For instance, if I plug in an OTG cable and reboot, the kernel log contains the following lines.
usb 2-1: new high speed USB device number 2 using fsl-ehci
usb 2-1: New USB device found, idVendor=0424, idProduct=2534
usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
hub 2-1:1.0: USB hub found
hub 2-1:1.0: 4 ports detected
usb 2-1.1: new high speed USB device number 3 using fsl-ehci
usb 2-1.1: New USB device found, idVendor=0424, idProduct=9e00
usb 2-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 2-1.2: new high speed USB device number 4 using fsl-ehci
usb 2-1.2: New USB device found, idVendor=0403, idProduct=6011
usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 2-1.2: Product: Quad RS232-HS
usb 2-1.2: Manufacturer: FTDI
If I then yank the OTG cable from port 1, it disconnects everything on port 2:
usb 2-1: USB disconnect, device number 2
usb 2-1.1: USB disconnect, device number 3
usb 2-1.2: USB disconnect, device number 4
and then tries to re-enumerate everything, but fails miserably:
usb 2-1: new high speed USB device number 5 using fsl-ehci
usb 2-1: new high speed USB device number 6 using fsl-ehci
usb 2-1: new high speed USB device number 7 using fsl-ehci
usb 2-1: device not accepting address 7, error -71
usb 2-1: new high speed USB device number 8 using fsl-ehci
usb 2-1: device not accepting address 8, error -71
hub 2-0:1.0: unable to enumerate USB device on port 1
I suspect that some code is using physical port numbers 1 and 2, irrespective of whether a port is a host or a device, while other code is only looking at actual host ports, and getting the port numbers confused internally. Has anyone seen this bug before? Googling didn't turn anything up. Or is there a more specialized forum where I should post this question?
In case anyone is interested, this turned out to be a hardware design issue. Both USB PHYs are powered off an internal regulator that is powered by +5V from either the host VBUS or the OTG VBUS, whichever is higher. The designer thought these were voltage sensing inputs, and drove the host VBUS with 5V through a 10K resistor. So it ran out of poop when the OTG port wasn't connected. Changing 10K to 0 ohms fixed it.

Trouble using TTL serial USB converter with CP2102

I bought a serial TTL to USB converter for monitoring my raspberry, but got stuck while booting. My OS is Ubuntu 14.04 with kernel 4.4.6
http://www.amazon.de/USB-TTL-Konverter-Modul-mit-eingebautem-CP2102/dp/B00AFRXKFU?ie=UTF8&psc=1&redirect=true&ref_=oh_aui_detailpage_o02_s00
(RaspberryPi with raspbian)
nano /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=120 elevator=deadline noatime nodiratime fsck.repair=yes data=writeback rootwait
Driver is working fine.
lsusb
Bus 002 Device 006: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
logging:
dmsg
[19265.407597] usb 2-1.2: New USB device found, idVendor=10c4, idProduct=ea60
[19265.407603] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[19265.407606] usb 2-1.2: Product: CP2102 USB to UART Bridge Controller
[19265.407609] usb 2-1.2: Manufacturer: Silicon Labs
[19265.407612] usb 2-1.2: SerialNumber: 0001
[19265.408610] cp210x 2-1.2:1.0: cp210x converter detected
[19265.408791] usb 2-1.2: cp210x converter now attached to ttyUSB1
connecting wires:
TX <-> RX
RX <-> TX
GRD <-> GRD
starting putty: sudo putty
settings:
Serial line to connect to /dev/ttyUSB1
Speed (baud) 115200
Data bits 8
Stop bits 1
Parity None
Flow control None
Serial terminal shows only one line and get stops working:
Uncompressing Linux... done, booting the kernel.
No more text.. and I can not press any key.
Any suggestion, how to fix this?
Try using console=ttyAMA0,115200 instead. Assuming your serial adapter is connected correctly (judging from the early lines, it is), you have just configured the console bootarg incorrectly.
To elaborate, the reason you get that one line is because the early bootcode doesn't care about the console bootarg, it'll write that line using a small UART driver embedded in the decompressor routine.

Virtual COM driver in Linux to receive data from USB device

I have a USB barcode reader which is developed for Windows only. But one of the developers told me that as soon as the device detects that it is connected to a virtual COM port it is ready to work.
So my question is whether I can create a virtual COM port on Linux and connect the device to this one.
Here the udevadm output when I switch on the device:
udevadm monitor --udev
UDEV [10487.232696] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
UDEV [10487.238105] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
UDEV [10507.430306] add /class/usbmisc (class)
UDEV [10507.453800] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.1 (usb)
UDEV [10507.455899] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.1/2-1.2.1:1.0 (usb)
UDEV [10507.456565] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.1/2-1.2.1:1.1 (usb)
UDEV [10507.459065] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.1/2-1.2.1:1.1/0003:1AC2:0135.0015 (hid)
UDEV [10507.461350] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.1/2-1.2.1:1.1/usbmisc/hiddev0 (usbmisc)
UDEV [10507.461669] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.1/2-1.2.1:1.1/0003:1AC2:0135.0015/hidraw/hidraw2 (hidraw)
The following is the dmsg output:
dmsg
[10473.572851] usb 2-1.2: New USB device found, idVendor=05e3, idProduct=0610
[10473.572863] usb 2-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[10473.572869] usb 2-1.2: Product: USB2.0 Hub
[10473.573596] hub 2-1.2:1.0: USB hub found
[10473.573971] hub 2-1.2:1.0: 4 ports detected
[10493.661296] usb 2-1.2.1: new high-speed USB device number 41 using ehci-pci
[10493.754539] usb 2-1.2.1: New USB device found, idVendor=1ac2, idProduct=0135
[10493.754550] usb 2-1.2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[10493.754557] usb 2-1.2.1: Product: *** USB DEVICE
[10493.754562] usb 2-1.2.1: Manufacturer: ***
[10493.754566] usb 2-1.2.1: SerialNumber: 00000017
[10493.757449] hid-generic 0003:1AC2:0135.0015: hiddev0,hidraw2: USB HID v1.10 Device [*** USB DEVICE ] on usb-0000:00:1d.0-1.2.1/input1
I played around with socat already, but I was not really successful. I would very much appreciate if one of you would be able to help me.
Thanks,
Ralf
I think you don't need to be thinking about virtual COM ports. This bar-code reader looks like it is an HID because I see messages about HID in your dmesg output. You could check for sure by looking at the actual USB descriptors of the device using lsusb.
Since it is an HID, the driver setup should be done automatically when you plug it in, and you should be able to just scan a barcode and it will probably show up on your Linux computer as if it were typed by a keyboard.
By the way, I don't think you can really "create" a virtual COM port. Normally the way it works is that the device's USB descriptors say that it has a USB CDC ACM virtual COM port, and the Linux USB drivers read these descriptors and use it to set up the PC side of the virtual COM port.

Linux and Primesense

I have for a longer time tried to get my Asus Pro Live sensor to work on Linux, currently Fedora, but I have tried ubuntu 12.04 and Ubuntu 13.10 as well. I have installed openni, openni2 and sensor_master on my computer. Everything compiles, but when I try to run NiViewer, all I get is
Could not open "1d27/0600#3/4": Failed to set USB interface!
The 55-primesense-usb.rules file is present in /etc/udev/rules.d/ and when I type lsusb it says:
Bus 003 Device 004: ID 1d27:0600 ASUS
I have googled for it but cannot find anything helpful. Does anyone have a clue where the problem is?
Some of the output from dmesg:
[55363.811218] usb 3-4: new high-speed USB device number 6 using xhci_hcd
[55363.826016] usb 3-4: New USB device found, idVendor=1d27, idProduct=0600
[55363.826018] usb 3-4: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[55363.826019] usb 3-4: Product: PrimeSense Device
[55363.826021] usb 3-4: Manufacturer: PrimeSense
[55363.826609] usb 3-4: Not enough bandwidth for new device state.
[55363.826614] usb 3-4: can't set config #1, error -28
[56819.384811] usb 3-3: USB disconnect, device number 5
I have tried both usb 2.0 and 3.0 and it works in windows.
/ Erik
The Asus Pro, like any other webcam, needs to reserve USB bandwidth, and this should be adaptive depending on the actual capture resolution and bandwidth, but that is not always the case: many WebCams, like Logitech C910 "preventively" reserve a chunk of USB capacity large enough to prevent other webcams from using it. The UVC driver, which is pervasively used in Linux knows about this under the feared I get a "No space left on device" (-28) error when trying to stream from more than one camera simultaneously., see UVC driver FAQ. This seems to be your issue. Trying to connect the cameras in your system in different USB port configurations can help.

Resources