13.09.2019
85
Error: Cannot Access /dev/ttyusb0 5,0/5 1287 reviews

I'm trying to communicate with an Arduino from Ubuntu 12.04. When plugging in the USB cable, the arduino's serial port occurs as /dev/ttyUSB0. When I try to connect to it using moserial, I'm getting an 'Could not open device /dev/ttyUSB0' error, but not when I launch moserial using sudo. What I have to configure to make the serial device accessible as normal non-root user?

Cfinley
1,4333 gold badges12 silver badges20 bronze badges

Jul 30, 2017  Welcome to LinuxQuestions.org, a friendly and active Linux Community. You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Serial binding - Could not open serial port. Setup, Configuration and Use. 1.x Compatibility. 0 Jan 19 22:15 /dev/ttyUSB0. And here is the error. So there is no problem with the port itself or with the access rights. When USB0 is occupied by modbus, serial binding is configured with USB1 and the same kind of.

Mike L.Mike L.
2,45411 gold badges42 silver badges60 bronze badges

1 Answer

You have several options:

Automatic ACL assignment

You most likely have systemd-logind or ConsoleKit running in Ubuntu, which can automatically configure ACLs on device nodes based on which user account is currenty logged in at the console. These ACLs grant access additionally to the usual permissions and can be seen using getfacl.

To use this, add the following to /etc/udev/rules.d/60-extra-acl.rules1:

(1Yes, create the file. It doesn't exist by default; the whole directory is for admin customizations.)

Group-based access

The tty devices are usually readable/writable by a specific group such as 'dialout' or 'uucp'. Add yourself to that group to gain access to all serial ports:

Don't forget to log out & log in again so that group changes get applied.

Permission or ownership changes

udev rules similar to above can also be used to set the 'main' owner & group as well as the permissions (which is how the default group got set in the first place). For example:

You can assign to OWNER, GROUP, and MODE parameters.

Temporary manual change

To do a one-time change, just use chmod and/or chown as you normally would.

grawitygrawity

Sudo Chmod -r 777 /dev/ttyusb0

253k38 gold badges534 silver badges599 bronze badges

Not the answer you're looking for? Browse other questions tagged linuxpermissions or ask your own question.

Basic Infos

Cannot Open Dev Ttyusb0

Each time i connect my ---Wemos d1 mini--- to upload a sketch arduino IDE shows me this DEBUG MESSAGE:

error: cannot access /dev/ttyUSB0

error: espcomm_open failed
error: espcomm_upload_mem failed
the selected serial port
does not exist or your board is not connected

-->The problem started when i uploaded this code:

//--------------SCRIPT---------------
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h> Barbie games for pc free download.

ESP8266WebServer server(80);

//Mis credenciales de la red a crear
char* mySsid='CarritoWiFi';
char* myPassword='SuperCarroFantastico';

void setup()
{
delay(1000);
Serial.begin(115200);

Serial.println('Configurando Access Point..');

//WiFi.mode(WIFI_AP);
WiFi.softAP(mySsid,myPassword);
IPAddress ip = WiFi.softAPIP();

Error: Cannot Access /dev/ttyusb0

Serial.println('IP:');
Serial.print(ip);

server.on('/movement', controlMovement);
server.begin();
}

Device dev ttyusb0 is locked

void loop(){
server.handleClient();
}

void controlMovement(){
String pass = server.arg('p');
if(pass'2244'){
String forward = server.arg('f');
String backward = server.arg('b');
String right = server.arg('r');
String left = server.arg('l');
Serial.println(forward+backward+right+left);
server.send(204,');
}
}
------END OF SCRIPT------
When finished uploading i pressed the reset button because the baud speed in the serial monitor was different to the one i put, and the message printing the IP seemed to have happened, so i heard that pressing the reset button would just restart the script; after severous number of tries decidered to see if it showed anything in the serial monitor (it does it all the time connected to the computer):

-----MESSAGE ON THE SERIAL MONITOR-----
ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset

load 0x4010f000, len 1384, room 16

tail 8

chksum 0x2d

csum 0x2d

v09f0c112

~ld
-----END OF MESSAGE ON THE SERIAL MONITOR-----

Cannot open dev ttyusb0

Thanks in advance 😄