Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -reff7b1575f008f81b29ef906f6346fac6012d3ab -r5829ee430c39b41b687cfd4ff4f86a1aae4380f3 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision eff7b1575f008f81b29ef906f6346fac6012d3ab) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 5829ee430c39b41b687cfd4ff4f86a1aae4380f3) @@ -27,43 +27,41 @@ #include "Interrupts.h" #include "MsgQueues.h" #include "SystemCommMessages.h" +#include "Utilities.h" #ifdef RM46_EVAL_BOARD_TARGET #include "CPLD.h" #endif // ********** private definitions ********** -#define NUM_OF_CAN_OUT_BUFFERS 4 // # of CAN buffers for transmit -#define NUM_OF_CAN_IN_BUFFERS 6 // # of CAN buffers for receiving -#define NUM_OF_MSG_IN_BUFFERS 7 // # of Msg buffers for receiving +#define NUM_OF_CAN_OUT_BUFFERS 5 // # of CAN buffers for transmit +#define NUM_OF_CAN_IN_BUFFERS 3 // # of CAN buffers for receiving +#define NUM_OF_MSG_IN_BUFFERS 4 // # of Msg buffers for receiving #define SCI1_RECEIVE_DMA_REQUEST 30 #define SCI1_TRANSMIT_DMA_REQUEST 31 // ********** private data ********** -const COMM_BUFFER_T CAN_OUT_BUFFERS[NUM_OF_CAN_OUT_BUFFERS] = +const COMM_BUFFER_T CAN_OUT_BUFFERS[ NUM_OF_CAN_OUT_BUFFERS ] = { - COMM_BUFFER_OUT_CAN_HD_ALARM, - COMM_BUFFER_OUT_CAN_HD_2_DG, - COMM_BUFFER_OUT_CAN_HD_2_UI, - COMM_BUFFER_OUT_CAN_HD_BROADCAST + COMM_BUFFER_OUT_CAN_DG_ALARM, + COMM_BUFFER_OUT_CAN_DG_2_HD, + COMM_BUFFER_OUT_CAN_DG_BROADCAST, + COMM_BUFFER_OUT_CAN_DG_2_PC, + COMM_BUFFER_OUT_UART_PC }; -const COMM_BUFFER_T MSG_IN_BUFFERS[NUM_OF_MSG_IN_BUFFERS] = +const COMM_BUFFER_T MSG_IN_BUFFERS[ NUM_OF_MSG_IN_BUFFERS ] = { - COMM_BUFFER_IN_CAN_DG_ALARM, - COMM_BUFFER_IN_CAN_UI_ALARM, - COMM_BUFFER_IN_CAN_DG_2_HD, - COMM_BUFFER_IN_CAN_DG_BROADCAST, - COMM_BUFFER_IN_CAN_UI_2_HD, - COMM_BUFFER_IN_CAN_UI_BROADCAST, - COMM_BUFFER_IN_UART_PC + COMM_BUFFER_IN_CAN_HD_2_DG, + COMM_BUFFER_IN_CAN_PC_2_DG, + COMM_BUFFER_IN_UART_PC }; -static U08 pcXmitPacket[PC_MESSAGE_PACKET_SIZE] = {0,0,0,0,0,0,0,0};// = {1,2,3,4,5,6,7,8}; -static U08 pcRecvPacket[PC_MESSAGE_PACKET_SIZE] = {0,0,0,0,0,0,0,0}; +static U08 pcXmitPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 };// = { 1,2,3,4,5,6,7,8}; +static U08 pcRecvPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 }; // DMA control records static g_dmaCTRL pcDMAXmitControlRecord; @@ -169,14 +167,14 @@ } else if ( TRUE == isCANBoxForRecv( srcCANBox ) ) { - U08 data[CAN_MESSAGE_CARGO_SIZE]; + U08 data[CAN_MESSAGE_PAYLOAD_SIZE]; // get CAN packet received on given CAN message box if ( FALSE != canIsRxMessageArrived( canREG1, srcCANBox ) ) { canGetData( canREG1, srcCANBox, data ); // add CAN packet to appropriate comm buffer based on the message box it came in on (s/b same #) - addToCommBuffer( srcCANBox, data, CAN_MESSAGE_CARGO_SIZE ); + addToCommBuffer( srcCANBox, data, CAN_MESSAGE_PAYLOAD_SIZE ); } } else @@ -364,7 +362,7 @@ // search for next priority CAN packet to transmit for ( i = 0; i < NUM_OF_CAN_OUT_BUFFERS; i++ ) { - if ( numberOfBytesInCommBuffer( CAN_OUT_BUFFERS[i] ) >= CAN_MESSAGE_CARGO_SIZE ) + if ( numberOfBytesInCommBuffer( CAN_OUT_BUFFERS[i] ) >= CAN_MESSAGE_PAYLOAD_SIZE ) { result = CAN_OUT_BUFFERS[i]; break; // found highest priority packet to transmit - we're done @@ -391,12 +389,12 @@ // if a buffer is found with a packet to transmit, get packet from buffer and transmit it if ( buffer != COMM_BUFFER_NOT_USED ) { - U08 data[CAN_MESSAGE_CARGO_SIZE]; - U32 dataSize = getFromCommBuffer( buffer, data, CAN_MESSAGE_CARGO_SIZE ); + U08 data[CAN_MESSAGE_PAYLOAD_SIZE]; + U32 dataSize = getFromCommBuffer( buffer, data, CAN_MESSAGE_PAYLOAD_SIZE ); CAN_MESSAGE_BOX_T mBox = buffer; // CAN message boxes and comm buffers are aligned // if there's another CAN packet to send, send it - if ( dataSize == CAN_MESSAGE_CARGO_SIZE ) + if ( dataSize == CAN_MESSAGE_PAYLOAD_SIZE ) { canTransmit( canREG1, mBox, data ); } @@ -485,8 +483,8 @@ memcpy( &(rcvMsg.msg.hdr), dataPtr, sizeof(MESSAGE_HEADER_T) ); dataPtr += sizeof(MESSAGE_HEADER_T); // copy message cargo portion of message data to the new message - memcpy( &(rcvMsg.msg.cargo), dataPtr, rcvMsg.msg.hdr.cargoLen ); - dataPtr += rcvMsg.msg.hdr.cargoLen; + memcpy( &(rcvMsg.msg.payload), dataPtr, rcvMsg.msg.hdr.payloadLen ); + dataPtr += rcvMsg.msg.hdr.payloadLen; // copy CRC portion of message data to the new message rcvMsg.crc = *dataPtr; // add new message to queue for later processing @@ -595,8 +593,8 @@ isThereMsgRcvd = getFromMsgQueue( MSG_Q_IN, &message ); if ( TRUE == isThereMsgRcvd ) { - // TODO - check CRC before processing a message - if ( 1 ) + // TODO - check CRC before processing a message and if it fails we will... + if ( message.crc == crc8( (U08*)(&message), sizeof(MESSAGE_HEADER_T) + message.msg.hdr.payloadLen ) ) { processReceivedMessage( &message.msg ); } @@ -625,15 +623,11 @@ switch ( msgID ) { - case MSG_ID_OFF_BUTTON_PRESS: - handleOffButtonConfirmMsgFromUI( message ); -#ifdef RM46_EVAL_BOARD_TARGET - setUserLED( TRUE ); -#endif + + case MSD_ID_DG_FILL_START_STOP: + handleDGFillStartStopMessages( message ); break; - - case MSG_ID_TESTER_LOGIN_REQUEST: handleTesterLogInRequest( message ); break; @@ -652,14 +646,6 @@ handleTestHDMessageRequest( message ); break; - case MSG_ID_OFF_BUTTON_STATE_OVERRIDE: - handleTestOffButtonStateOverrideRequest( message ); - break; - - case MSG_ID_STOP_BUTTON_STATE_OVERRIDE: - handleTestStopButtonStateOverrideRequest( message ); - break; - case MSG_ID_ALARM_LAMP_PATTERN_OVERRIDE: handleTestAlarmLampPatternOverrideRequest( message ); break;