Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r9d7ad180a18e29ba08bf65228d61b6179ddbfcca -rd3ae2d91603ae6d2d25b9abdb220cc144cf90692 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 9d7ad180a18e29ba08bf65228d61b6179ddbfcca) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision d3ae2d91603ae6d2d25b9abdb220cc144cf90692) @@ -120,6 +120,7 @@ static U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ); static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); +static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ); /************************************************************************* * @brief serializeMessage @@ -234,6 +235,36 @@ return result; } +/************************************************************************* + * @brief sendTestAckResponseMsg + * The sendTestAckResponseMsg function constructs a simple response \n + * message for a handled test message and queues it for transmit on the \n + * appropriate UART channel. + * @details + * Inputs : none + * Outputs : response message constructed and queued for transmit. + * @param msgID : ID of handled message that we are responding to + * @param buffer : outgoing buffer that message should be queued in + * @param ack : TRUE if test message was handled successfully, FALSE if not + * @return TRUE if response message successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ) +{ + BOOL result; + MESSAGE_T msg; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = msgID; + msg.hdr.payloadLen = sizeof( U08 ); + msg.payload[ 0 ] = (U08)ack; + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, buffer, ACK_NOT_REQUIRED ); + + return result; +} + // *********************************************************************** // ********************* MSG_ID_OFF_BUTTON_PRESS ************************* // *********************************************************************** @@ -336,7 +367,7 @@ memcpy( &payload, message->payload, sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ); result = setNewLoadCellReadings( payload.res1PrimaryLoadCell, payload.res1BackupLoadCell, payload.res2PrimaryLoadCell, payload.res2BackupLoadCell ); } - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); + // TODO - what to do if invalid payload length? } /************************************************************************* @@ -367,7 +398,7 @@ result = resumeUF(); } } - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); } /************************************************************************* @@ -392,7 +423,7 @@ result = verifyUFSettingsChange( payload.volume_mL, payload.adjustType ); } - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); } /************************************************************************* @@ -411,7 +442,7 @@ * @param rateDiff : alarm status record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendChangeUFSettingsResponse( BOOL accepted, F32 volume_mL, U32 time_min, F32 ufRate_mL_min, U32 timeDiff, F32 rateDiff ) +BOOL sendChangeUFSettingsResponse( BOOL accepted, F32 volume_mL, U32 time_min, F32 ufRate_mL_min, S32 timeDiff, F32 rateDiff ) { BOOL result; F32 volume_L = volume_mL / (F32)ML_PER_LITER; @@ -463,7 +494,7 @@ result = verifyUFSettingsConfirmation( payload.confirmed, payload.volume_mL, payload.treatTime_min, payload.uFRate_mL_min ); } - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); } /************************************************************************* @@ -488,7 +519,7 @@ result = verifyTreatmentDurationSettingChange( timeInMin ); } - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); } /************************************************************************* @@ -1349,13 +1380,10 @@ U08 days = message->payload[3]; U08 months = message->payload[4]; U32 years; + memcpy(&years, &message->payload[5], sizeof(U32)); + result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); - // TODO: Change setRTCTimestamp to return a boolean for this - result = TRUE; - - setRTCTimestamp( seconds, minutes, hours, days, months, years ); - // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); }