pavel-a / usb-relay-hid

Software for USB-connected relays with HID interface. See the WIKI for more info.
http://vusb.wikidot.com/project:driver-less-usb-relays-hid-interface
250 stars 106 forks source link

run make_release_linux.sh #14

Open racroi3010 opened 7 years ago

racroi3010 commented 7 years ago

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.

pavel-a commented 7 years ago

Run make_release_linux.sh after successful build. This script does not build, it only copies build products.

rochajoel commented 7 years ago

the file name is therefore a 'lie' or at least 'misleading', i would at least expect it to MAKE (what?) a RELEASE (for what?) LINUX. Pavel, i think i'll make a fork of this and contribute with my understanding of this project, thank you for making this sources available, hope you can contribute further! Thanks!

pavel-a commented 7 years ago

Hello rochajoel,

You are welcome to fork and contribute. Thanks!

P.

rochajoel commented 7 years ago

I already did, i'm not an expert on using git, but i tried to make a linux folder on my fork, and added a Makefile on that root folder, have a look at it if you'd like. Given what i have on my fork, all we need is to deploy libusb artifacts to include/usb and to lib/usb/x86 to be able to build the relay cmd utility.

pavel-a commented 7 years ago

Any decent Linux dusribution should include libusb. All you need is to install it using apt-get or whatever, then it's .h file will be found automatically.

Regards, P.

Sent from Outlookhttps://aka.ms/sdimjr for iPad


From: rochajoel notifications@github.com Sent: Friday, March 17, 2017 4:12:56 PM To: pavel-a/usb-relay-hid Cc: Pavel A.; Comment Subject: Re: [pavel-a/usb-relay-hid] run make_release_linux.sh (#14)

I already did, i'm not an expert on using git, but i tried to make a linux folder on my fork, and added a Makefile on that root folder, have a look at it if you'd like. Given what i have on my fork, all we need is to deploy libusb artifacts to include/usb and to lib/usb/x86 to be able to build the relay cmd utility.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/pavel-a/usb-relay-hid/issues/14#issuecomment-287364494, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHaeSbB-rovnipd39183qI8y1BklF2c3ks5rmpTogaJpZM4LBFMA.

rochajoel commented 7 years ago

Great! If you like my changes be my guest to push them to your repository!

Cheers, Joel.

zeeshan-k commented 7 years ago

How to build command line version on linux? I tried cd commandline/makemake && make as given in the wiki but encountered following error:

make: libusb-config: Command not found make: libusb-config: Command not found gcc -O -Wall -I.. -I../../lib -fPIC -c -o usbrelay-cmd.o ../usbrelay-cmd.c ../usbrelay-cmd.c: In function ‘enumFunc’: ../usbrelay-cmd.c:84:2: warning: statement with no effect [-Wunused-value] (context); // ~ unreferenced warning ^ gcc -O -Wall -I.. -I../../lib -fPIC -c -o hiddata_libusb01.o ../hiddata_libusb01.c ../hiddata_libusb01.c:14:17: fatal error: usb.h: No such file or directory compilation terminated.

: recipe for target 'hiddata_libusb01.o' failed make: *** [hiddata_libusb01.o] Error 1
rochajoel commented 7 years ago

Please have a look at my repository https://github.com/rochajoel/usb-relay-hid

As i have run into the same issue, i contributed with a makefile capable of building the cmd line utility. You are still required to build libusb on your own and to put it on the correct paths,

see my repository for more details.

pavel-a commented 7 years ago

Probably you don’t have libusb-dev installed. This stuff comes with libusb-dev.

From: Sergeymailto:notifications@github.com Sent: ‎Sat‎, ‎April‎ ‎8‎, ‎2017 ‎17‎:‎25 To: pavel-a/usb-relay-hidmailto:usb-relay-hid@noreply.github.com Cc: pavel amailto:pavel_a@live.com, Commentmailto:comment@noreply.github.com

How to build command line version on linux? I tried cd commandline/makemake && make as given in the wiki but encountered following error:

make: libusb-config: Command not found make: libusb-config: Command not found gcc -O -Wall -I.. -I../../lib -fPIC -c -o usbrelay-cmd.o ../usbrelay-cmd.c ../usbrelay-cmd.c: In function ‘enumFunc’: ../usbrelay-cmd.c:84:2: warning: statement with no effect [-Wunused-value] (context); // ~ unreferenced warning ^ gcc -O -Wall -I.. -I../../lib -fPIC -c -o hiddata_libusb01.o ../hiddata_libusb01.c ../hiddata_libusb01.c:14:17: fatal error: usb.h: No such file or directory compilation terminated. : recipe for target 'hiddata_libusb01.o' failed make: *** [hiddata_libusb01.o] Error 1

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/pavel-a/usb-relay-hid/issues/14#issuecomment-292721434, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHaeSRfG9pFCvwjn7Sb1hR8LP9GS5gLhks5rt5jNgaJpZM4LBFMA.

rochajoel commented 7 years ago

You DON'T NEED libusb installed on your system, AS LONG AS you have the libraries.

See this: https://github.com/rochajoel/usb-relay-hid/tree/master/linux/include/usb https://github.com/rochajoel/usb-relay-hid/tree/master/linux/lib/usb/x86

If i wanted to have support for ARM, i would have to cross-compile libusb for ARM and include it in (...)linux/lib/usb/arm to be able to compile this utility

If you want to cross-compile run:

ARCH=arm make clean all

I never tested it, but any feedback is welcome! :)

