Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r7acb9d914f79aaa921c95e1a4049594c889bf795 -rf267c42c91fd6e22db80e19039b8993582de51e9 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 7acb9d914f79aaa921c95e1a4049594c889bf795) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision f267c42c91fd6e22db80e19039b8993582de51e9) @@ -99,7 +99,7 @@ static U32 lastCANPacketSentTimeStamp = 0; #ifdef DEBUG_ENABLED -static U08 pcXmitPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +static U08 pcXmitPacket[ 1024 ]; static U08 pcRecvPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 }; #endif @@ -116,15 +116,6 @@ static U32 badCRCListIdx = 0; // where next bad message CRC time stamp will go in list static U32 badCRCListCount = 0; // # of bad CRCs in the list -#ifdef CAN_TEST -U08 dbgRcvdCANFrames[1024][8]; -U32 dbgRcvdCANFrameTS[1024]; -U32 dbgRcvdCANFrameIdx = 0; -U08 dbgXmitCANFrames[1024][8]; -U32 dbgXmitCANFrameTS[1024]; -U32 dbgXmitCANFrameIdx = 0; -#endif - // ********** private function prototypes ********** #ifdef DEBUG_ENABLED @@ -296,25 +287,6 @@ // if packet retrieved, add to buffer if ( result != 0 ) { -#ifdef CAN_TEST - if ( dbgRcvdCANFrameIdx >= 1000 ) - { - result = 99; // Break point here - } - else - { - dbgRcvdCANFrameTS[dbgRcvdCANFrameIdx] = getMSTimerCount(); - memcpy( &dbgRcvdCANFrames[dbgRcvdCANFrameIdx][0], data, 8); - dbgRcvdCANFrameIdx++; - } -#endif -//#ifdef DEBUG_ENABLED -// if ( srcCANBox == COMM_BUFFER_IN_CAN_PC ) -// { -// memcpy( &dbgRcvFromDialin[dbgRcvFromDialinIdx], data, CAN_MESSAGE_PAYLOAD_SIZE); -// dbgRcvFromDialinIdx += CAN_MESSAGE_PAYLOAD_SIZE; -// } -//#endif // add CAN packet to appropriate comm buffer based on the message box it came in on (s/b same #) addToCommBuffer( srcCANBox, data, CAN_MESSAGE_PAYLOAD_SIZE ); } @@ -557,18 +529,6 @@ memcpy( lastCANPacketSent, data, CAN_MESSAGE_PAYLOAD_SIZE ); lastCANPacketSentChannel = mBox; lastCANPacketSentTimeStamp = getMSTimerCount(); -#ifdef CAN_TEST - if ( dbgXmitCANFrameIdx > 1000 ) - { - dataSize = 99; // Break point here - } - else - { - dbgXmitCANFrameTS[dbgXmitCANFrameIdx] = getMSTimerCount(); - memcpy( &dbgXmitCANFrames[dbgXmitCANFrameIdx][0], data, 8); - dbgXmitCANFrameIdx++; - } -#endif if ( 0 != canTransmit( canREG1, mBox, data ) ) { result = CAN_MESSAGE_PAYLOAD_SIZE; @@ -604,20 +564,19 @@ { U32 result = 0; U32 dataPend = numberOfBytesInCommBuffer( COMM_BUFFER_OUT_UART_PC ); - U32 dataSize; - if ( dataPend >= PC_MESSAGE_PACKET_SIZE ) + if ( dataPend > 0 ) { - dataSize = getFromCommBuffer( COMM_BUFFER_OUT_UART_PC, pcXmitPacket, PC_MESSAGE_PACKET_SIZE ); + result = getFromCommBuffer( COMM_BUFFER_OUT_UART_PC, pcXmitPacket, dataPend ); - // if there's another UART packet to send, send it - if ( dataSize == PC_MESSAGE_PACKET_SIZE ) + // if there's data to transmit, transmit it + if ( result > 0 ) { signalSCI1XmitsInitiated(); + pcDMAXmitControlRecord.FRCNT = result; // set DMA transfer size dmaSetCtrlPacket( DMA_CH3, pcDMAXmitControlRecord ); dmaSetChEnable( DMA_CH3, DMA_HW ); setSCI1DMATransmitInterrupt(); - result = PC_MESSAGE_PACKET_SIZE; } } @@ -859,7 +818,8 @@ { if ( TRUE == didTimeout( timeOfLastHDCheckIn, HD_COMM_TIMEOUT_IN_MS ) ) { - //activateAlarmNoData( ALARM_ID_HD_COMM_TIMEOUT ); // TODO - add this alarm + hdIsCommunicating = FALSE; + //activateAlarmNoData( ALARM_ID_HD_COMM_TIMEOUT ); // TODO - add this alarm if we're in middle of a treatment? or if in a mode that comm loss would impact badly? } } @@ -876,10 +836,6 @@ static void checkTooManyBadMsgCRCs( void ) { U32 listTimeInMS; -#ifdef CAN_TEST - static U32 crcErrorCtr = 0; - crcErrorCtr++; -#endif // replace oldest bad CRC in list with this new one badCRCTimeStamps[ badCRCListIdx ] = getMSTimerCount(); @@ -892,10 +848,8 @@ if ( ( badCRCListCount >= MAX_COMM_CRC_FAILURES ) && ( listTimeInMS <= MAX_COMM_CRC_FAILURE_WINDOW_MS ) ) { #ifndef DISABLE_CRC_ERROR -#ifndef CAN_TEST activateAlarmNoData( ALARM_ID_COMM_TOO_MANY_BAD_CRCS ); #endif -#endif } }