Serial Object

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:


Serial Port

Receive Pin (in)

Transmit Pin (out)











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.


Data is received using the read function, which returns a string. Individual bytes of binary data can be accessed from the returned string using the element reference operator [].


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.

Static Functions


Receives data from the serial port.


Sends text data to the serial port.


Sends binary data to the serial port.

Static Properties


Gets or sets the serial data rate.


Gets the number of bytes available in the input buffer.


Gets the number of bytes free in the output buffer.


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