@@ -267,7 +267,7 @@ def __init__(
267
267
preamble_length = 4 ,
268
268
encryption_key = None ,
269
269
high_power = True ,
270
- baudrate = 5000000
270
+ baudrate = 1000000
271
271
):
272
272
self ._tx_power = 13
273
273
self .high_power = high_power
@@ -400,19 +400,6 @@ def _write_from(self, address, buf, length=None):
400
400
device .write (self ._BUFFER , end = 1 )
401
401
device .write (buf , end = length ) # send data
402
402
403
- def _write_fifo_from (self , buf , length = None ):
404
- # Write a number of bytes to the transmit FIFO and taken from the
405
- # provided buffer. If no length is specified (the default) the entire
406
- # buffer is written.
407
- if length is None :
408
- length = len (buf )
409
- with self ._device as device :
410
- self ._BUFFER [0 ] = (_REG_FIFO | 0x80 ) & 0xFF # Set top bit to 1 to
411
- # indicate a write.
412
- self ._BUFFER [1 ] = length & 0xFF # Set packt length
413
- device .write (self ._BUFFER , end = 2 ) # send address and lenght)
414
- device .write (buf , end = length ) # send data
415
-
416
403
def _write_u8 (self , address , val ):
417
404
# Write a byte register to the chip. Specify the 7-bit address and the
418
405
# 8-bit value to write to that address.
@@ -754,26 +741,27 @@ def send(
754
741
self .idle () # Stop receiving to clear FIFO and keep it clear.
755
742
# Fill the FIFO with a packet to send.
756
743
# Combine header and data to form payload
757
- payload = bytearray (4 )
744
+ payload = bytearray (5 )
745
+ payload [0 ] = 4 + len (data )
758
746
if destination is None : # use attribute
759
- payload [0 ] = self .destination
747
+ payload [1 ] = self .destination
760
748
else : # use kwarg
761
- payload [0 ] = destination
749
+ payload [1 ] = destination
762
750
if node is None : # use attribute
763
- payload [1 ] = self .node
751
+ payload [2 ] = self .node
764
752
else : # use kwarg
765
- payload [1 ] = node
753
+ payload [2 ] = node
766
754
if identifier is None : # use attribute
767
- payload [2 ] = self .identifier
755
+ payload [3 ] = self .identifier
768
756
else : # use kwarg
769
- payload [2 ] = identifier
757
+ payload [3 ] = identifier
770
758
if flags is None : # use attribute
771
- payload [3 ] = self .flags
759
+ payload [4 ] = self .flags
772
760
else : # use kwarg
773
- payload [3 ] = flags
761
+ payload [4 ] = flags
774
762
payload = payload + data
775
763
# Write payload to transmit fifo
776
- self ._write_fifo_from ( payload )
764
+ self ._write_from ( _REG_FIFO , payload )
777
765
# Turn on transmit mode to send out the packet.
778
766
self .transmit ()
779
767
# Wait for packet sent interrupt with explicit polling (not ideal but
@@ -873,7 +861,8 @@ def receive(
873
861
# RadioHead header and at least one byte of data --reject this packet and ignore it.
874
862
if fifo_length > 0 : # read and clear the FIFO if anything in it
875
863
packet = bytearray (fifo_length )
876
- self ._read_into (_REG_FIFO , packet )
864
+ self ._read_into (_REG_FIFO , packet , fifo_length )
865
+
877
866
if fifo_length < 5 :
878
867
packet = None
879
868
else :
0 commit comments