/ttyUSB1 testRead() Lock file failed

1,353 views
Skip to first unread message

Yannick Hein

unread,
Mar 28, 2015, 6:20:14 AM3/28/15
to ope...@googlegroups.com

Hi all,

I know there are a lot of topics around this issue, but none of them helped me right now.

I am using two USB-serial ports in OpenHAB, one with a self-written sml binding, one with the plain serial binding (tried v1.5.0 and 1.7.0 SNAPSHOT)
I start OH with -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyUSB1

The serial binding has the above mentioned error when starting. It worked once, now I get this error every time.

This is what I get when starting OH. This is the second time I started it, of course I do not get the first two warning when starting OH after power on.

RXTX Warning:  Removing stale lock file. /var/lock/LCK..ttyUSB0
RXTX Warning:  Removing stale lock file. /var/lock/LCK..ttyUSB1
RXTX fhs_lock() Error: opening lock file: /var/lock/LCK..ttyUSB1: File exists. It is mine

8|2/ttyUSB1 testRead() Lock file failed


My problem is the part after RXTX fhs_lock() Error:... The serial binding fails to access the USB1 port, and it seems like there is a concurrent access, but no other binding or device uses this port (afaik, how can I check?). The contents of the files /var/lock/LCK..ttyUSB0 and ..1 have the same sid. To be clear: I get the same error when powering up, i.e. when the lock files do not exist.

Both devices are mine (I start OH as root):

crw-rw---- 1 root root 188, 0 Jan  1  2013 /dev/ttyUSB0
crw-rw---- 1 root root 188, 1 Jan  1  2013 /dev/ttyUSB1

It appears to me as if the serial binding creates the lock file, then is surprised that there is one, then says "ok, never mind, it is mine", and then cannot access the port because of the lock file !?!?

Are there any stty command I can issue that might help?

A strange thing, that is maybe related:
I initialize the port right before starting OH using
stty -F "/dev/ttyUSB1" 75 time 1 min 1 -icanon -ixon
And when I keep doing stty -F "/dev/ttyUSB1" every second while OH starts, I get the correct setting in return (i.e. 75 baud). Immediately after the testRead error, the baud rate is back to 9600. Any ideas?

Thanks in advance!
Yannick

ge...@ge-volution.eu

unread,
Mar 30, 2015, 4:13:57 PM3/30/15
to ope...@googlegroups.com
Hi Yannick,

I too have two USB serial devices on my OpenHAB system, so have recently diving into this sort of issue as well.

I guess one question I would ask about your setup is are these serial ports really pointing to the correct devices?  The problem that I had was that the devices were sometimes alternating device names and thusly screwing up the binding configs and nobody was able to connect to the correct USB serial port devices.  The solution was to use udev generated links which point directly to the "by-id" device path, and include that device in the gnu.io.rxtx.SerialPorts parameter:

pi@BMS /dev/serial/by-id $ ls -l
total
0
lrwxrwxrwx
1 root root 13 Jan  1  1970 usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx
1 root root 13 Jan  1  1970 usb-RFXCOM_RFXtrx433_A1WP5709-if00-port0 -> ../../ttyUSB1

Or to create a udev rule which detects the specific serial port and creates a named symbolic link for it in /etc/udev/rules/50-usb-serial.rules:

pi@BMS /dev/serial/by-id $ cat /etc/udev/rules.d/50-usb-serial.rules
# SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{Product}=="RFXtrx433", ATTRS{SerialNumber}=="A1WP5709", SYMLINK+="USBrfxcom0", GROUP="dialout", MODE="0666"
SUBSYSTEM
=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="USBrfxcom0", GROUP="dialout", MODE="0666"
SUBSYSTEM
=="tty", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", SYMLINK+="USBteleinfo0", GROUP="dialout", MODE="0666"

From there, you know that they won't change, and hopefully the right bindings will be grabbing the right port.

Hope that helps!

Cheers,

Greg
Reply all
Reply to author
Forward
0 new messages