2017-08-12, 06:29 AM
Code:
while True:
t0 = time.time()
data = boatimu.IMURead()
if data:
#sending data to signal k node server here
server.HandleRequests()
dt = time.time() - t0
if dt > .1:
time.sleep(dt);
25% usage sounds like one of the four raspberry pi cores is completely blocked. And looking at the code, this makes sense. The while does not sleep at all, if IMURead and HandleRequests are faster than 0.1 second.
I guess the other way around was meant?
if dt < .1:
time.sleep(dt)
Still i find the variable sleep time amount weird.
Maybe time.sleep(.1-dt) makes more sense? Therefore IMURead() and HandleRequest are only called at most every .1 seconds.
Sorry, but i am not able to test this at the moment.