serial.init()
serial.init(port, baud) β number
Initialises a serial port at the given baud rate.
Specify a parameter object for advanced usage
serial.init(port,{baud:9600,stopBits:1,parity:"odd",mode:"0,swap:false,invert:false});
:Mode 0: tx+rx, 1: rx only, 2: tx only,
:Invert Invert the RS485 high low signaling (Experimental)
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| port | number | yes | β | 1 = isolated RS-485, 2 = non-isolated RS-485. |
| baud | config | number | object | yes | β | Baud rate, e.g. 9600, 19200. for standard 8n1 settings otherwise supply a json object with parameters |
Returns
number
Status code β 0 on success.
Example
let port = 1; // isolated RS-485
serial.init(port, 19200);