lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3559
Posted: 04:34pm 09 Jun 2025
I'm with Phenix--MMBasic serial is rock solid. If LOC(#1) is greater than 0, you can read bytes.
I think there are two things wrong with your loop--you are not adding what you read to g$, and you're looping UNTIL LOC(#1) = 0 instead of DO WHILE LOC(#1) > 0. Try this:
g$="" If LOC(#1) > 0 then DO WHILE LOC(#1) > 0 g$=g$+input$(LOC(#1),#1) PAUSE 10 ' allow time for more bytes to arrive if they are coming LOOP endif print g$
(But make sure you don't send more than 255 bytes so you don't overrun g$.)
(You can omit the IF ... ENDIF, but it may make it more clear that this block handles serial input when new input has been detected.)