Decoding response from modbus device

Discussion in 'Programmer's Corner' started by regdude, Apr 18, 2013.

  1. regdude

    Thread Starter New Member

    Apr 18, 2013
    I tested out a device that reads electrical current, from a computer I can send a command and the device will give a response trough modbus.
    I'm having trouble to decode the answer, here is what I received (the bottom part is the answer, upper part is the request):
    I'm also bit confused about the request code, it should be slave address, function, page, subaddress, starting address Hi, starting address Lo, Number of registers Hi, Number of registers Lo, CRC
    But it seems that it is missing SlaveAddress(2), function(4). But it starts with page(2), subaddress(4). I'm not sure, but is seems like that. Since I don't know it for sure, then I'm not sure if the answer is an integer, float(BigEndian) or Float(LittleEndian).
    There should be 3 possibilities: 2-byte integer BigEndian, Single float 4-byte BigEndian, Single float 4-bute LittleEndian.
    I'm not sure, but the result could be also negative.
    Also I', not sure about this, but the result should be something like 0.8568.
    The answer should be: page(2), subaddress(4), length(128), measurements, CRC.
    Can someone help me figuring out what is the response and how could I get actual values?
    Note that there should be many measurements in the response.
    Maybe each 4 numbers are making a float? If so, how could I calculate it to be something like 0.8568?