IO refresh time exceeded
Posted: 25 Oct 2024, 16:01
Hello, we are having the issue below
Here is the code snippet that starts the problem.
First code is the class below.
This above calls the class io_functions below, which after the load starts the warnings.
Some information:
1. we only call revpimodio2.RevPiModIO(autorefresh=True) once on the software
2. We tried to change cycle time to 50 and 100 but seems the same 20ms warning keeps appearing.
Any ideas?
Regards,
Here is the code snippet that starts the problem.
First code is the class below.
Code: Select all
import os
import time
import threading
import io_functions as io
from datetime import datetime
from camera_control import CameraControl
from config_manager import ConfigManager
class TempController(threading.Thread):
def __init__(self, camera_control : CameraControl, config_manager : ConfigManager, img_folder_path = '/home/pi/fotos/'):
threading.Thread.__init__(self)
self.img_folder_path = img_folder_path
self.sirene_status = 0
self.button_light_status = 0
self.temperature_alarm = 0
self.temperature_delta_alarm = 0
self.camera_control = camera_control
self.config_manager_sing = config_manager
#===END OF __init__()
def init(self):
self.running = 1
if not os.path.isdir(self.img_folder_path):
try:
os.makedirs(self.img_folder_path)
except Exception as e:
self.running = 0
print(f'Erro ao criar diretorios. err:{e}')
return
#===END OF init()
def run(self):
while self.running:
if(self.temperature_alarm or self.temperature_delta_alarm):
if not self.sirene_status and not io.get_button_click():
io.liga_led_botao()
io.liga_sinaleiro()
self.sirene_status = 1
img = self.camera_control.get_ir_img()
file_name = self.create_image_name()
if(img):
with open(file_name, 'wb') as fp:
fp.write(img)
if(io.get_button_click()):
if(self.temperature_alarm):
self.temperature_alarm = 0
if(self.temperature_delta_alarm):
self.camera_control.clean_temperature_list()
self.temperature_delta_alarm = 0
io.desliga_led_botao()
io.desliga_sinaleiro()
self.sirene_status = 0
if(self.camera_control.get_temperature() > self.config_manager_sing.get_temperature_limit()):
self.temperature_alarm = 1
if(self.camera_control.get_temperature_delta() > self.config_manager_sing.get_temperature_delta()):
self.temperature_delta_alarm = 1
time.sleep(0.001)
#===END OF run()
Code: Select all
import revpimodio2
import time
rodando = True
rpi = revpimodio2.RevPiModIO(autorefresh=True)
print("Initiating io_functions")
rpi.io.O_1.value = False
rpi.io.O_2.value = False
rpi.io.O_3.value = False
def liga_sinaleiro():
rpi.io.O_1.value = True
rpi.io.O_3.value = True
return rpi.io.O_1.value
def desliga_sinaleiro():
rpi.io.O_1.value = False
rpi.io.O_3.value = False
return rpi.io.O_1.value
def liga_led_botao():
rpi.io.O_2.value = True
return rpi.io.O_2.value
def desliga_led_botao():
rpi.io.O_2.value = False
return rpi.io.O_2.value
def get_button_click():
return rpi.io.I_1.value
1. we only call revpimodio2.RevPiModIO(autorefresh=True) once on the software
2. We tried to change cycle time to 50 and 100 but seems the same 20ms warning keeps appearing.
Any ideas?
Regards,