Virtual COM driver in Linux to receive data from USB device - linux

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.

Related

How to configure driver in Buildroot for Moxa UPort 1110 USB serial converter?

I have a board with an embedded system that is buildroot based. In "make linux-menuconfig" I would like to add the appropriate drivers for the USB-RS232 adapter "Moxa UPORT 1110". I marked in "make linux-menuconfig":
Device Drivers-> USB support -> USB Serial Converter support-> USB MoxaUPORT Serial Driver
after connecting the adapter with the device, linux will not recognize the device.
When I check "lsusb" I get:
lsusb
Bus 001 Device 006: ID 110a:1110
Bus 001 Device 001: ID 1d6b:0002
The board does not see the producer's name etc. On my Ubuntu computer I get after plugging in usb and typing "lsusb ::
Bus 001 Device 036: ID 110a:1110 Moxa Technologies Co., Ltd.
When I check dmesg after plugging in the USB and see:
[ 9752.822985] usb 1-1: USB disconnect, device number 5
[ 9754.605939] usb 1-1: new full-speed USB device number 6 using musb-hdrc
[ 9754.768212] usb 1-1: New USB device found, idVendor=110a, idProduct=1110
[ 9754.775263] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 9754.782783] usb 1-1: Product: UPort 1110
[ 9754.786903] usb 1-1: Manufacturer: Moxa Technologies Co., Ltd.
should I check any additional settings / drivers in "make linux-menuconfig" to see the USB-R232 adapter?
From looking at the Linux source code, I understand that you enabled the mxuport driver which does not cover the UPORT 1110. However, it looks like the ti_usb_3410_5052 driver does. You can enable it by setting CONFIG_USB_SERIAL_TI.
In the Buildroot sources I see that you must make sure that BR2_PACKAGE_LINUX_FIRMWARE_USB_SERIAL_TI is set in order to include the firmware file (moxa-1110.fw).
So, in make menuconfig enable USB TI 3410/5052 Serial Firmware under Target packages > Hardware handling > Firmware > linux-firmware > USB to Serial Firmware

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.

USB host and device functionality on SBC 6845 board using kernel modules

I am working on SBC 6845(Atmel processor) in linux embedded development. My kernel version is 2.6.30.
This board comes with 2 USB ports(Both with Type A), one can be configured as host and other as USB device.
I have configured these USB modules in kernel. I have burned kernel and file system with necessary modules including USB modules. I have loaded these USB modules through /init.d/rcS file.
When board turns on and I type lsmod on console it shows me these modules loaded.
When I connect board to computer, USB is not detected (device functionality).
When I connect pendrive to board, it is not detected (host functionality).
/init.d/rcS Script
#install USB Gadgate mass_storage
modprobe g_file_storage file=/home/mass_storage/backed_storage_file stall=n
losetup -o 4096 /dev/loop0 /home/mass_storage/backed_storage_file
#install USB ehci-hcd
modprobe ehci-hcd
rcS running log
g_file_storage gadget: File-backed Storage Gadget, version: 20 November 2008
g_file_storage gadget: Number of LUNs=1
g_file_storage gadget-lun0: ro=0, file: /home/mass_storage/backed_storage_file
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
atmel-ehci atmel-ehci: Atmel EHCI UHP HS
atmel-ehci atmel-ehci: new USB bus registered, assigned bus number 1
atmel-ehci atmel-ehci: irq 22, io mem 0x00800000
atmel-ehci atmel-ehci: USB 2.0 started, EHCI 1.00
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: Atmel EHCI UHP HS
usb usb1: Manufacturer: Linux 2.6.30 ehci_hcd
usb usb1: SerialNumber: atmel-ehci
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
lsmod output
Module Size Used by Not tainted
ehci_hcd 30132 0
g_file_storage 24260 0
Any help is welcome!
Your drivers seem well installed. I don't have a straight answer but I work with software-hardware integration very often. Here is what I would do to get more clues. That kind of processor often have pins that are multipurposes. Sometimes, on an evaluation board, they are not configured the way we want by default. You can look at the documentation but also, you can use an Oscilloscope and probe the D+ and D- of the USB. Are they OK when in IDLE? What happen when you connect a device on your host port? The first few things will be done by the USB controller and involves little even no interaction with the software after the controller is configured. If you see the beginning of a negociation (a bunch of 0s and 1s) then, you know your hardware is configured properly and your basic driver is installed and work properly. The result of this will narrow the scope of the problem.
You are missing upper layer drivers. EHCI is only an interface driver, you need device drivers on top of it. Board<-->PC communication is usually done via serial over USB, so for this you need USB Serial driver. In Kernel config go to Device Drivers -> USB Support -> USB Serial Converter support and select driver according to the chip on your board/cable.
Here's an example dmesg dump seen when board is connected to the Ubuntu laptop:
[ 3469.923779] usb 2-1.2: new full-speed USB device number 5 using
ehci_hcd
[ 3470.019145] cp210x 2-1.2:1.0: cp210x converter detected
[ 3470.091614] usb 2-1.2: reset full-speed USB device number 5 using
ehci_hcd
[ 3470.184995] usb 2-1.2: cp210x converter now attached to ttyUSB0
I believe similar situation is with pendrive too - upper layer driver is missing.

Discover where are my USB speakers (device)

I'm running Debian Sid and I want to know where are my USB speakers in system. For example: When I plug my pen drive, dmesg shows where it is (sda, sdb, etc). But when I plug my USB Speakers, it doesn't show anything:
[12032.284042] usb 2-2: new full speed USB device using ohci_hcd and address 2
[12032.497098] usb 2-2: New USB device found, idVendor=0d8c, idProduct=0103
[12032.497103] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[12032.497107] usb 2-2: Product: USB Sound Device
[12032.497109] usb 2-2: Manufacturer: C-Media INC.
[12032.497266] usb 2-2: configuration #1 chosen from 1 choice
How could I discover where it is? Is there a command to show devices connected?
Thank you.
It's added as the next available ALSA card.
cat /proc/asound/cards
The easiest way is to diff the listing of /dev before and after the device is connected.
(Oops, I see that I probably misunderstood the question. Sorry. I'll leave my answer in case it's remotely useful).
Try lsusb. It gives you an overview of USB devices connected.

Resources