*
[email protected]
| My code to read one CSV record included:
| while {-1 < [gets $ff line]} { ... }
| which works fine reading a file in blocking mode.
| In looking for why the library code might be different
| I found my code did not work for nonblocking mode,
| while the tcllib code works in blocking or nonblocking mode.
Note that the TCLLIB code is
while !eof
if -1 < gets continue
i.e. in non-blocking mode it busy-waits for EOF.
This is quite different from
while -1 < gets
...
which in non-blocking mode stops at the first no-data-available.
I doubt that the Tcllib CSV code will work on input from a serial line, blocking or not, since it waits for eof, which will never arrive on the
serial line (unless of course you remove the hardware).
Since the Tcllib code does not change the properties of the channel, it completely depends on how the channel is configured by the caller. And
since it waits for eof, it implicitely requires a channel which will
ultimately 'send' eof.
| I am reading from a file now, but might end up reading data over USB
| serial from a Teensy LC or 3.2 microcontroller.
I *think* your best bet in this case would be to set up an fileevent
handler for the serial line, and read the data event-based as they come
in. Note however that you would need some indication when no more input
is to be expected from the serial line.
R'
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)