darrylb123 / usbrelay

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

Added a sanity check to operate relay to prevent accidental renaming #30

Closed SeanMollet closed 5 years ago

SeanMollet commented 5 years ago

I accidentally renamed one of my relays to 0x00, which prompted me to add this sanity check.

darrylb123 commented 5 years ago

Can you give an example of the command you provided that renamed it. This has happened to someone else before and I could not work out how???

SeanMollet commented 5 years ago

I was using it via python and forgot that relays start at 1. Attempting to operate relay 0 triggered the rename with the subsequent bytes set to 0x00, thus renaming my relay board to 0x00.

From the command line, I don’t think the current version could do that. But, if I’m missing an edge case, this sanity check will prevent it from executing anyway.

darrylb123 commented 5 years ago

Sean, I think relay < board->relay_count should be relay <= board->relay_count to operate the last relay.

SeanMollet commented 5 years ago

I think you're correct. Fixed.