ClassicDIY / ModbusTool

A modbus master and slave test tool with import and export functionality, supports TCP, UDP and RTU.
Apache License 2.0
640 stars 193 forks source link

写多个寄存器,buffer个数算错了, #10

Closed laowengdiaodayu closed 4 years ago

laowengdiaodayu commented 5 years ago

public override void ServerDecode( ModbusCommand command, ByteArrayReader body) { ModbusCodecBase.PopRequestHeader( command, body);

        //var count = body.ReadByte() / 2;
        var count = body.ReadByte();
        command.Data = new ushort[count];
        command.QueryTotalLength += (count + 3);

        for (int i = 0; i < count; i++)
            command.Data[i] = body.ReadUInt16BE();
    }