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

  • Enable Boolean input socket that enables or disables reading.

  • ConnId Generic input socket that selects which serial connection to read from (connection identifier).

πŸ“€ Outputs

  • Data Generic 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 Type Dropdown 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. For Bytes enter 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

  1. Provide a connection identifier to ConnId that refers to an active serial connection.

  2. Use Enable to start or stop reading without removing the block.

  3. Set Stale timeout (s) to define how fresh the incoming data must be.

  4. Choose the desired Data Type to convert incoming lines.

  5. Define Default (on stale/parse fail) to control what the block outputs when there is no fresh or parseable data.

  6. Consume the output from Data in 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 Bytes type, the block treats the default as hexadecimal text.

πŸ’‘ Tips and Tricks

  • Use Debug Input to log or inspect raw results during development.

  • Forward serial readings to Data to JSON or CSV Export for structured logging or batch export.

  • Publish processed values with MQTT Publish or send them to a web service using REST API - Post.

  • Store values for later use with Data Write Local or Data Write Global and retrieve them with the corresponding read blocks.

  • Plot numeric data in real time using Scope to observe trends or anomalies.

  • Combine with Logic Input or 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 provided ConnId refers 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 Bytes type, ensure the default is provided as valid hexadecimal characters (no spaces or non-hex chars).

Last updated