ernstdevreede / lmic_pi

Raspberry Pi port LoRaMAC in C / LoRaWAN in C http://www.research.ibm.com/labs/zurich/ics/lrsc/lmic.html
55 stars 29 forks source link

WiringPi double initialization #3

Open rpp0 opened 7 years ago

rpp0 commented 7 years ago

Hi, it seems something changed in the WiringPi library that causes the following runtime error:

$ ./thethingsnetwork-send-v1 
wiringPiSetup*: You must only call this once per program run. This is a fatal error. Please fix your code.

I fixed it by commenting out https://github.com/ernstdevreede/lmic_pi/blob/c4a7c2080faf3fb76277f78b6d035c284a5eec9c/lmic/hal.c#L18

Additionally, in the example there is another call to wiringPiSetup() which needs to be commented out.

sbisca commented 7 years ago

Hi, i'm having the same issue. I also commented the line #130 but still seems doesn't work..

void setup() {
  // LMIC init
  wiringPiSetup();
rpp0 commented 7 years ago

Do you get the same error after commenting the line? Perhaps you forgot to rebuild the library (remove the .o files and compile again) or there's another wiringPiSetup() somewhere in the code.

sbisca commented 7 years ago

As you can see here, i commented that line, removed the file and runned make again, than executed. But still same error..

pi@raspberrypi:~/lmic_pi-master/examples/thethingsnetwork-send-v1 $ rm thethingsnetwork-send-v1
rm: remove write-protected regular file ‘thethingsnetwork-send-v1’? y
pi@raspberrypi:~/lmic_pi-master/examples/thethingsnetwork-send-v1 $ ls
Makefile  thethingsnetwork-send-v1.cpp  thethingsnetwork-send-v1.ino
pi@raspberrypi:~/lmic_pi-master/examples/thethingsnetwork-send-v1 $ sudo make
cd ../../lmic && make
make[1]: Entering directory '/home/pi/lmic_pi-master/lmic'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/pi/lmic_pi-master/lmic'
cc -I../../lmic -o thethingsnetwork-send-v1 thethingsnetwork-send-v1.cpp ../../lmic/*.o -lwiringPi
pi@raspberrypi:~/lmic_pi-master/examples/thethingsnetwork-send-v1 $ sudo ./thethingsnetwork-send-v1
wiringPiSetup*: You must only call this once per program run. This is a fatal error. Please fix your code.
pi@raspberrypi:~/lmic_pi-master/examples/thethingsnetwork-send-v1 $ ls
Makefile  thethingsnetwork-send-v1  thethingsnetwork-send-v1.cpp  thethingsnetwork-send-v1.ino
pi@raspberrypi:~/lmic_pi-master/examples/thethingsnetwork-send-v1 $