3

I'm trying to get a USB serial device ( a GlobalSat BU-353N5 USB GPS ) up and working on an Ubuntu 18.04 PC running as a VMWare VM. I have USB pass thru enabled and I can see the device appear and disappear when I plug and unplug it after running lsusb each time.

The Ubuntu 18.04 VM has kernel version : 5.4.0-84-generic

When I run dmesg however, it wont list any ttyUSB0 devices and it wont create a /dev/ttyUSB0 when I plug the device in. On another ubuntu PC with similar kernel version, it works fine.

So when I run my python script ( that works fine on my home PC ) I get this error :

import serial
from decimal import Decimal
ser = serial.Serial('/dev/ttyUSB0',4800,timeout=5)
while 1:
    line = ser.readline().decode()
    break

Script output :

Traceback (most recent call last):
 File "/home/xx/.local/lib/python3.6/site-packages/serial/serialposix.py", line 322, in open
  self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/ttyUSB0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "run_gps.py", line 4, in <module>
  ser = serial.Serial('/dev/ttyUSB0',4800,timeout=5)
 File "/home/xx/.local/lib/python3.6/site-packages/serial/serialutil.py", line 244, in __init__
  self.open()
 File "/home/xx/.local/lib/python3.6/site-packages/serial/serialposix.py", line 325, in open
  raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyUSB0: [Errno 2] No such file or directory: '/dev/ttyUSB0'

So wanted to make sure we had the correct drivers ( usbserial and pl2303 ) installed using this method :

$ apt list linux-modules-extra-5.4.0-84-generic

linux-modules-extra-5.4.0-84-generic/disco-updates,disco-security,now 5.4.0-84 amd64 [installed,automatic]

Then verify that the module is included in this installed package.

$ dpkg -L linux-modules-extra-5.4.0-84-generic | grep usbserial
/lib/modules/5.4.0-84-generic-generic/kernel/drivers/usb/serial/usbserial.ko
$ dpkg -L linux-modules-extra-5.4.0-84-generic | grep pl2303
/lib/modules/5.4.0-84-generic/kernel/drivers/usb/serial/pl2303.ko

Now install the kernel modules (drivers):

$ sudo modprobe usbserial
$ sudo modprobe pl2303

So now when I run lsmod, I can see the drivers in use.

testuser@ubuntu18:~/Documents# sudo lsmod
Module                  Size  Used by
pl2303                 24576  0
usbserial              49152  1 pl2303
rfcomm                 81920  4
binfmt_misc            24576  1
bnep                   24576  2
vmw_vsock_vmci_transport    32768  2
vsock                  36864  3 vmw_vsock_vmci_transport
intel_rapl_msr         20480  0
intel_rapl_common      24576  1 intel_rapl_msr
crct10dif_pclmul       16384  1

How do I confirm all components needed are in place for a connection to exist between the USB device and the linux OS e.g. need drivers, possibly a udev script, anything else?

I have seen some people working with files in /etc/udev/rules.d/ , but I am not sure if we need to modify these files manually and if so how could you build a basic script to test end to end functionality.

I'm not that experienced with linux, so need help to try and work out what's either missing and/or misconfigured. Sometimes you just don't know what you don't know. I'm not lazy, rather just absolutely flat out not sure what's broken or missing. I've spend close to 20 hours of research so far building VMs and trying ideas but so far no joy.

Any ideas appreciated.


Update 1

dmesg for faulty/not working PC: 
[ 272.061687] usb 2-2.2: new full-speed USB device number 5 using uhci_hcd 
[ 272.395020] usb 2-2.2: New USB device found, idVendor=067b, idProduct=23a3, bcdDevice= 1.05 
[ 272.395030] usb 2-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 
[ 272.395092] usb 2-2.2: Product: USB-Serial Controller 
[ 272.395100] usb 2-2.2: Manufacturer: Prolific Technology Inc. 
[ 272.395104] usb 2-2.2: SerialNumber: BGDGb115819


