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.
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:
String: Input treated as ASCII/text data. This is applicable for varType range 50-54.
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.
50
String
Terminate input read at new line (\n, or \r). Flush balance input buffer after read.
51
String
Do not terminal at newline. Read all input bytes based on mbReg.
52
String
Terminate read at new line (\n, or \r). Do not flush buffer after serial read.
55
Hex
Terminate input read at new line (\n, or \r). Flush balance input buffer after read.
56
Hex
Do not terminal at newline. Read all input bytes based on mbReg.
57
Hex
Terminate read at new line (\n, or \r). Do not flush buffer after serial read.
Sample Modbus Slave settings for String input
slaveID and mbRegCnt: These value remain 1 as default.
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.
// modbus settings for RS485 string read
"modBusSlaves": [
{
"slaveID": "1",
"mbRegCnt": 1,
"mbArray": [
{
"varName": "voltage_string",
"mbReg": "60050",
"varType": "50",
"varFactor": "1"
}
]
}
],
Last updated