DSMR binding: Unresolved requirement = solved. Now /dev/ttyUSB0 doesn't exists

Getting there. Log file is no longer complaining. I can’t select the right serial port though (not available in the drop down list). I’ll read through the various posts to figure that out. Thx.

edit: Unresolved requirement is solved. Now log-file is complaining about /dev/ttyUSB0 doesn’t exists.
When configuring the binding via PaperUI I have to manually enter the serial-port.

I’m using a socat sudo socat -d -d pty,link=/dev/ttyUSB0,cfmakeraw tcp4:192.168.2.30:2000 to add a virtual port.
I’v added the port to /etc/default/openhab2 by adding a line EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0" and openhab is part of dialout group.

Still the logfile states:

2018-08-16 23:17:41.976 [DEBUG] [internal.device.DSMRSerialAutoDevice] - Error during discovery of port settings: @text/error.connectordont_exists, current state:DISCOVER_SETTINGS.
2018-08-16 23:17:41.980 [DEBUG] [internal.device.DSMRSerialAutoDevice] - Stop discovery of port settings.
2018-08-16 23:18:11.959 [DEBUG] [nding.dsmr.handler.DSMRBridgeHandler] - No data received for 300 seconds, restarting port if possible.
2018-08-16 23:18:11.966 [DEBUG] [device.connector.DSMRSerialConnector] - Closing DSMR serial port
2018-08-16 23:18:11.970 [DEBUG] [internal.device.DSMRSerialAutoDevice] - Stop discovery of port settings.
2018-08-16 23:18:11.973 [DEBUG] [internal.device.DSMRSerialAutoDevice] - Stop discovery of port settings.
2018-08-16 23:18:11.979 [DEBUG] [device.connector.DSMRSerialConnector] - Port /dev/ttyUSB0 does not exists
gnu.io.NoSuchPortException: null
	at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:273) [210:com.neuronrobotics.nrjavaserial:3.14.0]
	at org.openhab.binding.dsmr.internal.device.connector.SerialPortManager.getIdentifier(SerialPortManager.java:36) [209:org.openhab.binding.dsmr:2.4.0.201807161200]
	at org.openhab.binding.dsmr.internal.device.connector.DSMRSerialConnector.open(DSMRSerialConnector.java:113) [209:org.openhab.binding.dsmr:2.4.0.201807161200]
	at org.openhab.binding.dsmr.internal.device.DSMRSerialAutoDevice.start(DSMRSerialAutoDevice.java:145) [209:org.openhab.binding.dsmr:2.4.0.201807161200]
	at org.openhab.binding.dsmr.internal.device.DSMRSerialAutoDevice.restart(DSMRSerialAutoDevice.java:155) [209:org.openhab.binding.dsmr:2.4.0.201807161200]
	at org.openhab.binding.dsmr.internal.device.DSMRDeviceRunnable.run(DSMRDeviceRunnable.java:78) [209:org.openhab.binding.dsmr:2.4.0.201807161200]
	at java.lang.Thread.run(Thread.java:748) [?:?]
2018-08-16 23:18:11.984 [DEBUG] [internal.device.DSMRSerialAutoDevice] - Error during discovery of port settings: @text/error.connectordont_exists, current state:DISCOVER_SETTINGS.
2018-08-16 23:18:11.987 [DEBUG] [internal.device.DSMRSerialAutoDevice] - Stop discovery of port settings.

And this is going on.

Have you added the JAVA_EXTRA_OPTS in etc/default/openhab2 ?

Note: if you are on a linux system, the framework may not see a symbolically linked device (i.e. /dev/ttyRS485). To use a symbolically linked device, add the following line to /etc/default/openhab2, EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyRS485"

More info at https://www.openhab.org/addons/bindings/pentair/#hardware-setup

/etc/default/openhab2 you may have missed the 2 at the end of openhab.

Also add openhab to part of the tty group as well.

unfortunately that was a typo in my post…not in my file.

Whats in the output of ls -al /dev

