Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -ra7bf3ca23ea37a61000379facae628a31b3ecc59 -r439894cb0508e69af3ece09ae57a62feac09e3f2 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision a7bf3ca23ea37a61000379facae628a31b3ecc59) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 439894cb0508e69af3ece09ae57a62feac09e3f2) @@ -17,7 +17,8 @@ #include // for memcpy() -#include "DrainPump.h" +#include "DrainPump.h" +#include "FPGA.h" #include "Heaters.h" #include "LoadCell.h" #include "MsgQueues.h" @@ -41,6 +42,10 @@ #define ACK_REQUIRED TRUE #define ACK_NOT_REQUIRED FALSE +#ifdef DEBUG_ENABLED + #define DEBUG_EVENT_MAX_TEXT_LEN 40 +#endif + #pragma pack(push,1) typedef struct @@ -52,6 +57,18 @@ U16 alarmsFlags; // bit flags: 1 = true, 0 = false for each bit } ALARM_COMP_STATUS_PAYLOAD_T; +typedef struct +{ + U08 major; + U08 minor; + U08 micro; + U16 build; + U08 fpgaId; + U08 fpgaMajor; + U08 fpgaMinor; + U08 fpgaLab; +} DG_VERSIONS_T; + typedef struct { U32 treatmentTimePrescribedinSec; @@ -719,25 +736,24 @@ 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 ); } @@ -972,26 +988,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 : # 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 /*************************************************************************