This command allows you to read one or more bytes, up to a whole string,
from the serial port. The simplest syntax is the one that allows you to
retrieve a string from the serial port, indicating the number of characters
(chars
) to read. It is possible to omit the size (in bytes) to read
and instead directly indicate the type
. In this case, a piece of data
will be read from the serial port as long as the indicated type. In this last
use case, the programmer must pay particular attention to the order of the
bytes, where the data exceeds the size of one byte. In other words, the data
is read with the endianess prevailing on the target computer. To change this
behavior and ensure that the endianess is the same, regardless of the computer
used, it is necessary to use the BIG ENDIAN
or LITTLE ENDIAN
option,
to indicate the preferred endianess.
= SERIAL READ [()] AS datatype [BIG ENDIAN|LITTLE ENDIAN] = SERIAL READ (chars)
result = SERIAL READ AS BYTE
Join BASIC 10Liner Contest with ugBASIC!
An interesting competition is held at the beginning of each year: the
BASIC 10Liner Contest.
It is possible to use ugBASIC to participate in the next
"BASIC10Liner" competition, in the following categories:
SERIAL READ ↔ SErR#
If you have found a problem with this keyword, if you think there is a bug or, more
simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!
open an issue
BACK TO KEYWORDS