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

How to use in script if two one channel usb relay with same ID #18

Closed
combat007 opened this issue Jan 25, 2018 · 20 comments
Closed

How to use in script if two one channel usb relay with same ID #18

combat007 opened this issue Jan 25, 2018 · 20 comments

Comments

@combat007
Copy link

combat007 commented Jan 25, 2018

Your program works great on one channel relay
But I am stuck with the problem that I have two 1 channel relays attached to two usb ports of my laptop.
Following is the output of the command ./usbrelay

Device Found
type: 16c0 05df
path: /dev/hidraw2
serial_number:
Manufacturer: www.dcttech.com
Product: USBRelay1
Release: 100
Interface: 0
Number of Relays = 1
959BI_1=0

Device Found
type: 16c0 05df
path: /dev/hidraw0
serial_number:
Manufacturer: www.dcttech.com
Product: USBRelay1
Release: 100
Interface: 0
Number of Relays = 1
959BI_1=0

When I provide the command "./usbrelay 959BI_1=1" it works on both the relays simultaneously, but I want that only one must work at a time. Why both channels device showing same ID?
How can I differentiate between those two relay channel in the command
./usbrelay
??

@darrylb123
Copy link
Owner

darrylb123 commented Jan 25, 2018 via email

@combat007
Copy link
Author

ID is provided as a parameter to ./usbrelay. Can't we provide the device path instead??
I think it will solve the problem if we can provide the device path.

@combat007
Copy link
Author

well I followed this link and got the solution
https://www.quora.com/How-do-I-enable-and-disable-USB-port-using-terminal-in-Ubuntu

then I wrote the script "mycmd"

---------Bash Script start here -------

if [ $1 == "small" ]
then
echo '2-1' | tee /sys/bus/usb/drivers/usb/unbind
./usbrelay 959BI_1=1;./usbrelay 959BI_1=0
echo '2-1' | tee /sys/bus/usb/drivers/usb/bind
fi

if [ $1 == "big" ]
then
echo '2-3' | tee /sys/bus/usb/drivers/usb/unbind
./usbrelay 959BI_1=1;./usbrelay 959BI_1=0
echo '2-3' | tee /sys/bus/usb/drivers/usb/bind
fi

---------Bash Script end here -------

Now this helped me out to start two machines one by one
./mycmd small
./mycmd big

the rest of the job was done by your utility and it worked like a charm.
Kindly share this solution to those who are seeking it like I was.

Regards

@darrylb123
Copy link
Owner

darrylb123 commented Jan 26, 2018 via email

@danbayona
Copy link

I'm having the same problem -- except I can't use the solution that combat007 provides. I can't turn any of them off as I have to potentially trigger channels simulataneously... Would it be possible to somehow provide device path + ID to the usbrelay command?

I currently have 3 boards and they are all given the same buf IDs (6QMBS_1 - 6QMBS_8). I feel it is highly unlikely that getting a replacement will enumerate unique IDs, but if it really is the only chance I guess i'll try!

@darrylb123
Copy link
Owner

darrylb123 commented Mar 14, 2018 via email

@danbayona
Copy link

danbayona commented Mar 14, 2018

Would it change anything if I use udev rules so that the USB relay devices are enumerated statically? I currently set rules for other USB devices so they can be referred to by a non-dynamic path.

PS. Thanks for your time and your timely responses I rly appreciate it!

@darrylb123
Copy link
Owner

darrylb123 commented Mar 14, 2018 via email

@danbayona
Copy link

The problem is -- even with different /dev/ paths the channel ID's are still identical. Am I missing something? When you refer to 'device ID' do you mean the ID '16c0:05df'?

@darrylb123
Copy link
Owner

darrylb123 commented Mar 15, 2018 via email

@darrylb123
Copy link
Owner

darrylb123 commented Mar 15, 2018 via email

@danbayona
Copy link

Wow thank you so much for your efforts! fyi I am running this on linux Ubuntu 16.04

@darrylb123
Copy link
Owner

darrylb123 commented Mar 16, 2018 via email

@darrylb123
Copy link
Owner

Ok, please test the new version. I have added the capability to change the serial. I have updated the documentation to show how to do it.
Worked fine on my test board. plug in one of the devices with the duplicate serial and change it.

@darrylb123 darrylb123 reopened this Mar 17, 2018
@darrylb123
Copy link
Owner

darrylb123 commented Mar 21, 2018 via email

@danbayona
Copy link

danbayona commented Mar 21, 2018 via email

@danbayona
Copy link

Hey! The IDs for each channel are now able to be enumerated uniquely and will work for my purposes, thank you so much for your time!

@darrylb123
Copy link
Owner

Tested by danbayona, tested by myself on 2 way and 8 way relay.
$ ./usbrelay
Device Found
type: 16c0 05df
path: /dev/hidraw0
serial_number:
Manufacturer: www.dcttech.com
Product: USBRelay8
Release: 100
Interface: 0
Number of Relays = 8
86UXU_1=0
86UXU_2=0
86UXU_3=0
86UXU_4=1
86UXU_5=0
86UXU_6=0
86UXU_7=0
86UXU_8=0

$ ./usbrelay 86UXU_0=86UXV
Orig: 86UXU, Serial: 86UXU, Relay: 0 State: 0
Device Found
type: 16c0 05df
path: /dev/hidraw0
serial_number:
Manufacturer: www.dcttech.com
Product: USBRelay8
Release: 100
Interface: 0
Number of Relays = 8
Serial: 86UXU, Relay: 0 State: 0
1 HID Serial: 86UXU
Serial: 86UXU, Relay: 0 State: 0 --- Not Found
$ ./usbrelay
Device Found
type: 16c0 05df
path: /dev/hidraw0
serial_number:
Manufacturer: www.dcttech.com
Product: USBRelay8
Release: 100
Interface: 0
Number of Relays = 8
86UXV_1=0
86UXV_2=0
86UXV_3=0
86UXV_4=1
86UXV_5=0
86UXV_6=0
86UXV_7=0
86UXV_8=0

$ ./usbrelay 86UXV_0=86UXU
Orig: 86UXV, Serial: 86UXV, Relay: 0 State: 0
Device Found
type: 16c0 05df
path: /dev/hidraw0
serial_number:
Manufacturer: www.dcttech.com
Product: USBRelay8
Release: 100
Interface: 0
Number of Relays = 8
Serial: 86UXV, Relay: 0 State: 0
1 HID Serial: 86UXV
Serial: 86UXV, Relay: 0 State: 0 --- Not Found
$ ./usbrelay
Device Found
type: 16c0 05df
path: /dev/hidraw0
serial_number:
Manufacturer: www.dcttech.com
Product: USBRelay8
Release: 100
Interface: 0
Number of Relays = 8
86UXU_1=0
86UXU_2=0
86UXU_3=0
86UXU_4=1
86UXU_5=0
86UXU_6=0
86UXU_7=0
86UXU_8=0

@ImXron
Copy link
Contributor

ImXron commented Mar 25, 2018

Hi,

I was working with Dan on the issue above. I built your new changes using Docker so I didn't have to install any dependencies locally. Would you be interested in adding the Dockerfile, a build script and an updated Readme to the project? I have branch ready to push. This way, anyone can build from source once they install Docker and not have to fuss with setting up their host machine.

Thanks for the help!

@darrylb123
Copy link
Owner

darrylb123 commented Mar 25, 2018 via email

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

4 participants