Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r9f403b860d7767f4fb07e13692ccdc9852a42105 -r9ce06772b2f651c57144327e6cbf886e2bc22dee --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 9f403b860d7767f4fb07e13692ccdc9852a42105) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 9ce06772b2f651c57144327e6cbf886e2bc22dee) @@ -260,7 +260,7 @@ * @param alarm ID of alarm cleared * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastAlarmCleared( U16 alarm ) +BOOL broadcastAlarmCleared( U32 alarm ) { BOOL result; MESSAGE_T msg; @@ -269,9 +269,9 @@ // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_ALARM_CLEARED; - msg.hdr.payloadLen = sizeof( U16 ); + msg.hdr.payloadLen = sizeof( U32 ); - memcpy( payloadPtr, &alarm, sizeof( U16 ) ); + memcpy( payloadPtr, &alarm, sizeof( U32 ) ); // 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_DG_ALARM, ACK_REQUIRED ); @@ -281,6 +281,35 @@ /*********************************************************************//** * @brief + * The broadcastAlarmConditionCleared function constructs an alarm condition + * cleared msg to be broadcast and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: alarm condition cleared msg constructed and queued. + * @param alarm ID of alarm which alarm condition is cleared + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastAlarmConditionCleared( U32 alarm ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_ALARM_CONDITION_CLEARED; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &alarm, sizeof( U32 ) ); + + // 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_DG_ALARM, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief * The broadcastAccelData function constructs an accelerometer data msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none @@ -875,6 +904,29 @@ return result; } +/*********************************************************************//** + * The sendCommandResponseMsg function constructs a command response to HD + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Command response msg constructed and queued. + * @param cmdResponsePtr pointer to command response data record + * @return none + *************************************************************************/ +void sendCommandResponseMsg( DG_CMD_RESPONSE_T *cmdResponsePtr ) +{ + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_COMMAND_RESPONSE; + msg.hdr.payloadLen = sizeof( DG_CMD_RESPONSE_T ); + + memcpy( msg.payload, cmdResponsePtr, sizeof( DG_CMD_RESPONSE_T ) ); + + // 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_DG_2_HD, ACK_REQUIRED ); +} + // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** @@ -894,20 +946,46 @@ if ( message->hdr.payloadLen == sizeof( U32 ) ) { - RESERVOIR_ID_T reservoirID; + DG_RESERVOIR_ID_T reservoirID; U32 resID; result = TRUE; memcpy( &resID, message->payload, sizeof( U32 ) ); - reservoirID = (RESERVOIR_ID_T)resID; + reservoirID = (DG_RESERVOIR_ID_T)resID; setActiveReservoirCmd( reservoirID ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } + /*********************************************************************//** * @brief + * The handleChangeValveSettingCmd function handles a switch reservoirs command + * from the HD. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChangeValveSettingCmd( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + DG_VALVE_SETTING_ID_T valveSettingID; + + result = TRUE; + memcpy( &valveSettingID, message->payload, sizeof( U32 ) ); + changeValveSettingCmd( valveSettingID ); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); +} + +/*********************************************************************//** + * @brief * The handleFillCmd function handles a fill command from the HD. * @details Inputs: none * @details Outputs: message handled @@ -1000,20 +1078,13 @@ { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof( U32 ) ) + if ( message->hdr.payloadLen == sizeof( TRIMMER_HEATER_CMD_T ) ) { - BOOL startingHeater; + TRIMMER_HEATER_CMD_T heaterCmd; - memcpy( &startingHeater, message->payload, sizeof( U32 ) ); - - if ( TRUE == startingHeater ) - { - result = startTrimmerHeaterCmd(); - } - else - { - result = stopTrimmerHeaterCmd(); - } + result = TRUE; + memcpy( &heaterCmd, message->payload, sizeof( TRIMMER_HEATER_CMD_T ) ); + handleTrimmerHeaterCmd( &heaterCmd ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result );