comRead(
const handle, // async handle
[const maxchars]) // # of bits per char
Reads up to maxchars characters from the input queue. comRead
returns immediately when at least 1 character is read. If no character is
available, comRead will wait for a character up to the read timeout
value.
If maxchars is omitted, 1 is assumed.
Example:
var hdl = comOpen('com1');
comReadTimeout(hdl,5000);
comWrite(hdl, 'Send a character, you have 5 seconds: ');
var data = comRead(hdl,10);
if (data == '')
comWrite(hdl, 'timed out');
else
comWrite(hd1, 'thanks!');
comClose(hdl);
|