|Top Previous Next|
Provides asynchronous serial I/O.
The WebCell can be configured with up to three asynchronous serial ports. The Serial object is a three-element array of these serial ports. The serial ports utilize pins according to the following table:
A serial port is enabled by setting its bitRate property to a positive value. Setting the bitRate property to zero disables the serial port and allows the corresponding pins to be used for other functions. Data rates can range from about 1000 bits/sec (baud) to 1.9 Mbps. The data format is always 8 bits, no parity, one stop bit.
Data is transmitted using the write function for text or the writeBytes function for binary data. The write function always converts its arguments to strings; the writeBytes function converts and truncates numeric arguments to bytes.
Each port has a dedicated input buffer and output buffer. The bytesCanWrite property returns how many bytes are free in the output buffer; writing more bytes than are free will cause the CellScript program to pause execution waiting for data to be sent. The bytesCanRead property returns the number of bytes that are available to read from the input buffer; reading more bytes than are available can cause the CellScript program to pause execution waiting for data to be received. The readTimeout property is used to set a limit on the amount of time waiting to receive data.