Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on connecting #6

Open
RZomerman opened this issue Aug 19, 2021 · 8 comments
Open

Error on connecting #6

RZomerman opened this issue Aug 19, 2021 · 8 comments

Comments

@RZomerman
Copy link

Installed it on a Odroid C4 system - installation was successful and easy

but VelbusLink version: 10.6.0.0 crashes on connect :

(an error occurred while performing the operation. A report will be made at ...

[sniplet]
exception number : 4
exception class : EIdSocketError
exception message : Socket Error # 10054 Connection reset by peer.

Also tried the VelServ on exactly the same infra - and that does work so it's not the connection itself.

@dukeofphilberg
Copy link
Contributor

Hi there

Have you checked the TLS/SSL checkbox? As the snap enables it by default.

image

If you want to disable TLS/SSL

snap set velbus-tcp tcp.ssl=false

You can check the entire config with

snap get velbus-tcp -d

You might also get additional information in the log with

snap logs velbus-tcp -f

@MDAR
Copy link

MDAR commented Aug 20, 2021

@pvanloo

Hi Philip

Roelf and I are trying to test the Velbus TCP snap.

I couldn't get it working either, no matter what settings I tried. It just wouldn't seem to start.

However....

I saw in another issue that you said the Snap Core hadn't been installed.

So by running snap install core followed by snap restart velbus-tcp I was suddenly able to see the open port and start to play with the settings.

That said, I've activated autodiscovery and it's come up with
"serial": { "autodiscover": true, "port": "/dev/ttyAMA0"

My system doesn't have a ttyAMA0 port, it does have a ttyACM0 port

Would it be possible to set the port as
/dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00

To ensure that velbus-tcp always uses the correct device?

(As I've seen that Linux can swap ttyACMx assignments at boot, which can lead to some very strange results)
Can I ask you to update the readme file to mention this?

It would also be very useful to have more information about the setting options.

(Your multiple port configuration example is very good and gave me a lot of hints)

Thanks.

Stuart

@MDAR
Copy link

MDAR commented Aug 20, 2021

So to get a working connection I had to do the following (on a Debian Linux based system on a Samsung Netbook, I'll try an Odroid C4 when I next set one up)

apt install snapd

snap install core

snap install velbus-tcp

snap connect velbus-tcp:raw-usb :raw-usb

snap set velbus-tcp serial.autodiscover=false

snap set velbus-tcp serial.port=/dev/ttyACM0

It continues to work if I change the serial port to

snap set velbus-tcp serial.port=/dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00

These TLS , SSL and authentication settings worked for a secure connection with VelbusLink 10.6.0

snap set velbus-tcp ntp.enabled=true tcp.auth=true tcp.ssl=true

using

snap get velbus-tcp -d

to reveal the complete configuration with the Authentication key


This command (on an Odroid C4 running the DietPi V7.4.2 version of Debian OS) also works to give an insecure connection to the local machine and a secure connection to everything else

snap set velbus-tcp tcp.host=0.0.0.0,127.0.0.1 tcp.port=27015,6000 tcp.relay=true,true tcp.ssl=true,false tcp.auth=true,false tcp.authkey={My_Auth_Key},

(I kept missing the very last , to balance the amount of entries in the configuration)

Which results in a configuration that looks like this

snap get velbus-tcp -d
{
        "logging": {
                "output": "stream",
                "type": "info"
        },
        "ntp": {
                "enabled": true,
                "synctime": ""
        },
        "serial": {
                "autodiscover": false,
                "port": "/dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00"
        },
        "tcp": {
                "auth": "true,false",
                "authkey": "xxxxxxxxxx-xxxxxxx-xxxxxxx-xxxxxxx,",
                "cert": "/var/snap/velbus-tcp/common/certificate.pem",
                "host": "0.0.0.0,127.0.0.1",
                "pk": "/var/snap/velbus-tcp/common/privkey.pem",
                "port": "27015,6000",
                "relay": "true,true",
                "ssl": "true,false"
        }
}

@pvanloo
Once I got over the learning curve, it was / is fairly easy to get running, but I did need to do some digging to get to this point.

@dukeofphilberg
Copy link
Contributor

Hi Stuart

You should not need to install core, as the snap is built for core18 devices as indicated here:

If a snap is installed that uses core/core18, it should automatically download its corresponding base core. Could you check if you have core18 listed in snap list?

When autodiscover is enabled it should be able to find any Velbus USB interfaces connected to the system using the VID/PID, if it doesn't it will fallback to the port define in serial.port, which you can ofcourse set to /dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00. The port is mainly there if you would use the old serial devices that can't get autodiscovered.

I'll update the README to reflect some of the findings here.

@MDAR
Copy link

MDAR commented Aug 20, 2021

If a snap is installed that uses core/core18, it should automatically download its corresponding base core. Could you check if you have core18 listed in snap list?

Hi

Thanks for the update.

It's odd that the Samsung Netbook with DietPi 7.4.2 (Debian) didn't work until I manually added the Snap Core

the snap list command returns this

Name        Version    Rev    Tracking       Publisher   Notes
core        16-2.51.3  11420  latest/stable  canonical✓  core
core18      20210722   2128   latest/stable  canonical✓  base
velbus-tcp  1.4.0      113    latest/stable  velbus      -

Which shows this as it's splash screen

Linux DietPi 4.19.0-17-amd64 #1 SMP Debian 4.19.194-3 (2021-07-18) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
 ─────────────────────────────────────────────────────
 DietPi v7.4.2 : 13:06 - Fri 20/08/21
 ─────────────────────────────────────────────────────
- Device model : Native PC (x86_64)

The Odroid C4 doesn't show the same

Name        Version    Rev    Tracking       Publisher   Notes
core        16-2.51.3  11424  latest/stable  canonical✓  core
core18      20210722   2127   latest/stable  canonical✓  base
velbus-tcp  1.4.0      116    latest/stable  velbus      -

(Curious that all of the revisions are different)

Odroid Splash Screen

Linux openHAB2-C4 4.9.241-arm64 #1 SMP PREEMPT Thu Feb 25 17:57:15 CET 2021 aarch64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
 ─────────────────────────────────────────────────────
 DietPi v7.4.2 : 13:03 - Fri 20/08/21
 ─────────────────────────────────────────────────────
 - Device model : Odroid C4/HC4 (aarch64)
 -

(I will confess I didn't even try to install / run velbus-tcp before running snap install core on that machine)

When autodiscover is enabled it should be able to find any Velbus USB interfaces connected to the system using the VID/PID

Now that is curious, because it definitely didn't work until I assigned the port.

I can unset the serial.port and try again if you want me to?

Thanks for your great efforts.

Cheers
Stuart


snap unset velbus-tcp serial.port
snap set velbus-tcp serial.autodiscover=true

results in

{
        "logging": {
                "output": "stream",
                "type": "info"
        },
        "ntp": {
                "enabled": true,
                "synctime": ""
        },
        "serial": {
                "autodiscover": true
        },
        "tcp": {
                "auth": "true,false",
                "authkey": "xxxxxx-xxxxxx-xxxxxx,",
                "cert": "/var/snap/velbus-tcp/common/certificate.pem",
                "host": "0.0.0.0,127.0.0.1",
                "pk": "/var/snap/velbus-tcp/common/privkey.pem",
                "port": "27015,6000",
                "relay": "true,true",
                "ssl": "true,false"
        }
}

and

snap logs velbus-tcp -f
2021-08-20T12:16:17Z systemd[1]: Stopped Service for snap application velbus-tcp.velbus-tcp.
2021-08-20T12:16:18Z systemd[1]: Started Service for snap application velbus-tcp.velbus-tcp.
2021-08-20T12:16:19Z velbus-tcp.velbus-tcp[23459]: 2021-08-20 13:16:19,873 - INFO - bus - Attempting to connect
2021-08-20T12:16:19Z velbus-tcp.velbus-tcp[23459]: 2021-08-20 13:16:19,874 - ERROR - bus - Couldn't create bus connection, waiting 5 seconds
2021-08-20T12:16:19Z velbus-tcp.velbus-tcp[23459]: 2021-08-20 13:16:19,878 - INFO - network - Listening to TCP connections on 0.0.0.0:27015 [SSL:True]
2021-08-20T12:16:19Z velbus-tcp.velbus-tcp[23459]: 2021-08-20 13:16:19,879 - INFO - network - Listening to TCP connections on 127.0.0.1:6000 [SSL:False]
2021-08-20T12:16:19Z velbus-tcp.velbus-tcp[23459]: 2021-08-20 13:16:19,881 - INFO - ntp - Started NTP broadcast, will wait until next minute transition
2021-08-20T12:16:24Z velbus-tcp.velbus-tcp[23459]: 2021-08-20 13:16:24,875 - ERROR - bus - Couldn't create bus connection, waiting 5 seconds
2021-08-20T12:16:29Z velbus-tcp.velbus-tcp[23459]: 2021-08-20 13:16:29,876 - ERROR - bus - Couldn't create bus connection, waiting 5 seconds
2021-08-20T12:16:34Z velbus-tcp.velbus-tcp[23459]: 2021-08-20 13:16:34,877 - ERROR - bus - Couldn't create bus connection, waiting 5 seconds

FYI

lsusb
Bus 002 Device 002: ID 2109:0817 VIA Labs, Inc.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 004: ID 0fe6:9700 ICS Advent DM9601 Fast Ethernet Adapter
Bus 001 Device 003: ID 10cf:0b1b Velleman Components, Inc.
Bus 001 Device 002: ID 2109:2817 VIA Labs, Inc.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Adding back in the Serial port doesn't help, I MUST set autodiscover to false for it to work again

snap get velbus-tcp -d
{
        "logging": {
                "output": "stream",
                "type": "info"
        },
        "ntp": {
                "enabled": true,
                "synctime": ""
        },
        "serial": {
                "autodiscover": false,
                "port": "/dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00"
        },
        "tcp": {
                "auth": "true,false",
                "authkey": "xxxxxxx-xxxxxxxx-xxxxxx,",
                "cert": "/var/snap/velbus-tcp/common/certificate.pem",
                "host": "0.0.0.0,127.0.0.1",
                "pk": "/var/snap/velbus-tcp/common/privkey.pem",
                "port": "27015,6000",
                "relay": "true,true",
                "ssl": "true,false"
        }
}
root@openHAB2-C4:~# snap logs velbus-tcp -f
2021-08-20T12:23:19Z systemd[1]: Stopping Service for snap application velbus-tcp.velbus-tcp...
2021-08-20T12:23:19Z systemd[1]: snap.velbus-tcp.velbus-tcp.service: Main process exited, code=killed, status=15/TERM
2021-08-20T12:23:19Z systemd[1]: snap.velbus-tcp.velbus-tcp.service: Succeeded.
2021-08-20T12:23:19Z systemd[1]: Stopped Service for snap application velbus-tcp.velbus-tcp.
2021-08-20T12:23:19Z systemd[1]: Started Service for snap application velbus-tcp.velbus-tcp.
2021-08-20T12:23:21Z velbus-tcp.velbus-tcp[25438]: 2021-08-20 13:23:21,031 - INFO - bus - Attempting to connect
2021-08-20T12:23:21Z velbus-tcp.velbus-tcp[25438]: 2021-08-20 13:23:21,035 - INFO - bus - Serial connection active on port /dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00
2021-08-20T12:23:21Z velbus-tcp.velbus-tcp[25438]: 2021-08-20 13:23:21,036 - INFO - network - Listening to TCP connections on 0.0.0.0:27015 [SSL:True]
2021-08-20T12:23:21Z velbus-tcp.velbus-tcp[25438]: 2021-08-20 13:23:21,037 - INFO - network - Listening to TCP connections on 127.0.0.1:6000 [SSL:False]
2021-08-20T12:23:21Z velbus-tcp.velbus-tcp[25438]: 2021-08-20 13:23:21,038 - INFO - ntp - Started NTP broadcast, will wait until next minute transition

@dukeofphilberg
Copy link
Contributor

(Curious that all of the revisions are different)

That's because the Odroid you're using has the aarch64 architecture and the other one is amd64, which means a different snap architecture is installed for each and thus a different revision.

Now that is curious, because it definitely didn't work until I assigned the port.

It's probably because the serial ports can't be enumerated, and leaving the port out will cause an exception that is thrown here and caught here. Should make the exception more clear to the user.

@RZomerman
Copy link
Author

RZomerman commented Aug 21, 2021

[update]
also tried using the standard Velbus USB cable - but same error

Running on a C4 - DietPI
[/update]

I'm trying to connect to the RS232 port on the Velbus VMUSB, for this in my C4 is have an USB->RS232 converter which is mounted as:
FTDI USB Serial Device converter now attached to ttyUSB0

I reconfigured using
snap set velbus-tcp serial.port=/dev/ttyUSB0

but the logs shows:
2021-08-21T11:54:20Z systemd[1]: Started Service for snap application velbus-tcp.velbus-tcp.
2021-08-21T11:54:22Z velbus-tcp.velbus-tcp[9849]: Traceback (most recent call last):
2021-08-21T11:54:22Z velbus-tcp.velbus-tcp[9849]: File "/snap/velbus-tcp/123/main.py", line 89, in
2021-08-21T11:54:22Z velbus-tcp.velbus-tcp[9849]: main = Main()
2021-08-21T11:54:22Z velbus-tcp.velbus-tcp[9849]: File "/snap/velbus-tcp/123/main.py", line 27, in init
2021-08-21T11:54:22Z velbus-tcp.velbus-tcp[9849]: self.__bridge.start()
2021-08-21T11:54:22Z velbus-tcp.velbus-tcp[9849]: File "/snap/velbus-tcp/123/lib/connection/bridge.py", line 55, in start
2021-08-21T11:54:22Z velbus-tcp.velbus-tcp[9849]: network.start()
2021-08-21T11:54:22Z velbus-tcp.velbus-tcp[9849]: File "/snap/velbus-tcp/123/lib/connection/network.py", line 159, in start
2021-08-21T11:54:22Z velbus-tcp.velbus-tcp[9849]: self.__bind_socket.listen(0)
2021-08-21T11:54:22Z velbus-tcp.velbus-tcp[9849]: PermissionError: [Errno 1] Operation not permitted
2021-08-21T11:54:22Z velbus-tcp.velbus-tcp[9849]: 2021-08-21 15:54:22,804 - INFO - bus - Attempting to connect
2021-08-21T11:54:22Z velbus-tcp.velbus-tcp[9849]: 2021-08-21 15:54:22,882 - INFO - bus - Serial connection active on port /dev/ttyUSB0
2021-08-21T11:54:23Z systemd[1]: snap.velbus-tcp.velbus-tcp.service: Main process exited, code=exited, status=1/FAILURE
2021-08-21T11:54:23Z systemd[1]: snap.velbus-tcp.velbus-tcp.service: Failed with result 'exit-code'.
2021-08-21T11:54:23Z systemd[1]: snap.velbus-tcp.velbus-tcp.service: Service RestartSec=100ms expired, scheduling restart.

Also tried with:
"port": "/dev/serial/by-id/usb-FTDI_US232R_FTGY89BK-if00-port0"

Any ideas?

@RZomerman
Copy link
Author

RZomerman commented Aug 21, 2021

small update;
installed snap core as per above - and it started to work -

and set serial to: velbus-tcp serial.port=/dev/serial/by-id/usb-FTDI_US232R_FTGY89BK-if00-port0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants