Re: NRF24L01+ in Python
Posted: Wed Aug 31, 2016 5:51 am
The HELO received is in a ascii decimal format (http://www.nthelp.com/ascii.htm)blavery wrote:luisantunes,
The RECV end (PRX mode) awaits packages, displays the "HELO" (in hex) it received,
... and every alternate time prepares a payload to be bundled with the next AUTO-ACK process.
So the reply is seen by the PTX a transaction delayed - it arrives with the ACK sequence of the next transfer. The PRX cannot initiate a transfer, it can only set up a return package to catch a free ride on the next ACK sequence.
Both forward packet payload and return payload are variable size to 32 bytes.
Brian
Code: Select all
print (''.join(chr(i) for i in recv_buffer))
I figured it was just easier to send string instead of a list. So I changed the code a bit. Just input the command you want to send, and if it reaches more than 32bits, the program will creates chunks of 32bits.
Code: Select all
#you still need the top portion of the code in send-rpi.py
#credits http://stackoverflow.com/questions/18854620/whats-the-best-way-to-split-a-string-into-fixed-length-chunks-and-work-with-the?answertab=active#tab-top
def chunkstring(string,length):
return (string[0+i:length+i] for i in range(0,len(string),length))
while True:
buf = input("enter the command to send")
buf = list(chunkstring(buf,32))
print("nombre de packet de 32bits : " + str(len(buf)))
radio.write("Chunk:" + str(len(buf)))
c = (c + 1) & 255
# send a packet to receiver
for i in buf:
radio.write(i)
print ("Sent:"),
print (i)
# did it return with a payload?
if radio.isAckPayloadAvailable():
pl_buffer=[]
radio.read(pl_buffer, radio.getDynamicPayloadSize())
print ("Received back:"),
print (pl_buffer)
else:
print ("Received: Ack only, no payload")
I don't know if this help anyone.
Thanks for OP for all the info
-Matt