You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When configuring CODAL_SERIAL_EVT_HEAD_MATCH and CODAL_SERIAL_EVT_DELIM_MATCH events for Serial (through the use of eventOn and eventAfter), there is no lazy initialisation of the rxBuffer/rxInterrupt performed with initialiseRx. This results in the events not being fired until the the rxInterrupt and buffer is then later configured by another function call, even if data is sent over serial to the device.
This seems to me quite unintuitive behaviour; if the event is configured and data is then sent to the device over serial, then it should follow that the event is called. You can replicate this behaviour with the following code:
#include<MicroBit.h>
MicroBit uBit;
//Callback for when serial data is received.voidcallback(MicroBitEvent e) {
while (true)
uBit.display.scroll("DATA!");
}
intmain() {
uBit.init();
//Set up an eventAfter for when we receive any bytes.
uBit.messageBus.listen(MICROBIT_ID_SERIAL, MICROBIT_SERIAL_EVT_HEAD_MATCH, callback);
uBit.serial.eventAfter(1);
//Release to the scheduler.release_fiber();
}
If this is is seen as unintended behaviour, then I can submit a pull request to lazy initialise the rxBuffer from both of these event functions. Let me know if this would be a change that would be acceptable!
The text was updated successfully, but these errors were encountered:
When configuring
CODAL_SERIAL_EVT_HEAD_MATCH
andCODAL_SERIAL_EVT_DELIM_MATCH
events forSerial
(through the use ofeventOn
andeventAfter
), there is no lazy initialisation of therxBuffer
/rxInterrupt
performed withinitialiseRx
. This results in the events not being fired until the therxInterrupt
and buffer is then later configured by another function call, even if data is sent over serial to the device.This seems to me quite unintuitive behaviour; if the event is configured and data is then sent to the device over serial, then it should follow that the event is called. You can replicate this behaviour with the following code:
If this is is seen as unintended behaviour, then I can submit a pull request to lazy initialise the rxBuffer from both of these event functions. Let me know if this would be a change that would be acceptable!
The text was updated successfully, but these errors were encountered: