USB Problems on linux

I am trying to figure out how USB works on openhabian on rpi3B+.

On windows USB sticks shows up as com5, com17 and so on… And the numbers changes on reboot. On my RPI I seem to experience the same:

So i have a usb rs485 dongle using the modbus binding, this now throws me tons of errors, and this is enough to make the whole Openhab to freeze, GUI, works fine, but no other events are occuring!!

2018-10-30 07:40:17.639 [ERROR] [et.wimpi.modbus.net.SerialConnection] - open port failed: Unknown Linux Application

2018-10-30 07:40:17.643 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: open port failed: Unknown Linux Application. Connection SerialConnection@b47d5d[portName=/dev/ttyUSB0,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@1a79a88[portName=/dev/ttyUSB0]

2018-10-30 07:40:19.372 [ERROR] [et.wimpi.modbus.net.SerialConnection] - open port failed: Unknown Linux Application

2018-10-30 07:40:19.375 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 2/3 error: open port failed: Unknown Linux Application. Connection SerialConnection@b47d5d[portName=/dev/ttyUSB0,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@1a79a88[portName=/dev/ttyUSB0]

2018-10-30 07:40:21.137 [ERROR] [et.wimpi.modbus.net.SerialConnection] - open port failed: Unknown Linux Application

2018-10-30 07:40:21.140 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 3/3 error: open port failed: Unknown Linux Application. Connection SerialConnection@b47d5d[portName=/dev/ttyUSB0,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@1a79a88[portName=/dev/ttyUSB0]

2018-10-30 07:40:21.143 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - re-connect reached max tries 3, throwing last error: open port failed: Unknown Linux Application. Connection SerialConnection@b47d5d[portName=/dev/ttyUSB0,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@1a79a88[portName=/dev/ttyUSB0]

2018-10-30 07:40:21.146 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection SerialConnection@b47d5d[portName=/dev/ttyUSB0,port=<null>] for endpoint ModbusSerialSlaveEndpoint@1a79a88[portName=/dev/ttyUSB0]: open port failed: Unknown Linux Application

So when I open up the USB I get this:

[07:57:39] openhabian@openHABianPi:~$ lsusb
Bus 001 Device 005: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I want to make static names to my usb dongles

`sudo nano /etc/udev/rules.d/99-usb-serial.rules`
`SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", OWNER="openhab" SYMLINK="modbus"`

and for my dmx dongle i followed another tutorial:

sudo nano /etc/udev/rules.d/30-ftdidmx.rules

#KERNEL=="ttyUSB*", MODE="0666"

SUBSYSTEM=="usb|usb_device", ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", GROUP="dialout"
  1. should every USB dongle have its own file?
  2. what should the files be called?
  3. what subsystem should it be?
  4. how do I know which group it should be?
  5. how should the cfg file look like, i.e whats the usb name? serial.vvfan.connection=/dev/ttyUSB0:19200:8:none:1:rtu:35:5000

Thanks for any input on this topic…

Try looking for the softlink that is created for each device.

I’m sure I’ve seen a system folder called “device_by_name” somewhere, but I can’t find it right now.

Updated, please refer to my later post for more information on the by-path symlinks. (Post No. 8)

Thanks, however all my question are still the same after reading it though, they only talk about giving static name to one device.

  1. should every USB dongle have its own file?
  2. what should the files be called?
  3. what subsystem should it be?
  4. how do I know which group it should be?
  5. how should the cfg file look like, i.e whats the usb name? serial.vvfan.connection=/dev/ttyUSB0:19200:8:none:1:rtu:35:5000

Have you tried adding the USB info to the EXTRA_JAVA_OPTS in etc/default/openhab2 ? Openhabian should take care of the rest.

Yes. On Linux EVERYTHING is a file. Each device gets it’s own file.

Usually the device files created are named /dev/ttyUSB# or /dev/ttyAM#.

I don’t understand the question.

It will probably come up with either dialout or tty as the group. Make sure that what ever user needs to read/write to the device (i.e. openhab) is a member of that group. You can see by running ls -l /dev/tty*.

/dev/ttyUSB0

As with Windows, if you have more than one USB serial device then they may not end up on the same /dev/ttyUSB#. The link Stuart provided is a way to figure out which /dev/ttyUSB# a specific device came up on and link that to a static name you can use in OH. That way, no matter what /dev/ttyUSB# it shows up on it will have a static name.

As H102 indicates, you may need to add the device as EXTRA_JAVA_OPTS as well.

1 Like

Thanks for the clarifying of question 4.

Yes, like tty0,tty1 and so on, but when you use symlink should that be defined in one file or having one for each usb device?

  1. sudo nano /etc/udev/rules.d/99-usb-serial.rules
  2. sudo nano /etc/udev/rules.d/30-ftdidmx.rules

and so on

In the usb sym file for that device there is a subsystem setting, but I do not understand what it means:

I thought the whole point was that it then could be refered to as :
SYMLINK="modbus"
modbus or sth like dev/modbus…

Basically on the internet I found two quite differnet examples of symlink files and i do not quite understand the differences and how it should be set up to properly work with OH:

  1. SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", OWNER="openhab" SYMLINK="modbus"
  2. SUBSYSTEM=="usb|usb_device", ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", GROUP="dialout"

Question 6 :slight_smile: How do I find out which user belongs to which group as well?
So any help on this topic would be great!

I can’t help with the rest. But the last question

id openhab

This will list all the groups openhab belongs to.

If it helps anyone…

I have a Velleman VMBRSUSB USB serial adapter for my Velbus network.

Although the tty port is assigned the same every time, I thought I’d see if my Ubuntu 16 LTS machine automatically created a symlink for it.

I found this …

/dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00

an ls -l command shows that it is a symlink.

   root@{device}:/dev/serial/by-id#  ls -l
    total 0
    lrwxrwxrwx 1 root root 13 Oct  9 17:45 usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00 -> ../../ttyACM0

I haven’t tried running Velserv with this symlink, but I don’t see any reason why it wouldn’t work.

Curiously, there is a by-path folder too, which might be useful

cd /dev/serial/by-path

I see only this file

root@{device}:/dev/serial/by-path# ls -l
total 0
lrwxrwxrwx 1 root root 13 Oct  9 17:45 platform-12120000.usb-usb-0:1:1.0 -> ../../ttyACM0

Update

I am now running VelServ using the symlink and it’s working perfectly

./velserv - d /dev/serial/by-id/Velleman_Projects_VMB1USB_Velbus_USB_interface-if00 - p 6000

1 Like