Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rd7b793881e8414f2daf75825d5de4e25a25d10ac -rf760ffc4b10556e5186e9ceb90294262063440ca --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision d7b793881e8414f2daf75825d5de4e25a25d10ac) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision f760ffc4b10556e5186e9ceb90294262063440ca) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2022 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. * * 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 SystemCommMessages.c * -* @author (last) Dara Navaei -* @date (last) 03-Nov-2022 +* @author (last) Sean Nash +* @date (last) 27-Jan-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -94,7 +94,6 @@ U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) { BOOL result = 0; - BOOL error = FALSE; BOOL blocked = FALSE; U32 msgSize = 0; U32 sizeMod, sizePad; @@ -167,17 +166,13 @@ { if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) { - error = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL, (U32)(msg.hdr.msgID) ) } } } - if ( FALSE == error ) - { - // Add serialized message data to appropriate out-going comm buffer - result = addToCommBuffer( buffer, data, msgSize ); - } + // Add serialized message data to appropriate out-going comm buffer + result = addToCommBuffer( buffer, data, msgSize ); } else { @@ -796,14 +791,14 @@ *************************************************************************/ void handleUITreatmentLogDataRequest( MESSAGE_T *message ) { + BOOL ack = FALSE; + if ( 0 == message->hdr.payloadLen ) { + ack = TRUE; sendTreatmentLogDataToUI(); } - else - { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); - } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ack ); } /*********************************************************************//** @@ -2355,7 +2350,7 @@ TEMPERATURE_SENSORS_DATA_T payload; memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); - setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); + setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant, payload.heatDisinfect ); } } @@ -3117,6 +3112,30 @@ /*********************************************************************//** * @brief + * The sendFWVersionRequest function constructs a firmware version request + * message and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Firmware version request msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendFWVersionRequest( void ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_REQUEST_FW_VERSIONS; + msg.hdr.payloadLen = sizeof( UI_VERSIONS_T ); // usually UI sends this request w/ UI version info - we will leave that blank + + // 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 handleUIVersionResponse function handles a response to request for * UI version information. * @details Inputs: none @@ -3224,7 +3243,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &dgData.dgServiceRecord.lastServiceDateEpoch, sizeof( U32 ) ); + memcpy( payloadPtr, &dgData.dgServiceRecord.lastServiceEpochDate, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &dgData.dgServiceRecord.serviceIntervalSeconds, sizeof( U32 ) ); } @@ -3272,7 +3291,6 @@ *************************************************************************/ void handleUIConfirmationResponse( MESSAGE_T *message ) { - BOOL result = FALSE; U08* payloadPtr = message->payload; if ( message->hdr.payloadLen == 2 * sizeof(U32) ) @@ -3291,7 +3309,7 @@ } } - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); } /*********************************************************************//** @@ -7111,6 +7129,45 @@ } /*********************************************************************//** + * @brief + * The sendHDUsageRecord function sends out the HD service record. + * @details Inputs: none + * @details Outputs: HD system record msg constructed and queued + * @param payloadCurrNum: current payload number + * @param payloadTotalNum: total number of payloads + * @param length: buffer length to be written + * @param srvcRcrdAddress: start address of the usage record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendHDUsageRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* sysRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_USAGE_INFO_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, sysRcrdAddress, length ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** * @brief * The handleUIServiceModeRequest function handles a request to enter service * mode. @@ -7130,10 +7187,9 @@ { if ( ( MODE_STAN == currentMode ) || ( MODE_FAUL == currentMode ) ) { - requestNewOperationMode( MODE_SERV ); - if ( (DG_MODE_STAN == currentDGMode) || (DG_MODE_FAUL == currentDGMode) ) + if ( ( DG_MODE_STAN == currentDGMode ) || ( DG_MODE_FAUL == currentDGMode ) ) { status = TRUE; cmdSetDGToServiceMode(); @@ -7272,11 +7328,11 @@ *************************************************************************/ void handleDGServiceScheduleData( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == sizeof( HD_VERSION_DG_SERVICE_RECORD_T ) ) + if ( message->hdr.payloadLen == sizeof( DG_SERVICE_RECORD_T ) ) { - HD_VERSION_DG_SERVICE_RECORD_T payload; + DG_SERVICE_RECORD_T payload; - memcpy( &payload, message->payload, sizeof( HD_VERSION_DG_SERVICE_RECORD_T ) ); + memcpy( &payload, message->payload, sizeof( DG_SERVICE_RECORD_T ) ); setHDVersionDGServiceRecord( &payload ); } } @@ -7292,16 +7348,37 @@ *************************************************************************/ void handleDGUsageInfoData( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == sizeof( HD_VERSION_DG_USAGE_INFO_T ) ) + if ( message->hdr.payloadLen == sizeof( DG_USAGE_INFO_RECORD_T ) ) { - HD_VERSION_DG_USAGE_INFO_T payload; + DG_USAGE_INFO_RECORD_T payload; - memcpy( &payload, message->payload, sizeof( HD_VERSION_DG_USAGE_INFO_T ) ); + memcpy( &payload, message->payload, sizeof( DG_USAGE_INFO_RECORD_T ) ); setHDVersionDGUsageInfo( &payload ); } } /*********************************************************************//** + * @brief + * The handleSetHDServiceTime function sets the HD service time once the + * command is received from UI + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetHDServiceTime( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + result = setServiceTime(); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** * @brief * The handleGetHDUsageInfoRecord function handles a request to get the HD * usage information record. @@ -7461,11 +7538,12 @@ * the blood leak embedded mode command response. * @details Inputs: none * @details Outputs: blood leak embedded mode command response msg constructed and queued + * @param cmd: the command its response is being sent * @param responseLen: the length of the buffer * @param response: pointer to the response buffer * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendBloodLeakEmbeddedModeCommandResponse( U32 responseLen, U08* response ) +BOOL sendBloodLeakEmbeddedModeCommandResponse( U08 cmd, U32 responseLen, U08* response ) { BOOL result; MESSAGE_T msg; @@ -7474,8 +7552,10 @@ // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE; - msg.hdr.payloadLen = sizeof( U32 ) + responseLen; + msg.hdr.payloadLen = sizeof( U08 ) + sizeof( U32 ) + responseLen; + memcpy( payloadPtr, &cmd, sizeof( U08 ) ); + payloadPtr += sizeof( U08 ); memcpy( payloadPtr, &responseLen, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, response, responseLen ); @@ -7615,4 +7695,88 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** +* @brief +* The handleTestHDNVRecordCRCOverride function handles a request to override +* the selected NV record's CRC. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestHDNVRecordCRCOverride( 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 ) ); + result = testSetNVRecordCRCOverride( payload.index, (U16)payload.state.u32 ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleAirPumpIntervalOverrideRequest function handles a request to override +* the air pump's broadcast interval. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleAirPumpIntervalOverrideRequest( 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 = testSetAirPumpDataPublishIntervalOverride( (U32)( payload.state.u32 ) ); + } + else + { + result = testResetAirPumpDataPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleAirPumpSetState function handles a request to set the +* air pump state. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleAirPumpSetState( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + U32 payLoad; + + memcpy( &payLoad, message->payload, sizeof( U32 ) ); + + result = testSetAirPump( payLoad ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/