mysensors / MySensors

MySensors library and examples

Home Page:https://www.mysensors.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

High GPIO pin number doesn't work when compiling mysgw

DocRuben opened this issue · comments

I'm trying to compile mysgw with the IRQ pin set to 360 wich is the pin number for my SBC(Orange Pi 3 LTS)
but after compiling the number has been changed to 104 and that causes an error at runtime.

ERROR attachInterrupt: Unable to open GPIO edge interface for pin 104: Permission denied

Works fine without specifying an IRQ pin, probably because all other pin-numbers are < 255

attachInterrupt takes an uint8_t, so any value above 255 will result in whatever C does when things don't fit (360 - 256 is 104 so I guess it just ignores the higher bits). This normally result in warnings during compilation. Could you post the full output of the compilation?

Could you also provide the full configure command? That would make it possible to try to reproduce the problem.

When using ./configure --my-rf24-irq-pin=360 I get the following warnings, confirming that 360 is truncated to 104:

./hal/transport/RF24/driver/RF24.cpp: In function ‘bool RF24_initialize()’:
<command-line>: warning: unsigned conversion from ‘int’ to ‘uint8_t’ {aka ‘unsigned char’} changes value from ‘360’ to ‘104’ [-Woverflow]
./hal/transport/RF24/driver/RF24.cpp:522:12: note: in expansion of macro ‘MY_RF24_IRQ_PIN’
  hwPinMode(MY_RF24_IRQ_PIN,INPUT);
            ^~~~~~~~~~~~~~~
In file included from ./MySensors.h:39,
                 from examples_linux/mysgw.cpp:82:
<command-line>: warning: unsigned conversion from ‘int’ to ‘uint8_t’ {aka ‘unsigned char’} changes value from ‘360’ to ‘104’ [-Woverflow]
./hal/architecture/Linux/drivers/core/Arduino.h:40:62: note: in definition of macro ‘digitalPinToInterrupt’
 #define digitalPinToInterrupt(pin) RPi.digitalPinToInterrupt(pin)
                                                              ^~~
./hal/transport/RF24/driver/RF24.cpp:537:48: note: in expansion of macro ‘MY_RF24_IRQ_PIN’
  RF24_SPI.usingInterrupt(digitalPinToInterrupt(MY_RF24_IRQ_PIN));
                                                ^~~~~~~~~~~~~~~
<command-line>: warning: unsigned conversion from ‘int’ to ‘uint8_t’ {aka ‘unsigned char’} changes value from ‘360’ to ‘104’ [-Woverflow]
./hal/architecture/Linux/drivers/core/Arduino.h:40:62: note: in definition of macro ‘digitalPinToInterrupt’
 #define digitalPinToInterrupt(pin) RPi.digitalPinToInterrupt(pin)
                                                              ^~~
./hal/transport/RF24/driver/RF24.cpp:539:40: note: in expansion of macro ‘MY_RF24_IRQ_PIN’
  attachInterrupt(digitalPinToInterrupt(MY_RF24_IRQ_PIN), RF24_irqHandler, FALLING);
                                        ^~~~~~~~~~~~~~~
./hal/architecture/Linux/MyMainLinuxGeneric.cpp: In function ‘void handle_sigint(int)’:
<command-line>: warning: unsigned conversion from ‘int’ to ‘uint8_t’ {aka ‘unsigned char’} changes value from ‘360’ to ‘104’ [-Woverflow]
./hal/architecture/Linux/MyMainLinuxGeneric.cpp:45:18: note: in expansion of macro ‘MY_RF24_IRQ_PIN’
  detachInterrupt(MY_RF24_IRQ_PIN);

My complete configure command getting this error is

./configure --spi-spidev-device=/dev/spidev1.0 --my-transport=rf24 --my-rf24-channel=76 --my-rf24-ce-pin=117 --my-rf24-cs-pin=227 --my-rf24-irq-pin=360 --my-rf24-pa-level=RF24_PA_MAX

When compiling I get a lot of warnings about different vars getting truncated both with and without specifying a IRQ-pin, in both cases it compiles sucsessfully but with the IRQ-pin specified I get the previous error at runtime.
Without it compiles and seams to run fine eaven though all warnings.

Attaching my output from make.
make.txt