pi@raspberrypi-1:~ $ ls -al /dev
total 4
drwxr-xr-x 15 root root        3420 Aug 16 23:28 .
drwxr-xr-x 21 root root        4096 Jun  1 20:18 ..
crw-r--r--  1 root root     10, 235 Aug 16 23:26 autofs
drwxr-xr-x  2 root root         580 Aug 16 23:26 block
crw-------  1 root root     10, 234 Aug 16 23:26 btrfs-control
drwxr-xr-x  3 root root          60 Jan  1  1970 bus
crw-------  1 root root     10,  63 Aug 16 23:26 cachefiles
drwxr-xr-x  2 root root        2640 Aug 16 23:27 char
crw-------  1 root root      5,   1 Aug 16 23:26 console
crw-------  1 root root     10,  62 Aug 16 23:26 cpu_dma_latency
crw-------  1 root root     10, 203 Aug 16 23:26 cuse
drwxr-xr-x  7 root root         140 Aug 16 23:26 disk
crw-rw----  1 root video    29,   0 Aug 16 23:26 fb0
lrwxrwxrwx  1 root root          13 Nov  3  2016 fd -> /proc/self/fd
crw-rw-rw-  1 root root      1,   7 Aug 16 23:26 full
crw-rw-rw-  1 root root     10, 229 Aug 16 23:27 fuse
crw-rw----  1 root gpio    254,   0 Aug 16 23:26 gpiochip0
crw-rw----  1 root gpio    254,   1 Aug 16 23:26 gpiochip1
crw-rw----  1 root gpio    254,   2 Aug 16 23:26 gpiochip2
crw-rw----  1 root gpio    248,   0 Aug 16 23:26 gpiomem
crw-------  1 root root    247,   0 Aug 16 23:26 hidraw0
crw-------  1 root root    247,   1 Aug 16 23:26 hidraw1
crw-------  1 root root     10, 183 Aug 16 23:26 hwrng
lrwxrwxrwx  1 root root          25 Nov  3  2016 initctl -> /run/systemd/initctl/fifo
drwxr-xr-x  2 root root          60 Jan  1  1970 input
crw-r--r--  1 root root      1,  11 Aug 16 23:26 kmsg
lrwxrwxrwx  1 root root          28 Nov  3  2016 log -> /run/systemd/journal/dev-log
brw-rw----  1 root disk      7,   0 Aug 16 23:26 loop0
brw-rw----  1 root disk      7,   1 Aug 16 23:26 loop1
brw-rw----  1 root disk      7,   2 Aug 16 23:26 loop2
brw-rw----  1 root disk      7,   3 Aug 16 23:26 loop3
brw-rw----  1 root disk      7,   4 Aug 16 23:26 loop4
brw-rw----  1 root disk      7,   5 Aug 16 23:26 loop5
brw-rw----  1 root disk      7,   6 Aug 16 23:26 loop6
brw-rw----  1 root disk      7,   7 Aug 16 23:26 loop7
crw-rw----  1 root disk     10, 237 Aug 16 23:26 loop-control
drwxr-xr-x  2 root root          60 Aug 16 23:26 mapper
crw-r-----  1 root kmem      1,   1 Aug 16 23:26 mem
crw-------  1 root root     10,  59 Aug 16 23:26 memory_bandwidth
brw-rw----  1 root disk    179,   0 Aug 16 23:26 mmcblk0
brw-rw----  1 root disk    179,   1 Aug 16 23:26 mmcblk0p1
brw-rw----  1 root disk    179,   2 Aug 16 23:26 mmcblk0p2
drwxrwxrwt  2 root root          40 Jan  1  1970 mqueue
drwxr-xr-x  2 root root          60 Aug 16 23:26 net
crw-------  1 root root     10,  61 Aug 16 23:26 network_latency
crw-------  1 root root     10,  60 Aug 16 23:26 network_throughput
crw-rw-rw-  1 root root      1,   3 Aug 16 23:26 null
crw-------  1 root root    108,   0 Aug 16 23:26 ppp
crw-rw-rw-  1 root tty       5,   2 Aug 16 23:33 ptmx
drwxr-xr-x  2 root root           0 Nov  3  2016 pts
brw-rw----  1 root disk      1,   0 Aug 16 23:26 ram0
brw-rw----  1 root disk      1,   1 Aug 16 23:26 ram1
brw-rw----  1 root disk      1,  10 Aug 16 23:26 ram10
brw-rw----  1 root disk      1,  11 Aug 16 23:26 ram11
brw-rw----  1 root disk      1,  12 Aug 16 23:26 ram12
brw-rw----  1 root disk      1,  13 Aug 16 23:26 ram13
brw-rw----  1 root disk      1,  14 Aug 16 23:26 ram14
brw-rw----  1 root disk      1,  15 Aug 16 23:26 ram15
brw-rw----  1 root disk      1,   2 Aug 16 23:26 ram2
brw-rw----  1 root disk      1,   3 Aug 16 23:26 ram3
brw-rw----  1 root disk      1,   4 Aug 16 23:26 ram4
brw-rw----  1 root disk      1,   5 Aug 16 23:26 ram5
brw-rw----  1 root disk      1,   6 Aug 16 23:26 ram6
brw-rw----  1 root disk      1,   7 Aug 16 23:26 ram7
brw-rw----  1 root disk      1,   8 Aug 16 23:26 ram8
brw-rw----  1 root disk      1,   9 Aug 16 23:26 ram9
crw-rw-rw-  1 root root      1,   8 Aug 16 23:26 random
drwxr-xr-x  2 root root          60 Jan  1  1970 raw
crw-rw-r--  1 root netdev   10,  58 Aug 16 23:26 rfkill
lrwxrwxrwx  1 root root           7 Aug 16 23:26 serial1 -> ttyAMA0
drwxrwxrwt  2 root root          40 Nov  3  2016 shm
drwxr-xr-x  4 root root         240 Aug 16 23:27 snd
lrwxrwxrwx  1 root root          15 Nov  3  2016 stderr -> /proc/self/fd/2
lrwxrwxrwx  1 root root          15 Nov  3  2016 stdin -> /proc/self/fd/0
lrwxrwxrwx  1 root root          15 Nov  3  2016 stdout -> /proc/self/fd/1
crw-rw-rw-  1 root tty       5,   0 Aug 16 23:26 tty
crw--w----  1 root tty       4,   0 Aug 16 23:26 tty0
crw--w----  1 root tty       4,   1 Aug 16 23:27 tty1
crw--w----  1 root tty       4,  10 Aug 16 23:26 tty10
crw--w----  1 root tty       4,  11 Aug 16 23:26 tty11
crw--w----  1 root tty       4,  12 Aug 16 23:26 tty12
crw--w----  1 root tty       4,  13 Aug 16 23:26 tty13
crw--w----  1 root tty       4,  14 Aug 16 23:26 tty14
crw--w----  1 root tty       4,  15 Aug 16 23:26 tty15
crw--w----  1 root tty       4,  16 Aug 16 23:26 tty16
crw--w----  1 root tty       4,  17 Aug 16 23:26 tty17
crw--w----  1 root tty       4,  18 Aug 16 23:26 tty18
crw--w----  1 root tty       4,  19 Aug 16 23:26 tty19
crw--w----  1 root tty       4,   2 Aug 16 23:26 tty2
crw--w----  1 root tty       4,  20 Aug 16 23:26 tty20
crw--w----  1 root tty       4,  21 Aug 16 23:26 tty21
crw--w----  1 root tty       4,  22 Aug 16 23:26 tty22
crw--w----  1 root tty       4,  23 Aug 16 23:26 tty23
crw--w----  1 root tty       4,  24 Aug 16 23:26 tty24
crw--w----  1 root tty       4,  25 Aug 16 23:26 tty25
crw--w----  1 root tty       4,  26 Aug 16 23:26 tty26
crw--w----  1 root tty       4,  27 Aug 16 23:26 tty27
crw--w----  1 root tty       4,  28 Aug 16 23:26 tty28
crw--w----  1 root tty       4,  29 Aug 16 23:26 tty29
crw--w----  1 root tty       4,   3 Aug 16 23:26 tty3
crw--w----  1 root tty       4,  30 Aug 16 23:26 tty30
crw--w----  1 root tty       4,  31 Aug 16 23:26 tty31
crw--w----  1 root tty       4,  32 Aug 16 23:26 tty32
crw--w----  1 root tty       4,  33 Aug 16 23:26 tty33
crw--w----  1 root tty       4,  34 Aug 16 23:26 tty34
crw--w----  1 root tty       4,  35 Aug 16 23:26 tty35
crw--w----  1 root tty       4,  36 Aug 16 23:26 tty36
crw--w----  1 root tty       4,  37 Aug 16 23:26 tty37
crw--w----  1 root tty       4,  38 Aug 16 23:26 tty38
crw--w----  1 root tty       4,  39 Aug 16 23:26 tty39
crw--w----  1 root tty       4,   4 Aug 16 23:26 tty4
crw--w----  1 root tty       4,  40 Aug 16 23:26 tty40
crw--w----  1 root tty       4,  41 Aug 16 23:26 tty41
crw--w----  1 root tty       4,  42 Aug 16 23:26 tty42
crw--w----  1 root tty       4,  43 Aug 16 23:26 tty43
crw--w----  1 root tty       4,  44 Aug 16 23:26 tty44
crw--w----  1 root tty       4,  45 Aug 16 23:26 tty45
crw--w----  1 root tty       4,  46 Aug 16 23:26 tty46
crw--w----  1 root tty       4,  47 Aug 16 23:26 tty47
crw--w----  1 root tty       4,  48 Aug 16 23:26 tty48
crw--w----  1 root tty       4,  49 Aug 16 23:26 tty49
crw--w----  1 root tty       4,   5 Aug 16 23:26 tty5
crw--w----  1 root tty       4,  50 Aug 16 23:26 tty50
crw--w----  1 root tty       4,  51 Aug 16 23:26 tty51
crw--w----  1 root tty       4,  52 Aug 16 23:26 tty52
crw--w----  1 root tty       4,  53 Aug 16 23:26 tty53
crw--w----  1 root tty       4,  54 Aug 16 23:26 tty54
crw--w----  1 root tty       4,  55 Aug 16 23:26 tty55
crw--w----  1 root tty       4,  56 Aug 16 23:26 tty56
crw--w----  1 root tty       4,  57 Aug 16 23:26 tty57
crw--w----  1 root tty       4,  58 Aug 16 23:26 tty58
crw--w----  1 root tty       4,  59 Aug 16 23:26 tty59
crw--w----  1 root tty       4,   6 Aug 16 23:26 tty6
crw--w----  1 root tty       4,  60 Aug 16 23:26 tty60
crw--w----  1 root tty       4,  61 Aug 16 23:26 tty61
crw--w----  1 root tty       4,  62 Aug 16 23:26 tty62
crw--w----  1 root tty       4,  63 Aug 16 23:26 tty63
crw--w----  1 root tty       4,   7 Aug 16 23:27 tty7
crw--w----  1 root tty       4,   8 Aug 16 23:26 tty8
crw--w----  1 root tty       4,   9 Aug 16 23:26 tty9
crw-rw----  1 root dialout 204,  64 Aug 16 23:26 ttyAMA0
crw-------  1 root root      5,   3 Aug 16 23:26 ttyprintk
lrwxrwxrwx  1 root root          10 Aug 16 23:28 ttyUSB0 -> /dev/pts/1
crw-------  1 root root     10, 239 Aug 16 23:26 uhid
crw-------  1 root root     10, 223 Aug 16 23:26 uinput
crw-rw-rw-  1 root root      1,   9 Aug 16 23:26 urandom
drwxr-xr-x  2 root root          80 Nov  3  2016 usb
crw-rw----  1 root video   245,   0 Aug 16 23:26 vchiq
crw-rw----  1 root video   249,   0 Aug 16 23:26 vcio
crw-------  1 root root    250,   0 Aug 16 23:26 vc-mem
crw-rw----  1 root tty       7,   0 Aug 16 23:26 vcs
crw-rw----  1 root tty       7,   1 Aug 16 23:26 vcs1
crw-rw----  1 root tty       7,   2 Aug 16 23:26 vcs2
crw-rw----  1 root tty       7,   3 Aug 16 23:26 vcs3
crw-rw----  1 root tty       7,   4 Aug 16 23:26 vcs4
crw-rw----  1 root tty       7,   5 Aug 16 23:26 vcs5
crw-rw----  1 root tty       7,   6 Aug 16 23:26 vcs6
crw-rw----  1 root tty       7,   7 Aug 16 23:27 vcs7
crw-rw----  1 root tty       7, 128 Aug 16 23:26 vcsa
crw-rw----  1 root tty       7, 129 Aug 16 23:26 vcsa1
crw-rw----  1 root tty       7, 130 Aug 16 23:26 vcsa2
crw-rw----  1 root tty       7, 131 Aug 16 23:26 vcsa3
crw-rw----  1 root tty       7, 132 Aug 16 23:26 vcsa4
crw-rw----  1 root tty       7, 133 Aug 16 23:26 vcsa5
crw-rw----  1 root tty       7, 134 Aug 16 23:26 vcsa6
crw-rw----  1 root tty       7, 135 Aug 16 23:27 vcsa7
crw-rw----  1 root video   246,   0 Aug 16 23:26 vcsm
crw-------  1 root root     10, 137 Aug 16 23:26 vhci
crw-------  1 root root     10, 130 Aug 16 23:26 watchdog
crw-------  1 root root    252,   0 Aug 16 23:26 watchdog0
crw-rw-rw-  1 root root      1,   5 Aug 16 23:26 zero

