Ubuntu – How to know which serial port corresponds to a PCI card

linuxmodempciserial portUbuntu

I have a vehicle computer with a internal 3G PCIe card for cellular communications, but I can't figure out which serial port I have to use in order to send AT commands.

This computer also includes a GPS onboard where I can access very well through /dev/ttyS5 with a speed of 9600. I have been reading some documents and I have seen that the 3G card speed should be 115200. This 3G PCI card is a "Telit HE910 Mini PCIe data card" and I'm running on Ubuntu 14.04.

Also, I have been trying to open a serial com with n (0…5) ports as below without results:

stty -F /dev/ttySn ispeed 115200 && cat </dev/ttySn

Executing sudo setserial -g /dev/ttyS[012345] it yields:

/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4  
/dev/ttyS1, UART: 16550A, Port: 0x02f8, IRQ: 3  
/dev/ttyS2, UART: 16550A, Port: 0x03e8, IRQ: 5  
/dev/ttyS3, UART: 16550A, Port: 0x02e8, IRQ: 7  
/dev/ttyS4, UART: 16550A, Port: 0x02f0, IRQ: 11  
/dev/ttyS5, UART: 16550A, Port: 0x02e0, IRQ: 10

Please, help to figure out how to access this 3G card through a serial port to send AT commands.

Best Answer

You can use lspci -v to list PCI device information, along with their IRQs. Correlate the IRQ listed via lspci with the setserial info you already gathered, and that should tell you what tty matches which PCI card.

Also, if the port is disabled, you can enable it using setpci. More info on how to determine that, and how to enable it, can be found here: http://www.tldp.org/HOWTO/Serial-HOWTO-8.html#ss8.7

If the port communicates via an IO address then "lspci -vv" should show "Control: I/O+ ..." with + meaning that the IO address is enabled. If it shows "I/O-" (and "I/O ports at ... [disabled]") then you may need to use the setpci command to enable it. For example "setpci -d 151f:000 command=101". 151f is the vendor id, and 000 is the device id both obtained from "lspci -n -v" or from /proc/bus/pci or from "scanpci -v". The "command=101" means that 101 is put into the command register which is the same as the "Control" register displayed by "lspci". The 101h sets two bits: the 1 sets I/O to + and the 100 part keeps SERR# set to +. In this case only the SERR# bit of the Control register was initially observed to be + when the lspci command was run. So we kept it enabled to + by setting bit 8 (where bit 0 is I/O) to 1 by the first 1 in 101. Some serial cards don't use SERR# so if you see SERR#- then there's no need to enable it so then use: command=1. Then you'll need to set up "setserial" to tell the driver the IO and IRQ.

Per the documentation for Telit, looks like that 3G modem does ACM. Check to see if you have /dev/ttyACM* devices. If so, per the documentation you can use those to send AT commands. The documenation also has instructions on how to load the kernel module, if it isn't already loaded. http://teleorigin.com/file_upl/pliki/1/Telit_HE910_HE863_GE910_UL865_Linux_Driver_UserGuide_r2.pdf

Of those only the following devices can be used:

/dev/ttyACM0: data port for PPP connections and AT commands

/dev/ttyACM3: generic port for AT commands

Related Question