Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -ra7bf3ca23ea37a61000379facae628a31b3ecc59 -rf308cc4c35eab630ebbbde405cfe47d049afeafb --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision a7bf3ca23ea37a61000379facae628a31b3ecc59) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision f308cc4c35eab630ebbbde405cfe47d049afeafb) @@ -7,22 +7,27 @@ * * @file SystemCommMessages.c * -* @author (last) Sean Nash -* @date (last) 29-Jun-2020 +* @author (last) Quang Nguyen +* @date (last) 21-Jul-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ #include // for memcpy() - -#include "DrainPump.h" + +#include "Accel.h" +#include "ConductivitySensors.h" +#include "DrainPump.h" +#include "FPGA.h" #include "Heaters.h" #include "LoadCell.h" -#include "MsgQueues.h" +#include "MessagePayloads.h" #include "ModeStandby.h" #include "ModeRecirculate.h" +#include "MsgQueues.h" +#include "NVDataMgmt.h" #include "OperationModes.h" #include "Pressures.h" #include "Reservoirs.h" @@ -41,75 +46,10 @@ #define ACK_REQUIRED TRUE #define ACK_NOT_REQUIRED FALSE -#pragma pack(push,1) +#ifdef DEBUG_ENABLED + #define DEBUG_EVENT_MAX_TEXT_LEN 40 +#endif -typedef struct -{ - U32 alarmState; // 0 = no alarms, 1 = low priority, 2 = medium priority, 3 = high priority - U32 alarmTop; // ID of top active alarm - U32 escalatesIn; // seconds - U32 silenceExpiresIn; // seconds - U16 alarmsFlags; // bit flags: 1 = true, 0 = false for each bit -} ALARM_COMP_STATUS_PAYLOAD_T; - -typedef struct -{ - U32 treatmentTimePrescribedinSec; - U32 treatmentTimeElapsedinSec; - U32 treatmentTimeRemaininginSec; -} TREATMENT_TIME_DATA_T; - -typedef struct -{ - F32 loadCellA1inGram; - F32 loadCellA2inGram; - F32 loadCellB1inGram; - F32 loadCellB2inGram; -} LOAD_CELL_DATA_T; - -typedef struct -{ - U32 setROPumpPressure; - F32 measROFlowRate; - F32 roPumpPWM; -} RO_PUMP_DATA_T; - -typedef struct -{ - U32 setDrainPumpSpeed; - U32 dacValue; -} DRAIN_PUMP_DATA_T; - -typedef struct -{ - F32 roPumpInletPressure; - F32 roPumpOutletPressure; - F32 drainPumpInletPressure; - F32 drainPumpOutletPressure; -} PRESSURES_DATA_T; - -typedef struct -{ - U32 activeReservoir; - U32 fillToVolumeMl; - U32 drainToVolumeMl; -} RESERVOIR_DATA_T; - -typedef struct -{ - F32 targetPrimaryHeaterTemp; - F32 targetTrimmerHeaterTemp; -} TARGET_TEMPS_PAYLOAD_T; - -typedef struct -{ - U32 mainPrimayHeaterDC; - U32 smallPrimaryHeaterDC; - U32 trimmerHeaterDC; -} HEATERS_DATA_T; - -#pragma pack(pop) - // ********** private data ********** static BOOL testerLoggedIn = FALSE; @@ -131,9 +71,9 @@ * @details * Inputs : none * Outputs : given data array populated with serialized message data and queued for transmit. - * @param msg : message to serialize - * @param buffer : outgoing buffer that message should be queued in - * @param ackReq : is an acknowledgement from receiver required? + * @param msg message to serialize + * @param buffer outgoing buffer that message should be queued in + * @param ackReq is an acknowledgement from receiver required? * @return size (in bytes) of serialized message populated in given data array. *************************************************************************/ static U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) @@ -191,7 +131,7 @@ if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) { error = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) } } @@ -211,7 +151,7 @@ * @details * Inputs : none * Outputs : ACK message queued for transmit on broadcast CAN channel. - * @param message : message to send an ACK for + * @param message message to send an ACK for * @return TRUE if ACK message queued successfully, FALSE if not *************************************************************************/ BOOL sendACKMsg( MESSAGE_T *message ) @@ -242,9 +182,9 @@ * @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 + * @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 ) @@ -275,9 +215,9 @@ * @details * Inputs : none * Outputs : alarm triggered msg constructed and queued. - * @param alarm : ID of alarm triggered - * @param almData1 : 1st data associated with alarm - * @param almData2 : 2nd data associated with alarm + * @param alarm ID of alarm triggered + * @param almData1 1st data associated with alarm + * @param almData2 2nd data associated with alarm * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastAlarmTriggered( U16 alarm, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ) @@ -310,7 +250,7 @@ * @details * Inputs : none * Outputs : alarm cleared msg constructed and queued. - * @param alarm : ID of alarm cleared + * @param alarm ID of alarm cleared * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastAlarmCleared( U16 alarm ) @@ -332,14 +272,61 @@ return result; } +/************************************************************************* + * @brief + * The broadcastAccelData function constructs an accelerometer data msg to \n + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details + * Inputs : none + * Outputs : accelerometer data broadcast msg constructed and queued. + * @param x X axis vector magnitude (in g) + * @param y Y axis vector magnitude (in g) + * @param z Z axis vector magnitude (in g) + * @param xm max X axis vector magnitude (in g) + * @param ym max Y axis vector magnitude (in g) + * @param zm max Z axis vector magnitude (in g) + * @param xt X axis tilt (in degrees) + * @param yt Y axis tilt (in degrees) + * @param zt Z axis tilt (in degrees) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastAccelData( F32 x, F32 y, F32 z, F32 xm, F32 ym, F32 zm, F32 xt, F32 yt, F32 zt ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + ACCEL_DATA_PAYLOAD_T payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_ACCELEROMETER_DATA; + msg.hdr.payloadLen = sizeof( ACCEL_DATA_PAYLOAD_T ); + payload.x = x; + payload.y = y; + payload.z = z; + payload.xMax = xm; + payload.yMax = ym; + payload.zMax = zm; + payload.xTilt = xt; + payload.yTilt = yt; + payload.zTilt = zt; + + memcpy( payloadPtr, &payload, sizeof( ACCEL_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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + /************************************************************************* * @brief broadcastRTCEpoch * The broadcastRTCEpoch function constructs an epoch msg to \n * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details * Inputs : none * Outputs : RTC time and date in epoch - * @param epoch : Current time and date in epoch + * @param epoch Current time and date in epoch * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastRTCEpoch( U32 epoch ) @@ -368,8 +355,8 @@ * @details * Inputs : none * Outputs : DG operation mode msg constructed and queued - * @param mode : current operation mode of the DG. - * @param subMode : current sub-mode of the current operation mode of the DG. + * @param mode current operation mode of the DG. + * @param subMode current sub-mode of the current operation mode of the DG. * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastDGOperationMode( U32 mode, U32 subMode ) @@ -399,10 +386,10 @@ * @details * Inputs : none * Outputs : load cell data msg constructed and queued - * @param loadCellA1 : load cell A 1 data in grams. - * @param loadCellA2 : load cell A 2 data in grams. - * @param loadCellB1 : load cell B 1 data in grams. - * @param loadCellB2 : load cell B 2 data in grams. + * @param loadCellA1 load cell A 1 data in grams + * @param loadCellA2 load cell A 2 data in grams + * @param loadCellB1 load cell B 1 data in grams + * @param loadCellB2 load cell B 2 data in grams * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastLoadCellData( F32 loadCellA1, F32 loadCellA2, F32 loadCellB1, F32 loadCellB2 ) @@ -436,7 +423,7 @@ * @details * Inputs : none * Outputs : Valves states msg constructed and queued - * @param valvesStates : valves states + * @param valvesStates valves states * refer to setFPGAValveStates function in FPGA.c for details * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -465,9 +452,9 @@ * @details * Inputs : heaters data * Outputs : heatears data msg constructed and queued - * @param mainPrimaryDC : main primary heater duty cycle - * @param smallPrimaryDC : small primary heater duty cycle - * @param trimmerDC : trimmer heater duty cycle + * @param mainPrimaryDC main primary heater duty cycle + * @param smallPrimaryDC small primary heater duty cycle + * @param trimmerDC trimmer heater duty cycle * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastHeatersData ( U32 mainPrimaryDC, U32 smallPrimaryDC, U32 trimmerDC ) @@ -500,9 +487,9 @@ * @details * Inputs : none * Outputs : RO pump data msg constructed and queued - * @param tgtPressure : target pressure for RO pump in PSI. - * @param measFlow : measure RO flow rate in LPM. - * @param setPWM : set PWM duty cycle in %. + * @param tgtPressure target pressure for RO pump in PSI + * @param measFlow measure RO flow rate in LPM + * @param setPWM set PWM duty cycle in % * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastROPumpData( U32 tgtPressure, F32 measFlow, F32 setPWM ) @@ -535,8 +522,8 @@ * @details * Inputs : none * Outputs : Drain pump data msg constructed and queued - * @param tgtSpeed : target speed for drain pump in RPM. - * @param dac : set DAC value. + * @param tgtSpeed target speed for drain pump in RPM + * @param dac set DAC value * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastDrainPumpData( U32 tgtSpeed, U32 dac ) @@ -568,10 +555,10 @@ * @details * Inputs : none * Outputs : Pressure data msg constructed and queued - * @param measROIn : measured RO pump inlet pressure in PSI. - * @param measROOut : measured RO pump outlet pressure in PSI. - * @param measDrainIn : measured Drain pump inlet pressure in PSI. - * @param measDrainOut : measured Drain pump outlet pressure in PSI. + * @param measROIn measured RO pump inlet pressure in PSI + * @param measROOut measured RO pump outlet pressure in PSI + * @param measDrainIn measured Drain pump inlet pressure in PSI + * @param measDrainOut measured Drain pump outlet pressure in PSI * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastPressureSensorsData( F32 measROIn, F32 measROOut, F32 measDrainIn, F32 measDrainOut ) @@ -605,9 +592,9 @@ * @details * Inputs : none * Outputs : Reservoir data msg constructed and queued - * @param resID : ID of currently active reservoir. - * @param fillToVol : Current target fill to volume for inactive reservoir. - * @param drainToVol : Current target drain to volume for inactive reservoir. + * @param resID ID of currently active reservoir + * @param fillToVol Current target fill to volume for inactive reservoir + * @param drainToVol Current target drain to volume for inactive reservoir * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastReservoirData( U32 resID, U32 fillToVol, U32 drainToVol ) @@ -640,7 +627,7 @@ * sensors data * Inputs : heaters data * Outputs : temperatur sensors data msg constructed and queued - * @param sensorsValue : sensors value array + * @param sensorsValue sensors value array * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastTemperatureSensorsData ( U08 *sensorsValue, U32 byteLength ) @@ -661,6 +648,41 @@ return result; } + + +/************************************************************************* + * @brief + * The broadcastConductivityData function sends out conductivity data. + * @details + * Inputs : none + * Outputs : conductivity data msg constructed and queued + * @param cpi: water inlet conductivity data. + * @param cpo : water outlet conductivity data. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastConductivityData( F32 cpi, F32 cpo ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + CONDUCTIVITY_DATA_T payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_CONDUCTIVITY_DATA; + msg.hdr.payloadLen = sizeof( CONDUCTIVITY_DATA_T ); + + payload.cpi = cpi; + payload.cpo = cpo; + + memcpy( payloadPtr, &payload, sizeof( CONDUCTIVITY_DATA_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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + // *********************************************************************** // **************** Message Handling Helper Functions ******************** @@ -673,12 +695,15 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handlePowerOffWarning( MESSAGE_T *message ) -{ - // TODO - signal modules that require a warning +{ + if ( message->hdr.payloadLen == 0 ) + { + signalPowerOffWarning(); + } } /************************************************************************* @@ -688,7 +713,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetDialysateTemperatureCmd( MESSAGE_T *message ) @@ -713,31 +738,30 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleFWVersionCmd( MESSAGE_T *message ) { MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - U08 major = (U08)DG_VERSION_MAJOR; - U08 minor = (U08)DG_VERSION_MINOR; - U08 micro = (U08)DG_VERSION_MICRO; - U16 build = (U16)DG_VERSION_BUILD; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_VERSION; - msg.hdr.payloadLen = sizeof( U08 ) + sizeof( U08 ) + sizeof( U08 ) + sizeof( U16 ); - - memcpy( payloadPtr, &major, sizeof( U08 ) ); - payloadPtr += sizeof( U08 ); - memcpy( payloadPtr, &minor, sizeof( U08 ) ); - payloadPtr += sizeof( U08 ); - memcpy( payloadPtr, µ, sizeof( U08 ) ); - payloadPtr += sizeof( U08 ); - memcpy( payloadPtr, &build, sizeof( U16 ) ); - + DG_VERSIONS_T payload; + U08 *payloadPtr = msg.payload; + + // populate payload + payload.major = (U08)DG_VERSION_MAJOR; + payload.minor = (U08)DG_VERSION_MINOR; + payload.micro = (U08)DG_VERSION_MICRO; + payload.build = (U16)DG_VERSION_BUILD; + getFPGAVersions( &payload.fpgaId, &payload.fpgaMajor, &payload.fpgaMinor, &payload.fpgaLab ); + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_VERSION; + msg.hdr.payloadLen = sizeof( DG_VERSIONS_T ); + + // fill message payload + memcpy( payloadPtr, &payload, sizeof( DG_VERSIONS_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_BROADCAST, ACK_NOT_REQUIRED ); } @@ -749,7 +773,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSwitchReservoirCmd( MESSAGE_T *message ) @@ -765,7 +789,8 @@ memcpy( &resID, message->payload, sizeof(U32) ); reservoirID = (RESERVOIR_ID_T)resID; setActiveReservoirCmd( reservoirID ); - } + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } @@ -775,7 +800,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleFillCmd( MESSAGE_T *message ) @@ -789,7 +814,8 @@ result = TRUE; memcpy( &fillToVolumeMl, message->payload, sizeof(U32) ); startFillCmd( fillToVolumeMl ); - } + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } @@ -799,7 +825,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleDrainCmd( MESSAGE_T *message ) @@ -814,7 +840,8 @@ memcpy( &drainToVolMl, message->payload, sizeof(U32) ); startDrainCmd( drainToVolMl ); - } + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } @@ -825,7 +852,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleStartStopTreatmentMsg( MESSAGE_T *message ) @@ -846,7 +873,8 @@ { result = requestDGStop(); } - } + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } @@ -857,7 +885,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleStartStopTrimmerHeaterCmd( MESSAGE_T *message ) @@ -878,7 +906,8 @@ { result = stopTrimmerHeaterCmd(); } - } + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } @@ -888,7 +917,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSampleWaterCmd( MESSAGE_T *message ) @@ -901,7 +930,8 @@ { result = requestWaterSample(); } - } + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } @@ -912,7 +942,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetRTCTimestamp( MESSAGE_T *message ) @@ -939,7 +969,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return result *************************************************************************/ BOOL handleStartStopPrimaryHeater( MESSAGE_T * message ) @@ -961,7 +991,8 @@ stopPrimaryHeater(); result = TRUE; } - } + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); return result; @@ -972,26 +1003,54 @@ *************************************************************************/ -/************************************************************************* - * @brief sendDebugData - * The sendDebugData function sends debug data out to the PC port. - * @details - * Inputs : none - * Outputs : PC serial port - * @param dbgData : Pointer to debug data - * @param len : # of bytes of debug data - * @return TRUE if debug data was successfully queued for transmit, FALSE if not - *************************************************************************/ -#ifdef DEBUG_ENABLED -BOOL sendDebugData( U08 *dbgData, U32 len ) -{ - BOOL result; +#ifdef DEBUG_ENABLED + /************************************************************************* + * @brief sendDebugData + * The sendDebugData function sends debug data out to the PC port. + * @details + * Inputs : none + * 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 ); + // add serialized message data to appropriate comm buffer + result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, dbgData, len ); - return result; -} + return result; + } + + /************************************************************************* + * @brief + * The sendDebugDataToUI function sends debug string to the UI for logging. + * @details + * Inputs : none + * 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_DG_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_DG_2_UI, ACK_NOT_REQUIRED ); + } + } #endif /************************************************************************* @@ -1001,7 +1060,6 @@ * @details * Inputs : testerLoggedIn * Outputs : none - * @param none * @return TRUE if a tester has logged in to activate testing, FALSE if not *************************************************************************/ BOOL isTestingActivated( void ) @@ -1017,8 +1075,8 @@ * @details * Inputs : none * Outputs : response message constructed and queued for transmit. - * @param msgID : ID of handled message that we are responding to - * @param ack : TRUE if test message was handled successfully, FALSE if not + * @param msgID ID of handled message that we are responding to + * @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 sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ) @@ -1045,7 +1103,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTesterLogInRequest( MESSAGE_T *message ) @@ -1071,7 +1129,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestWatchdogCheckInStateOverrideRequest, testSetWatchdogTaskCheckInOverride, testResetWatchdogTaskCheckInOverride ) @@ -1083,7 +1141,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestAlarmStateOverrideRequest, testSetAlarmStateOverride, testResetAlarmStateOverride ) @@ -1095,7 +1153,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestLoadCellOverrideRequest, testSetLoadCellOverride, testResetLoadCellOverride ) @@ -1107,7 +1165,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestTemperatureSensorsOverrideRequest, \ @@ -1120,7 +1178,7 @@ * @details * Inputs : none * Outputs : message handled -* @param message : a pointer to the message to handle +* @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestTemperatureSensorsDataPublishOverrideRequest, \ @@ -1133,7 +1191,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestHeatersDataPublishOverrideRequest, \ @@ -1146,7 +1204,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestLoadCellDataBroadcastIntervalOverrideRequest, testSetLoadCellDataPublishIntervalOverride, testResetLoadCellDataPublishIntervalOverride ) @@ -1158,7 +1216,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestPressureSensorOverrideRequest, testSetDGPressureSensorOverride, testResetDGPressureSensorOverride ) @@ -1170,7 +1228,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestPressureDataBroadcastIntervalOverrideRequest, testSetPressuresDataPublishIntervalOverride, testResetPressuresDataPublishIntervalOverride ) @@ -1182,7 +1240,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestROPumpSetPointOverrideRequest, testSetTargetROPumpPressureOverride, testResetTargetROPumpPressureOverride ) @@ -1194,7 +1252,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestROMeasuredFlowOverrideRequest, testSetMeasuredROFlowRateOverride, testResetMeasuredROFlowRateOverride ) @@ -1206,7 +1264,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestROPumpDataBroadcastIntervalOverrideRequest, testSetROPumpDataPublishIntervalOverride, testResetROPumpDataPublishIntervalOverride ) @@ -1218,7 +1276,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDrainPumpSetPointOverrideRequest, testSetTargetDrainPumpSpeedOverride, testResetTargetDrainPumpSpeedOverride ) @@ -1230,7 +1288,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDrainPumpDataBroadcastIntervalOverrideRequest, testSetDrainPumpDataPublishIntervalOverride, testResetDrainPumpDataPublishIntervalOverride ) @@ -1242,7 +1300,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestValveStateOverrideRequest, testSetValveStateOverride, testResetValveStateOverride ) @@ -1254,7 +1312,7 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestValvesStatesPublishIntervalOverrideRequest, testSetValvesStatesPublishIntervalOverride, testResetValvesStatesPublishIntervalOverride ) @@ -1266,33 +1324,94 @@ * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDGSafetyShutdownOverrideRequest, testSetSafetyShutdownOverride, testResetSafetyShutdownOverride ) - -#ifdef CAN_TEST -void broadcastCANTest1LargeFrequentMessage() -{ - static U16 seqNo = 0; - MESSAGE_T msg; - U32 i; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = 99; - msg.hdr.payloadLen = 96; - - for ( i = 0; i < 12; i++ ) - { - memcpy(&msg.payload[i*8], &seqNo, 2); - seqNo++; - } - memcpy(&msg.payload[94], &seqNo, 2); - seqNo++; - - // 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_BROADCAST, ACK_NOT_REQUIRED ); -} - -#endif + +/************************************************************************* + * @brief + * The handleTestDGAccelOverrideRequest function handles a request to \n + * override the measured accelerometer sensor readings. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDGAccelOverrideRequest, testSetAccelAxisOverride, testResetAccelAxisOverride ) + +/************************************************************************* + * @brief + * The handleTestDGAccelMaxOverrideRequest function handles a request to \n + * override the measured accelerometer sensor maximum readings. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDGAccelMaxOverrideRequest, testSetAccelMaxOverride, testResetAccelMaxOverride ) + +/************************************************************************* + * @brief + * The handleTestDGAccelBroadcastIntervalOverrideRequest function handles a \n + * request to override the broadcast interval for accelerometer data messages. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDGAccelBroadcastIntervalOverrideRequest, testSetAccelDataPublishIntervalOverride, testResetAccelDataPublishIntervalOverride ) + +/************************************************************************* + * @brief + * The handleSetAccelCalibration function handles a request to set + * accelerometer calibration factors. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetAccelCalibration( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(ACCEL_CAL_PAYLOAD_T) ) + { + ACCEL_CAL_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(ACCEL_CAL_PAYLOAD_T) ); + result = setAccelCalibration( payload.xOffset, payload.yOffset, payload.zOffset ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/************************************************************************* + * @brief + * The handleTestSetConductivityOverrideRequest function handles a + * request to override a conductivity sensor's value + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestSetConductivityOverrideRequest, testSetConductivityOverride, testResetConductivityOverride ) + +/************************************************************************* +* @brief +* The handleTestSetConductivityDataPublishIntervalOverrideRequest function +* handles a request to override the publish interval of conductivity sensors data +* @details +* Inputs : none +* Outputs : message handled +* @param message : a pointer to the message to handle +* @return none +*************************************************************************/ +DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestSetConductivityDataPublishIntervalOverrideRequest, \ + testSetConductivityDataPublishIntervalOverride, testResetConductivityDataPublishIntervalOverride )