Skip to content

Commit

Permalink
Add nrjavaserial lock file documentation #117
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Häussler <[email protected]> (github: @cniweb)
  • Loading branch information
cniweb authored Dec 10, 2017
1 parent a67bccf commit b256e6c
Showing 1 changed file with 38 additions and 20 deletions.
58 changes: 38 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,59 @@ The second log `openHAB-start-stop.log` will be generated by starting and stoppi

Installation und Prerequisite Install Java Documentation: [Official openHAB Usage Manual](http://docs.openhab.org/installation/synology.html)

For usage of serial devices you need to check if openhab2 user has the appropriate rights to access the device in /dev and to create lock files in /run/lock
To do so the installer tries to add the openhab2 user to the groups dialout and uucp. But these groups are not present on all synology diskstations.
/run/lock for instance is created as this on a ds214play:
drwxr-xr-x 5 root root 160 Dec 9 20:11 lock
and /dev/ttyUSB0 is per default also created for root only:
crw------- 1 root root 188, 0 Dec 4 12:55 /dev/ttyUSB0
For usage of serial devices you need to check if openhab user has the appropriate rights to access the device in `/dev` and to create lock files in `/run/lock`

To do so the installer tries to add the `openhab` user to the groups `dialout` and `uucp`. But these groups are not present on all synology diskstations.

`/run/lock` for instance is created as this on a ds214play:

`drwxr-xr-x 5 root root 160 Dec 9 20:11 lock`

and `/dev/ttyUSB0` is per default also created for root only:

`crw------- 1 root root 188, 0 Dec 4 12:55 /dev/ttyUSB0`

The result in nrjavaserial / RXTX to access this port would be a no port found exception.

To correct this you need three steps (login as admin on diskstations ssh login):
a) create a group and assign openhab2 user to it
sudo synogroup --add uucp openhab2

b) setup udev rule so that access rights in /dev/ are permanent and reload udev rules
a) create a group and assign openhab user to it

`sudo synogroup --add uucp openhab`

b) setup udev rule so that access rights in `/dev/` are permanent and reload udev rules

example for pl2303 usb to serial converter:
sudo echo 'SUBSYSTEM=="tty", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", GROUP="uucp", MODE="0660"' >>/usr/lib/udev/rules.d/50-yourrules

`sudo echo 'SUBSYSTEM=="tty", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", GROUP="uucp", MODE="0660"' >>/usr/lib/udev/rules.d/50-yourrules`

example for general ttyUSB rule:
sudo echo 'KERNEL=="ttyUSB*", ACTION=="add", MODE="0660", GROUP="uucp"' >>/usr/lib/udev/rules.d/50-yourrules

`sudo echo 'KERNEL=="ttyUSB*", ACTION=="add", MODE="0660", GROUP="uucp"' >>/usr/lib/udev/rules.d/50-yourrules`

reload rules now:
sudo udevadm control --reload

c) enable access for openhab2 user for lock file creation
`sudo udevadm control --reload`

c) enable access for openhab user for lock file creation

`chmod 0775 /run/lock`

`chown root.uucp /run/lock`

edit `/etc/init/root-file-system.conf` to persist this change.

chmod 0775 /run/lock
chown root.uucp /run/lock
`sudo vi /etc/init/root-file-system.conf`

edit /etc/init/root-file-system.conf to persist this change.
sudo vi /etc/init/root-file-system.conf
change line
/bin/mkdir -p /run/lock || true

`/bin/mkdir -p /run/lock || true`

to
/bin/mkdir -m 0775 -p /run/lock || true
chown root.uucp /run/lock || true

`/bin/mkdir -m 0775 -p /run/lock || true`

`chown root.uucp /run/lock || true`

## Forum

Expand Down

0 comments on commit b256e6c

Please sign in to comment.