Serial Read
This function block reads the latest line from a serial connection (non-blocking) and converts it to a chosen data type. It is designed to be resilient to stale or malformed input by returning a user-defined default when needed.
π₯ Inputs
EnableBoolean input socket that enables or disables reading.ConnIdGeneric input socket that selects which serial connection to read from (connection identifier).
π€ Outputs
DataGeneric output socket that emits the latest converted value (or the default value when stale/failed).
πΉοΈ Controls
Stale timeout (s)Text input that sets how long to wait for a new line before treating the reading as stale.Data TypeDropdown to choose the conversion type for incoming lines. Available options:String,Int,Float,Boolean,HexInt,Bytes.Default (on stale/parse fail)Text input that provides the fallback value returned when no fresh data is available or conversion fails. ForBytesenter hex characters (e.g.,AA55).
π― Features
Non-blocking read of the latest available line.
Stale detection so old lines are not forwarded indefinitely.
Multiple conversion types with a configurable fallback value.
Simple inputs and outputs to integrate into larger scenarios.
π Usage
Provide a connection identifier to
ConnIdthat refers to an active serial connection.Use
Enableto start or stop reading without removing the block.Set
Stale timeout (s)to define how fresh the incoming data must be.Choose the desired
Data Typeto convert incoming lines.Define
Default (on stale/parse fail)to control what the block outputs when there is no fresh or parseable data.Consume the output from
Datain subsequent blocks for logging, visualization, or publishing.
π Evaluation
When enabled, the block attempts to read the latest line from the selected connection.
If no new line arrives within the configured stale timeout, the block emits the configured default.
If conversion to the selected data type fails, the block emits the configured default.
For
Bytestype, the block treats the default as hexadecimal text.
π‘ Tips and Tricks
Use
Debug Inputto log or inspect raw results during development.Forward serial readings to
Data to JSONorCSV Exportfor structured logging or batch export.Publish processed values with
MQTT Publishor send them to a web service usingREST API - Post.Store values for later use with
Data Write LocalorData Write Globaland retrieve them with the corresponding read blocks.Plot numeric data in real time using
Scopeto observe trends or anomalies.Combine with
Logic Inputor comparison blocks to trigger actions based on incoming values (for example, alarm when a numeric reading exceeds a threshold).
π οΈ Troubleshooting
If no data appears on
Data, verify the providedConnIdrefers to an active connection.If output is always the default, increase
Stale timeout (s)or ensure the source is actively sending lines.If conversion fails for a numeric or boolean type, check the raw text format from the device and adjust the default accordingly.
For
Bytestype, ensure the default is provided as valid hexadecimal characters (no spaces or non-hex chars).
Last updated