chwiede / pyads

Beckhoff ADS implementation for python
MIT License
49 stars 14 forks source link

cache next packet instead of passing along as data #22

Closed turnerpeterk closed 5 years ago

turnerpeterk commented 5 years ago

I've had an occasional issue where pyads never receives a response after setting a variable, and times out. ReadAmsPacketFromSocket reads all data from Socket, generates a packet, and appends any additional bytes as data. The additional bytes could be another packet, so this is lost. In the example below, the "dropped" packet specifies data length 0, but still has data. This data is actually another packet which was never received properly.

Screen Shot 2019-04-16 at 4 44 08 PM

This PR updates pyads to only return packets of length specified in AMS header, and any additional data is cached in self.response for use the next time ReadAmsPacketFromSocket is called.

chwiede commented 5 years ago

Yes, this could be the "next" packet sent from PLC. Are there any active notifications set on your device?

turnerpeterk commented 5 years ago

Not that I know of, but the PLC is periodically sending out empty packets with Command ID 4 - can this be turned off?

(Also - thanks for this repo. I've found it very useful!)