Subversion Repositories NaviCtrl

Rev

Rev 190 | Rev 245 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 190 Rev 244
Line 201... Line 201...
201
                }
201
                }
202
                else if (pRxBuff->Position < pRxBuff->Size) // rx buffer not full
202
                else if (pRxBuff->Position < pRxBuff->Size) // rx buffer not full
203
                {
203
                {
204
                        pRxBuff->pData[pRxBuff->Position++] = c; // copy byte to rxd buffer
204
                        pRxBuff->pData[pRxBuff->Position++] = c; // copy byte to rxd buffer
205
                        pRxBuff->DataBytes++;
205
                        pRxBuff->DataBytes++;
-
 
206
                        // termination character received and sync has been established
206
                        if (c == '\r') // termination character received
207
                        if ((c == '\r') && (pRxBuff->pData[0]== '#'))
207
                        {
208
                        {
208
                                // calculate checksum from transmitted data
209
                                // calculate checksum from transmitted data
209
                                u16 crc = 0, i;
210
                                u16 crc = 0, i;
210
                                u8 crc1, crc2;
211
                                u8 crc1, crc2;
211
                                for(i = 0; i < (pRxBuff->Position-3); i++)
212
                                for(i = 0; i < (pRxBuff->Position-3); i++)
Line 215... Line 216...
215
                                crc %= 4096;
216
                                crc %= 4096;
216
                                crc1 = '=' + crc / 64;
217
                                crc1 = '=' + crc / 64;
217
                                crc2 = '=' + crc % 64;
218
                                crc2 = '=' + crc % 64;
218
                                // compare checksum to transmitted checksum bytes
219
                                // compare checksum to transmitted checksum bytes
219
                                if((crc1 == pRxBuff->pData[pRxBuff->Position-3]) && (crc2 == pRxBuff->pData[pRxBuff->Position-2]))
220
                                if((crc1 == pRxBuff->pData[pRxBuff->Position-3]) && (crc2 == pRxBuff->pData[pRxBuff->Position-2]))
-
 
221
                                {
220
                                {   // checksum is valid
222
                                    // checksum is valid
221
                                        pRxBuff->Position = 0;                                 
223
                                        pRxBuff->Position = 0;                                 
222
                                        pRxBuff->Locked = TRUE;                                     // lock the rxd buffer 
224
                                        pRxBuff->Locked = TRUE;                                     // lock the rxd buffer 
223
                                        // if 2nd byte is an 'R' start bootloader
225
                                        // if 2nd byte is an 'R' start bootloader
224
                                        if(pRxBuff->pData[2] == 'R')
226
                                        if(pRxBuff->pData[2] == 'R')
225
                                        {
227
                                        {