Index: dialin/hd/blood_leak.py =================================================================== diff -u -rcb04db4bbb066c806d47398f3b2e819bbacc55e4 -r24ca06e85edf41258e11246f5172fd6a108d07d1 --- dialin/hd/blood_leak.py (.../blood_leak.py) (revision cb04db4bbb066c806d47398f3b2e819bbacc55e4) +++ dialin/hd/blood_leak.py (.../blood_leak.py) (revision 24ca06e85edf41258e11246f5172fd6a108d07d1) @@ -5,7 +5,7 @@ # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # -# @file fluid_leak.py +# @file blood_leak.py # # @author (last) Peman Montazemi # @date (last) 15-Apr-2021 @@ -30,9 +30,15 @@ """ # Blood leak detector status - BLOOD_LEAK_DETECTED = 0 # Blood - NO_BLOOD_LEAK_DETECTED = 1 # No blood + BLOOD_LEAK_DETECTED = 0 # Blood detected + NO_BLOOD_LEAK_DETECTED = 1 # No blood detected + # Blood leak detector state machine states + BLOOD_LEAK_INIT_STATE = 0 # Initial state + BLOOD_LEAK_ZERO_STATE = 1 # Zero state + BLOOD_LEAK_SELF_TEST_STATE = 2 # Self-test state + BLOOD_LEAK_NORMAL_STATE = 3 # Normal state + def __init__(self, can_interface, logger: Logger): """ @@ -44,11 +50,12 @@ if self.can_interface is not None: channel_id = DenaliChannels.hd_sync_broadcast_ch_id - msg_id = MsgIds.MSG_ID_HD_BLOOD_LEAK_STATUS_OVERRIDE.value + msg_id = MsgIds.MSG_ID_HD_BLOOD_LEAK_DATA.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_blood_leak_sync) self.blood_leak_status = self.NO_BLOOD_LEAK_DETECTED + self.blood_leak_state = self.BLOOD_LEAK_INIT_STATE def get_blood_leak_status(self): """ @@ -68,19 +75,21 @@ @return: None """ - state = struct.unpack('i', bytearray( + status = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1])) + state = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2])) + self.blood_leak_status = status[0] self.blood_leak_state = state[0] def cmd_blood_leak_detector_override(self, detected, reset=NO_RESET): """ Constructs and sends the blood leak detector state override command Constraints: Must be logged into HD. - Given detector must be one of the detectors listed below. - @param detected: unsigned int - detected (0=wet, 1=dry) to override detector with + @param detected: unsigned int - detected (0=detected, 1=undetected) to override detector with @param reset: integer - 1 to reset a previous override, 0 to override @return: 1 if successful, zero otherwise """ @@ -111,7 +120,7 @@ Constructs and sends the blood leak state broadcast interval override command Constraints: Must be logged into HD. - Given interval must be non-zero and a multiple of the HD priority task interval (10 ms). + Given interval must be non-zero and a multiple of the HD general task interval (50 ms). @param ms: integer - interval (in ms) to override with @param reset: integer - 1 to reset a previous override, 0 to override