jpbarraca / pynrf24

Python port of the RF24 library for NRF24L01+ radios.
GNU General Public License v2.0
152 stars 84 forks source link

whatHappened clears status before reading status #32

Open AidanHolmes opened 7 years ago

AidanHolmes commented 7 years ago

The initial call to self.write_register(NRF24.STATUS, NRF24.RX_DR | NRF24.TX_DS | NRF24.MAX_RT) clears the status flags so whatHappened never returns that anything happened for RX_DR, TX_DS or MAX_RT

diodelass commented 7 years ago

It sure doesn't work now, but since the STATUS register is shifted out immediately every time any command (including a 'write register' command) is executed, the best way to grab the status in this case (and, judging by the comments, what was originally intended) would be to catch the output of the call to spi.xfer2 in write_register. Because of this behavior of the device, write_register should probably return the STATUS register's contents whenever it's called anyway, so this seems like a perfectly reasonable change. I'll see if I can put together a pull request implementing this soon.