dmesg for working PC: 
[552777.274363] usb 1-12: new full-speed USB device number 23 using xhci_hcd 
[552777.423614] usb 1-12: New USB device found, idVendor=067b, idProduct=23a3, bcdDevice= 1.05 
[552777.423620] usb 1-12: New USB device strings: Mfr=1, Product=2, SerialNumber=3 
[552777.423623] usb 1-12: Product: USB-Serial Controller 
[552777.423627] usb 1-12: Manufacturer: Prolific Technology Inc. 
[552777.423629] usb 1-12: SerialNumber: BGDGb115819 
[552777.425292] pl2303 1-12:1.0: pl2303 converter detected 
[552777.425659] usb 1-12: pl2303 converter now attached to ttyUSB0 

Update 2

Output from dmesg just now for faulty/not working PC:

[  723.726923] usb 2-2.2: new full-speed USB device number 7 using uhci_hcd
[  724.063701] usb 2-2.2: New USB device found, idVendor=067b, idProduct=23a3, bcdDevice= 1.05
[  724.063712] usb 2-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  724.063718] usb 2-2.2: Product: USB-Serial Controller 
[  724.063723] usb 2-2.2: Manufacturer: Prolific Technology Inc. 
[  724.063727] usb 2-2.2: SerialNumber: BGDGb115819
6
  • 1
    "When I run dmesg however ..." - Little-known (newbie) fact: of all the things you've done, analyzing the syslog (e.g. retrieving kernel messages using the dmesg command) needs to be the first step in trying to solve this type of problem. Since you have one system that you claim success, and another that has issues, you need to capture the kernel messages when the USB adapter is inserted on each system, and compare them.
    – sawdust
    Commented Jan 12 at 8:14
  • Thnak you, thats really helpful!
    – steve
    Commented Jan 12 at 8:18
  • So my question now would be - what is the relevence of a missing "pl2303 converter detected" message and how we would fix it?
    – steve
    Commented Jan 12 at 8:43
  • 1
    Those kernel message should be edited into your post (so that it's readable), rather than entered as comments. The kernel messages (as expected) report that the host has detected a newly attached USB device. Those messages are from the USB Host controller driver. The next set of messages should be from the USB gadget driver, in this case, the Prolific driver. The typical reason for no driver initialized for the gadget after the USB Host finds the device is that the proper driver is not installed (in the filesystem).
    – sawdust
    Commented Jan 12 at 9:32
  • Thanks. I'm seeing using lsmod that the drivers appear to be loaded, so from my newbie perspective it looks OK ( obviously its not....). What steps would you suggest to determine what would be the correct driver please, if I've loaded what I think is the corresponding drivers for the kernel version?
    – steve
    Commented Jan 12 at 10:16

1 Answer 1

0

I finally got it working. Agreed its an older version, we are a little limited due to Vendor older product.

The solution was :

(1) Update to Ubuntu kernel 5.4.0-150-generic
(2) sudo apt-get update
(3) sudo apt-get install linux-modules-extra-5.4.0-150-generic

Then I plugged in the USB GPS device, it found it, mounted /dev/ttyUSB0 and off it went.

Seems even though I was running 5.4.0-84-generic previously, it seems the -84 version it wasnt quite good enough to handle the USB serial properly.

Thanks everyone for your help.

Edit :

If you want to run the identical python code on a Rapsberry Pi 4 B ( because the powers that be possibly wont let you upgrade your linux kernel ) then for a Raspberry Pi 4 B with a kernel 6.1.0-rpi7-rpi-v8 and with all the latest Rapsberry Pi 4 B updates ( as at 14/01/2024 ) installed from inside the Rapsberry Pi 4 B - once you plug in the same GlobalSat BU-353N5 USB GPS, it accesses the ttyUSB0 port ( but make sure the pyserial python package is installed first! ), and then it just works. Hint - if you enable the rapsberry pi as an access point, you will have a wifi-enabled GPS unit that can be used for many uses if wired or other connectivity issues stop using existing hardware for GPS use.

import serial
from decimal import Decimal

ser = serial.Serial('/dev/ttyUSB0',4800,timeout=5)

while 1:
    line = ser.readline().decode()
    print(line)
    break

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .