Skip to content

Commit 3f8e66e

Browse files
committed
Ensure jshPushIOCharEvent is more stable when the FIFO is full
1 parent f86870d commit 3f8e66e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
nRF5x: Ensure Bluetooth notifications work correctly when two separate connections use the same handle for their characteristics
22
nRF5x: Remove handlers from our handlers array when a device is disconnected
33
Bangle.js: Fix wrapString when wrapping a non-UTF8 string containing UTF8 characters (fix #2633)
4+
Ensure jshPushIOCharEvent is more stable when the FIFO is full
45

56
2v26 : nRF5x: ensure TIMER1_IRQHandler doesn't always wake idle loop up (fix #1900)
67
Puck.js: On v2.1 ensure Puck.mag behaves like other variants - just returning the last reading (avoids glitches when used with Puck.magOn)

src/jsdevices.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,7 @@ bool CALLED_FROM_INTERRUPT jshPushEvent(IOEventFlags evt, uint8_t *data, unsigne
449449
* USB and USART data to be coming in at the same time, and it can trip
450450
* things up if one IRQ interrupts another. */
451451
jshInterruptOff();
452-
int available = IOBUFFERMASK+1-jshGetEventsUsed();
453-
if (available < (int)length+2) {
452+
if (jshGetIOCharEventsFree() < (int)length+2) {
454453
jshInterruptOn();
455454
jshIOEventOverflowed();
456455
return false; // queue full - dump this event!
@@ -491,7 +490,8 @@ void jshPushIOCharEvents(IOEventFlags channel, char *data, unsigned int count) {
491490
if (ioLastHead != ioHead && // we have a 'last head'
492491
ioLastHead != ioTail && // it's not something that'll be processed immediately (we're in IRQ so main loop might be in the process right now)
493492
ioBuffer[(ioLastHead+1)&IOBUFFERMASK] == channel && // same channel
494-
ioBuffer[ioLastHead]+count < IOEVENT_MAX_LEN // we have space in this event!
493+
ioBuffer[ioLastHead]+count < IOEVENT_MAX_LEN && // we have space in this event!
494+
jshGetIOCharEventsFree()>0 // we actually have space in our queue!
495495
) {
496496
// increase event count
497497
ioBuffer[ioLastHead] += (uint8_t)count;

0 commit comments

Comments
 (0)