port names on Linux?

I used to communicate with my Python program and Arduino by simply supplying the port name ("PORTx"). In Linux it seems more complicated. In the IDE I see "dev/ttyusb0" no matter which usb slot I plug the Arduino into, and when I input that as the port in PySerial I get a crash that the port doesnt exist.

Did you try "/dev/ttyUSB0"? There's a slash at the beginning and the name is case sensitive.

My Arduino ports are:

/dev/ttyACM0   (for the Uno)
/dev/ttyACM1   (for the Uno, sometimes)
/dev/ttyUSB0   (for the Leonardo)

With ttyUSB0 I get Permission Denied error

    arduinoSerialData = serial.Serial('/dev/ttyUSB0', 9600)
  File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 261, in __init__
    self.open()
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 278, in open
    raise SerialException("could not open port %s: %s" % (self._port, msg))
serial.serialutil.SerialException: could not open port /dev/ttyUSB0: [Errno 13] Permission denied: '/dev/ttyUSB0'

With anything else, "no such file or directory".

You have to have user permissions for this port. Set them or use root account.

Don't run as root, sheesh.

There are ways of getting access to devices without doing that.

Google:

/dev/ttyUSB0 python permission

I got thousands of hits, people seemed to have solved that one.

I'm using Puppy Linux at the moment which runs everything as Root. From what I recall of Xubuntu there is a group associated with the serial ports and you need to make yourself a member of that group.

...R

ghosttrain:
With ttyUSB0 I get Permission Denied error

The ports are normally owned by 'root' and accessible to members of the 'dialout' group so you need to add yourself to the 'dialout' group.

Okay, Ill test. I hope it wont ask for password every single time I’ll execute the program. That would be bad.

EDIT:

stowite:
you need to add yourself to the ‘dialout’ group.

How?
I googled “linux dialog group” without luck.

Robin2:
I’m using Puppy Linux at the moment which runs everything as Root.

Well, Robin:

All your base are belong to us

ghosttrain:
Okay, Ill test. I hope it wont ask for password every single time I'll execute the program. That would be bad.

EDIT:How?
I googled "linux dialog group" without luck.

:slight_smile: Interesting - the command is 'addgroup'. Do a man of addgroup to see the options.

If you prefer you can look under the "Administration" menu for "Users and Groups" .

How?
I googled “linux dialog group” without luck.

dialout not dialog!

or if all else fails us root enter chmod 666

Mark

I wrote

sudo adduser myname dialout

But it said I'm already in that group.
Same when addign me to group 'root'

ghosttrain:
I wrote

sudo adduser myname dialout

But it said I'm already in that group.
Same when addign me to group 'root'

I don't understand!

Login as you (not as root)
Bring up a terminal.
Invoke "qroups" to find which groups you are currently in
If the list does not include 'dialout' then invoke
sudo adduser whaterver-your-login-name-is dialout"

You may have to log out and then back in to get the system to recognize that you are now in group dialout.

Right, had to log out.

After plugging Arduino in goto terminal and type: dmesg |tail. ( Thats dmesg tail).
You should see something like:

2575.318591] usbserial: USB Serial support registered for generic
[ 2575.330603] usbcore: registered new interface driver ftdi_sio
[ 2575.330630] usbserial: USB Serial support registered for FTDI USB Serial Device
[ 2575.330824] ftdi_sio 2-1.1.1:1.0: FTDI USB Serial Device converter detected
[ 2575.330878] usb 2-1.1.1: Detected FT232RL
[ 2575.330882] usb 2-1.1.1: Number of endpoints 2
[ 2575.330886] usb 2-1.1.1: Endpoint 1 MaxPacketSize 64
[ 2575.330889] usb 2-1.1.1: Endpoint 2 MaxPacketSize 64
[ 2575.330893] usb 2-1.1.1: Setting MaxPacketSize 64
[ 2575.331831] usb 2-1.1.1: FTDI USB Serial Device converter now attached to ttyUSB0

I must be slow. I have read the link but I still don't understand.

...R

jcallen:
After plugging Arduino in goto terminal and type: dmesg |tail. ( Thats dmesg tail).
You should see something like:

2575.318591] usbserial: USB Serial support registered for generic
[ 2575.330603] usbcore: registered new interface driver ftdi_sio
[ 2575.330630] usbserial: USB Serial support registered for FTDI USB Serial Device
[ 2575.330824] ftdi_sio 2-1.1.1:1.0: FTDI USB Serial Device converter detected
[ 2575.330878] usb 2-1.1.1: Detected FT232RL
[ 2575.330882] usb 2-1.1.1: Number of endpoints 2
[ 2575.330886] usb 2-1.1.1: Endpoint 1 MaxPacketSize 64
[ 2575.330889] usb 2-1.1.1: Endpoint 2 MaxPacketSize 64
[ 2575.330893] usb 2-1.1.1: Setting MaxPacketSize 64
[ 2575.331831] usb 2-1.1.1: FTDI USB Serial Device converter now attached to ttyUSB0

Hi, what does this do exactly? The issue seems to have gotten away after I added me to the dialout group and logged out/in.

dmesg is like a running log of what Unix / Linux is doing in the background, if you want to see everything since startup type:

dmesg |less

First column is seconds since startup, its very handy for troubleshooting startup problems.