phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 3348
Posted: 12:46am 12 Jun 2025
So no it won't wait. The manual could be changed to read " This function will return as many characters as are in the file or receive buffer up to ‘nbr’, removing them from the buffer." If there are more than n characters in the buffer the rest remain and Loc(#x) is adjusted. In my previous program changing 255 to 11 (g$ = Input$(11,#1)) shows this.
> LIST ' Serial Rx test program on Pico B SetPin gp1,gp0, com1 : Open "COM1:115200" As #1 g$ = Input$(255,#1) : g$="" 'purge the Rx buffer Do Do While Loc(#1) = 0 : Loop 'wait for data to start arriving
Pause 2 'allow time for the rest if the message to arrive 'increase for longer message or lower baud rate Print Loc(#1); " Bytes in Rx buffer", g$ = Input$(11,#1) Print g$; Loop > > RUN 21 Bytes in Rx buffer 12-06-2025 10 Bytes in Rx buffer 11:02:15 21 Bytes in Rx buffer 12-06-2025 10 Bytes in Rx buffer 11:02:16 21 Bytes in Rx buffer 12-06-2025 10 Bytes in Rx buffer 11:02:17 21 Bytes in Rx buffer 12-06-2025 10 Bytes in Rx buffer 11:02:18 21 Bytes in Rx buffer 12-06-2025 10 Bytes in Rx buffer 11:02:19