Ошибка при открытии последовательного порта dev ttyusb0

Offline

Зарегистрирован: 03.03.2020

Люди, требуется помощь …

Система Ubuntu 19.10. Плата Arduino Nano на процессоре ATmega168P (согласно мануалу).

При подключении к компу (через USB) определяется как :
Bus 001 Device 005: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

Плата с загрузчиком (мигает красный светодиод)

В IDE выставлено: Arduino Nano, процессор ATmega168,  порт ttyUSB0 (стоит галочка),

Пользователь состоит в группах dialout, tty, sudo

Компиляция скетча проходит без ошибок, ошибки возникают при загрузке — пишет ошибку can’t open device «/dev/ttyUSB0», понятно, что нет доступа к девайсу через порт, но почему (?), теоретически все должно работать… Или все же плата неисправна? Или дело в процессоре ?

Запустив рабочую среду Arduino IDE (версия 1.8.9) при попытке залить скетч или открыть монитор порта получил ошибку can’t open device «/dev/ttyUSB0»: Permission denied.

Данная ошибка явно говорит об отсутствии прав для записи в порт.

Для решения проблемы, необходимо добавить пользователя, из под которого производится работа, в группу которой позволено работать с данным портом. Выяснить название группы можно следующим образом. В консоли вводим:

user@pc:~$ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 фев 17 16:36 /dev/ttyUSB0

Группа называется «dialout». Добавим себя в группу командой:

sudo usermod -a -G dialout user

Далее рекомендуют перезагрузиться или выйти и зайти в сеанс, для того чтобы изменения учетной записи применились.

Но можно поступить другим способом. Выполняем команду:

sudo chmod a+rw /dev/ttyUSB0

И порт становится доступен для работы c Arduino.

I’ve been working for quite while on little project of mine with some XBee’s. Until now all the code has been tested and working on a UBUNTU-SERVER 10.04 LTS, making use of the libftdi libraries for serial-usb simulation/conversion.

At the beginning of this week, I’ve tried to use the exact same code on a laptop with kubuntu 12.04 make using of the same library versions of libftdi.

The thing is that, in my Satellite L755 — 18K laptop, every time I now try to open my XBee device at /dev/ttyUSB0, it gives me «Bad file descriptor». From the log messages from dmesg, the device registers quite normally and can’t seem to put my finger one it.

Here it is the part of code used to open the device:

cfmakeraw(&tio);
cfsetospeed(&tio,B9600);            // 9600 baud
cfsetispeed(&tio,B9600);            // 9600 baud
tio.c_cc[VMIN]=0;
tio.c_cc[VTIME]=10;

serial_fd=open("/dev/ttyUSB0", O_RDWR);

tcsetattr(serial_fd,TCSANOW,&tio);


if (serial_fd < 0){

    cout << "Error while opening device... " << "errno = " << errno << endl;

    printf("Something went wrong with open()! %sn", strerror(errno));
    exit(1);
}

Any thoughts on the subject would be greatly appreciated.

Regards

I did all the above, but I still get this error:

Toolchain path: /home/dan/dev/esp/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
Toolchain version: esp-2020r3-49-gd5524c1
Compiler version: 8.4.0
Python requirements from /home/dan/dev/esp/ESP8266_RTOS_SDK/requirements.txt are satisfied.
App "hello-world" version: v3.4-28-g08e225dd
Flashing binaries to serial port /dev/ttyUSB0 (app at offset 0x10000)...
esptool.py v2.4.0
Traceback (most recent call last):
  File "/home/dan/.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)
OSError: [Errno 5] Input/output error: '/dev/ttyUSB0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dan/dev/esp/ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py", line 3034, in <module>
    _main()
  File "/home/dan/dev/esp/ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py", line 3027, in _main
    main()
  File "/home/dan/dev/esp/ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py", line 2735, in main
    esp = chip_class(args.port, initial_baud, args.trace)
  File "/home/dan/dev/esp/ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py", line 212, in __init__
    self._port = serial.serial_for_url(port)
  File "/home/dan/.local/lib/python3.6/site-packages/serial/__init__.py", line 90, in serial_for_url
    instance.open()
  File "/home/dan/.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 5] could not open port /dev/ttyUSB0: [Errno 5] Input/output error: '/dev/ttyUSB0'
