Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r07a5add2dff254f7be3699e4efac2b99d3554847 -r9a9d04b84f4345fca87fb14d26f09d497b08aae8 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 07a5add2dff254f7be3699e4efac2b99d3554847) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 9a9d04b84f4345fca87fb14d26f09d497b08aae8) @@ -662,28 +662,25 @@ if ( msgSize > 0 ) { + MESSAGE_WRAPPER_T rcvMsg; + U08 *dataPtr = data+1; // skip over sync byte + // consume message (+sync byte) msgSize = getFromCommBuffer( MSG_IN_BUFFERS[ i ], data, msgSize + 1 ); - // if message data is at least minimum size, convert received message data to a message and add to message queue - if ( msgSize > MESSAGE_OVERHEAD_SIZE ) - { - MESSAGE_WRAPPER_T rcvMsg; - U08 *dataPtr = data+1; // skip over sync byte - - messagesInBuffer = TRUE; - // blank the new message record - blankMessageInWrapper( &rcvMsg ); - // copy message header portion of message data to the new message - memcpy( &(rcvMsg.msg.hdr), dataPtr, sizeof(MESSAGE_HEADER_T) ); - dataPtr += sizeof(MESSAGE_HEADER_T); - // copy message payload portion of message data to the new message - 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 - addToMsgQueue( MSG_Q_IN, &rcvMsg ); - } // message is at least as large as minimum size + // convert received message data to a message and add to message queue + messagesInBuffer = TRUE; + // blank the new message record + blankMessageInWrapper( &rcvMsg ); + // copy message header portion of message data to the new message + memcpy( &(rcvMsg.msg.hdr), dataPtr, sizeof(MESSAGE_HEADER_T) ); + dataPtr += sizeof(MESSAGE_HEADER_T); + // copy message payload portion of message data to the new message + 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 + addToMsgQueue( MSG_Q_IN, &rcvMsg ); } // looks like there is a complete message in the comm buffer } // enough data left in comm buffer to possibly be a complete message } // while loop to get all complete messages for each comm buffer @@ -750,7 +747,7 @@ // if a minimum sized msg would fit in remaining, continue if ( remSize >= MESSAGE_OVERHEAD_SIZE ) { - payloadSize = data[ pos + sizeof( U16 ) ]; + payloadSize = data[ pos + sizeof( U16 ) + sizeof( U16) ]; msgSize = MESSAGE_OVERHEAD_SIZE + payloadSize; // we now know the size of the message - we can now know if full message is contained in buffer if ( msgSize <= remSize ) @@ -889,7 +886,11 @@ { pendingAckList[ i ].used = TRUE; _enable_IRQ(); - pendingAckList[ i ].seqNo = msg->hdr.seqNo &= ~MSG_ACK_BIT; + if ( msg->hdr.seqNo < 0 ) + { + msg->hdr.seqNo *= -1; + } + pendingAckList[ i ].seqNo = msg->hdr.seqNo; pendingAckList[ i ].channel = channel; pendingAckList[ i ].timeStamp = getMSTimerCount(); pendingAckList[ i ].retries = MSG_NOT_ACKED_MAX_RETRIES;