# String read in RS485/RS232

YuDash devices use the built-in **Modbus RS485/RS232 interface** to receive ASCII/text data from serial instruments such as weather sensors, analyzers, or weighing systems. The interface is defined as custom Modbus registers, for a flexible **raw text inputs** parsing.&#x20;

The input string is defined with modbus register value of 60000 range.

mbReg: 60ABC:  ABC represent maximum bytes to be read from the input stream.

varType:  defines the format and handline of input read.

The input can be treated as String (ASCII) or HEX data:

1. String: Input treated as ASCII/text data. This is applicable for varType range 50-54.
2. Hex: The input is treated as HEX data. A two character output in capital letters (followed by a space) is written for every input hex byte. This is applicable for varType range 55-59.

<table><thead><tr><th width="119">varType</th><th width="102">Input Type</th><th>Input read behavior</th></tr></thead><tbody><tr><td>50</td><td>String</td><td>Terminate input read at new line (\n, or \r). Flush balance input buffer after read.</td></tr><tr><td>51</td><td>String</td><td>Do not terminal at newline. Read all input bytes based on mbReg.</td></tr><tr><td>52</td><td>String</td><td>Terminate read at new line (\n, or \r). Do not flush buffer after serial read.</td></tr><tr><td>55</td><td>Hex</td><td>Terminate input read at new line (\n, or \r). Flush balance input buffer after read. </td></tr><tr><td>56</td><td>Hex</td><td>Do not terminal at newline. Read all input bytes based on mbReg.</td></tr><tr><td>57</td><td>Hex</td><td>Terminate read at new line (\n, or \r). Do not flush buffer after serial read.</td></tr></tbody></table>

#### Sample Modbus Slave settings for String input

* **slaveID and mbRegCnt:** These value remain 1 as default.&#x20;
* **varName**: The output variable name (**voltage\_string**) in which output string will be stored for further processing.
* mbReg: 60050. A register number >6000 represent string input read. 50 represents maximum 50 bytes to be read from the input. This can be set based on estimated text input line from the instrument.
* varType: 50.  50 means we treat input as string (ASCII), terminate reading at a newline and flush the baalnce input buffer. This will be the typical setting for most of the use-cases.&#x20;

```json
// modbus settings for RS485 string read
  "modBusSlaves": [
    {
      "slaveID": "1",
      "mbRegCnt": 1,
      "mbArray": [
        {
          "varName": "voltage_string",
          "mbReg": "60050",
          "varType": "50",
          "varFactor": "1"
        }
      ]
    }
  ],
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yudash.com/dc/df/modbus/string.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
