Linux USB to Serial Port Converter Question

Another newbie to Linux question here. On Mac and Windows my USB to Serial converters simply show up when I cycle through the Serial Ports:

For i As Integer = 0 to System.SerialPortCount - 1 dim s as string = System.SerialPort(i).Name //Do stuff with Serial port Next

However, in Linux Mint this is not happening. This list is blank.

In terminal if I type lsusb I get Bus 002 Device 007: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
When I do dmesg | grep tty I get:

[ 0.000000] console [tty0] enabled
[ 5.477797] 00:05: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[ 79.894335] usb 2-2.2: pl2303 converter now attached to ttyUSB0
[ 2026.596446] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
[ 2043.653543] usb 2-2.2: pl2303 converter now attached to ttyUSB0
[ 3078.017310] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
[ 3089.347848] usb 2-2.2: pl2303 converter now attached to ttyUSB0
[ 3665.543535] pl2303 ttyUSB0: pl2303_get_line_request - failed: -110
[ 3666.217760] pl2303 ttyUSB0: pl2303_set_line_request - failed: -110
[ 3667.216539] pl2303 ttyUSB0: pl2303_set_control_lines - failed: -110

So I think the OS is recognizing the USB to Serial converter but the Xojo app is not.

What am I doing wrong? How do I get the app to recognize and use this serial device?

are you in the dialout group?

sudo adduser bob dialout

[quote=216247:@Russ Lunn]are you in the dialout group?

sudo adduser bob dialout[/quote]

Um, I have no idea. How would I even check for that?

You may need to set the permissions (which will be every time you plug in the converter, unfortunately).

Try:

sudo chmod 666 /dev/ttyUSB0

if you use the id command like

id -Gn

that should show you the groups (-G) you are in with the names (-n) rather than numbers. You would need to be in the dialout group to use the usb serial.

you can add yourself to that group with

sudo adduser bob dialout

once you do that, you shouldn’t have to change permissions etc.

Is there an idiots guide on how to do use serial ports in Linux? Feeling way out of my depth on this topic.

Not an expert at Linux, but some thoughts / notes…

1 ) I take it this particular USB converter has tested out OK on Windows or Mac.

2 ) [quote=216194:@Bob Keeney][ 79.894335] usb 2-2.2: pl2303 converter now attached to ttyUSB0
[ 2026.596446] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
[ 2043.653543] usb 2-2.2: pl2303 converter now attached to ttyUSB0
[ 3078.017310] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
[ 3089.347848] usb 2-2.2: pl2303 converter now attached to ttyUSB0[/quote]

I’m guessing that these mean you unplugged and replugged the device a couple of times - if not it’s strange.

  1. [quote=216194:@Bob Keeney][ 3665.543535] pl2303 ttyUSB0: pl2303_get_line_request - failed: -110
    [ 3666.217760] pl2303 ttyUSB0: pl2303_set_line_request - failed: -110
    [ 3667.216539] pl2303 ttyUSB0: pl2303_set_control_lines - failed: -110[/quote]

These don’t look great : I have tried Googling, but no luck so far.

if it exists in /dev then Linux at least thinks it has - the following command will show a line if it has…

ls -l /dev/ttyUSB0 … ( The l characters are lowercase L )

If it does not, then the driver is not loading properly

  1. I don’t think it is a privilege issue as If I look at serial ports with Xojo I still see them OK as a normal user, but need privilege to actually open them.
    Privilege issue is typically solved by adding the user to the dialout group - ( or running Xojo apps with root privileges ).

Hm…

  1. Yes. Works well on Mac and Windows
  2. Nope. Didn’t unplug anything. So yes, something to be concerned about.
  3. I have no reference to pull from since on Mac/Windows everything ‘just works’.
  4. Thanks, I’ll take a look at this today (hopefully).

is there anything connected to the usb-serial?

you can test if it works using the program ‘screen’

screen /dev/ttyUSB0 9600

should open a terminal and connect it. if there is nothing connected to the serial port, then when you type you should see nothing returned.

if you then connect pin 2 to pin 3 (anything metal will do, like the end of a screwdriver, or a biro ) you should see what you type on the screen, this proves that what goes out of the tx pin, is received at the rx pin. it also proves the serialport is working and the driver is good.

Revisiting this (now that I have time). I do get messages if I send them to screen.

When I create a very small test project to work with serial I get an Access Denied Error when I attempt to open the serial port through the Xojo application. Changing the Permissions on the Port doesn’t change anything.

Anything to try next?

I suspect you just need to add your user to the dial out group.

That should give you permissions.

From the terminal
Assuming you are using a pi and you are logged on as pi

sudo usermod -a -G dialout pi

Unless you’ve done a load of other stuff trying to get it working, that should be all you need.

If you’ve changed permissions and stuff.

Use the command above and then

Try plugging it into a different USB port

I had mine running in minutes. Just added my user to dial out and off It went.

Ive also used them on Ubuntu a few times and never had much trouble.

Are you using an ftdi (best) or prolifi (not best )c?

Actually, this isn’t on the Pi, it’s Linux Mint and doing this through VMWare. The client has a real computer to work with.

Using sudo usermod -a -G dial out pi with the appropriate username doesn’t appear to do anything (though no errors). And I’m not getting any messages consumed by the Xojo app.

You may be having issues with USB PASS THRU to your VM.

You might find these links helpful
link text
You will also find the name TTYUSB may change each time you plug the adapter in.
link text

Ah ok.

So ‘pi’ in that command refers to the default user on the raspi.

If you change it to $USER the shell will replace it with your current username, so :-

sudo usermod -a -G dialout $USER

You will need to logout, or reboot.
Then it should work.

If I get a chance I will install mint later and have a go.
What version of mint?

I cant even get Mint to install under VMware Fusion!

hmm…

When VMWare asks you what operating system it is pick Ubuntu or Debian (I forget which) but after that it works fine.

The customer on their Dell laptops can’t get any of the data either so I don’t think VMWare has anything to do with this issue. Plus, using screen I can see the messages coming through on the serial port. What’s not happening is that the Xojo application can’t read the serial port data.

So there’s some level of disconnect between the OS and the Xojo application.

ok,

so i have created a new MINT VM on fusion,
installed the tools.
plugged in the usb which became /dev/ttyUSB0

tested with sudo screen /dev/ttyUSB0 9600 8N1 (works)
tested without sudo (screen /dev/ttyUSB0 9600 8N1) doesnt work as expected

added myself to the dialout group.
reboot

screen now works as user.

installed Xojo in Mint

ran my xojo code in the IDE.
works just fine.

so, something must be different about your setup. I used 32bit, are you using 64?

Update on this. It looks like there might be a bug in Linux using the DTR line in Serial. <https://xojo.com/issue/41513>

The customer is using a Fiber to RS232 converter at the end of the USB to Serial converter (yeah, lots of converters) and is using the DTR line power it. Works on all versions of Mac and Windows tested but not in Linux.