I have a usb device that I am playing with that I have not found a driver for, and I am using it as an opportunity to learn a bit about Linux devices, drivers, and how hardware is handled by the OS. I am using opensuse 12.3
My question is about the /dev/serial directory. I noticed that when I plug this device in, the directory /dev/serial appears and I have an entry that must be this device. When I unplug the device, the entire /dev/serial directory goes away. This is what I see when I look in the directory with the device plugged in to a USB port:
dmiller@linux-tqci:/dev/serial> ls
by-id by-path
dmiller@linux-tqci:/dev/serial> cd by-path
dmiller@linux-tqci:/dev/serial/by-path> ls
pci-0000:00:02.0-usb-0:5:1.0-port0
dmiller@linux-tqci:/dev/serial/by-path>
Does this mean that this device is ready to go as a character device or something? I seem to be able to open the device and write to it, but I never get any response when I read from it.
I had assumed that I would need to build and register a device driver that would interface with the USB system, but when I saw this, I thought maybe not. Since this particular USB device only has one bulk endpoint in, and one bulk endpoint out, maybe it could already be setup in the system as a character device?
Any information about the behavior of devices in the /dev/serial directory would be appreciated.
If you have ‘usbutils’ installed, it is also possible to run
usb-devices
and if it is supported by a kernel driver, the driver associated (if any) will be reported.
My question is about the /dev/serial directory. I noticed that when I plug this device in, the directory /dev/serial appears and I have an entry that must be this device. When I unplug the device, the entire /dev/serial directory goes away.
The kernel drivers are responsible for the device node creation. The kernel communicates with the device manager (udev) by uevent messages. It is udev that is responsible for the dynamic management of device nodes in /dev, permissions, symlinks, running scripts etc, done by udev rules (in the /etc/udev/rules.d/, /lib/udev/rules.d/, and /run/udev/rules.d/ directories).
This is what I see when I look in the directory with the device plugged in to a USB port:
dmiller@linux-tqci:/dev/serial> ls
by-id by-path
dmiller@linux-tqci:/dev/serial> cd by-path
dmiller@linux-tqci:/dev/serial/by-path> ls
pci-0000:00:02.0-usb-0:5:1.0-port0
dmiller@linux-tqci:/dev/serial/by-path>
Does this mean that this device is ready to go as a character device or something? I seem to be able to open the device and write to it, but I never get any response when I read from it.
It depends on what the device in question is, and how it needs to be handled. If it is a serial device, then it may be supported by the generic ‘usbserial’ kernel driver, or if is like my USB-serial converter, it may use some other driver. My device has a chipset that is supported by the ‘pl2303’ driver for example.
Any information about the behavior of devices in the /dev/serial directory would be appreciated.
Thanks
Dave Miller
I missed this before.
The /dev/serial/by-path and /dev/serial/by-path symlinks to the actual ‘kernel-generated’ device nodes are created by udev rules. In particular: /lib/udev/rules.d/60-persistent-serial.rules
They are useful if you want to communicate with a particular hardware device, since the kernel naming is not persistent, and depends on the order in which are the devices discovered by the kernel, or if the devices are removed or added at random times for example. (Additional custom rules can be used to create symlinks with convenient names if desired.)
For example, I have an in-built 3G broadband modem device (which is supported by the sierra driver)
ls -l /dev/serial/by-id
total 0
lrwxrwxrwx 1 root root 13 Nov 8 20:30 usb-0557_2008-if00-port0 -> ../../ttyUSB3
lrwxrwxrwx 1 root root 13 Nov 8 19:57 usb-HP_HP_hs2300_HSDPA_Broadband_Wireless_Module-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Nov 8 19:57 usb-HP_HP_hs2300_HSDPA_Broadband_Wireless_Module-if00-port1 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Nov 8 19:57 usb-HP_HP_hs2300_HSDPA_Broadband_Wireless_Module-if00-port2 -> ../../ttyUSB2
When my USB-serial converter is attached, it then shows up like
Thanks – I did not use -l when I did the directory listing, and I did not notice that it was a link to /dev/ttyUSB2
dmiller@linux-tqci:/dev/serial/by-id> ls -l
total 0
lrwxrwxrwx 1 root root 13 Nov 8 06:43 usb-FTDI_FT232R_USB_UART_A6028N64-if00-port0 -> ../../ttyUSB2
I believe this does mean that it is essentially ready to go. My guess is that internally it looks like a serial port connected to legacy hardware, so even though it is a direct connect USB device, I may have to set up a baud rate. It seems clear that the USB part is a common chip that my linux system knew about and so I already have a driver. The actual device is an Insteon Model 2413U. You can look at it here if you want to see what it is: PowerLinc Modem - INSTEON Serial Interface (Dual-Band) - Smarthome
Here is the output from lsusb and usb-devices so you can see what I am talking about.
lsusb output with unit plugged in:
dmiller@linux-tqci:/dev/serial/by-path> lsusb
Bus 001 Device 003: ID 058f:6366 Alcor Micro Corp. Multi Flash Reader
Bus 002 Device 043: ID 046d:c318 Logitech, Inc. Illuminated Keyboard
Bus 002 Device 047: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
With unit removed:
dmiller@linux-tqci:/dev/serial/by-path> lsusb
Bus 001 Device 003: ID 058f:6366 Alcor Micro Corp. Multi Flash Reader
Bus 002 Device 043: ID 046d:c318 Logitech, Inc. Illuminated Keyboard
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
It works now that I got all the settings correct using stty. The settings are shown below in case anyone else is using the INSTEON Model 2413U PowerLinc Modem
dmiller@linux-tqci:~/Projects> stty -F /dev/ttyUSB2
speed 19200 baud; line = 0;
min = 1; time = 0;
-brkint -icrnl -imaxbel
-opost
-isig -icanon -iexten -echo