GithubHelp home page GithubHelp logo

pavel-a / usb-relay-hid Goto Github PK

View Code? Open in Web Editor NEW
244.0 24.0 105.0 134 KB

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

Shell 1.52% Python 4.67% C 47.48% Makefile 1.19% C++ 41.99% Batchfile 1.22% QMake 1.19% CMake 0.74%
hardware usb-relays usb-hid home-automation lab-automation atmega

usb-relay-hid's People

Contributors

christophgysin avatar pavel-a avatar sergboec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

usb-relay-hid's Issues

run make_release_linux.sh

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.

hidusb-relay-cmd ID change operation support

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?

how to operate. two one channel relay connected to one laptop

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.

USB relay to alert when there's no power in the grid

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?

wrapper for C# .net

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!

nodejs API

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...

os x leopard 10.5.8 header add issue

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

Questions

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:

  1. It is a little jarring that the number of relays on the board must be obtained from the name of the device. Maybe there is a separate command that returns the number of relays?
  2. Is it possible to switch several relays at the same time in one command?

There was a problem using two identical relays

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!

Request for 64-bit Linux binaries

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.

Resolve issue with usb_relay_device_open_with_serial_number (orig. lib)

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.

Bad usbrelay ID string!

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

Qt based solution and Gui

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?

New relay boards don't work?

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?

error 0xc000012f

Hi, firstly so sorry, i'm newbie in python :D

Can you help me with it error?
I using win10x64 and python 3
image

usb_relay_device_enumerate return Null pointer access

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

How to implement dll with Matlab

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')

qt use error

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?

Strange behavior of second relay

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.

Believe there are typo(s) in a commandline printf

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

Can not Find more then 2 device

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

Building a 64bit Windows dll

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.

Use 2 board link to one control pc, they have the same ID

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)
`

Relay as "Unknown device"

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?

Python Windows 32 bit and 64 bit driver usb_relay_device.dll - where to find?

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!

OSX unknown error(0)

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

New devices have the same ID and are indistinguishable

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.