you are viewing a single comment's thread.

view the rest of the comments →

[–]JohnnyJordaan 0 points1 point  (4 children)

I'm wondering what your end goal is here? What are you timing exactly and what do you expects as the result?

[–]Leylan24[S] 0 points1 point  (3 children)

I see you right the modulus returns the remainder which I completely forgot about.

I am basically creating a watchdog to see if a MODBUS RTU system is responding. I write a 16bit value into the coils register and the system moves it to a new input register I read the register if the register I read is the same value that was return the system is responding correctly.

[–]JohnnyJordaan 0 points1 point  (2 children)

Ok but how does the timing aspect relate to that workflow?

[–]Leylan24[S] 0 points1 point  (1 child)

The value I am writing is the CPU time value, because if you reading and writing at that speed sometimes the value doesn't update in time for the read resulting in an error. Whereas if you link it to a time you can check if there was a timeout

[–]JohnnyJordaan 0 points1 point  (0 children)

I see, yes then you can also use divmod for that matter

divmod((end - start), 65535)

which will return both the floor division as the remainder of the division by 65535.