readTimeout Property

Top  Previous  Next

Gets or sets the maximum time to wait for receive data.

Syntax

Cell.Serial[n].readTimeout

Property Value

The maximum time, in milliseconds, for the read function to wait for receive data.

Remarks

The default value for this property is zero, meaning the read function will return immediately with only data that was already in the receive buffer. The maximum value is around 60,000, or one minute, except that the property may also be set to the value Infinity (or +Infinity). In the latter case the read function will block execution indefinitely until the requested number of bytes is received.

Examples

// Wait up to 2 seconds until a 4-byte message received

// Much simpler than example for bytesCanRead

Cell.Serial[0].readTimeout = 2000;// 2 seconds

val = Cell.Serial[0].read(4);

if (val.length < 4)

 ; // timeout

 

// Disable timeout

Cell.Serial[1].readTimeout = Infinity;

val = Cell.Serial[1].read(1);

See Also

read Function