Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r66cc826068b54bc436cde0fae70a05ba6c1ac974 -r1e22b6ff6f42ddc57ad6c17e56057ab8a3765680 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 66cc826068b54bc436cde0fae70a05ba6c1ac974) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 1e22b6ff6f42ddc57ad6c17e56057ab8a3765680) @@ -3469,4 +3469,136 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** +* @brief +* The handleGetDGUsageInfoRecord function handles a request to get the DG +* usage information record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetDGUsageInfoRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = sendRecordToDialin( NVDATAMGMT_USAGE_INFO_RECORD ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetDGUsageInfoRecord function handles a request to set the DG +* information record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetDGUsageInfoRecord( MESSAGE_T *message ) +{ + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + BOOL status = FALSE; + U08* payloadPtr = message->payload; + + if ( message->hdr.payloadLen >= ( sizeof(currentMessage) + sizeof(totalMessages) + sizeof(payloadLength) ) ) + { + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = receiveRecordFromDialin( NVDATAMGMT_USAGE_INFO_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** + * @brief + * The sendDGUsageInfoRecord function sends out the DG usage information record. + * @details Inputs: none + * @details Outputs: DG usage information record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param usageInfoAddress: start address of the susage information record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGUsageInfoRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* usageInfoAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_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, usageInfoAddress, 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 handleSetHDOperationMode function receives the HD operation modes data + * publish message. + * @details Inputs: none + * @details Outputs: none + * @param message a pointer to the message to handle + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL handleSetHDOperationMode( MESSAGE_T *message ) +{ + BOOL status = FALSE; + U08* payloadPtr = message->payload; + + // HD mode broadcast is operations mode and submode so 8 bytes + if ( message->hdr.payloadLen == sizeof( U32 ) + sizeof( U32 ) ) + { + U32 mode; + + // NOTE: the HD operations modes broadcast message contains the mode and submode states + // In this case, only the mode is needed. The mode is received to check if HD is in treatment + // and therefore, DG can void the last disinfect. + memcpy( payloadPtr, &mode, sizeof( U32 ) ); + setHDOperationMode( mode ); + status = TRUE; + } + + return status; +} + /**@}*/