@@ -439,7 +439,12 @@ void CALLED_FROM_INTERRUPT jshIOEventOverflowed() {
439439/// Push an IO event (max IOEVENT_MAX_LEN) into the ioBuffer (designed to be called from IRQ), returns true on success, Calls jshHadEvent();
440440bool CALLED_FROM_INTERRUPT jshPushEvent (IOEventFlags evt , uint8_t * data , unsigned int length ) {
441441 assert (length < IOEVENT_MAX_LEN );
442- if (length > IOEVENT_MAX_LEN ) length = IOEVENT_MAX_LEN ;
442+ if (length > IOEVENT_MAX_LEN ) {
443+ #ifndef RELEASE
444+ jsiConsolePrintf ("%d>IOEVENT_MAX_LEN\n" , length );
445+ #endif
446+ length = IOEVENT_MAX_LEN ;
447+ }
443448 /* We're disabling IRQs for this bit because it's actually quite likely for
444449 * USB and USART data to be coming in at the same time, and it can trip
445450 * things up if one IRQ interrupts another. */
@@ -496,8 +501,13 @@ void jshPushIOCharEvents(IOEventFlags channel, char *data, unsigned int count) {
496501 ioHead = (ioHead + 1 ) & IOBUFFERMASK ;
497502 }
498503 } else {
499- // Push the event
500- jshPushEvent (channel , (uint8_t * )data , count );
504+ // Push the event (split into IOEVENT_MAX_LEN chunks just in case)
505+ while (count ) {
506+ unsigned int c = (count > IOEVENT_MAX_LEN ) ? IOEVENT_MAX_LEN : count ;
507+ jshPushEvent (channel , (uint8_t * )data , c );
508+ count -= c ;
509+ data += c ;
510+ }
501511 }
502512 // Set flow control (as we've just filled the buffer up more)
503513 if (DEVICE_HAS_DEVICE_STATE (channel ) && jshGetEventsUsed () > IOBUFFER_XOFF )
0 commit comments