zeeshan-k commented 7 years ago

Thanks @pavel-a I installed libusb-dev and the build succeeded.

zeeshan-k commented 7 years ago

@rochajoel I will try your method on another linux machine and update soon.

mengzhuo commented 7 years ago

@rochajoel cross compile won't work

ARCH=arm make clean all

host

Linux web1 4.10.17-041017-generic #201705201051 SMP Sat May 20 14:53:33 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

target Linux RT-AC68U 2.6.36.4brcmarm #16 SMP PREEMPT Sun May 28 12:34:56 CST 2017 armv7l ASUSWRT-Merlin

rochajoel commented 7 years ago

Thank you for the negative feedback. However, the reason why the build fails is unclear to me. Can you be more specific?

mengzhuo commented 7 years ago

@rochajoel

root@web1:~/usb-relay-hid/commandline/makemake# ARCH=arm make clean all

rm -f *.o hidusb-relay-cmd usb_relay_device.so
gcc -O -Wall   -I.. -I../../lib -fPIC   -c -o usbrelay-cmd.o ../usbrelay-cmd.c
gcc -O -Wall   -I.. -I../../lib -fPIC   -c -o hiddata_libusb01.o ../hiddata_libusb01.c
gcc -o hidusb-relay-cmd usbrelay-cmd.o hiddata_libusb01.o -L/usr/lib/x86_64-linux-gnu -lusb
gcc -O -Wall   -I.. -I../../lib -fPIC   -c -o usb_relay_lib.o ../../lib/usb_relay_lib.c
../../lib/usb_relay_lib.c: In function ‘usb_relay_device_enumerate’:
../../lib/usb_relay_lib.c:382:9: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
     int ret;
         ^
../../lib/usb_relay_lib.c: At top level:
../../lib/usb_relay_lib.c:74:20: warning: ‘usbErrorMessage’ defined but not used [-Wunused-function]
 static const char *usbErrorMessage(int errCode)
                    ^
gcc -shared -Wl,-shared hiddata_libusb01.o usb_relay_lib.o -L/usr/lib/x86_64-linux-gnu -lusb -o usb_rela
y_device.so

and I copy hidusb-relay-cmd to my router

admin@RT-AC68U:/mnt/sda# ./hidusb-relay-cmd
bash: ./hidusb-relay-cmd: cannot execute binary file: Exec format error
rochajoel commented 7 years ago

Your build is probably not using any cross compiler such as arm-linux-gnueabi-gcc (or something of the like). It uses plain gcc. Are you using the sources from my fork of this repository? It's been a long time since i've looked into this. Please inspect my makefile and make sure it contains instructions to use a cross-compiler. (Maybe you have to define it?)

Any way. The problem is that you are not cross compiling. Use readelf or ldd to inspect the output binary so that you know it is in the proper ARM format.

rochajoel commented 7 years ago

If you look closely into my Makefile, it does not declare the ARM GCC compiler, it just has some statements that help you organize the libs in folders preceeded by the name of the arch you are targeting. It is hard coded to work with GCC so, either you create a sym link of GCC to your cross compiler, or you change the CC definition to your cross compiler name. You can even change it so that if ARCH == x86 it uses gcc, otherwise it will use arm-linux-****-gcc.

Also: from your log i can see you are probably forgetting to cross compile libusb! Compile it and add the library to the proper lib folder. If you are going to use 'arm' as ARCH=arm, you have to put it under 'lib/usb/arm'.

ekakela commented 6 years ago

Is there ARM binary available or any instructions how to compile this on Raspberry Pi?

mengzhuo commented 6 years ago

@ekakela if you like Golang , you can try my lib https://github.com/mengzhuo/go-usb-relay no cross compile issue

rochajoel commented 6 years ago

https://github.com/ekakela : I think one can manage to build this for ARM, at least i think i did (it's been a while and i did not save the bin) however, you have to change some stuff as i say in the previous comments above. I'm not saying for sure it will work on your case (i never tried) but that there is a chance you can build it using the sources available at my branch.

ekakela commented 6 years ago

Managed to get it working with your branch.

deurenkletser commented 6 years ago

Can someone help me with more instructions to run this on a respberrypi? I copied rochajoel git to /domoticz/scripts/ but it's unable to run... I also used input from this git: https://github.com/bbqkees/Domoticz-Pi-USB8-relay-board-SOS-solutions. I have that board I want to run on the pi. But it's always giving this error:

image

rochajoel commented 6 years ago

Have you built the executable? Please make sure to build it before you try to run it.

And if you run into some issue, please post the build log so that we can help.

Thanks!

pavel-a commented 6 years ago

Of course. There is no such file usbrelay-cmd. The correct name is hidusb-relay.cmd.

Regards, P.

deurenkletser commented 6 years ago

Ik was following BBQkees instructions to get this to run. Where can I find more instructions on how you build this on the pi? Or does someone know where i can find more on how they build/compile. I now some Linux commands but nothing from programming. Sorry