Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions e2e/protocol.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,27 @@ print('done')
await simulator.expectSerial(/^b'hell'\ndone\n/);
});

test("receives a message of the maximum length", async ({ simulator }) => {
await simulator.run(`import radio
from microbit import *
radio.on()
radio.config(length=251)
while True:
message = radio.receive()
if message:
print(len(message), message[-3:])
break
sleep(20)
`);
await simulator.waitForState((s) => (s.radio as any)?.enabled === true);
// The header radio.send adds to strings counts towards the length.
const text = "x".repeat(245) + "end";
await simulator.radioInput(
new Uint8Array([1, 0, 1, ...new TextEncoder().encode(text)]),
);
await simulator.expectSerial(/^248 end\n/);
});

test("input beyond the queue size is dropped", async ({ simulator }) => {
await simulator.run(receive("radio.config(queue=2)"));
await simulator.waitForState((s) => (s.radio as any)?.enabled === true);
Expand Down
2 changes: 1 addition & 1 deletion src/drv_radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
// 4 bytes time
#define RADIO_PACKET_OVERHEAD (1 + 1 + 4)

static uint8_t rx_buf_size = 0;
static size_t rx_buf_size = 0;

void microbit_radio_enable(microbit_radio_config_t *config) {
microbit_radio_disable();
Expand Down
Loading