<< openserial serial serialstatus >>

serial >> serial > readserial

readserial

read characters from serial port

Calling Sequence

buf = readserial(h [,n])

Parameters

h

string, Tcl handle to the serial port

n

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).

buf

string retrieved from the serial port.

Description

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.

Examples

h = openserial(1, "9600,n,8,1")
writeserial(h, "#02"+ascii(13))
readserial(h)
closeserial(h)

See Also

Contributors

Enrico SEGRE
Aditya SENGUPTA <apsengupta@iitb.ac.in>
Samuel GOUGEON

Bibliography


Report an issue
<< openserial serial serialstatus >>