How do I ensure that a Python while-loop takes a particular amount of time to run?
问题 I'm reading serial data with a while loop. However, I have no control over the sample rate. The code itself seems to take 0.2s to run, so I know I won't be able to go any faster than that. But I would like to be able to control precisely how much slower I sample. I feel like I could do it using 'sleep', but the problem is that there is potential that at different points the loop itself will take longer to read(depending on precisely what is being transmitted over serial data), so the code