read characters from serial port
buf = readserial(h [,n])
string, Tcl handle to the serial port
number of characters to be read. If omitted, all the characters currently in the input buffer are retrieved (serialstatus is used).
NB: if the input buffer contains less
than n
characters and the blocking
mode of openserial is true,
readserial
hangs until n
are received (this can last forever).
string retrieved from the serial port.
Read characters from the serial port
The translation
setting of
openserial can come in the way,
affecting the number of characters effectively read. If that is the case,
omitting the parameter n
might be a bad idea,
as scilab can hang. This would happen if the input stream contains
CR
or LF
characters which are
filtered out: in such cases serialstatus
counts them, but readserial does not see
them and keeps wating (if the blocking
mode of
openserial was true) until the total
number is received.
h = openserial(1, "9600,n,8,1") writeserial(h, "#02"+ascii(13)) readserial(h) closeserial(h) | ![]() | ![]() |
Enrico SEGRE | |
Aditya SENGUPTA | <apsengupta@iitb.ac.in> |
Samuel GOUGEON |