Closed martinwork closed 1 year ago
Describe the bug
Arising from support ticket https://support.microbit.org/helpdesk/tickets/56783 (private)
The documentation for radio.sendString says it sends up to 19 characters. https://makecode.microbit.org/reference/radio/send-string
MakeCode V1 sent 19 characters, but only 18 have been sent since MakeCode V2.
In MakeCode's radio packet code, MAX_PAYLOAD_LENGTH has always been 20.
In MakeCode V1, sendString copied up to MAX_PAYLOAD_LENGTH - 1 bytes after one byte storing the string length. https://github.com/microsoft/pxt-microbit/blob/5d5b348757b15c6d00f5b7f560fd69592ca29424/libs/radio/radio.cpp#L307
From MakeCode V2, the radio code moved, and the maximum string length became MAX_PAYLOAD_LENGTH - 2. https://github.com/microsoft/pxt-common-packages/blob/master/libs/radio/radio.ts#L398
Either the code or the documentation is currently wrong. I don't know if there was a technical reason why a termination byte became necessary.
To Reproduce
Here is a zipped folder of V1, V2 and V5 builds of the same project. Drag a hex to 2 micro:bits and press A on one. radio-string-length.zip
micro:bit version (please complete the following information): not hardware related
Desktop (please complete the following information):
@pelikhan remember anything here?
Either we should fix the documentation or increase the limit.
can't remember.
Describe the bug
Arising from support ticket https://support.microbit.org/helpdesk/tickets/56783 (private)
The documentation for radio.sendString says it sends up to 19 characters. https://makecode.microbit.org/reference/radio/send-string
MakeCode V1 sent 19 characters, but only 18 have been sent since MakeCode V2.
In MakeCode's radio packet code, MAX_PAYLOAD_LENGTH has always been 20.
In MakeCode V1, sendString copied up to MAX_PAYLOAD_LENGTH - 1 bytes after one byte storing the string length. https://github.com/microsoft/pxt-microbit/blob/5d5b348757b15c6d00f5b7f560fd69592ca29424/libs/radio/radio.cpp#L307
From MakeCode V2, the radio code moved, and the maximum string length became MAX_PAYLOAD_LENGTH - 2. https://github.com/microsoft/pxt-common-packages/blob/master/libs/radio/radio.ts#L398
Either the code or the documentation is currently wrong. I don't know if there was a technical reason why a termination byte became necessary.
To Reproduce
Here is a zipped folder of V1, V2 and V5 builds of the same project. Drag a hex to 2 micro:bits and press A on one. radio-string-length.zip
micro:bit version (please complete the following information): not hardware related
Desktop (please complete the following information):