davidLin7692 / pymodbus

Automatically exported from code.google.com/p/pymodbus
0 stars 0 forks source link

ReadFileRecordResponse <calculateRtuFrameSize> calculates invalid size #55

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Working on current SVN trunk, Revision r176
Code to reproduce:

records = []
        records.append(FileRecord(file_number=26, record_number=0, record_length=1))
        request = ReadFileRecordRequest(records)
        request.unit_id = 4

        rq = c.client.execute(request)

Problem:
 - When calculating the response frame, the function ReadFileRecordResponse.calculateRtuFrameSize will have the whole frame as argument in <buffer> including address and function code.

If changed from
byte_count = struct.unpack('B', buffer[0])[0]
to
byte_count = struct.unpack('B', buffer[2])[0] + 5
the function starts to work correctly.

Original issue reported on code.google.com by armin.no...@gmail.com on 29 Nov 2011 at 10:26

GoogleCodeExporter commented 9 years ago
You are correct, in fact the calculateRtuFrameSize needs to be checked for all 
the methods. I will go through the code and make sure each method is correct 
and has tests.

Original comment by Bashw...@gmail.com on 29 Nov 2011 at 3:37

GoogleCodeExporter commented 9 years ago
Issue fixed on github commit 6320cd7..e1ca892

Original comment by Bashw...@gmail.com on 26 Feb 2012 at 4:17