Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r65d0f3fed34c836640f502d80a8aeb4e10ddf5ac -re0af40e2557c9f9c4fd9f97e909b3cccdc2d15fe --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 65d0f3fed34c836640f502d80a8aeb4e10ddf5ac) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision e0af40e2557c9f9c4fd9f97e909b3cccdc2d15fe) @@ -15,9 +15,9 @@ * ***************************************************************************/ -#include // For memcpy() +#include // For memcpy() -#include "reg_system.h" +#include "reg_system.h" // Used to access system register to reset processor on request #include "Accel.h" #include "AlarmLamp.h" @@ -49,10 +49,6 @@ // ********** private definitions ********** -#ifdef DEBUG_ENABLED - #define DEBUG_EVENT_MAX_TEXT_LEN 40 -#endif - #define MAX_MSGS_BLOCKED_FOR_XMIT 8 ///< Maximum number of messages to block transmission for. #pragma pack(push,1) @@ -1369,15 +1365,17 @@ /*********************************************************************//** * @brief - * The sendDialysateTempTargetsToDG function constructs a dialysate temperature - * set points message for DG and queues the msg for transmit on the appropriate CAN channel. + * The sendDialysateTempTargetsAndReservoirCycleTimeToDG function constructs a + * dialysate temperature set points message and the active reservoir cycle time + * for DG and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: Dialysate temperature set points msg constructed and queued. - * @param primary temperature set point for primary heater - * @param trimmer temperature set point for trimmer heater + * @param trimmer temperature set point for trimmer heater + * @param rsrvrCycleTime active reservoir cycle time in milliseconds + * @param rsrvrWait2Switch time to switch the inactive and active reservoirs in milliseconds * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendDialysateTempTargetsToDG( F32 primary, F32 trimmer ) +BOOL sendDialysateHeatingParamsToDG( DG_CMD_DIALYSATE_HEATING_PARAMS_T *params ) { BOOL result; MESSAGE_T msg; @@ -1386,11 +1384,9 @@ // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS; - msg.hdr.payloadLen = sizeof( F32 ) + sizeof( F32 ); + msg.hdr.payloadLen = sizeof( DG_CMD_DIALYSATE_HEATING_PARAMS_T ); - memcpy( payloadPtr, &primary, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &trimmer, sizeof( F32 ) ); + memcpy( payloadPtr, params, sizeof( DG_CMD_DIALYSATE_HEATING_PARAMS_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_2_DG, ACK_REQUIRED ); @@ -1461,10 +1457,11 @@ * @details Inputs: none * @details Outputs: DG fill command msg constructed and queued. * @param cmd start or stop fill command - * @param fillToVolumeMl volume (in mL) to fill inactive reservoir to + * @param fillToVolumeMl volume (in mL) to fill inactive reservoir to + * @param targetFlowLRatePM target fill flow rate in L/min * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendDGFillCommand( U32 cmd, U32 fillToVolumeMl ) +BOOL sendDGFillCommand( U32 cmd, U32 fillToVolumeMl, F32 targetFlowRateLPM ) { BOOL result; MESSAGE_T msg; @@ -1473,11 +1470,13 @@ // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_FILL_CMD; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ); memcpy( payloadPtr, &fillToVolumeMl, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &cmd, sizeof( U32 ) ); + memcpy( payloadPtr, &cmd, sizeof( U32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &targetFlowRateLPM, sizeof( F32 ) ); // 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 ); @@ -1935,6 +1934,52 @@ return result; } +/*********************************************************************//** + * @brief + * The sendDGConcentrateMixingRatiosRequest function constructs a request msg + * to the DG to request the concentrate ratios and queues the msg for transmit + * on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG POST result request msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGConcentrateMixingRatiosRequest( void ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_REQUEST_DG_CONCENTRATE_MIXING_RATIOS; + msg.hdr.payloadLen = 0; + + // 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 ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDGMixingRatios function handles a concentrate mixing ratios and + * prepare fill time broadcast from DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGMixingRatios( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( DG_MIXING_RATIOS_T ) ) + { + DG_MIXING_RATIOS_T payload; + + memcpy( &payload, message->payload, sizeof( DG_MIXING_RATIOS_T ) ); + + setDGMixingRatios( payload ); + } +} + #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) { @@ -2262,7 +2307,7 @@ TEMPERATURE_SENSORS_DATA_T payload; memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); - setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); + setDialysateTemperatureReadings( payload.TDi, payload.TRo ); } // TODO - what to do if invalid payload length? // TODO - how to know if DG stops sending these? @@ -2279,11 +2324,11 @@ *************************************************************************/ void handleDialysateFlowData( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == sizeof(DIALYSATE_FLOW_METER_DATA_T) ) + if ( message->hdr.payloadLen == sizeof( DIALYSATE_FLOW_METER_DATA_T ) ) { DIALYSATE_FLOW_METER_DATA_T payload; - memcpy( &payload, message->payload, sizeof(DIALYSATE_FLOW_METER_DATA_T) ); + memcpy( &payload, message->payload, sizeof( DIALYSATE_FLOW_METER_DATA_T ) ); setDialysateFlowData( payload.measuredDialysateFlowRate ); } } @@ -3158,55 +3203,6 @@ *************************************************************************/ -#ifdef DEBUG_ENABLED - /*********************************************************************//** - * @brief - * The sendDebugData function sends debug data out to the PC port. - * @details - * @details Inputs: none - * @details Outputs: PC serial port - * @param dbgData Pointer to debug data - * @param len number of bytes of debug data - * @return TRUE if debug data was successfully queued for transmit, FALSE if not - *************************************************************************/ - BOOL sendDebugData( U08 *dbgData, U32 len ) - { - BOOL result; - - // Add serialized message data to appropriate comm buffer - result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, dbgData, len ); - - return result; - } - - /*********************************************************************//** - * @brief - * The sendDebugDataToUI function sends debug string to the UI for logging. - * @details Inputs: none - * @details Outputs: Message constructed and queued for transmit - * @param str Pointer to debug string - * @return none - *************************************************************************/ - void sendDebugDataToUI( U08 *str ) - { - MESSAGE_T msg; - U32 txtLen = strlen( (char*)str ); - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_DEBUG_EVENT; - msg.hdr.payloadLen = DEBUG_EVENT_MAX_TEXT_LEN + 1; // Add 1 byte for null terminator - if ( txtLen <= DEBUG_EVENT_MAX_TEXT_LEN ) - { - memcpy( payloadPtr, str, txtLen + 1 ); - - // 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 ); - } - } -#endif - /*********************************************************************//** * @brief * The isTestingActivated function determines whether a tester has successfully @@ -5127,6 +5123,7 @@ if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) { result = testSetBatteryRemainingPercentOverride( payload.state.u32 ); @@ -6730,7 +6727,6 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - /*********************************************************************//** * @brief * The handleStopHDRTCClock function handles a request to stop the RTC clock.