Hello,
input $ expects n characters from the terminal (or serial link rx0);
temp.input $ expects n characters from treminal or rx0. If the timeout is exceeded, returns an empty string or the characters received.
This function is particularly useful when you are expecting characters transmitted over a serial link, such as a LoRa transmitter for example.
The advantage of temp.input $ is that it does not wait indefinitely for a transmission or a transmission that does not end with cr.
:::forth -input marker -input \ accept n characters from terminal FORTH buffer \ leave addr n : input$ ( n --- addr n) pad swap accept pad swap ; 2000 value IN_DELAY \ increase or decrase if necessary : temp.rx0 IN_DELAY begin 1- 1 ms rx0? \ char recevied from rx0 ? if drop rx0 exit then dup 0= until drop 13 \ if no char, leave $0a (cr) ; \ temporised input : temp.input$ ( n --- addr n) ['] temp.rx0 'key ! input$ ['] rx0 'key ! ;
Log in to post a comment.
Hello,
input $ expects n characters from the terminal (or serial link rx0);
temp.input $ expects n characters from treminal or rx0. If the timeout is exceeded, returns an empty string or the characters received.
This function is particularly useful when you are expecting characters transmitted over a serial link, such as a LoRa transmitter for example.
The advantage of temp.input $ is that it does not wait indefinitely for a transmission or a transmission that does not end with cr.
Last edit: PETREMANN 2020-11-21