/home/dan/dev/esp/ESP8266_RTOS_SDK/components/esptool_py/Makefile.projbuild:75: recipe for target 'flash' failed
make: *** [flash] Error 1

ttyUSB0
mod_rules

I also did this:
sudo chmod -R 777 /dev/ttyUSB0

  1. Доброво времени суток. Помогите справиться с ошибкой (can’t open device «/dev/ttyUSB0»: Permission denied) есть ссылка на документ http://playground.arduino.cc/Linux/All#Permission
    И там говориться, что нужно себя включить в группу
    usermod -a -G group-name username
    username — понятно, это свой аккаунт.
    group-name — нужно себя внести в группу, а вот в какую группу включать? Как определить?

  2. В ту, которая должна иметь право писать в устройство. Выполните в терминале команду

    На выходе должно быть что-то вроде

    crw-rw—- 1 root uucp 188, 0 ноя 16 22:40 /dev/ttyUSB0

    что означает:
    c — устройство посимвольного ввода-вывода
    rw- — владелец (в данном случае root) может читать и писать, но не запускать как программу
    rw- — участники группы (в данном случае uucp) могут читать и писать, но не запускать как программу
    — — больше никто не имеет доступа.

    Если есть группа, имеющая право писать в устройство — в неё и включайтесь. По умолчанию она может быть в разных дистрибутивах Linux разная (выше был пример из Gentoo, в Debian присваивается группа dialout). Если нет — надо крутить udev.


    shoegaze_boi нравится это.

  3. Кстати, по ссылке почти это же и написано.

  4. Благодарю за ответ.
    Действительно после прописывания в группу dialout, всё заработало (после перезагрузки).

  5. А какую группу нужно указать на Ubuntu 18.04?

  6. Некропостеры…
    Уже по несколько раз писалось все это…

    sudo usermod -a  -G tty ИМЯ_ПОЛЬЗОВАТЕЛЯ
    sudo usermod -a  -G dialout ИМЯ_ПОЛЬЗОВАТЕЛЯ


    shoegaze_boi нравится это.

  7. Всё равно не работает. У меня изначально все sudo были настроены.

    crw-rw—- 1 root dialout 188, 0 янв 14 22:56 /dev/ttyUSB0
     

    Ошибка всё та же.

    avrdude: ser_open(): can‘t open device «/dev/ttyUSB0»: Permission denied

    Что делать?

    *Если это поможет, то я сижу на Ubuntu 18.04.03*

  8. а учетная запись в группу dialout входит?

  9. Да конечно.

    shoegaze_boi : shoegaze_boi adm tty dialout cdrom sudo dip plugdev lpadmin sambashare fuse

I have two PICAXE microcontrollers. Actually, I have Ubuntu 14.04 LTS (Trusty Tahr).

I had to download the LinAXEpad application and install these libraries:

sudo apt-get install libgtk2.0-0: libcairo2 i386: i386 libpango1.0-0: libgdk-pixbuf2.0-0 i386: i386 libstdc ++ 6: i386

I followed these instructions:

4.0) Linux Installation

The AXE027 cable contains an internal electronic circuit, based upon an FTDI USB-to-serial converter chip. This chip is already supported by the default Linux installation, via the kernel driver named ‘ftdi_sio’ (kernel 2.4.20 and later). Therefore no driver download is required.

However, as many different products from many different companies all use the same FTDI chip, each product is given a unique ‘product id’ number for identification purposes.

This unique product id is programmed into the chip inside the cable, so that when the cable is connected to the computer it can be uniquely identified.

The unique product id for the AXE027 USB cable is 0xbd90. The vendor id is 0x0403. However the default driver, ftdi_sio, as installed by most Linux distributions, only recognises a couple of (default) product ids for the FTDI chip (e.g. 0x6001). Therefore it is required to ‘patch’ the driver so that it correctly supports the AXE027’s 0xbd90 product id.

