Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rbb643418e1f0c59ca3ee75c642aaa1f31850069e -r747c714d2b4f80b598a66326d62a179aeefda390 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 747c714d2b4f80b598a66326d62a179aeefda390) @@ -7,8 +7,8 @@ * * @file SystemCommMessages.c * -* @author (last) Dara Navaei -* @date (last) 20-Oct-2023 +* @author (last) Vinayakam Mani +* @date (last) 23-Feb-2024 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -1987,7 +1987,7 @@ * @brief * The sendHDServiceRecord function sends out the HD service record. * @details Inputs: none - * @details Outputs: HD system record msg constructed and queued + * @details Outputs: HD service record msg constructed and queued * @param msgCurrNum: current payload number * @param msgTotalNum: total number of payloads * @param length: buffer length to be written @@ -3593,7 +3593,41 @@ } } +/*********************************************************************//** + * @brief + * The sendInstitutionalRecordToUI function sends the institutional record to UI + * @details Inputs: none + * @details Outputs: none + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void sendInstitutionalRecordToUI( MESSAGE_T* message ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 accept = 1; + U32 reson = 0; + HD_INSTITUTIONAL_RECORD_T hdInstitutionalRecord; + + getNVRecord2Driver( GET_INSTITUTIONAL_RECORD, (U08*)&hdInstitutionalRecord, sizeof( HD_INSTITUTIONAL_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_INSTITUTIONAL_RECORD_RESPONSE; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( HD_INSTITUTIONAL_RECORD_T ) - sizeof( U32 ) - sizeof( U16 ); + + memcpy( payloadPtr, &accept, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &reson, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &hdInstitutionalRecord, sizeof( HD_INSTITUTIONAL_RECORD_T ) - sizeof( U32 ) - sizeof( U16 ) ); + + // 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 *************************************************************************/ @@ -5210,6 +5244,38 @@ /*********************************************************************//** * @brief + * The handleSetRawAirTrapLevelSensorOverrideRequest function handles a request to + * override an air trap level sensor raw value. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetRawAirTrapLevelSensorOverrideRequest( 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 = testSetRawAirTrapLevelOverride( (AIR_TRAP_LEVEL_SENSORS_T)payload.index, (AIR_TRAP_LEVELS_T)( payload.state.u32 ) ); + } + else + { + result = testResetRawAirTrapLevelOverride( (AIR_TRAP_LEVEL_SENSORS_T)payload.index ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleSetFluidLeakBroadcastIntervalOverrideRequest function handles a * request to override the fluid leak state broadcast interval. * @details Inputs: none @@ -8529,4 +8595,106 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** +* @brief +* The handleGetHDInstitutionalRecord function handles a request to get the HD +* institutional record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetHDInstitutionalRecord( 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_INTITUTIONAL_RECORD ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The sendHDInstitutionalRecord function sends out the HD institutional record. + * @details Inputs: none + * @details Outputs: HD institutional record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param srvcRcrdAddress: start address of the institutional record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendHDInstitutionalRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* srvcRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_INSTITUTIONAL_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, srvcRcrdAddress, 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 handleSetHDInstitutionalRecord function handles a request to set the HD +* institutional data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetHDInstitutionalRecord( MESSAGE_T *message ) +{ + BOOL status = FALSE; + U08* payloadPtr = message->payload; + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + if ( ( message->hdr.payloadLen >= ( sizeof(currentMessage) + sizeof(totalMessages) + sizeof(payloadLength) ) ) && + ( MODE_SERV == getCurrentOperationMode() ) ) + { + 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_INTITUTIONAL_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + /**@}*/