Not really rc-switch but more like a test I made of the CGO wrapper on a cross-compiled C arm lib.
wget https://git.io/fjnXH && \
unzip send_sniffer_0.0.1.zip
./send 0 9999
./sniffer 2
- more doc
- more experiment
- real auto tests
- raspberry pi with GPIO,
- antenna receiver plugged on GPIO 2
- antenna transmitter plugged on GPIO 0
- Go 1.12
- wiring pi lib https://github.com/WiringPi/WiringPi
- raspberry pi toolchain https://github.com/raspberrypi/tools
- Wiring-pi lib installed on the target raspberry pi http://wiringpi.com/download-and-install/
get the toolchain
git clone https://github.com/raspberrypi/tools
add toolchain compilers to path
PATH=$PATH:~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/
build wiring pi lib (command has to be ran on the target)
apt install git && \
cd /tmp && \
git clone https://github.com/WiringPi/WiringPi && \
cd WiringPi && \
./build
repatriate the compiled .so(s) to the compiler
scp <user@pi>:/usr/local/lib/libwiringPi* ~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/lib/
cross the hell compile to arm
make
send binary to target
scp build/send build/sniffer <user@pi>:/tmp
run (target)
./sniffer 2
./send 0 9999
easy way to find out if compilation is well made and lib is loaded in the wrapper:
env GOOS=linux GOARCH=arm CC=arm-linux-gnueabihf-gcc CC_FOR_TARGET=arm-linux-gnueabihf-gcc CGO_ENABLED=1 go build -i -v -o build/test tests/testCompilation.go
./build/test
2019/04/22 15:06:16 calling setup
2019/04/22 15:06:16 calling handler
compilation succeed, lib loaded