All three options are checked for correct operation in the same simple way – after inserting the AXE027 cable into the USB port the symbolic link file called /dev/ttyUSB0 should automatically appear within the operating system.

Note that any application using the AXE027 cable needs to address this USB symbolic link:

/dev/ttyUSB0

Which is not the same as the traditional serial (e.g. “COM1”) port link:

/dev/ttyS0

4.2) Linux Patch Option 2 (recommended)
Create a new udev rule, so that the modprobe rule is automatically applied every time the computer boots. Create a new file (e.g. using KWrite, gedit or similar text editor) named:

/etc/udev/rules.d/99-axe027.rules

To do this, open a Terminal console and then type:

sudo kwrite /etc/udev/rules.d/99-axe027.rules

Then enter the following text (note the last two lines below should be entered as one long line) and then save the file.

# /etc/udev/rules.d/99-axe027.rules
# contains axe027 udev rule to patch default
# FTDI product id to AXE027 product id (0xbd90)
SYSFS{idProduct}=="bd90",
SYSFS{idVendor}=="0403",
RUN+="/sbin/modprobe -q ftdi_sio product=0xbd90 vendor=0x0403"

The new rule will then always be applied when the system boots. To immediately try out the new rule without rebooting open a Terminal console and then type:

(Original code)

sudo udevcontrol reload_rules

(My Code)

sudo udevadm control --reload-rules

Then, I tried to execute the LinAXEpad application, accessing to:
VIEW>>OPTIONS (choose the microcontroller), and finally «click» on FIRMWARE

I got this:

Can’t open port /dev/ttyUSB0
(err=2: No such file or directory)

What can I do?

Trying with LSUSB: http://www.subirimagenes.com/otros-lsusb-9076605.html

Trying with DMESG: http://www.subirimagenes.com/otros-dmesg-9076607.html

I did all the above, but I still get this error:

Toolchain path: /home/dan/dev/esp/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
Toolchain version: esp-2020r3-49-gd5524c1
Compiler version: 8.4.0
Python requirements from /home/dan/dev/esp/ESP8266_RTOS_SDK/requirements.txt are satisfied.
App "hello-world" version: v3.4-28-g08e225dd
Flashing binaries to serial port /dev/ttyUSB0 (app at offset 0x10000)...
esptool.py v2.4.0
Traceback (most recent call last):
  File "/home/dan/.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)
OSError: [Errno 5] Input/output error: '/dev/ttyUSB0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dan/dev/esp/ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py", line 3034, in <module>
    _main()
  File "/home/dan/dev/esp/ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py", line 3027, in _main
    main()
  File "/home/dan/dev/esp/ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py", line 2735, in main
    esp = chip_class(args.port, initial_baud, args.trace)
  File "/home/dan/dev/esp/ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py", line 212, in __init__
    self._port = serial.serial_for_url(port)
  File "/home/dan/.local/lib/python3.6/site-packages/serial/__init__.py", line 90, in serial_for_url
    instance.open()
  File "/home/dan/.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 5] could not open port /dev/ttyUSB0: [Errno 5] Input/output error: '/dev/ttyUSB0'
/home/dan/dev/esp/ESP8266_RTOS_SDK/components/esptool_py/Makefile.projbuild:75: recipe for target 'flash' failed
make: *** [flash] Error 1

ttyUSB0
mod_rules

I also did this:
sudo chmod -R 777 /dev/ttyUSB0

When I try to upload my program on the Arduino Uno Chinese clone, It says

 -> avrdude: ser_open(): can't open device "/dev/ttyUSB0": No such file or directory
ioctl("TIOCMGET"): Inappropriate ioctl for device
  • My Arduino Programmer: ArduinoISP
  • My Arduino Software version: 1.6.8
  • My OS: Linux Mint

Can you help me fix this error?

Greenonline's user avatar

Greenonline

