Skip to content

Commit f6d0804

Browse files
committed
modify .receive timeout - fix README typo
1 parent 41e9926 commit f6d0804

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ For breakout boards or other configurations where the boards are separated,
4747
it may be necessary to reduce the baudrate for reliable data transmission.
4848
The baud rate may be specified as an keyword parameter when initializing the board.
4949
To set it to 1000000 use :
50-
.. code-block:: python# Initialze RFM radio
5150
.. code-block:: python
5251
# Initialze RFM radio
5352
rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, RADIO_FREQ_MHZ,baudrate=1000000)

adafruit_rfm69.py

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -741,31 +741,32 @@ def receive(self, timeout=0.5, keep_listening=True):
741741
packet = None
742742
# Enter idle mode to stop receiving other packets.
743743
self.idle()
744-
if not timed_out:
745-
# Read the data from the FIFO.
746-
with self._device as device:
747-
self._BUFFER[0] = _REG_FIFO & 0x7F # Strip out top bit to set 0
748-
# value (read).
749-
device.write(self._BUFFER, end=1)
750-
# Read the length of the FIFO.
751-
device.readinto(self._BUFFER, end=1)
752-
fifo_length = self._BUFFER[0]
753-
# Handle if the received packet is too small to include the 4 byte
754-
# RadioHead header--reject this packet and ignore it.
755-
if fifo_length < 4:
756-
# Invalid packet, ignore it. However finish reading the FIFO
757-
# to clear the packet.
758-
device.readinto(self._BUFFER, end=fifo_length)
759-
packet = None
760-
else:
761-
# Read the 4 bytes of the RadioHead header.
762-
device.readinto(self._BUFFER, end=4)
763-
# Ignore validating any of the header bytes.
764-
# Now read the remaining packet payload as the result.
765-
fifo_length -= 4
766-
packet = bytearray(fifo_length)
767-
device.readinto(packet)
768-
# Listen again if necessary and return the result packet.
769-
if keep_listening:
770-
self.listen()
744+
if timed_out:
745+
return None
746+
# Read the data from the FIFO.
747+
with self._device as device:
748+
self._BUFFER[0] = _REG_FIFO & 0x7F # Strip out top bit to set 0
749+
# value (read).
750+
device.write(self._BUFFER, end=1)
751+
# Read the length of the FIFO.
752+
device.readinto(self._BUFFER, end=1)
753+
fifo_length = self._BUFFER[0]
754+
# Handle if the received packet is too small to include the 4 byte
755+
# RadioHead header--reject this packet and ignore it.
756+
if fifo_length < 4:
757+
# Invalid packet, ignore it. However finish reading the FIFO
758+
# to clear the packet.
759+
device.readinto(self._BUFFER, end=fifo_length)
760+
packet = None
761+
else:
762+
# Read the 4 bytes of the RadioHead header.
763+
device.readinto(self._BUFFER, end=4)
764+
# Ignore validating any of the header bytes.
765+
# Now read the remaining packet payload as the result.
766+
fifo_length -= 4
767+
packet = bytearray(fifo_length)
768+
device.readinto(packet)
769+
# Listen again if necessary and return the result packet.
770+
if keep_listening:
771+
self.listen()
771772
return packet

0 commit comments

Comments
 (0)