mikep wrote:I put the following stand-alone test code around your function and it does hang without the sleep as you have observed.
SNIP
Busy loops with no idle time are generally a bad thing. The testcase above using a separate consumer task illustrates why you need a sleep in your busy wait loop. It is just not so obvious with the COM3 serial port.
I suspect that in the ZVM version, the task dispatcher has a chance to run and allows the software UART to transmit the characters. Perhaps a similar facility is needed is some of the zxLib functions to allow other tasks to run when the time slice has expired.
P.S. I had a small browser problem so this append arrived later than I wanted. Sorry to hear about your back pack.
All in all, while the Native mode implementation of the loop is so tight as to not allow task switching (or so it appears), I think that it is a GOOD THING!
I'd rather have tight loops be very efficient rather than ALWAYS be saddled with inefficient loops. I have learned my lesson in tight loops inside a nultitasking architecture. While I love ZBasic's ability to multitask, my instincts are most definitely of a single tasking (with hardware interrupts) nature! It does not automatically seem to me to be a bad idea to burn time in a tight loop waiting for something else to happen. The lesson is learned, I hope. I just wonder where else in some of my old code I have these little gremlins....
I will try out the code you suggested.
As for the dead backpack, well, I just have to assemble another backpack of my own for the dead unit. I have a bunch of PCBs and parts readfy to go. I was using the Sparkfun display because it was the only 4-line LCD display that I have on hand. All the rest are 2 line displays, though with nice BIG characters. This way I get to test out my backpack code's ability to be set to more than a 2 line display. I wrote that code for the backpack, but never actually used it!
Also, the backpack alone from Sparkfun is not all that costly.
-Tony