0

I using NModbus4.dll to communicate with modbus device. I read this register:

Register: 0257-0288

Number of registers:32

Variable name: monitor buffer area

Data type: BCD

Description: readable

Using this code:

byte slaveId = byte.Parse ("1");
ushort startAddress = 257;
ushort[] readValue =  _serialMaster.ReadHoldingRegisters(slaveId, startAddress, 32);
byte[] asciiValue = Modbus.Utility.ModbusUtility.GetAsciiBytes(readValue);
string result = System.Text.Encoding.UTF8.GetString(asciiValue);

I use this converter to convert from hex to text and i get this:

epO tureD aiemet r 7 646.58 mm 4

This register is to read device lcd content, and this content is:

Pipe Outer Perimeter 2345.78 mm

I can't get correct lcd content.

DjuricS.
  • 36
  • 10

2 Answers2

0

According to source code, GetAsciiBytes method applies the conversation with UTF8;

string result = Encoding.UTF8.GetString(asciiValue);
lucky
  • 12,734
  • 4
  • 24
  • 46
0

I solved problem. There is no problem in code, device response is bad.

DjuricS.
  • 36
  • 10