Index: leahi_dialin/td/modules/air_trap.py =================================================================== diff -u -rb4e77cdb95bebe6ba3fc49c2389d7e6127a81e9c -rdf2b51a17a2ccdaf3587f631de7623fa7fcae624 --- leahi_dialin/td/modules/air_trap.py (.../air_trap.py) (revision b4e77cdb95bebe6ba3fc49c2389d7e6127a81e9c) +++ leahi_dialin/td/modules/air_trap.py (.../air_trap.py) (revision df2b51a17a2ccdaf3587f631de7623fa7fcae624) @@ -234,7 +234,7 @@ vlv = integer_to_bytearray(valve) sts = integer_to_bytearray(valve_state) - payload = sts + vlv + payload = vlv + sts message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_td_ch_id, message_id=MsgIds.MSG_ID_TD_2_WAY_VALVE_SET_STATE_REQUEST.value, @@ -245,7 +245,34 @@ # If there is content... if received_message is not None: # response payload is OK or not OK + self.logger.debug("Air trap valve " + str(valve) + " set to " + str(valve_state)) return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug("timeout!!") return False + + def cmd_set_td_air_trap_control(self, control: int = 0) -> int: + """ + Constructs and sends a set control command to the TD air trap. + + @param control: start/stop for air trap control (0=stop, 1=start) + @returns 1 if successful, zero otherwise + """ + + ctl = integer_to_bytearray(control) + payload = ctl + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_td_ch_id, + message_id=MsgIds.MSG_ID_TD_SET_AIR_TRAP_CONTROL.value, + payload=payload) + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + # response payload is OK or not OK + self.logger.debug("Air trap control set to " + str(control)) + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("timeout!!") + return False \ No newline at end of file