Skip to content

Node rosepetal-serial-in ​

Emits the data read from a serial port. The node does not open the port: the engine reads it and publishes the bytes on NATS, and the node turns them into messages. It has no input and one output, and appears under the network category of the palette.

Properties ​

FieldDescription
NameOptional label. Without it the node shows the name of the configuration node, or its port when the configuration node has no name
Serial PortThe rosepetal-serial-config node that describes the port (required)

Output ​

One message for each piece of data, as the Input settings of the configuration node split it: by default a message ends at every \n, which stays in the payload.

PropertyTypeDescription
msg.payloadstring or BufferThe data. A string decoded as UTF-8 when the configuration node delivers ASCII strings, a Buffer when it delivers binary buffers
msg.portstringThe port the data was read from
msg.timestampstringThe time the engine put on the last chunk of data of the message, in ISO 8601
msg.natsobjectThe meta object that the engine attached to that chunk. The engine in engine/ sends { "source": "engine" }
json
{
  "payload": "READY\n",
  "port": "/dev/ttyUSB0",
  "timestamp": "2024-01-01T12:00:01.000Z",
  "nats": { "source": "engine" }
}

Data of a port other than the one of the configuration node is ignored. All the rosepetal-serial-in nodes that share a configuration node emit the same messages.

Example ​

A barcode scanner on a USB serial adapter sends every code followed by a carriage return. On its configuration node, choose the scanner's port and baud rate, set Split input to on the character \r and deliver ASCII strings. Each scan then arrives as one message whose msg.payload is the code followed by the carriage return, for example "ABC-12345\r". Remove the \r with msg.payload = msg.payload.trim(); in a function node before using the code.

Status ​

The status shows the NATS connection first and, once it is connected, the state of the port that the engine reports.

StatusMeaning
nats connecting (yellow ring)Connecting to the NATS server
nats reconnecting (yellow ring)The connection to the NATS server was lost and the client is reconnecting
nats error (red ring)The NATS server could not be reached, or the client reported an error
nats disconnected (red ring)There is no connection to the NATS server
serial pending (yellow ring)Connected to NATS; the engine has not reported the state of the port yet
serial connecting (yellow ring)The engine is opening the port
serial connected (green dot)The engine has the port open
serial reconnecting (yellow ring)The engine failed to open the port, or lost it, and waits to try again
serial error (red ring)The engine reported an error of the port
serial closed (red ring)The port is closed
serial heartbeat lost (red ring)The engine has not reported the state of the port for 15 seconds

Notes ​

  • When the node starts and when it stops it publishes a node-status message (online or offline) on the control subject. The engine in engine/ takes no action on it.
  • The subjects and payloads are described in NATS channels.