Page 4 of 4

Re: Use micropython to do dead simple "over-the-air" code updates

Posted: Thu Nov 01, 2018 11:32 am
by pythoncoder
That is very odd. I've today run the following under CPython. I've also run it under MicroPython on the following ports: Unix, Pyboard and ESP8266. All without issue.

Code: Select all

radioBuffer = bytearray(256)
mv = memoryview(radioBuffer)

def copyStringToRadioBuffer(s):
    l = len(s)
    mv[: l] = s.encode('utf8')[: l]
    mv[l] = 0

copyStringToRadioBuffer('The quick brown fox\n')
print(radioBuffer)
If it fails on your platform it could be a build-time option otherwise it's a port specific bug. I'm not well-up on the build options but if it were a space-saving optimisation I'd have expected to see it on the ESP8266.

Has anyone else any thoughts on this?

Re: Use micropython to do dead simple "over-the-air" code updates

Posted: Thu Nov 01, 2018 5:26 pm
by WhiteHare
OK, until that gets sorted, I reverted to the prior copyStringToRadioBuffer definition for the current files posted on GitHub. That way anyone downloading the files should have something that works.

I also made a few upgrades:
1. Rather than running open loop and transmitting each packet 3 times, the receiver node now transmits an acknowledgement to the transmitter to let the transmitter know that the receiver received a valid packet and for the transmitter to please the next packet.
2. Upgraded from 1mbps to 2mbps over the air datarate.
3. Enabled data-whitening.
4. Now using a longer preamble on transmitted packets.

https://github.com/rabbithat/NRF52840_M ... TA_Updates

Re: Use micropython to do dead simple "over-the-air" code updates

Posted: Fri Nov 02, 2018 8:19 am
by pythoncoder
WhiteHare wrote:
Thu Nov 01, 2018 5:26 pm
OK, until that gets sorted, I reverted to the prior copyStringToRadioBuffer definition for the current files posted on GitHub...
Fair enough.

I've posted this message to establish why this orthodox bit of Python is failing, and to determine which Nordic targets are affected.

As an optimisation it's pretty small beer, but we should know why it's failing.

Re: Use micropython to do dead simple "over-the-air" code updates

Posted: Sat Nov 03, 2018 1:04 am
by WhiteHare
Thanks! Now that we've solved that, I added your code back into the official github release: https://github.com/rabbithat/NRF52840_M ... TA_Updates

Re: Use micropython to do dead simple "over-the-air" code updates

Posted: Sat Nov 03, 2018 11:14 am
by pythoncoder
Alas we proved that my solution requires users to create a special build. Your code avoids this so is arguably more usable, at least until the official build gets better ;)