Skip to main content

uart.readstring(numberOfChars)

Reads a string of characters from the serial port

Availability

Device (from impOS™ 30)

Parameters

Name Type Description
numberOfChars integer Optional number of characters to read (default = 80)

Returns

String — the characters read from the UART FIFO, or an empty string if the FIFO is empty

Description

This method reads a specified numbers of bytes from the UART’s receive FIFO and returns them as a string. If you do not specify the number of characters you require — the numberOfChars parameter is optional — the method returns all of the available bytes as characters up to the size of the FIFO itself. By default, the receive FIFO is set at 80 characters is size. However, under impOS™ Release 32 and up, the size of the FIFO may be altered using uart.setrxfifosize().

If fewer characters than requested are available, the method will return a shorter string containing as many characters as there were bytes in the FIFO. If no data is available, it will return an empty string, "".

The method does not block.