SimpleIDE question: terminal input not buffered? (SOLVED)
mpark
Posts: 1,305
The little Spin program below echoes what I type but very slowly: one character per second. If I type many characters (e.g., HELLO) in less than a second, the characters are buffered and over the next five seconds the program prints H... E... L... L... O, one character per second.
_clkmode = xtal1+pll16x _clkfreq = 80_000_000 obj term: "fullduplexserial" pub Main | ch term.start(31, 30, 0, 115200) repeat waitcnt(clkfreq + cnt) ch := term.rx term.tx(ch) term.tx(13)Now I'm trying to do the same thing in C, but I obviously don't know what I'm doing. Whenever the following C program pauses for one second, it just ignores anything I type during that time. If I type EXCELSIOR, the program might print L or S or whatever I happen to type after the pause expires.
#include "simpletools.h" // Include simple tools int main() // Main function { while(1) { pause(1000); char ch = getChar(); putChar(ch); putChar('\n'); } }How do I do in C what I did in Spin?
Comments
In your code you are using the full duplex object and here is the same in C.
Mike
I changed the newline character to a return character so it moves down the page.
Now, since I already have code using get/putXXX, can I replace the default object, like so? Or, to save space, is there a way to not load the half-duplex object at all and just use full-duplex from the get-go?
Also, I didn't understand your remark re newline vs return. They both behave the same in SimpleIDE Terminal, afaict?
You don't need to close simple serial because the full duplex version see you using pins 31, 30 and will automatically close it for you.
Since the simple serial is part of the startup code I guess there is no way to remove it from the code.
Mike