pavel-a / usb-relay-hid Goto Github PK
View Code? Open in Web Editor NEWSoftware for USB-connected relays with HID interface. See the WIKI for more info.
Home Page: http://vusb.wikidot.com/project:driver-less-usb-relays-hid-interface
Software for USB-connected relays with HID interface. See the WIKI for more info.
Home Page: http://vusb.wikidot.com/project:driver-less-usb-relays-hid-interface
That error message is displayed when runnint ./make_release_linux.sh
Have you even tested the shell script before releasing it?
Dear Team,
I run make_release_linux.sh to build on Linux, but it's failed
cannot stat ‘commandline/makemake/hidusb-relay-cmd’: No such file or directory
I think there are some missing files, could you please help me solve it?
Best regards.
Hello Pavel,
Do you know if it is possible to change the device ID? I've received 2 boards and they conflict with each other because they both have the same ID=HURTM, so if i do:
./hidusb-relay-cmd ID=HURTM ON ALL
Only one board will switch on. Could it be possible to change the board ID?
My problem is I have two one channel relay hid device.
the command "./hidusb-relay-cmd enum" show the following output
Board ID=[959BI] State: R1=OFF
Board ID=[959BI] State: R1=OFF
but when I provide the command "./hidusb-relay-cmd ID=959BI ON 1" it works for one device but changing the number to 2,3 or 4 dosen't help operating second device. How can I achieve this. How can I operate the second one.
Hi! I am looking for the way to detect power outage in the 220V circuit. Will it be possible to reuse your code and take some device/appliances which will alert via USB to my microserver about absence/presence of the power in the grid?
Hello, is there any working wraper for .net / c#? the one at https://github.com/mmcs-robotics/USB-Relay does not work.
And following code,
[DllImport("usb_relay_device.dll", EntryPoint = "usb_relay_device_open_all_relay_channel", SetLastError = true,
CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int usb_relay_device_open_all_relay_channel(int hHandle);
throws exception, 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'
any help?
thanks!
Hey, I've made a library for nodejs, based on your project (it uses your DLL), but I'm not sure if I can publish it to github and npm repository. I don't want to break the license...
TODO: choose a license. BSD? MIT?
Hello! Thanks for this very useful library.
But i had encountered a problem on my system.
i had to add header #include <IOKit/hid/IOHIDManager.h> in hiddata_osx.c to get it working.
Perhaps, it would help someone
Colleagues, hello.
I took your project as a basis and developed my own implementation for relay control.
But there are a couple of questions left:
If connect two relays. then lsusb say:
Bus 004 Device 003: ID 16c0:05df VOTI
Bus 004 Device 005: ID 16c0:05df VOTI
The ID is identical but the device is different, add the option to specify which device to control, for example:
hidusb-relay-cmd ID = ID=ABCDE: 003 ON 1
or
hidusb-relay-cmd ID = ID=ABCDE: 005 ON 1
Thank you very much!
Seems that this project releases binaries for Windows/OSX and Linux x32, but not Linux x64. Kindly consider releasing binaries for Linux x64 as well. Thank you.
Will this work on Linux (ubuntu) without the use of sudo?
I don't understand what this function should return: the low -level handle or struct usb_relay_device_info *. If the former, how to get the info (number of relays, etc.) from this handle.
Currently in my lib the handle is same as usb_relay_device_info * but this may change later?
I'd like this f() to publicly return the struct ptr, or add another f() because I need to know at least the number of relays.
In original package the command util uses only usb_relay_device_open_with_serial_number and the GUI uses only usb_relay_device_enumerate and usb_relay_device_open.
I am using https://github.com/pavel-a/usb-relay-hid/blob/master/Test/test2m.py implementation with python 3.8 same code works fine with Python 2.8, which failed with error "ctypes.ArgumentError: argument 1: <class 'OverflowError'>: int too long to convert"
Any workaround or suggestion to fix this issue?
TODO: Library (class) for Python
TODO: More example scripts & tests
My PC failed to detect the USB relay. After some debugging I traced the issue to the checks on the buffer returned by usb_relay_lib.c->rel_read_status_raw
the loop(s) that checks all of the char in the array are failing on the first element (buffer[1]) as it has the value 0xFF. The buffer conntents are: 0x00, 0xFF, 0x57, 0x33, 0x34 0x31, 0x00....
Anybody knwo why this ID is now reported differently by the OS?
I've temporarilly modified all of the for loops to start at element 2
Hello @pavel-a
I have made an Qt base solution for building usb-relay-hid library and super simple little gui client also based on Qt widget.
What do you think about this?
Is it a good idea to suggest a pull request?
I've been using your utility for years, but the recent boards I've been buying on eBay aren't recognized by the utility. It doesn't detect any relays when I run "enum" using the commandline utility.
I don't imagine there's any tests I could do to help add support for them?
As subj. The original (Windows) library does this, but I want to finish the simple utility first.
I download USB_RELAY_DEVICE.dll and use lib.usb_relay_device_enumerate(), but it return NUll pointer access,
please help me to take a look.Thanks very mush
Traceback (most recent call last):
File "F:\SelfProject\TrainPython\venv\lib\site-packages\automotive\utils\usb_relay.py", line 105, in usb_relay_device_enumerate
p = resp.contents
ValueError: NULL pointer access
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
line 324, in open_relay_device
dev = self.__lib.usb_relay_device_enumerate()
in usb_relay_device_enumerate
raise RuntimeError(error[1])
RuntimeError: NULL pointer access
My problem is that I have to use this dll on matlab tools.
But when I try to use it I got error.
libname='usb_relay_device'
if ~libisloaded ('libname')
hfile='usb_relay_device.h'
[notfound, warnings]=loadlibrary (libname, hfile)
libfunctions (libname)
end
[res, st] =calllib (libname, 'usb_relay_init')
error: No rule to make target '../../lib/usb_relay_lib.c', needed by 'debug/usb_relay_lib.o'. Stop.
i just add qt and build it it make error
what should i do?
Hi
I installed the application with apt-get on raspbian (RPi1 B+) and I'm able to control both relays via usb.
However:
If I set the state of the second relay to 0, the state of the first relay is also set to 0. The same does not happen the other way around.
In short:
sudo usbrelay 1FX9M_2=0
sets states of both relays to 0.
Thanks for some great code.
I recently bought a 2 channel USB relay board which identified itself as a 4 channel board.
This caused me to see / find the following code, which I believe has a mistake in it.
commandline/usbrelay-cmd.c, line 282:
case 4:
printf("Board ID=[%5.5s] State: R1=%s R3=%s R1=%s R4=%s\n",
&buffer[1], onoff(0), onoff(1), onoff(2), onoff(3) );
Where the labels R1, R3, R1, R4 should probably be R1, R2, R3, R4.
Thanks,
-Mike
old:
printf("Board ID=[%5.5s] State: R1=%s R3=%s R1=%s R4=%s\n",
new:
printf("Board ID=[%5.5s] State: R1=%s R2=%s R3=%s R4=%s\n",
forgot to switch tail to next device while creating device Info list
should add "ectx->tail = q;" in usb_relay_lib.c at line 283
Could you, please, put together some instructions? I have WDC installed and very little idea what to do next. Checked the wiki and googled all over the place.
When I use 2 board in one pc & use this project ,the enum list two same ID,I dont know why ,Could you help me about this,thx
The code as follow
`root@acrn-HP-Compaq-8200-Elite-SFF-PC:/tmp/tempdir/usb-relay-hid/commandline# ls /dev/usb/
hiddev0 hiddev1
root@acrn-HP-Compaq-8200-Elite-SFF-PC:/tmp/tempdir/usb-relay-hid/commandline# ./hidusb-relay-cmd enum
Board ID=[HW554] State: 00 (hex)
Board ID=[HW554] State: 00 (hex)
`
I have 2 HID relays connected to one PC (Windows 7). They've different IDs. Often, one of them is displaying as an "unknown device" in the Device Manager and I can't connect to it. Sometimes, unplugging and plugging a USB cable or computer reboot helps but not always...
The problem is always with only one relay. The second one is fine. I used the problematic one as the only connected relay for a few years without any issues. They started only after connecting also second one.
Any suggestions?
I cannot find the 64-bit version of the usb_relay_device.dll
In the documentation it states:
"Python programs can use this library via the Ctypes module. Examples are in Test directory. Be sure to use the correct variant (32 or 64-bit) for your Python interpreter."
Makes, sense as during loading L.dll = ctypes.CDLL('usb_relay_device.dll') I get the error [WinError 193] %1 is not a valid Win32 application
I am running a 64-bit Anaconda Python v.3.9.7 and I seem to only have the 32-bit usb_relay_device.dll I found at random here: https://www.dropbox.com/sh/7clljb4h1aeb0m1/AAA-oUOCE2a15PC9BoMWY-Cha
Many thanks for helping me retrieve the 64-bit .dll!
I was able to build the Xcode project on Mojave, OSX. But when I run the executable I get this error
error finding USB relay: Unknown error (0)
Do I need to do anything before I can run the hidusb-relay-cmd
Hello, devices I've bought recently (2 relay version) all have the same ID=HURTM:
hidusb-relay-cmd.exe ENUM
Board ID=[HURTM] State: R1=OFF R2=OFF
Board ID=[HURTM] State: R1=OFF R2=OFF
It is impossible to address them independently, only the first one reacts. This makes them useless.
Is there any workaround to this? I'm using Windows 10.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.