nRF24 / RF24

OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices
https://nrf24.github.io/RF24
GNU General Public License v2.0
2.2k stars 1.01k forks source link

SPIDEV driver failed, on Raspberry pi 3b+, modify to 'virtual ~SPI();' in spi.h fixes it. #481

Closed Edward-CNRG-NTU closed 3 years ago

Edward-CNRG-NTU commented 5 years ago

https://github.com/nRF24/RF24/blob/a3ab7ddb075360deac54fe2c8e2fab286793d21c/utility/SPIDEV/spi.h#L79

as title, the SPIDEV driver was installed without error message, but failed to import pyRF24.

after some tinkering, I found that tweaking this line to virtual ~SPI(); fixes it. I have no idea how that did the trick, any explanation?

BTW, I'm actually investigating in initializing two RF24 objects in my python application to control two NRF24 module at the same time physically.

  1. I've found that the RPi driver utilizing the bcm2835.c driver, but the spi interface is defined as static methods of the SPI class. And the Aux SPI bus (the secondary spi bus available on Rasbpi 3b+) can only be accessed by different set of functions in bcm2835.c. (I've tried to modifying the SPI class to remember the busNo parameter and switch to main or aux spi functions in bcm2835.c accordingly. But I failed, not clear why, I'm not familiar with bcm2835 or c++ driver coding.) I did modify the _SPI definition in RF24 driver to using the spi instance instead of the SPI class.
  2. I've tried to tackle this problem with SPIDEV driver. And therefore I found this virtual ~SPI(); thing. But after that, I'm still unable to instantiating two RF24 objects in my python application. I only got segmentation fault.

thanks

TMRh20 commented 3 years ago

Kind of an old issue, but the v1.3.5 release in July allowed for multiple instances of SPI via SPIDEV, so that should be working now. Still unsure what to make of the virtual ~SPI() thing...

Please reopen if still ongoing issues.