call receiveNumber in onDataReceived to flush queue if needed (startup race)

fixed simulator issue when event onDataReceived gets raised
This commit is contained in:
Peli de Halleux
2016-08-08 16:54:43 -07:00
parent de5def8dde
commit 7481b9c24c
4 changed files with 27 additions and 22 deletions

View File

@ -517,6 +517,7 @@ namespace pxsim.radio {
export function onDataReceived(handler: RefAction): void {
pxt.registerWithDal(DAL.MICROBIT_ID_RADIO, DAL.MICROBIT_RADIO_EVT_DATAGRAM, handler);
radio.receiveNumber();
}
}

View File

@ -72,10 +72,9 @@ namespace pxsim {
}
queue(packet: PacketBuffer) {
if (this.datagram.length < 5) {
if (this.datagram.length < 4)
this.datagram.push(packet);
(<Board>runtime.board).bus.queue(DAL.MICROBIT_ID_RADIO, DAL.MICROBIT_RADIO_EVT_DATAGRAM);
}
(<Board>runtime.board).bus.queue(DAL.MICROBIT_ID_RADIO, DAL.MICROBIT_RADIO_EVT_DATAGRAM);
}
send(buffer: number[] | string) {