bytesCanRead Property

Top  Previous  Next

Gets the number of bytes available in the input buffer.



Property Value

The number bytes available to read in the input buffer for serial port n, n in the range 0 - 2.


The value of this property is maximum amount the read function can return without pausing execution.


Setting bytesCanRead to zero will discard all data in the input buffer. Setting it to any other value will have no effect.


// Read all the bytes in the input buffer

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


// Flush (discard) the input buffer

Cell.Serial[1].bytesCanRead = 0;


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

// readTimeout property provides a simpler alternative

for (i = 0; i < 10; i++)


 if (Cell.Serial[0].bytesCanRead >= 4)


 System.Process.yield(200);// check again in 200ms


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

if (val.length < 4)

 ; // timeout

See Also

read Function