Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rb6f63e07d64382b76940e9be1c2e5e922904dc26 -rca8a4a4cf6d2c59d9296c3abdf314765550a2624 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision b6f63e07d64382b76940e9be1c2e5e922904dc26) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision ca8a4a4cf6d2c59d9296c3abdf314765550a2624) @@ -8,7 +8,7 @@ * @file SystemCommMessages.c * * @author (last) Dara Navaei -* @date (last) 18-Mar-2024 +* @date (last) 02-Nov-2024 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -96,7 +96,11 @@ // ********** private data ********** +#ifndef CARTRIDGE_TEST_BUILD static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether an external tester (connected PC) has sent a valid login message. +#else +static BOOL testerLoggedIn = TRUE; ///< Flag indicates whether an external tester (connected PC) has sent a valid login message. +#endif static volatile U16 nextSeqNo = 1; ///< Value of sequence number to use for next transmitted message. /// List of message IDs that are requested not to be transmitted. @@ -871,26 +875,34 @@ memcpy( &cmd, message->payload, sizeof(U32) ); - if ( DG_DISINFECT_FLUSH_STATE == cmd ) // Command 0 = Flush + if ( DG_DISINFECT_FLUSH_STATE == cmd ) // Command 0 = Flush { result = signalUserInitiateFlushMode(); } - else if ( DG_DISINFECT_HEAT_STATE == cmd ) // Command 1 = Heat disinfect + else if ( DG_DISINFECT_HEAT_STATE_ACTIVE_COOL == cmd ) // Command 1 = Heat disinfect active cool { - result = signalUserInitiateHeatDisinfectMode(); + result = signalUserInitiateHeatDisinfectActiveCoolMode(); } - else if ( DG_DISINFECT_CHEM_STATE == cmd ) // Command 2 = chemical disinfect + else if ( DG_DISINFECT_CHEM_STATE == cmd ) // Command 2 = chemical disinfect { result = signalUserInitiateChemicalDisinfectMode(); } - else if ( DG_DISINFECT_CHEM_FLUSH_STATE == cmd ) // Command 3 = chemical disinfect flush + else if ( DG_DISINFECT_CHEM_FLUSH_STATE == cmd ) // Command 3 = chemical disinfect flush { result = signalUserInitiateChemicalDisinfectFlushMode(); } - else if ( DG_DISINFECT_RO_PERMEATE_SAMPLE_STATE == cmd ) // Command 4 = RO permeate sample + else if ( DG_DISINFECT_RO_PERMEATE_SAMPLE_STATE == cmd ) // Command 4 = RO permeate sample { result = signalUserInitiateROPermeateSampleMode(); } + else if ( DG_DISINFECT_HEAT_STATE_PASSIVE_COOL == cmd ) // Command 5 = Heat disinfect passive coode + { + result = signalUserInitiateHeatDisinfectPassiveCoolMode(); + } + else if ( DG_DISINFECT_ACTIVE_COOL == cmd ) // Command 6 = Active cool + { + result = signalUserInitiateActiveCoolMode(); + } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); @@ -1090,22 +1102,22 @@ * @param almData1 data associates with the alarm * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendTreatmentLogAlarmEventData( ALARM_ID_T alarmID, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ) +BOOL sendTreatmentLogAlarmEventData( ALARM_ID_T alarmID, F32 alarmData1, F32 alarmData2 ) { MESSAGE_T msg; U08 *payloadPtr = msg.payload; - U32 id = (U32)alarmID; + U32 id = (U32)alarmID; // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_ALARM_EVENT; + msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_ALARM_EVENT; msg.hdr.payloadLen = sizeof( U32 ) + 2 * sizeof( F32 ); memcpy( payloadPtr, &id, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &almData1.data, sizeof( F32 ) ); + memcpy( payloadPtr, &alarmData1, sizeof( F32 ) ); payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &almData2.data, sizeof( F32 ) ); + memcpy( payloadPtr, &alarmData2, sizeof( F32 ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -1806,21 +1818,22 @@ /*********************************************************************//** * @brief - * The sendDGStartHeatDisinfectModeCommand function constructs a DG start/stop - * heat disinfect mode command message and queues the msg for transmit on - * the appropriate CAN channel. + * The sendDGStartHeatDisinfectActiveCoolModeCommand function constructs a + * DG start/stop heat disinfect with active coolmode command message and + * queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: DG start heat disinfect mode command msg constructed * and queued. * @param start TRUE indicates start heat disinfect mode * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendDGStartHeatDisinfectModeCommand( BOOL start ) +BOOL sendDGStartHeatDisinfectActiveCoolModeCommand( BOOL start ) { BOOL result; MESSAGE_T msg; DG_HEAT_DISINFECTION_MODE_CMD_T cmd; + // Start command cmd.start = start; // Create a message record @@ -3322,8 +3335,14 @@ *************************************************************************/ void handleHDSerialNumberRequest( void ) { + typedef struct + { + U08 topLevelSN[ MAX_TOP_LEVEL_SN_CHARS ]; + } LOCAL_TOP_SN_T; MESSAGE_T msg; HD_SYSTEM_RECORD_T system; + U08 i; + LOCAL_TOP_SN_T localTopLevelSN; // Get the system's record. There are no arrays of system to check and also, raise no alarm since the system record // has been already checked in POST @@ -3338,8 +3357,15 @@ // Add 1 byte for null terminator msg.hdr.payloadLen = MAX_TOP_LEVEL_SN_CHARS + 1; + for ( i = 0; i < MAX_TOP_LEVEL_SN_CHARS; i++ ) + { + // NOTE: A local variable was created to avoid system.topLevelSN in the messages list + // NOTE: For loop was used instead of memory copy to ensure it is not parsed in the messages list script + localTopLevelSN.topLevelSN[ i ] = system.topLevelSN[ i ]; + } + // Fill message payload - memcpy( payloadPtr, &system.topLevelSN, sizeof( U08 ) * MAX_TOP_LEVEL_SN_CHARS ); + memcpy( payloadPtr, &localTopLevelSN, sizeof( LOCAL_TOP_SN_T ) ); payloadPtr += MAX_TOP_LEVEL_SN_CHARS; *payloadPtr = 0; @@ -3418,16 +3444,22 @@ void handleHDUsageInfoRequest( MESSAGE_T *message ) { MESSAGE_T msg; - U32 payload = 0; // TODO update this one implemented + HD_USAGE_INFO_RECORD_T usageRecord; U08 *payloadPtr = msg.payload; + getNVRecord2Driver( GET_USAGE_RECORD, (U08*)&usageRecord, sizeof( HD_USAGE_INFO_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_USAGE_DATA; - msg.hdr.payloadLen = sizeof( U32 ); + msg.hdr.msgID = MSG_ID_HD_USAGE_DATA; + msg.hdr.payloadLen = sizeof( F32 ) + sizeof( F32 ) + sizeof( U32 ); // Fill message payload - memcpy( payloadPtr, &payload, sizeof( U32 ) ); + memcpy( payloadPtr, &usageRecord.txTimeTotalHrs, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &usageRecord.txTimeSinceLastSrvcHrs, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &usageRecord.txLastStartTimeEpoch, sizeof( U32 ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -3529,13 +3561,14 @@ * active cool mode command * @details Inputs: none * @details Outputs: none + * @param start the boolean flag to indicate whether to start or stop the + * active cool * @return TRUE if the command was serialized successfully *************************************************************************/ -BOOL sendDGStopActiveCoolModeCommand( void ) +BOOL sendDGStopActiveCoolModeCommand( BOOL start ) { BOOL result; MESSAGE_T msg; - BOOL start = FALSE; // Create a message record blankMessage( &msg ); @@ -3678,7 +3711,61 @@ serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } +/*********************************************************************//** + * @brief + * The handleUIHDResetInServiceModeRequest function handles the UI request + * to reset HD in service mode + * @details Inputs: none + * @details Outputs: none + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIHDResetInServiceModeRequest( MESSAGE_T* message ) +{ + // Verify payload length + if ( ( 0 == message->hdr.payloadLen ) && ( MODE_SERV == getCurrentOperationMode() ) ) + { +#ifndef _VECTORCAST_ + systemREG1->SYSECR = (0x2) << 14; // Reset processor +#endif + } + // Respond to request + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); +} + +/*********************************************************************//** + * @brief + * The sendDGStartHeatDisinfectPassiveCoolModeCommand function handles the send + * request to start or stop nocturnal heat disinfect. + * @details Inputs: none + * @details Outputs: none + * @param start TRUE indicates start heat disinfect mode + * @return none + *************************************************************************/ +BOOL sendDGStartHeatDisinfectPassiveCoolModeCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + DG_HEAT_DISINFECTION_MODE_CMD_T cmd; + + // Start command + cmd.start = start; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_PASSIVE_COOL_HEAT_DISINFECT; + msg.hdr.payloadLen = sizeof( DG_HEAT_DISINFECTION_MODE_CMD_T ); + + memcpy( &msg.payload, &cmd, sizeof( DG_HEAT_DISINFECTION_MODE_CMD_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -4580,6 +4667,70 @@ /*********************************************************************//** * @brief + * The handleTestFilteredBloodPumpOcclusionOverrideRequest function handles a request to + * override the filtered blood pump occlusion sensor readings. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestFilteredBloodPumpOcclusionOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetFilteredBloodPumpOcclusionOverride( payload.state.f32 ); + } + else + { + result = testResetFilteredBloodPumpOcclusionOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestBloodPumpOcclusionBaselineOverrideRequest function handles a request to + * override the blood pump occlusion baseline value. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestBloodPumpOcclusionBaselineOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetBloodPumpPartialOcclusionBaselineOverride( payload.state.f32 ); + } + else + { + result = testResetBloodPumpPartialOcclusionBaselineOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleTestPresOcclBroadcastIntervalOverrideRequest function handles a request to * override the broadcast interval for pressure/occlusion data. * @details Inputs: none @@ -8748,4 +8899,100 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } +/*********************************************************************//** +* @brief +* The handleBloodLeakEmbModeInfoValuesOverride function handles the blood +* leak embedded mode info commands override. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleBloodLeakEmbModeInfoValuesOverride( MESSAGE_T* message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetBloodLeakEmbeddedModeInfoOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetBloodLeakEmbeddedModeInfoOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleBloodLeakIntensityMovingAverageOverride function handles a + * request to override the blood leak intensity moving average. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleBloodLeakIntensityMovingAverageOverride( MESSAGE_T* message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetBloodLeakIntensityMovingAverageOverride( payload.state.f32 ); + } + else + { + result = testResetBloodLeakIntensityMovingAverageOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleBloodLeakZeroingIntervalInMinutesOverride function handles a + * request to override the blood leak zeroing interval in minutes. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleBloodLeakZeroingIntervalInMinutesOverride( MESSAGE_T* message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetBloodLeakZeroingIntervalInMinsOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetBloodLeakZeroingIntervalInMinsOverride( payload.index ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/