[patch] Support for persistent USB paths

This Forum is about the Opentherm gateway (OTG) from Schelte

Moderator: hvxl

[patch] Support for persistent USB paths

Postby rickvanderzwet » Wed Nov 29, 2017 10:26 am

Persistent USB path listings are currently recognized as hostname, due to the colon in the path:

Code: Select all
/sys/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.4/3-3.4.2/3-3.4.2:1.0/ttyUSB0/tty/ttyUSB0/device
/dev/serial/by-path/platform-20980000.usb-usb-0:1.3.4.1:1.0-port0

Those are useful to support, since they will not change names as their /dev/ttyUSBX counterparts do, when you have multiple installed.

Since forward slash is not supported in hostname, more strict checking at hostname level should fix it:
Code: Select all
diff -ur ../otmonitor.vfs.orig/otmonitor.tcl ./otmonitor.tcl
--- ../otmonitor.vfs.orig/otmonitor.tcl   2017-11-29 10:00:59.575541879 +0100
+++ ./otmonitor.tcl   2017-11-29 10:18:34.525891843 +0100
@@ -1537,7 +1537,7 @@
       help
   } elseif {[llength $arg] == 0} {
       # Use default/saved connection settings
-   } elseif {[regexp {^(.+):(.+)} $fn -> host port]} {
+   } elseif {[regexp {^([^/]+):(.+)} $fn -> host port]} {
       set optcfg(connection,type) tcp
       set optcfg(connection,host) $host
       set optcfg(connection,port) $port



FYI: The source code file has otmonitor.orig included, is this intended on purpose?
Code: Select all
$ unzip -t ~/otmonitor.zip  | grep orig
    testing: otmonitor.vfs/otmonitor.tcl.orig   OK
User avatar
rickvanderzwet
Starting Member
Starting Member
 
Posts: 6
Joined: January 2017
Location: Zoeterwoude

Re: [patch] Support for persistent USB paths

Postby hvxl » Thu Nov 30, 2017 6:05 pm

Persistent USB paths only work if you always use the same USB port to connect the OTGW. For that reason I usually use an udev rule to create a symbolic link from something like /dev/otgw to the USB device. Then you can just specify "/dev/otgw" in otmonitor.

Of course you can only use that technique if you have root access. So I will implement your suggestion as that works for regular users as well. Thanks.

And no, otmonitor.tcl.orig was not supposed to be in the zip file.
Schelte
hvxl
Senior Member
Senior Member
 
Posts: 1105
Joined: June 2010


Return to Opentherm Gateway Forum

Who is online

Users browsing this forum: No registered users and 1 guest