QNEthernet and TeensyThreads causes assertions/crashes. ...solved!

This post is solution to a problem in hopes it helps others in the future since no web search lead me to an answer directly. ;)

When using QNEthernet and Teensythreads in the same program while sending large data at fast rate (25k every 250ms) one of the following assertions occur within a few minutes:
Code:
Assertion "tcp_write: no pbufs on queue => both queues empty" failed at line 344 in .pio\libdeps\teensy41\QNEthernet\src\lwip\tcp_out.c
Code:
Assertion "tcp_receive: valid queue length" failed at line 1122 in .pio\libdeps\teensy41\QNEthernet\src\lwip\tcp_in.c

The fix is replacing delay(n) in each thread with threads.delay(n). This change will trigger yields() significantly more frequent (pending each thread is fairly lightweight in terms of using their allocated timeslice).

This only took me a few days to realize :eek:
Thanks for the excellent libraries @ftrias and @ssilverman!
 
Back
Top