I have a RevPi connect with a RevPI DIO module. I'm controlling the DIO module via a python script running inside a Docker container. The script is switching the output states of the DIO module in the order of 10-100 times a day.
I noticed that sometimes (once every 2-3 days) the script fails to change the load state, i.e., from the script log I see that the script has correctly switched off the output but the output is not switched off (e.g. if I execute piTest -r output)
I'm changing the load state by calling the _issue_deactivation_command of the below class:
I'm also trying to monitor the ioerror value of the RevPiModIO class but the value remains 0.
class RevPiAttachedLoad(Load): def __init__(self, name: str, consumption: int, revpi_io_obj: IOList, revpi_output_name: str, active_on_high: bool = True): super(RevPiAttachedLoad, self).__init__(name, consumption) self._revpi_io_obj = revpi_io_obj self._revpi_output_name = revpi_output_name if active_on_high: self._deactivation_value = False self._activation_value = True else: self._deactivation_value = True self._activation_value = False if revpi_io_obj is None: raise ValueError("RevpiConnector MUST be instantiated if one wants to use RevPiAttachedLoad") if self._revpi_output_name not in self._revpi_io_obj: raise ValueError("Unvalid/Unknown output name %s" % self._revpi_output_name) def _issue_deactivation_action(self): self._revpi_io_obj[self._revpi_output_name].value = self._deactivation_value def _issue_activation_action(self): self._revpi_io_obj[self._revpi_output_name].value = self._activation_value
Is the above code the right way to change an output?
Is there a way to ensure that the output has correctly changed state?
I noticed that there is also a wait function in the io object but I'm not sure how to use it.
Some additional details on the setup:
Not sure if it's important but the script run several threads. Only one thread is changing the state of a specific output.
I'm running the python script inside a Docker container, with the following docker-compose config:
Revpi software verson:
version: '2' services: watt-cutter: image: watt-cutter:devel container_name: watt-cutter restart: unless-stopped command: /app/start.sh /app/conf.json volumes: - ./conf.json:/app/conf.json - /etc/revpi/config.rsc:/etc/revpi/config.rsc ports: - 9105:9105 devices: - /dev/piControl0:/dev/piControl0
I really appreciate your help, let me know if you need further details.
Found 2 devices: Address: 0 module type: 105 (0x69) RevPi Connect V1.0 Module is present input offset: 113 length: 6 output offset: 119 length: 5 Address: 31 module type: 96 (0x60) RevPi DIO V1.5 Module is present input offset: 0 length: 70 output offset: 70 length: 18