Class: SerialPort

SerialPort

Provides parsing of ASCII serial data from a serial port.

See AsciiHandler for additional supported properties/methods.


Mixes In:
Example
// select a main board serial port to use, one from an IO board could also be used
var serial = ui.serials[0];
// configure the port for 115200,7E1
// use CR or LF to delimit, but also send data after 100ms of idle
serial.reset(); // reset to known state
serial.baud = 115200;
serial.bits = 7;
serial.parity = serial.Parity.Even;
serial.stop = 1;
serial.delimAnd = false;
serial.delimiter = "\r\n";
serial.delimStrip = true;
serial.dropEmpty = true;
serial.eomTime = 100;
serial.dataReceived.connect(function(data) {
   console.log("Got: '" + data.str + "'");
});

Members


baud :number

Gets/sets the baud rate of communications.

Type:
  • number
Since:
  • 1.0
Default Value:
  • 9600

bits :number

Gets/sets the number of bits for communications.

Type:
  • number
Since:
  • 1.0
Default Value:
  • 8

cts :bool

Gets the state of the CTS pin on the serial port. If flowControl is set to FlowControl.Hardware, then this pin will be determine when data can be sent. NOTE: some ports/modes may not support CTS.

Type:
  • bool
Since:
  • 2.2
See:

flowControl :number

Gets/sets the flow control used. NOTE: some ports/modes may not support flow control.

Type:
  • number
Since:
  • 1.4
Default Value:
  • FlowControl.None

FlowControl :object

Available flow control options.

Type:
  • object
Properties:
Name Type Description
None number

0

Hardware number

1

Since:
  • 1.4
See:

halfDuplex :bool

Gets/sets the half duplex mode of the serial port. When set, the serial port will use the same wire(s) for sending and receiving (if supported). NOTE: some ports/modes may not support half duplex.

Type:
  • bool
Since:
  • 2.2
Default Value:
  • false

loop :bool

Gets/sets the loop back state of the serial port. When set, data written to the serial port will be read back. Typically used for testing. NOTE: some ports/modes may not support loop.

Type:
  • bool
Since:
  • 2.2
Default Value:
  • false

mode :string

Gets/sets the mode of the serial port (e.g. "rs232"). Must be one of the modes listed in modes.

Type:
  • string
Since:
  • 2.2
See:

modes :Array.<string>

Gets the available modes of the serial port. The current mode can be accessed from mode.

Type:
  • Array.<string>
Since:
  • 2.2
See:

parity :number

Gets/sets the parity for communications.

Type:
  • number
Since:
  • 1.0
Default Value:
  • Parity.None
See:

Parity :object

Available parities.

Type:
  • object
Properties:
Name Type Description
None number

0

Even number

1

Odd number

2

Since:
  • 1.4
See:

rts :bool

Gets/sets the state of the RTS pin on the serial port. If flowControl is set to FlowControl.Hardware, then this pin will be controlled automatically. NOTE: some ports/modes may not support RTS.

Type:
  • bool
Since:
  • 1.4
Default Value:
  • true
See:

rxWhileTx :bool

Gets/sets whether data transmitted in half duplex mode will be read back. This setting is ignore when not in half duplex mode.

Type:
  • bool
Since:
  • 2.2
Default Value:
  • false
See:

stop :number

Gets/sets the number of stop bits for communications.

Type:
  • number
Since:
  • 1.0
Default Value:
  • 1

termination :bool

Gets/sets the termination state of the serial port. When set, termination will be applied to the differential pairs (if supported). NOTE: some ports/modes may not support termination.

Type:
  • bool
Since:
  • 2.2
Default Value:
  • false