billroy / bitlash

Bitlash: a programmable command shell for arduino
http://bitlash.net
MIT License
344 stars 73 forks source link

Problem of output buffer when using bitlash #60

Closed rmd13 closed 5 years ago

rmd13 commented 5 years ago

I am using matlab's serial command to communicate with COm3 on arduino uno already loaded with bitlash. Unlike interactive Serial terminal windows, whenI send char to COM3 to do comand, these is no output on screen, and they are stored in output buffer.

Sometimes I need to read the output of a command such as % get pin 12 level: aStr = 'print d12'; fprintf(obj1,'%s\n',aStr); tline = fgetl(obj1) tline = fgetl(obj1) tline = fgetl(obj1) tline = fgetl(obj1) tline = fgetl(obj1) tline = fgetl(obj1) tline = fgetl(obj1) ...

I need to run a lot of tline = fgetl(obj1) . Each calling will return a echo history that take place at early stages, and after try many times I can get the most fresh output buffer: the pin level.

So this is very inconvenient for me to get the output I want.

Is there a way to auto-flush the output buffer so that only the last line remains in output buffer, so that I can read it directly.

Call the tline = fgetl(obj1) repeatly is a bad idea because I cannot tell how much times to call. And when it returns the last ftresh line of output buffer, more calling will block the matlab untill timeout, which is very unwanted.