Index: firmware/App/Controllers/DialInFlow.h =================================================================== diff -u -rac5a409920099e701227c507cbda86d5d1ea8bf8 -r32367866387722d779fa89d0a0bbe837e5dd4972 --- firmware/App/Controllers/DialInFlow.h (.../DialInFlow.h) (revision ac5a409920099e701227c507cbda86d5d1ea8bf8) +++ firmware/App/Controllers/DialInFlow.h (.../DialInFlow.h) (revision 32367866387722d779fa89d0a0bbe837e5dd4972) @@ -7,8 +7,8 @@ * * @file DialInFlow.h * -* @author (last) Michael Garthwaite -* @date (last) 28-Sep-2022 +* @author (last) Dara Navaei +* @date (last) 18-Oct-2022 * * @author (original) Sean * @date (original) 16-Dec-2019 @@ -71,6 +71,7 @@ F32 getMeasuredDialInPumpMCSpeed( void ); F32 getMeasuredDialInPumpMCCurrent( void ); F32 getDialInPumpPWMDutyCyclePct( BOOL init ); +U32 getPumpRotorErrorPersistTime( F32 mtr_speed, F32 gear_ratio ); U32 getDialInPumpRotorCount( void ); BOOL testSetDialInFlowDataPublishIntervalOverride( U32 value ); Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -ref6283257df7c1f993d58fb934da57ea3e0a7067 -r32367866387722d779fa89d0a0bbe837e5dd4972 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision ef6283257df7c1f993d58fb934da57ea3e0a7067) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 32367866387722d779fa89d0a0bbe837e5dd4972) @@ -159,6 +159,9 @@ treatmentCompleted = FALSE; rinsebackDone = FALSE; + resetBloodPumpRotorCount(); + resetDialInPumpRotorCount(); + treatmentTimeMS = 0; lastTreatmentTimeStamp = 0; treatmentTimeBroadcastTimerCtr = TREATMENT_TIME_DATA_PUB_INTERVAL; // So we send time data immediately when we begin treatment mode Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -re8053e6bdafd0638102e01c4250dfd74c0850ba1 -r32367866387722d779fa89d0a0bbe837e5dd4972 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision e8053e6bdafd0638102e01c4250dfd74c0850ba1) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 32367866387722d779fa89d0a0bbe837e5dd4972) @@ -1376,6 +1376,10 @@ handleHDBloodPumpRotorCountOverrideRequest( message ); break; + case MSG_ID_DIALYSATE_INLET_PUMP_ROTOR_COUNT_OVERRIDE: + handleHDDialInPumpRotorCountOverrideRequest( message ); + break; + case MSG_ID_BLOOD_PUMP_HOME_CMD: handleTestBloodPumpHomeRequest( message ); break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rac5a409920099e701227c507cbda86d5d1ea8bf8 -r32367866387722d779fa89d0a0bbe837e5dd4972 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision ac5a409920099e701227c507cbda86d5d1ea8bf8) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 32367866387722d779fa89d0a0bbe837e5dd4972) @@ -8,7 +8,7 @@ * @file SystemCommMessages.c * * @author (last) Michael Garthwaite -* @date (last) 12-Oct-2022 +* @date (last) 19-Oct-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -36,6 +36,7 @@ #include "SystemComm.h" #include "SystemCommMessages.h" #include "Temperatures.h" +#include "Timers.h" #include "TreatmentEnd.h" #include "TreatmentRecirc.h" #include "TreatmentStop.h" @@ -63,6 +64,7 @@ #pragma pack(pop) // ********** private data ********** + static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether an external tester (connected PC) has sent a valid login message. static volatile U16 nextSeqNo = 1; ///< Value of sequence number to use for next transmitted message. @@ -2309,17 +2311,36 @@ *************************************************************************/ void handleLoadCellReadingsFromDG( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ) + if ( message->hdr.payloadLen == sizeof( LOAD_CELL_DATA_T ) ) { - LOAD_CELL_READINGS_PAYLOAD_T payload; + LOAD_CELL_DATA_T payload; - memcpy( &payload, message->payload, sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ); - setNewLoadCellReadings( payload.res1PrimaryLoadCell, payload.res1BackupLoadCell, payload.res2PrimaryLoadCell, payload.res2BackupLoadCell ); + memcpy( &payload, message->payload, sizeof( LOAD_CELL_DATA_T ) ); + setNewLoadCellReadings( payload.loadCellA1inGram, payload.loadCellA2inGram, payload.loadCellB1inGram, payload.loadCellB2inGram ); } } /*********************************************************************//** * @brief + * The handleDGHeatersData function handles the heaters data reading from DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGHeatersData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( HEATERS_DATA_T ) ) + { + HEATERS_DATA_T payload; + + memcpy( &payload, message->payload, sizeof( HEATERS_DATA_T ) ); + setDGHeatersData( &payload ); + } +} + +/*********************************************************************//** + * @brief * The handleDGTemperatureData function handles a temperature readings * broadcast message from the DG. * @details Inputs: none @@ -2349,12 +2370,12 @@ *************************************************************************/ void handleDialysateFlowData( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == sizeof( DIALYSATE_FLOW_METER_DATA_T ) ) + if ( message->hdr.payloadLen == sizeof( FLOW_SENSORS_DATA_T ) ) { - DIALYSATE_FLOW_METER_DATA_T payload; + FLOW_SENSORS_DATA_T payload; - memcpy( &payload, message->payload, sizeof( DIALYSATE_FLOW_METER_DATA_T ) ); - setDialysateFlowData( payload.measuredDialysateFlowRate ); + memcpy( &payload, message->payload, sizeof( FLOW_SENSORS_DATA_T ) ); + setDialysateFlowData( payload.dialysateFlowRateLPM ); } } @@ -3068,6 +3089,11 @@ HD_VERSIONS_T payload; U08 *payloadPtr = msg.payload; + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_VERSION; + msg.hdr.payloadLen = sizeof( HD_VERSIONS_T ); + if ( message->hdr.payloadLen == sizeof( UI_VERSIONS_T ) ) { // Get UI version data from this request msg and have it recorded @@ -3081,11 +3107,6 @@ payload.compatibilityRev = (U32)SW_COMPATIBILITY_REV; getFPGAVersions( &payload.fpgaId, &payload.fpgaMajor, &payload.fpgaMinor, &payload.fpgaLab ); - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_VERSION; - msg.hdr.payloadLen = sizeof( HD_VERSIONS_T ); - // Fill message payload memcpy( payloadPtr, &payload, sizeof( HD_VERSIONS_T ) ); } @@ -3185,22 +3206,27 @@ { MESSAGE_T msg; HD_SERVICE_RECORD_T service; + DG_SERVICE_AND_USAGE_DATA_T dgData; + U08 *payloadPtr = msg.payload; getNVRecord2Driver( GET_SRV_RECORD, (U08*)&service, sizeof( HD_SERVICE_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + getHDVersionDGServiceAndUsageData( &dgData ); - U08 *payloadPtr = msg.payload; + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SERVICE_SCHEDULE_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - if ( message->hdr.payloadLen == sizeof( U32 ) + sizeof( U32 ) ) + if ( 0 == message->hdr.payloadLen ) { - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_SERVICE_SCHEDULE_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - // Fill message payload memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &dgData.dgServiceRecord.lastServiceDateEpoch, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &dgData.dgServiceRecord.serviceIntervalSeconds, sizeof( U32 ) ); } // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer @@ -3235,7 +3261,73 @@ serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); } +/*********************************************************************//** + * @brief + * The handleUIConfirmationResponse function handles a UI response for + * confirmation request. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIConfirmationResponse( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08* payloadPtr = message->payload; + if ( message->hdr.payloadLen == 2 * sizeof(U32) ) + { + U32 request_id; + U32 status; + + memcpy( &request_id, payloadPtr, sizeof(U32) ); + payloadPtr += sizeof(U32); + memcpy( &status, payloadPtr, sizeof(U32) ); + + if ( ( CONFIRMATION_REQUEST_STATUS_REJECTED == status ) || + ( CONFIRMATION_REQUEST_STATUS_ACCEPTED == status ) ) + { + setConfirmationRequestStatus( (GENERIC_CONFIRM_ID_T) request_id, (CONFIRMATION_REQUEST_STATUS_T) status ); + } + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief + * The sendConfirmationRequest function sends a confirmation request to UI + * @details Inputs: none + * @details Outputs: none + * @param request ID + * @param request type + * @param reject reason + * @return request ID - will be non-zero if sent + *************************************************************************/ +void sendConfirmationRequest( GENERIC_CONFIRM_ID_T request_id, GENERIC_CONFIRM_COMMAND_T request_type, U32 reject_reason ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 temp_request = request_id; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_REQUEST_UI_CONFIRMATION; + // The payload length is U32 Request ID, U32 Type, U32 Reject Reason + msg.hdr.payloadLen = 3 * sizeof( U32 ); + + memcpy( payloadPtr, &temp_request, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + temp_request = request_type; + memcpy( payloadPtr, &temp_request, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &reject_reason, 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_NOT_REQUIRED ); +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -5159,9 +5251,10 @@ if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) { - result = testSetBatteryRemainingPercentOverride( payload.state.u32 ); + result = testSetBatteryRemainingPercentOverride( payload.state.f32 ); } else { @@ -6397,14 +6490,11 @@ BOOL result = FALSE; // Verify payload length - if ( sizeof( F32 ) == message->hdr.payloadLen ) + if ( 0 == message->hdr.payloadLen ) { if ( TRUE == isTestingActivated() ) { - F32 dacVRef; - - memcpy( &dacVRef, message->payload, sizeof( F32 ) ); // TODO - Payload no longer used. Update Dialin command and expected payload len in f/w. - result = setSyringePumpDACVref(); + result = setSyringePumpDACVref(); } } @@ -7123,6 +7213,96 @@ } /*********************************************************************//** + * @brief + * The sendDGUsageInfoRequestToDG function constructs a request msg + * to the DG to request the DG usage info and queues the msg for transmit + * on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG usage info result request msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGUsageInfoRequestToDG( void ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_REQUEST_DG_USAGE_INFO; + 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_HD_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGServiceRequestToDG function constructs a request msg + * to the DG to request the DG service record and queues the msg for transmit + * on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG usage info result request msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGServiceRequestToDG( void ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_REQUEST_DG_SERVICE_RECORD; + 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_HD_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDGServiceScheduleData function receives the HD version of the + * DG service record. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGServiceScheduleData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( HD_VERSION_DG_SERVICE_RECORD_T ) ) + { + HD_VERSION_DG_SERVICE_RECORD_T payload; + + memcpy( &payload, message->payload, sizeof( HD_VERSION_DG_SERVICE_RECORD_T ) ); + setHDVersionDGServiceRecord( &payload ); + } +} + +/*********************************************************************//** + * @brief + * The handleDGUsageInfoData function receives the HD version of the + * DG usage info. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGUsageInfoData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( HD_VERSION_DG_USAGE_INFO_T ) ) + { + HD_VERSION_DG_USAGE_INFO_T payload; + + memcpy( &payload, message->payload, sizeof( HD_VERSION_DG_USAGE_INFO_T ) ); + setHDVersionDGUsageInfo( &payload ); + } +} + +/*********************************************************************//** * @brief * The handleGetHDUsageInfoRecord function handles a request to get the HD * usage information record. Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -rfc65332fb8fa0e83ddccbdc72592cc4a4b41e382 -r32367866387722d779fa89d0a0bbe837e5dd4972 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision fc65332fb8fa0e83ddccbdc72592cc4a4b41e382) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 32367866387722d779fa89d0a0bbe837e5dd4972) @@ -7,8 +7,8 @@ * * @file SystemCommMessages.h * -* @author (last) Michael Garthwaite -* @date (last) 28-Sep-2022 +* @author (last) Dara Navaei +* @date (last) 18-Oct-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -63,9 +63,6 @@ #define ACK_REQUIRED TRUE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. #define ACK_NOT_REQUIRED FALSE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. -#define ACK_REQUIRED TRUE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. -#define ACK_NOT_REQUIRED FALSE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. - // ********** public function prototypes ********** // Serialize message @@ -139,15 +136,18 @@ void handleUIPOSTFinalResult( MESSAGE_T *message ); // MSG_ID_LOAD_CELL_READINGS -void handleLoadCellReadingsFromDG( MESSAGE_T *message ); +void handleLoadCellReadingsFromDG( MESSAGE_T *message ); + +// MSG_ID_DG_HEATERS_DATA +void handleDGHeatersData( MESSAGE_T *message ); // MSG_ID_DG_TEMPERATURE_DATA: void handleDGTemperatureData( MESSAGE_T *message ); // MSG_ID_RO_PUMP_DATA: void handleROPumpData( MESSAGE_T *message ); -// MSG_ID_DG_DIALYSATE_FLOW_METER_DATA: +// MSG_ID_DG_FLOW_SENSORS_DATA void handleDialysateFlowData( MESSAGE_T *message ); // MSG_ID_DRAIN_PUMP_DATA: @@ -431,10 +431,30 @@ // MSG_ID_HD_SET_SW_CONFIG_RECORD void handleSetHDSoftwareConfigRecord( MESSAGE_T *message ); +// MSG_ID_HD_SEND_ALARMS_COMMAND +void handleResendAllAlarmsCommand( MESSAGE_T* message ); +// MSG_ID_UI_CONFIRMATION_RESULT +void handleUIConfirmationResponse( MESSAGE_T *message ); + +// MSG_ID_HD_REQUEST_UI_CONFIRMATION +void sendConfirmationRequest( GENERIC_CONFIRM_ID_T request_id, GENERIC_CONFIRM_COMMAND_T request_type, U32 reject_reason ); + // MSG_ID_HD_REQUEST_DG_ALARMS BOOL sendRequestForDGResendAlarms( void ); +// MSG_ID_HD_REQUEST_DG_USAGE_INFO +BOOL sendDGUsageInfoRequestToDG( void ); + +// MSG_ID_HD_REQUEST_DG_SERVICE_INFO +BOOL sendDGServiceRequestToDG( void ); + +// MSG_ID_DG_SERVICE_SCHEDULE_DATA +void handleDGServiceScheduleData( MESSAGE_T *message ); + +// MSG_ID_DG_USAGE_DATA +void handleDGUsageInfoData( MESSAGE_T *message ); + // *********** public test support message functions ********** // MSG_TESTER_LOG_IN @@ -813,9 +833,6 @@ // MSG_ID_HD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE BOOL sendBloodLeakEmbeddedModeCommandResponse( U32 responseLen, U08* response ); -// MSG_ID_HD_SEND_ALARMS_COMMAND -void handleResendAllAlarmsCommand( MESSAGE_T* message ); - // MSG_ID_HD_BLOOD_PUMP_SET_PWM void handleTestBloodPumpSetPWM( MESSAGE_T* message );