demntor / pymodbus

Modbus Python release (tools included)
0 stars 0 forks source link

pymodbus does not handle RTU messages correctly #44

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The extraction of RTU frames is not yet implemented: the
`checkFrame` method always returns False.

I've attached a patch for fixing this problem.

Every kind of PDU has a new method called `calculateRtuFrameSize`.
It returns a number (either calculated from the byte count field,
or a constant - depending on the kind of PDU). This method is called
in the ModbusRtuFramer to determine if a frame is complete (and to
set the 'len' item in its `__header` instance variable.

In order to determine the kind of PDU, I've added `lookupPduClass`
to both decoders. It might be preferable to extract the code for
looking up the PDU kind based on the function code to a separate
class that is used from both the decoders and the ModbusRtuFramer.

Finally, there is a new utility function, rtuFrameSize, which reads
the byte count field from the buffer and calculates the size of the
whole frame.

I have only started to rework the unittests. But I'd like to make
available the current patch ASAP, so I'll deliver them later.

Please check if the changes are meaningful. Any comments are welcome.

Thanks & best regards,

Albert

Original issue reported on code.google.com by albert.k...@gmail.com on 25 Feb 2011 at 9:33

GoogleCodeExporter commented 8 years ago
Hmmm... I thought I added a diff file... - next attempt :-)

Original comment by albert.k...@gmail.com on 25 Feb 2011 at 10:09

Attachments:

GoogleCodeExporter commented 8 years ago
Sounds fair, I checked it in and just get the tests in when you can. As an 
aside, I gave you commit access to the repository and created a branch for you 
to work in (RTU).  

Original comment by Bashw...@gmail.com on 25 Feb 2011 at 3:01