I’m also looking at raspi-config to see if that could help me

Someone else had a similar issue a few days ago. The last post by someone was:
On the RPI3 board the AMA serial is used for the Bluetooth connection. There are two serial ports enabled and these can be seen to be linked to their ttyUSBx devices in /dev/erial/by-id directory

[10:10:34] openhabian@openhabtest:~$ ls -all /dev/serial/by-id
total 0
drwxr-xr-x 2 root root 80 Aug 16 10:01 .
drwxr-xr-x 4 root root 80 Aug 16 10:01 …
lrwxrwxrwx 1 root root 13 Aug 16 10:01 usb-1a86_USB2.0-Serial-if00-port0 -> …/…/ttyUSB0
lrwxrwxrwx 1 root root 13 Aug 16 10:01 usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0 -> …/…/ttyUSB1

I’m not using a serial device on my RPI so I can’t test and honestly I’m not sure what the above means.

If you find the solution please let me know.

Possible it doesn’t work because ttyUSB0 is not part of the dailout group.

Did you get it to work?

Went on holiday :sunglasses:
To be continued in 2 weeks

A few day’s ago I read where someone else was having a USB issue and their solution was to edit the /boot/cmdline.txt and delete ‘console=serial0,115200 then reboot. This allowed /dev/ttyAMA0 to be added to group dialout with rw rights for the group.

