darrylb123 / usbrelay

Control usb relay - based on hidapi
GNU General Public License v2.0
310 stars 98 forks source link

USBRelay device naming bug #99

Closed wasikan-git closed 1 year ago

wasikan-git commented 1 year ago

Hi, I think there's a bug in the code. I've a relay which identifies itself (sudo usbrelay -e /dev/hidraw4) as:

ELSD__1=0 IDSERIAL=ELSD

Please note underscore as a last character of ID_SERIAL.

sudo usbrelay -d gives:

libusbrelay: 1.0-2~bpo11+1 usbrelay: 1.0-2~bpo11+1 enumerate_relay_boards()Found 1 devices Device Found type: 16c0 05df path: /dev/hidraw4 serialnumber: ELSD Manufacturer: www.dcttech.com Product: USBRelay1 Release: 100 Interface: 0 Number of Relays = 1 Module_type = 1 ELSD__1=0

and sudo usbrelay ELSD1=1 Invalid relay specification: ELSD1=1

I also have another relay of the same type but its ID_SERIAL does not end with underscore. This relay works as expected. Hopefully usbrelay can be fixed without too much trouble.

Regards Andrzej

darrylb123 commented 1 year ago

Yep, looks like a bug. In the mean time, why not change the one with the trailing underscore to remove it. You can use the device path to change the name. Find out the device path for your relay, it seems to be the same as the documentation (/dev/hidraw4) . Use usbrelay -v to find the device path From the documentation: $ sudo usbrelay ZXCV_1=0 ZXCV_2=0

$ sudo usbrelay ZXCV_0=ZAQ12 # or /dev/hidraw4_0=ZAQ12 ZXCV_1=0 ZXCV_2=0 Setting new serial

$ sudo usbrelay ZAQ12_1=0 ZAQ12_2=0

Darryl

On Tue, Jan 17, 2023 at 7:42 AM wasikan-git @.***> wrote:

Hi, I think there's a bug in the code. I've a relay which identifies itself (sudo usbrelay -e /dev/hidraw4) as:

ELSD__1=0 IDSERIAL=ELSD

Please note underscore as a last character of ID_SERIAL.

sudo usbrelay -d gives:

libusbrelay: 1.0-2bpo11+1 usbrelay: 1.0-2bpo11+1 enumerate_relay_boards()Found 1 devices Device Found type: 16c0 05df path: /dev/hidraw4 serialnumber: ELSD Manufacturer: www.dcttech.com Product: USBRelay1 Release: 100 Interface: 0 Number of Relays = 1 Module_type = 1 ELSD__1=0

and sudo usbrelay ELSD1=1 Invalid relay specification: ELSD1=1

I also have another relay of the same type but its ID_SERIAL does not end with underscore. This relay works as expected. Hopefully usbrelay can be fixed without too much trouble.

Regards Andrzej

— Reply to this email directly, view it on GitHub https://github.com/darrylb123/usbrelay/issues/99, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTSUVOIEM3HMOZINNEW5A3WSW6FLANCNFSM6AAAAAAT5FJVXY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

wasikan-git commented 1 year ago

Hi!

I followed your advice and changed the device name. Now the relay works as expected. Thanks.

Regards

Andrzej

W dniu 17.01.2023 o 00:24, Darryl Bond pisze:

Yep, looks like a bug. In the mean time, why not change the one with the trailing underscore to remove it. You can use the device path to change the name. Find out the device path for your relay, it seems to be the same as the documentation (/dev/hidraw4) . Use usbrelay -v to find the device path From the documentation: $ sudo usbrelay ZXCV_1=0 ZXCV_2=0

$ sudo usbrelay ZXCV_0=ZAQ12 # or /dev/hidraw4_0=ZAQ12 ZXCV_1=0 ZXCV_2=0 Setting new serial

$ sudo usbrelay ZAQ12_1=0 ZAQ12_2=0

Darryl

On Tue, Jan 17, 2023 at 7:42 AM wasikan-git @.***> wrote:

Hi, I think there's a bug in the code. I've a relay which identifies itself (sudo usbrelay -e /dev/hidraw4) as:

ELSD__1=0 IDSERIAL=ELSD

Please note underscore as a last character of ID_SERIAL.

sudo usbrelay -d gives:

libusbrelay: 1.0-2bpo11+1 usbrelay: 1.0-2bpo11+1 enumerate_relay_boards()Found 1 devices Device Found type: 16c0 05df path: /dev/hidraw4 serialnumber: ELSD Manufacturer: www.dcttech.com Product: USBRelay1 Release: 100 Interface: 0 Number of Relays = 1 Module_type = 1 ELSD__1=0

and sudo usbrelay ELSD1=1 Invalid relay specification: ELSD1=1

I also have another relay of the same type but its ID_SERIAL does not end with underscore. This relay works as expected. Hopefully usbrelay can be fixed without too much trouble.

Regards Andrzej

— Reply to this email directly, view it on GitHub https://github.com/darrylb123/usbrelay/issues/99, or unsubscribe

https://github.com/notifications/unsubscribe-auth/ABTSUVOIEM3HMOZINNEW5A3WSW6FLANCNFSM6AAAAAAT5FJVXY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/darrylb123/usbrelay/issues/99#issuecomment-1384668059, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3YRISTOJS7NQ2YCHFHXAXLWSXKDFANCNFSM6AAAAAAT5FJVXY. You are receiving this because you authored the thread.Message ID: @.***>

-- Pozdrawiam Andrzej Wasik

darrylb123 commented 1 year ago

Not a bug. The code only allows A-Z0-9 Updated the documentation to describe how to rename in the event of illegal characters in the serial ID