Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -ra35d5e68aad457339f625848809207a9650ad019 -rd9d085cdca67200ecddbdfbc75c489e704b23081 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision a35d5e68aad457339f625848809207a9650ad019) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision d9d085cdca67200ecddbdfbc75c489e704b23081) @@ -17,7 +17,7 @@ #include // for memcpy() -#include "Accel.h" +#include "Accel.h" #include "AlarmLamp.h" #include "BloodFlow.h" #include "Buttons.h" @@ -26,6 +26,7 @@ #include "Dialysis.h" #include "FPGA.h" #include "MessagePayloads.h" +#include "ModePreTreat.h" #include "ModeStandby.h" #include "ModeTreatment.h" #include "ModeTreatmentParams.h" @@ -738,7 +739,8 @@ payload.alarmsFlags |= ( almStatus.noNewTreatment ? BIT_BY_POS(6) : 0 ); payload.alarmsFlags |= ( almStatus.bypassDialyzer ? BIT_BY_POS(7) : 0 ); payload.alarmsFlags |= ( almStatus.alarmsToEscalate ? BIT_BY_POS(8) : 0 ); - payload.alarmsFlags |= ( almStatus.alarmsSilenced ? BIT_BY_POS(9) : 0 ); + payload.alarmsFlags |= ( almStatus.alarmsSilenced ? BIT_BY_POS(9) : 0 ); + payload.alarmsFlags |= ( almStatus.lampOn ? BIT_BY_POS(10) : 0 ); memcpy( payloadPtr, &payload, sizeof( ALARM_COMP_STATUS_PAYLOAD_T ) ); @@ -1158,26 +1160,38 @@ return result; } -// TODO remove this function -BOOL broadcastFastTempHDValves() +/***********************************************************************//** + * @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 + * Outputs : air trap data msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastAirTrapData( AIR_TRAP_LEVELS_T lowerLevel, AIR_TRAP_LEVELS_T upperLevel ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; + U32 lower = (U32)lowerLevel; + U32 upper = (U32)upperLevel; // create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TEMP_FAST_HD_VALVES_REMOVE_LATER; - msg.hdr.payloadLen = sizeof( HD_VALVE_FAST_DATA_T ); + msg.hdr.msgID = MSG_ID_HD_AIR_TRAP_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - memcpy( payloadPtr, &fastDataRemoveLater, sizeof( HD_VALVE_FAST_DATA_T ) ); + memcpy( payloadPtr, &lower, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &upper, 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_HD_BROADCAST, ACK_NOT_REQUIRED ); return result; -} - +} + #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) { @@ -1509,7 +1523,7 @@ } else if ( 2 == cmd ) // start treatment { - // TODO - handle when pre-treatment mode is ready for this + result = signalUserBeginningTreatment(); } } @@ -3349,6 +3363,7 @@ { BOOL result = FALSE; + // verify payload length if ( message->hdr.payloadLen == sizeof(ACCEL_CAL_PAYLOAD_T) ) { ACCEL_CAL_PAYLOAD_T payload; @@ -3375,6 +3390,7 @@ { BOOL result = FALSE; + // verify payload length if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) { LINEAR_F32_CAL_PAYLOAD_T payload; @@ -3401,6 +3417,7 @@ { BOOL result = FALSE; + // verify payload length if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) { LINEAR_F32_CAL_PAYLOAD_T payload; @@ -3427,6 +3444,7 @@ { BOOL result = FALSE; + // verify payload length if ( message->hdr.payloadLen == sizeof(CRITICAL_DATAS_T) + sizeof(CRITICAL_DATAS_T) ) { CRITICAL_DATAS_T payload[2]; @@ -3452,6 +3470,7 @@ { BOOL result = FALSE; + // verify payload length if ( message->hdr.payloadLen == sizeof(U32) ) { U32 valve; @@ -3481,7 +3500,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - /* verify payload length */ + // verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3495,7 +3514,7 @@ } } - /* respond to request */ + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3540,12 +3559,13 @@ void handleSetHDValvePositionOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; - BOOL result = 0; - /* verify payload length */ + 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 ( 0 == payload.reset ) + if ( FALSE == payload.reset ) { result = testSetValvesPositionOverride( payload.index, (BOOL)(payload.state.u32) ); } @@ -3554,7 +3574,8 @@ result = testResetValvesPositionOverride( payload.index ); } } - /* respond to request */ + + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3571,12 +3592,13 @@ void handleSetHDValvePWMOverrideRequest( MESSAGE_T *message ) { OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T payload; - BOOL result = 0; - /* verify payload length */ + BOOL result = FALSE; + + // verify payload length if ( sizeof(OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T) ); - if ( 0 == payload.reset ) + if ( FALSE == payload.reset ) { result = testSetValvePWMOverride( payload.valve, payload.pwm, payload.direction ); } @@ -3585,8 +3607,75 @@ result = testResetValvePWMOverride( payload.valve ); } } - /* respond to request */ + + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/************************************************************************* + * @brief + * The handleSetAirTrapBroadcastIntervalOverrideRequest function handles a + * request to override the air trap data broadcast interval. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetAirTrapBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetAirTrapDataPublishIntervalOverride( (U32)(payload.state.u32) ); + } + else + { + result = testResetAirTrapDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/************************************************************************* + * @brief + * The handleSetAirTrapLevelSensorOverrideRequest function handles a request to + * override an air trap level sensor. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetAirTrapLevelSensorOverrideRequest( 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 = testSetAirTrapLevelOverride( (AIR_TRAP_LEVEL_SENSORS_T)payload.index, (AIR_TRAP_LEVELS_T)(payload.state.u32) ); + } + else + { + result = testResetAirTrapLevelOverride( (AIR_TRAP_LEVEL_SENSORS_T)payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/