|Top Previous Next|
Sends binary data to the serial port.
Cell.Serial[n].writeBytes(data [, data ...])
Zero if successful, or a negative number if failure.
The data sent for each data argument depends on its type as shown in the table:
If the serial port's output buffer has sufficient free space, this function will return immediately. Otherwise, execution will pause while data is sent. The bytesCanWrite property returns how many bytes are free in the output buffer.
This function can fail if the serial port has not been enabled by setting its bitRate property to a positive value.
// Command a DirecTV receiver to change channel
// 16-bit values are transmitted high byte first
function ChanChange(chan, subChan)
Cell.Serial.bitRate = 9600;
if (subChan == undefined)
subChan = 0xFFFF;
Cell.Serial.writeBytes(0xFA, 0xA6); // command
// 6 bytes sent: FA A6 00 CA FF FF