2,8177 gold badges31 silver badges45 bronze badges

asked May 12, 2016 at 7:47

Abhay Bh's user avatar

10

This could be any number of different problems. Here are several common causes:

  1. You have multiple USB serial port devices connected to your computer. Try using the command ls -l /dev/ttyUSB* to check if your computer thinks there are more than one terminal USB device. Disconnect all of them, then only connect the Arduino Uno. Then repeat the check.

  2. You do not have permissions. This is tricky to check as Linux offers a flexible but complicated root, group and user permission paradigm. You should NOT make a habit of this, but, for a quick check, you can try running the Arduino application as root and check if you can upload a sketch to the Arduino Uno.

  3. You have a counterfeit FTDI chip on your Arduino Uno that has been rendered useless by certain versions of the Windows FTDI Driver. The USB IDs can get reset to useless values. I believe the current FTDI Windows Driver no longer does this.

  4. You did not install the Linux FTDI driver. A driver is a program to abstract the hardware from the application. In this way, different hardware can be treated the same by the application, simplifying the application. However, the wrong driver/hardware combination may not work as expected.

Greenonline's user avatar

Greenonline

2,8177 gold badges31 silver badges45 bronze badges

answered May 12, 2016 at 12:52

st2000's user avatar

st2000st2000

6,7862 gold badges10 silver badges19 bronze badges

2

I had the same problem and solved with the suggestion of ndemou:

sudo chown root:YOURUSERNAME /dev/ttyUSB0

Greenonline's user avatar

Greenonline

2,8177 gold badges31 silver badges45 bronze badges

answered Oct 27, 2016 at 22:14

João Paulo O. Freitas's user avatar

4

When I try to upload my program on the Arduino Uno Chinese clone, It says

 -> avrdude: ser_open(): can't open device "/dev/ttyUSB0": No such file or directory
ioctl("TIOCMGET"): Inappropriate ioctl for device
  • My Arduino Programmer: ArduinoISP
  • My Arduino Software version: 1.6.8
  • My OS: Linux Mint

Can you help me fix this error?

Greenonline's user avatar

Greenonline

2,8177 gold badges31 silver badges45 bronze badges

asked May 12, 2016 at 7:47

Abhay Bh's user avatar

10

This could be any number of different problems. Here are several common causes:

  1. You have multiple USB serial port devices connected to your computer. Try using the command ls -l /dev/ttyUSB* to check if your computer thinks there are more than one terminal USB device. Disconnect all of them, then only connect the Arduino Uno. Then repeat the check.

  2. You do not have permissions. This is tricky to check as Linux offers a flexible but complicated root, group and user permission paradigm. You should NOT make a habit of this, but, for a quick check, you can try running the Arduino application as root and check if you can upload a sketch to the Arduino Uno.

  3. You have a counterfeit FTDI chip on your Arduino Uno that has been rendered useless by certain versions of the Windows FTDI Driver. The USB IDs can get reset to useless values. I believe the current FTDI Windows Driver no longer does this.

  4. You did not install the Linux FTDI driver. A driver is a program to abstract the hardware from the application. In this way, different hardware can be treated the same by the application, simplifying the application. However, the wrong driver/hardware combination may not work as expected.

Greenonline's user avatar

Greenonline

2,8177 gold badges31 silver badges45 bronze badges

answered May 12, 2016 at 12:52

st2000's user avatar

st2000st2000

6,7862 gold badges10 silver badges19 bronze badges

2

I had the same problem and solved with the suggestion of ndemou:

sudo chown root:YOURUSERNAME /dev/ttyUSB0

Greenonline's user avatar

Greenonline

2,8177 gold badges31 silver badges45 bronze badges

answered Oct 27, 2016 at 22:14

João Paulo O. Freitas's user avatar

4

  • Ошибка при открытии порта минбанк
  • Ошибка при открытии порта com3
  • Ошибка при открытии повер поинт
  • Ошибка при открытии плей маркета df dferh 01
  • Ошибка при открытии панели управления nvidia