12. USB-serial converters under Linux.

Here things vary a bit. Many of the converter cables available (which usually consists of a cable with an USB-A male to a slightly more bulkier than usual DE9 male connector end) use the PL-2303 or UC-232 chips and the corresponding pl2303 serial driver. The Linux usb_uhci system links the devices when they are connected, and reports it so we can find it directly using dmesg. Typical device names are /dev/ttyUSB0, /dev/ttyUSB1 and so on. These should be opened and otherwise handled just like the /dev/ttyS0 traditional serial port drivers. There is no longer a 8250-style UART in these anymore, but the system will expose the same device driver interface to the programmer, even though the internals are quite different.

Not all versions of these drivers and hardware units are the same. I have tested 3 different varieties of these units, (an UC-232 and two PL-2303's of different vintages) and only one of them (the oldest PL-2303) works reasonably well on the driver supplied with the kernel 2.4.20. This driver is limited to only handling the two output lines, it does not read any of the 4 input lines, so only the async data part is useful here. The oldest of the lot, the UC-232, didn't work at all, and the third, the newest PL-2303, did only receive and not transmit under this version. Actually, I have never got that old UC-232 to work under MS-windows 2000 or XP either, so it has been a bit of an unknown.

However, using kernel 2.6.10 where the pl2303 USB drivers and the usb_uhci subsystem are turned on, did make the UC-232 work, complete with the 4 inputs and 2 outputs controllable as for the traditional /dev/ttyS0. This is one better than MS-Windows! The newer PL-2303 also worked fully here. The older PL-2303 however, seemed to "stick" on its DCD line (22/25). This would go to 1 at Space, but stay at 1 until the DSR was changed from Mark to Space. Otherwise, the DSR, RTS, and RNG lines would behave properly. The reading and writing is all done using the TCIOMGET and TCIOMSET commands from ioctl.

Another old driver, from version 2.4.22 (slackware 9) does seem to allow TIOCMGET calls to read the states of DSR and CTS, but not RI and CD. I have not bothered with testing this, since the 2.6.10 kernel driver (drivers/usb/serial/pl2303.c) handles reading of all the 4 input lines.

However, even this recent kernel does not handle any of the changes on the input lines using the TIOCGICOUNT/TIOCMIWAIT mechanism. This part of the driver simply isn't present, and the ioctl() calls return -1. It may be that this can be added later, but for now, only static actions do work fine.

Programming these is thus similar to programming the regular devices, the reading and writing functions and the other IO line functions work the same as described in these previous sections.

Pinout of USB-cables and pin-headers on some SBCs.

The USB-serial cables from Adafruit have 4 cores with female connectors that fit the 0.1 inch pin-headers on Raspberry Pi or PineA64+ devices. These are used as follows:

Color Signal Raspberry Pi
ttyAMA0
Pine A64+
ttyS0
Pine A64+
ttyS1
Pine A64+
ttyS2
Pine A64+
ttyS3
Pine A64+
ttyS4
White (USB-RX) UART_TX P1/J8-8 J47-29, J51-7 J50-2 J47-8 J48-24 J48-19
Green (USB-TX) UART_RX P1/J8-10 J47-30, J51-8 J50-4 J47-10 J48-23 J48-21
Black (GND) GND P1/J8-6 J47-34, J51-6/J51-9 J50-10 J47-6 J48-25 J48-20
Red (+5V) +5V P1/J8-4 NC NC NC NC NC

To 0. Introduction

To 11. The other IO lines

To 13. On shared interrupts under Linux.

Table of ASCII codes

To index page