Maybe this will help, enjoy your holiday.

I’m back again.
Still having the same errors.

Could if have something to do with user-rights?
When I log-in to my RPi via SSH (user pi) and type cat I get:

pi@raspberrypi-1:~ $ cat /dev/ttyUSB0
cat: /dev/ttyUSB0: Permission denied

However when I sudo:

pi@raspberrypi-1:~ $ sudo cat /dev/ttyUSB0

I get a continues flow of data.

Setting the Socat however only seems to be possible with Sudo. When I don’t use it I get:

pi@raspberrypi-1:~ $ socat -d -d pty,link=/dev/ttyUSB0,cfmakeraw tcp4:192.168.2.30:2000
2018/09/04 23:23:44 socat[23021] N PTY is /dev/pts/1
2018/09/04 23:23:44 socat[23021] E unlink("/dev/ttyUSB0"): Permission denied
2018/09/04 23:23:44 socat[23021] N exit(1)

Any ideas?

@hilbrand
Both users pi and openhab are a member of dailout

What are the rights and what is the group? Run:

ll /dev/ttyUSB0

You probably need to add it to the right group (e.g. dialout) with chgrp or change rights with chmod. You probably also need to persist it in startup otherwise a reboot will reset the settings.

Hi,

Try adding group=dialout,mode=0660 to the socat cmdline e.g.

