Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r766708fceb0bdf1af8c7897df29d4f5036bfd3db -rb4114c4cd078650769bf8a0379f47989660cc6e1 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 766708fceb0bdf1af8c7897df29d4f5036bfd3db) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision b4114c4cd078650769bf8a0379f47989660cc6e1) @@ -566,9 +566,7 @@ * and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: DG drain command msg constructed and queued. - * @param drainToVolumeMl volume (in mL) to drain the inactive reservoir to - * @param tareLoadCells set to TRUE if inactive reservoir load cells should be - * tared after draining + * @param drainCmdPtr drain command data record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendDGDrainCommand( DRAIN_RESERVOIR_CMD_PAYLOAD_T *drainCmdPtr ) @@ -625,10 +623,11 @@ * appropriate CAN channel. * @details Inputs: none * @details Outputs: DG start/stop trimmer heater command msg constructed and queued. - * @param start TRUE indicates start heater, FALSE indicates stop heater + * @param start TRUE indicates start heater, FALSE indicates stop heater + * @param trimmerHtrTemp target temperature for trimmer heater * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start ) +BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start, F32 trimmerHtrTemp ) { BOOL result; MESSAGE_T msg; @@ -637,10 +636,12 @@ // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_START_STOP_TRIMMER_HEATER_CMD; - msg.hdr.payloadLen = sizeof( BOOL ); + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( F32 ); + + memcpy( payloadPtr, &start, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &trimmerHtrTemp, sizeof( F32 ) ); - memcpy( payloadPtr, &start, sizeof( BOOL ) ); - // 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 ); @@ -669,10 +670,55 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); return result; -} +} + +/*********************************************************************//** + * @brief + * The handleDGCmdResp function handles a DG command response message. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param messagePtr pointer to the message to handle. + * @return none + *************************************************************************/ +void handleDGCmdResp( MESSAGE_T *messagePtr ) +{ + BOOL result = FALSE; + if ( messagePtr->hdr.payloadLen == sizeof( DG_CMD_RESPONSE_T ) ) + { + result = TRUE; + handleDGCommandResponse( messagePtr->payload ); + } + + sendAckResponseMsg( (MSG_ID_T)messagePtr->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, result ); +} + /*********************************************************************//** * @brief + * The handleDGOpMode function handles a DG broadcast of its current mode. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param message pointer to the message to handle. + * @return none + *************************************************************************/ +void handleDGOpMode( MESSAGE_T *message ) +{ + U32 payloadSize = sizeof(U32) + sizeof(U32); + + if ( message->hdr.payloadLen == payloadSize ) + { + U32 mode, subMode; + + memcpy( &mode, message->payload, sizeof(U32) ); + memcpy( &subMode, &message->payload[sizeof(U32)], sizeof(U32) ); + + setDGOpMode( mode, subMode ); + checkInFromDG(); // TODO - here until we implement DG check-in w/ HD broadcast + } +} + +/*********************************************************************//** + * @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 @@ -1100,7 +1146,8 @@ * broadcast message and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: HD operation mode msg constructed and queued - * @param mode current HD operation mode + * @param mode current HD operation mode + * @param subMode current HD operation sub-mode * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastHDOperationMode( U32 mode, U32 subMode ) @@ -1130,6 +1177,7 @@ * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: HD valves msg constructed and queued + * @param valveData valve data record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastHDValves( HD_VALVE_DATA_T *valveData ) @@ -1157,6 +1205,7 @@ * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: saline bolus data msg constructed and queued + * @param data saline bolus data record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastSalineBolusData( SALINE_BOLUS_DATA_PAYLOAD_T data ) @@ -1184,6 +1233,8 @@ * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: air trap data msg constructed and queued + * @param lowerLevel air trap lower level data + * @param upperLevel air trap upper level data * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastAirTrapData( AIR_TRAP_LEVELS_T lowerLevel, AIR_TRAP_LEVELS_T upperLevel ) @@ -1209,6 +1260,34 @@ return result; } +/***********************************************************************//** + * @brief + * The broadcastAirTrapData function constructs an HD air trap data msg to \n + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: air trap data msg constructed and queued + * @param primeDataPtr prime data record pointer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastPrimeData( PRIMING_DATA_PAYLOAD_T *primeDataPtr ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_PRIMING_STATUS_DATA; + msg.hdr.payloadLen = sizeof( PRIMING_DATA_PAYLOAD_T ); + + memcpy( payloadPtr, primeDataPtr, sizeof( PRIMING_DATA_PAYLOAD_T ) ); + + // 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_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) { @@ -1676,35 +1755,6 @@ /*********************************************************************//** * @brief - * The sendTreatmentEndResponseMsg function constructs a treatment end - * request response message to the UI and queues the msg for transmit on - * the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: Treatment end response msg constructed and queued. - * @param accepted T/F - request accepted? - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendTreatmentEndResponseMsg( BOOL accepted ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_TREATMENT_END_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ); - - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - - // 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_UI, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief * The handleTreatmentParametersFromUI function handles a treatment parameters * set and validate request message from the UI. * @details Inputs: none @@ -2047,30 +2097,6 @@ /*********************************************************************//** * @brief - * The handleDGOpMode function handles a DG broadcast of its current mode. - * @details Inputs: none - * @details Outputs: message handled, response constructed and queued for transmit. - * @param message a pointer to the message to handle. - * @return none - *************************************************************************/ -void handleDGOpMode( MESSAGE_T *message ) -{ - U32 payloadSize = sizeof(U32) + sizeof(U32); - - if ( message->hdr.payloadLen == payloadSize ) - { - U32 mode, subMode; - - memcpy( &mode, message->payload, sizeof(U32) ); - memcpy( &subMode, &message->payload[sizeof(U32)], sizeof(U32) ); - - setDGOpMode( mode, subMode ); - checkInFromDG(); // TODO - here until we implement DG check-in w/ HD broadcast - } -} - -/*********************************************************************//** - * @brief * The handleFWVersionRequest function handles a request for HD f/w version. * @details Inputs: none * @details Outputs: message handled, response constructed and queued for transmit. @@ -3629,7 +3655,7 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleTestSetTreatmentParameter function handles a request to set * a specific treatment parameter value. @@ -3655,7 +3681,7 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleHomeHDValve function handles a request to home an HD valve * @details Inputs: none @@ -3807,7 +3833,7 @@ } #endif -/************************************************************************* +/*********************************************************************//** * @brief * The handleSetAirTrapBroadcastIntervalOverrideRequest function handles a * request to override the air trap data broadcast interval. @@ -3839,7 +3865,7 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleSetAirTrapLevelSensorOverrideRequest function handles a request to * override an air trap level sensor.