Index: firmware/App/Services/Messaging.c =================================================================== diff -u -rc34e7ec999eee096c1b596d4f7ac0986da8c8760 -r3f325a9fe7cbfb660a3ddf274d471d635266c586 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision c34e7ec999eee096c1b596d4f7ac0986da8c8760) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 3f325a9fe7cbfb660a3ddf274d471d635266c586) @@ -7,8 +7,8 @@ * * @file Messaging.c * -* @author (last) Vijay Pamula -* @date (last) 08-Jun-2026 +* @author (last) Praneeth Bunne +* @date (last) 10-Aug-2026 * * @author (original) Sean Nash * @date (original) 01-Aug-2024 @@ -20,6 +20,7 @@ #include "AirTrap.h" #include "AlarmMgmt.h" #include "BloodFlow.h" +#include "BPModule.h" #include "Bubbles.h" #include "Buttons.h" #include "Compatible.h" @@ -31,6 +32,8 @@ #include "FpgaTD.h" #include "LevelSensors.h" #include "Messaging.h" +#include "ModeInitPOST.h" +#include "ModePreTreat.h" #include "ModeStandby.h" #include "ModeTreatment.h" #include "OperationModes.h" @@ -40,6 +43,8 @@ #include "StateTxBloodPrime.h" #include "StateTxDialysis.h" #include "StateTxPaused.h" +#include "StateTxRecirc.h" +#include "StateTxRinseback.h" #include "Switches.h" #include "SyringePump.h" #include "SystemCommTD.h" @@ -111,6 +116,7 @@ { MSG_ID_FW_VERSIONS_REQUEST, &handleVersionRequestMessage }, { MSG_ID_UI_CHECK_IN, &handleUICheckIn }, { MSG_ID_DD_OP_MODE_DATA, &setDDOpMode }, + { MSG_ID_UI_VERSION_INFO_RESPONSE, &handleUIVersionResponse }, { MSG_ID_DD_GEN_DIALYSATE_MODE_DATA, &setDialysateData }, { MSG_ID_DD_PRESSURES_DATA, &setDialysatePressure }, { MSG_ID_UI_TREATMENT_PARAMS_TO_VALIDATE, &validateAndSetTreatmentParameters }, @@ -121,6 +127,7 @@ { MSG_ID_UI_VITALS_ADJUSTMENT_REQUEST, &vitalsAdjustmentHandleChangeRequest }, { MSG_ID_UI_BOLUS_VOLUME_CHANGE_REQUEST, &validateAndSetBolusVolume }, { MSG_ID_UI_INITIATE_TREATMENT_WORKFLOW, &signalUserInitiateTreatment }, + { MSG_ID_UI_START_TREATMENT_REQUEST, &handleStartTreatmentRequest }, { MSG_ID_UI_UF_PAUSE_RESUME_REQUEST, &signalPauseResumeUF }, { MSG_ID_TESTER_LOGIN_REQUEST, &handleTesterLogInRequest }, { MSG_ID_UI_PRESSURE_LIMIT_WIDEN_REQUEST, &pressureLimitHandleWidenRequest }, @@ -133,9 +140,14 @@ { MSG_ID_UI_TREATMENT_SET_POINT_BLOOD_FLOW_CHANGE_REQUEST, &bloodPrimeHandleBloodFlowChangeRequest }, { MSG_ID_UI_TUBE_SET_AUTHENTICATION_ACK_RESPONSE, &drySelfTestHandleTubingSetAuthResponse }, { MSG_ID_UI_ADJUST_DISPOSABLES_CONFIRM_REQUEST, &handleAutoLoadRequest }, + { MSG_ID_UI_SETUP_TUBING_SET_CONNECTIONS_CONFIRM_REQUEST, &handleSetupTubingSetConnectionConfirmRequest }, { MSG_ID_UI_ADJUST_DISPOSABLES_REMOVAL_CONFIRM_REQUEST, &handleAutoEjectRequest }, + { MSG_ID_UI_BLOOD_PRESSURE_REQUEST, &bpModuleHandleVitalsRequest }, { MSG_ID_FFU_SIGNAL_TD_UPDATE_AVAILABLE, &handleUpdateAvailable }, { MSG_ID_UI_FLUID_BOLUS_REQUEST, &handleFluidBolusRequest }, + { MSG_ID_UI_RINSEBACK_CMD_REQUEST, &signalRinsebackUserAction }, + { MSG_ID_UI_RECIRCULATE_REQUEST, &signalTreatmentRecircUserAction }, + { MSG_ID_UI_GENERIC_CONFIRMATION_RESULT_RESPONSE, &handleUIConfirmation }, { MSG_ID_TD_SOFTWARE_RESET_REQUEST, &testTDSoftwareResetRequest }, { MSG_ID_TD_BUBBLE_OVERRIDE_REQUEST, &testBubbleDetectOverride }, { MSG_ID_TD_BUBBLE_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testBubblesDataPublishIntervalOverride }, @@ -145,6 +157,7 @@ { MSG_ID_TD_PRESSURE_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testPressuresDataPublishIntervalOverride }, { MSG_ID_TD_AIR_PUMP_SET_STATE_REQUEST, &testSetAirPump }, { MSG_ID_TD_AIR_PUMP_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testAirPumpDataPublishIntervalOverride }, + { MSG_ID_TD_AIR_PUMP_RPM_OVERRIDE_REQUEST, &testAirPumpRPMOverride }, { MSG_ID_TD_SWITCHES_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testSwitchesDataPublishIntervalOverride }, { MSG_ID_TD_SWITCH_STATE_OVERRIDE_REQUEST, &testSwitchOverride }, { MSG_ID_TD_OFF_BUTTON_OVERRIDE_REQUEST, &testOffButtonOverride }, @@ -218,6 +231,9 @@ { MSG_ID_TD_SYRINGE_PUMP_ADC_READ_COUNTER_OVERRIDE_REQUEST, &testSyringePumpADCReadCounterOverride }, { MSG_ID_TD_HEPARIN_BOLUS_TARGET_RATE_OVERRIDE_REQUEST, &testHeparinBolusTargetRateOverride }, { MSG_ID_TD_SYRINGE_PUMP_FORCE_SENSOR_CALIBRATION_REQUEST, &testCalibrateForceSensor }, + { MSG_ID_TD_GET_ALARM_PROPERTIES_REQUEST, &testGetAlarmPropertiesRequest }, + { MSG_ID_TD_RINSEBACK_VOLUME_OVERRIDE, &testRinsebackVolumeOverride }, + { MSG_ID_TD_RINSEBACK_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testRinsebackPublishIntervalOverride }, }; /// Number of entries in the message handling function lookup table. @@ -238,7 +254,6 @@ static MsgFuncPtr getMsgHandler( U16 msgID ); static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); -static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ); /*********************************************************************//** * @brief @@ -397,7 +412,7 @@ * @param ack TRUE to ACK, FALSE to NAK * @return TRUE if response message successfully queued for transmit, FALSE if not *************************************************************************/ -static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ) +BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ) { BOOL result; MESSAGE_T msg; @@ -524,7 +539,79 @@ return result; } +/*********************************************************************//** + * @brief + * The handleUIVersionResponse function handles a response to request for + * UI version information. + * @details Inputs: none + * @details Outputs: none + * @param message a pointer to the message to handle. + * @return none + *************************************************************************/ +BOOL handleUIVersionResponse( MESSAGE_T *message ) +{ + BOOL result = TRUE; + // Get UI version data and have it recorded + if ( sizeof(UI_VERSIONS_T) == message->hdr.payloadLen ) + { + UI_VERSIONS_T uiVersion; + + memcpy( &uiVersion, &message->payload[ 0 ], sizeof(UI_VERSIONS_T) ); + signalUIVersion( uiVersion ); + } + + return result; +} + +/*********************************************************************//** + * The sendPOSTFinalResult function sends the overall TD POST result + * and queues the message for transmit on the appropriate CAN channel. + * @details \b Message \b Sent: MSG_ID_TD_POST_FINAL_TEST_RESULT + * @details \b Inputs: none + * @details \b Outputs: TD POST final result msg queued for CAN transmit. + * @param passed TRUE if all TD POST tests passed, FALSE otherwise. + * @return TRUE if message successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendPOSTFinalResult( BOOL passed ) +{ + // Use the generic send helper for transmission. + return sendMessage( MSG_ID_TD_POST_FINAL_TEST_RESULT, COMM_BUFFER_OUT_CAN_TD_BROADCAST, (U08 *)&passed, sizeof( BOOL ) ); +} + +/*********************************************************************//** + * @brief + * The handleUIConfirmationResponse function handles a UI response for a + * confirmation request. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message pointer to the received confirmation response message + * @return TRUE if message handled successfully, FALSE if not + *************************************************************************/ +BOOL handleUIConfirmation( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( ( 2U * sizeof(U32) ) == message->hdr.payloadLen ) + { + U32 requestID; + U32 status; + + memcpy( &requestID, message->payload, sizeof(U32) ); + memcpy( &status, message->payload + sizeof(U32), sizeof(U32) ); + + if ( ( CONFIRMATION_REQUEST_STATUS_ACCEPTED == ( CONFIRMATION_REQUEST_STATUS_T)status ) || + ( CONFIRMATION_REQUEST_STATUS_REJECTED == ( CONFIRMATION_REQUEST_STATUS_T)status ) ) + { + setConfirmationRequestStatus( ( GENERIC_CONFIRM_ID_T )requestID, + ( CONFIRMATION_REQUEST_STATUS_T)status ); + result = TRUE; + } + } + + return result; +} + // *********************************************************************** // ***************** Message Sending Helper Functions ******************** // *********************************************************************** @@ -569,36 +656,108 @@ /*********************************************************************//** * @brief - * The sendOffButtonMsgToUI function constructs an off button msg to the UI - * and queues the msg for transmit on the appropriate CAN channel. - * @details \b Message \b Sent: MSG_ID_OFF_BUTTON_PRESS_REQUEST + * The sendUIVersionRequest function constructs a UI version request msg + * to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details \b Message \b Sent: MSG_ID_TD_UI_VERSION_INFO_REQUEST * @details \b Inputs: none - * @details \b Outputs: Off button msg constructed and queued. - * @param prompt 0=prompt user to confirm, 1=cancel prompt, 2=reject user off request + * @details \b Outputs: none * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendOffButtonMsgToUI( U08 prompt ) +BOOL sendUIVersionRequest( void ) { BOOL result; MESSAGE_T msg; - UI_OFF_BUTTON_RESPONSE_PAYLOAD_T cmd; - cmd.userRequest = prompt; - // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS_REQUEST; - msg.hdr.payloadLen = sizeof( UI_OFF_BUTTON_RESPONSE_PAYLOAD_T ); + msg.hdr.msgID = MSG_ID_TD_UI_VERSION_INFO_REQUEST; + msg.hdr.payloadLen = 0; - memcpy( &msg.payload, &cmd, sizeof( UI_OFF_BUTTON_RESPONSE_PAYLOAD_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_TD_2_UI, ACK_REQUIRED ); return result; } +/*********************************************************************//** + * @brief + * The sendRequestForDDResendAlarms function sends out the TD request for + * DD re-send all active alarms. + * @details \b Inputs: none + * @details \b Outputs: DD alarms re-send request msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendRequestForDDResendAlarms( void ) +{ + BOOL result; + MESSAGE_T msg; + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_TD_DD_ALARMS_REQUEST; + msg.hdr.payloadLen = 0; + + // 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_TD_2_DD, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * The sendPOSTTestResult function sends the result of a single TD POST + * test to the UI. + * @details \b Message \b Sent: MSG_ID_TD_POST_SINGLE_TEST_RESULT + * @details \b Inputs: none + * @details \b Outputs: TD POST test result msg queued for CAN transmit. + * @param test ID of the TD POST test. + * @param passed TRUE if POST test passed, FALSE if POST test failed. + * @return TRUE if message successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendPOSTTestResult( TD_POST_STATE_T test, BOOL passed ) +{ + U08 payload[ sizeof( BOOL ) + sizeof( U32 ) ]; + U32 testID = (U32)test; + + memcpy( payload, &passed, sizeof( BOOL ) ); + memcpy( &payload[ sizeof( BOOL ) ], &testID, sizeof( U32 ) ); + + // Use the generic send helper for transmission. + return sendMessage( MSG_ID_TD_POST_SINGLE_TEST_RESULT, COMM_BUFFER_OUT_CAN_TD_BROADCAST, payload, sizeof( payload ) ); +} + +/*********************************************************************//** + * @brief + * The sendConfirmationRequest function constructs and transmits a + * confirmation request message to the UI. + * @details \b Message \b Sent: MSG_ID_TD_UI_GENERIC_CONFIRMATION_REQUEST + * @details \b Inputs: none + * @details \b Outputs: none + * @param requestID ID of the confirmation being requested + * @param requestType Type of confirmation being requested + * @param rejectReason Reason for reject if type is reject, 0 otherwise + * @return none + *************************************************************************/ +void sendConfirmationRequest( GENERIC_CONFIRM_ID_T requestID, + GENERIC_CONFIRM_COMMAND_T requestType, + U32 rejectReason ) +{ + GENERIC_CONFIRMATION_REQUEST_T payload; + + payload.requestID = (U32)requestID; + payload.requestType = (U32)requestType; + payload.rejectReason = rejectReason; + payload.genericPayload1 = 0.0F; + payload.genericPayload2 = 0.0F; + payload.genericPayload3 = 0.0F; + payload.genericPayload4 = 0.0F; + + sendMessage( MSG_ID_TD_UI_GENERIC_CONFIRMATION_REQUEST, + COMM_BUFFER_OUT_CAN_TD_2_UI, + (U08*)&payload, + sizeof( GENERIC_CONFIRMATION_REQUEST_T ) ); +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/