socat -d -d pty,link=/dev/ttyUSB0,group=dialout,mode=0660,cfmakeraw tcp4:192.168.2.30:2000

You also might want to create a systemd service that starts the socat that is what I use to have
a virtual serial port to a USR-TCP232-302 connected to a cm11a X10 interface.

Marco

1 Like

ll is not working but ls-l gives

pi@raspberrypi-1:~ $ ls -l /dev/ttyUSB0
lrwxrwxrwx 1 root root 10 Sep  6 20:45 /dev/ttyUSB0 -> /dev/pts/1

This seems to be getting somewhere. Things pop-up in my Inbox in PaperUI and I can create items!!!

Note for other users. I had to type

sudo socat -d -d pty,link=/dev/ttyUSB0,group=dialout,mode=0660,cfmakeraw tcp4:192.168.2.30:2000

Last thing to do is create working systemd service to start at boot.

Once in a while socat and permission problems pop up so I’ll just link this here so maybe future searchers have better luck.

@mvwieringen can you post a copy of the file you used to create the systemd service?
That’s my last hurdle.

# /etc/systemd/system/socatcm11a.service

[Unit]
Description=socat cm11a
After=network.target
Before=openhab2.service

[Service]
Type=simple
User=root
ExecStart=/usr/bin/socat pty,link=/dev/ttyNET0,group=dialout,mode=0660,rawer tcp:<host>:1243,keepalive
Restart=on-failure

[Install]
WantedBy=multi-user.target

It starts after the network is up and before openhab2 starts.

I’ve got everything up and running. The socat command is started via a service.
Sometimes I notice that the ‘things’ are offline. Then I have to restart the service I’ve defined and everything is working again. This has nothing to do with Openhab, but does anyone have an idea where to start looking?