@@ -7,7 +7,7 @@ extern UM980 *ptrUM980; // Global pointer for external parser access into librar
7
7
// If it's a response to a command, is it OK or BAD? $command,badResponse,response:
8
8
// PARSING FAILD NO MATCHING FUNC BADRESPONSE*40
9
9
// If it's Unicore binary, load into target variables If it's NMEA or RTCM, discard
10
- void eomHandler (PARSE_STATE *parse)
10
+ void eomHandler (UNICORE_PARSE_STATE *parse)
11
11
{
12
12
// Switch on message type (NMEA, RTCM, Unicore Binary, etc)
13
13
@@ -67,7 +67,7 @@ void eomHandler(PARSE_STATE *parse)
67
67
}
68
68
}
69
69
70
- void waitForPreamble (PARSE_STATE *parse, uint8_t data)
70
+ void um980WaitForPreamble (UNICORE_PARSE_STATE *parse, uint8_t data)
71
71
{
72
72
// Verify that this is the preamble byte
73
73
switch (data)
@@ -95,7 +95,7 @@ void waitForPreamble(PARSE_STATE *parse, uint8_t data)
95
95
96
96
parse->check = 0 ;
97
97
parse->nmeaMessageNameLength = 0 ;
98
- parse->state = PARSE_STATE_NMEA_FIRST_COMMA ;
98
+ parse->state = UNICORE_PARSE_STATE_NMEA_FIRST_COMMA ;
99
99
return ;
100
100
101
101
case 0xD3 :
@@ -115,7 +115,7 @@ void waitForPreamble(PARSE_STATE *parse, uint8_t data)
115
115
//
116
116
117
117
// Start the CRC with this byte
118
- parse->state = PARSE_STATE_RTCM_LENGTH1 ;
118
+ parse->state = UNICORE_PARSE_STATE_RTCM_LENGTH1 ;
119
119
return ;
120
120
121
121
case 0xAA :
@@ -134,17 +134,17 @@ void waitForPreamble(PARSE_STATE *parse, uint8_t data)
134
134
// |<------------------------ CRC --------------->|
135
135
//
136
136
137
- parse->state = PARSE_STATE_UNICORE_SYNC2 ;
137
+ parse->state = UNICORE_PARSE_STATE_UNICORE_SYNC2 ;
138
138
return ;
139
139
}
140
140
141
141
// Preamble byte not found
142
142
parse->length = 0 ;
143
- parse->state = PARSE_STATE_WAITING_FOR_PREAMBLE ;
143
+ parse->state = UNICORE_PARSE_STATE_WAITING_FOR_PREAMBLE ;
144
144
}
145
145
146
146
// Read the message name
147
- void nmeaFindFirstComma (PARSE_STATE *parse, uint8_t data)
147
+ void um980NmeaFindFirstComma (UNICORE_PARSE_STATE *parse, uint8_t data)
148
148
{
149
149
parse->check ^= data;
150
150
if ((data != ' ,' ) || (parse->nmeaMessageNameLength == 0 ))
@@ -159,35 +159,35 @@ void nmeaFindFirstComma(PARSE_STATE *parse, uint8_t data)
159
159
{
160
160
// Zero terminate the message name
161
161
parse->nmeaMessageName [parse->nmeaMessageNameLength ++] = 0 ;
162
- parse->state = PARSE_STATE_NMEA_FIND_ASTERISK ; // Move to next state
162
+ parse->state = UNICORE_PARSE_STATE_NMEA_FIND_ASTERISK ; // Move to next state
163
163
}
164
164
}
165
165
166
166
// Read the message data
167
- void nmeaFindAsterisk (PARSE_STATE *parse, uint8_t data)
167
+ void um980NmeaFindAsterisk (UNICORE_PARSE_STATE *parse, uint8_t data)
168
168
{
169
169
if (data != ' *' )
170
170
parse->check ^= data;
171
171
else
172
- parse->state = PARSE_STATE_NMEA_CHECKSUM1 ; // Move to next state
172
+ parse->state = UNICORE_PARSE_STATE_NMEA_CHECKSUM1 ; // Move to next state
173
173
}
174
174
175
175
// Read the first checksum byte
176
- void nmeaChecksumByte1 (PARSE_STATE *parse, uint8_t data)
176
+ void um980NmeaChecksumByte1 (UNICORE_PARSE_STATE *parse, uint8_t data)
177
177
{
178
- parse->state = PARSE_STATE_NMEA_CHECKSUM2 ; // Move to next state
178
+ parse->state = UNICORE_PARSE_STATE_NMEA_CHECKSUM2 ; // Move to next state
179
179
}
180
180
181
181
// Read the second checksum byte
182
- void nmeaChecksumByte2 (PARSE_STATE *parse, uint8_t data)
182
+ void um980NmeaChecksumByte2 (UNICORE_PARSE_STATE *parse, uint8_t data)
183
183
{
184
184
parse->nmeaLength = parse->length ;
185
185
parse->bytesRemaining = 2 ;
186
- parse->state = PARSE_STATE_NMEA_TERMINATION ; // Move to next state
186
+ parse->state = UNICORE_PARSE_STATE_NMEA_TERMINATION ; // Move to next state
187
187
}
188
188
189
189
// Read the line termination
190
- void nmeaLineTermination (PARSE_STATE *parse, uint8_t data)
190
+ void um980NmeaLineTermination (UNICORE_PARSE_STATE *parse, uint8_t data)
191
191
{
192
192
// We expect a \r\n termination, but may vary between receiver types
193
193
if (data == ' \r ' || data == ' \n ' )
@@ -280,7 +280,7 @@ void nmeaLineTermination(PARSE_STATE *parse, uint8_t data)
280
280
eomHandler (parse);
281
281
282
282
parse->length = 0 ;
283
- parse->state = PARSE_STATE_WAITING_FOR_PREAMBLE ; // Move to next state
283
+ parse->state = UNICORE_PARSE_STATE_WAITING_FOR_PREAMBLE ; // Move to next state
284
284
return ;
285
285
}
286
286
@@ -315,14 +315,14 @@ void nmeaLineTermination(PARSE_STATE *parse, uint8_t data)
315
315
// We already have new data, process it immediately
316
316
parse->length = 0 ;
317
317
parse->buffer [parse->length ++] = data;
318
- parse->state = PARSE_STATE_WAITING_FOR_PREAMBLE ; // Move to next state
319
- return (waitForPreamble (parse, data));
318
+ parse->state = UNICORE_PARSE_STATE_WAITING_FOR_PREAMBLE ; // Move to next state
319
+ return (um980WaitForPreamble (parse, data));
320
320
}
321
321
else
322
322
{
323
323
// We're done. Move on to waiting.
324
324
parse->length = 0 ;
325
- parse->state = PARSE_STATE_WAITING_FOR_PREAMBLE ; // Move to next state
325
+ parse->state = UNICORE_PARSE_STATE_WAITING_FOR_PREAMBLE ; // Move to next state
326
326
}
327
327
}
328
328
}
@@ -340,37 +340,37 @@ int AsciiToNibble(int data)
340
340
}
341
341
342
342
// Read the second sync byte
343
- void unicoreBinarySync2 (PARSE_STATE *parse, uint8_t data)
343
+ void um980UnicoreBinarySync2 (UNICORE_PARSE_STATE *parse, uint8_t data)
344
344
{
345
345
// Verify sync byte 2
346
346
if (data != 0x44 )
347
347
{
348
348
// Invalid sync byte, place this byte at the beginning of the buffer
349
349
parse->length = 0 ;
350
350
parse->buffer [parse->length ++] = data;
351
- return (waitForPreamble (parse, data)); // Start searching for a preamble byte
351
+ return (um980WaitForPreamble (parse, data)); // Start searching for a preamble byte
352
352
}
353
353
354
- parse->state = PARSE_STATE_UNICORE_SYNC3 ; // Move on
354
+ parse->state = UNICORE_PARSE_STATE_UNICORE_SYNC3 ; // Move on
355
355
}
356
356
357
357
// Read the third sync byte
358
- void unicoreBinarySync3 (PARSE_STATE *parse, uint8_t data)
358
+ void um980UnicoreBinarySync3 (UNICORE_PARSE_STATE *parse, uint8_t data)
359
359
{
360
360
// Verify sync byte 3
361
361
if (data != 0xB5 )
362
362
{
363
363
// Invalid sync byte, place this byte at the beginning of the buffer
364
364
parse->length = 0 ;
365
365
parse->buffer [parse->length ++] = data;
366
- return (waitForPreamble (parse, data)); // Start searching for a preamble byte
366
+ return (um980WaitForPreamble (parse, data)); // Start searching for a preamble byte
367
367
}
368
368
369
- parse->state = PARSE_STATE_UNICORE_READ_LENGTH ; // Move on
369
+ parse->state = UNICORE_PARSE_STATE_UNICORE_READ_LENGTH ; // Move on
370
370
}
371
371
372
372
// Read the message length
373
- void unicoreBinaryReadLength (PARSE_STATE *parse, uint8_t data)
373
+ void um980UnicoreBinaryReadLength (UNICORE_PARSE_STATE *parse, uint8_t data)
374
374
{
375
375
if (parse->length == offsetHeaderMessageLength + 2 )
376
376
{
@@ -390,17 +390,17 @@ void unicoreBinaryReadLength(PARSE_STATE *parse, uint8_t data)
390
390
parse->buffer [parse->length ++] = data;
391
391
392
392
// Start searching for a preamble byte
393
- return waitForPreamble (parse, data);
393
+ return um980WaitForPreamble (parse, data);
394
394
}
395
395
396
396
// Account for the bytes already received
397
397
parse->bytesRemaining -= parse->length ;
398
- parse->state = PARSE_STATE_UNICORE_READ_DATA ; // Move on
398
+ parse->state = UNICORE_PARSE_STATE_UNICORE_READ_DATA ; // Move on
399
399
}
400
400
}
401
401
402
402
// Read the message content until we reach the end, then check CRC
403
- void unicoreReadData (PARSE_STATE *parse, uint8_t data)
403
+ void um980UnicoreReadData (UNICORE_PARSE_STATE *parse, uint8_t data)
404
404
{
405
405
// Account for this data byte
406
406
parse->bytesRemaining -= 1 ;
@@ -434,7 +434,7 @@ void unicoreReadData(PARSE_STATE *parse, uint8_t data)
434
434
435
435
// Search for another preamble byte
436
436
parse->length = 0 ;
437
- parse->state = PARSE_STATE_WAITING_FOR_PREAMBLE ; // Move on
437
+ parse->state = UNICORE_PARSE_STATE_WAITING_FOR_PREAMBLE ; // Move on
438
438
}
439
439
440
440
// Calculate and return the CRC of the given buffer
@@ -447,7 +447,7 @@ uint32_t calculateCRC32(uint8_t *charBuffer, uint16_t bufferSize)
447
447
}
448
448
449
449
// Read the upper two bits of the length
450
- void rtcmReadLength1 (PARSE_STATE *parse, uint8_t data)
450
+ void um980RtcmReadLength1 (UNICORE_PARSE_STATE *parse, uint8_t data)
451
451
{
452
452
// Verify the length byte - check the 6 MS bits are all zero
453
453
if (data & (~3 ))
@@ -457,16 +457,16 @@ void rtcmReadLength1(PARSE_STATE *parse, uint8_t data)
457
457
parse->buffer [parse->length ++] = data;
458
458
459
459
// Start searching for a preamble byte
460
- return waitForPreamble (parse, data);
460
+ return um980WaitForPreamble (parse, data);
461
461
}
462
462
463
463
// Save the upper 2 bits of the length
464
464
parse->bytesRemaining = data << 8 ;
465
- parse->state = PARSE_STATE_RTCM_LENGTH2 ;
465
+ parse->state = UNICORE_PARSE_STATE_RTCM_LENGTH2 ;
466
466
}
467
467
468
468
// Read the lower 8 bits of the length
469
- void rtcmReadLength2 (PARSE_STATE *parse, uint8_t data)
469
+ void um980RtcmReadLength2 (UNICORE_PARSE_STATE *parse, uint8_t data)
470
470
{
471
471
parse->bytesRemaining |= data;
472
472
@@ -480,28 +480,28 @@ void rtcmReadLength2(PARSE_STATE *parse, uint8_t data)
480
480
parse->buffer [parse->length ++] = data;
481
481
482
482
// Start searching for a preamble byte
483
- return waitForPreamble (parse, data);
483
+ return um980WaitForPreamble (parse, data);
484
484
}
485
485
486
- parse->state = PARSE_STATE_RTCM_MESSAGE1 ;
486
+ parse->state = UNICORE_PARSE_STATE_RTCM_MESSAGE1 ;
487
487
}
488
488
489
489
// Read the upper 8 bits of the message number
490
- void rtcmReadMessage1 (PARSE_STATE *parse, uint8_t data)
490
+ void um980RtcmReadMessage1 (UNICORE_PARSE_STATE *parse, uint8_t data)
491
491
{
492
492
parse->bytesRemaining -= 1 ;
493
- parse->state = PARSE_STATE_RTCM_MESSAGE2 ;
493
+ parse->state = UNICORE_PARSE_STATE_RTCM_MESSAGE2 ;
494
494
}
495
495
496
496
// Read the lower 4 bits of the message number
497
- void rtcmReadMessage2 (PARSE_STATE *parse, uint8_t data)
497
+ void um980RtcmReadMessage2 (UNICORE_PARSE_STATE *parse, uint8_t data)
498
498
{
499
499
parse->bytesRemaining -= 1 ;
500
- parse->state = PARSE_STATE_RTCM_DATA ;
500
+ parse->state = UNICORE_PARSE_STATE_RTCM_DATA ;
501
501
}
502
502
503
503
// Read the rest of the message
504
- void rtcmReadData (PARSE_STATE *parse, uint8_t data)
504
+ void um980RtcmReadData (UNICORE_PARSE_STATE *parse, uint8_t data)
505
505
{
506
506
// Account for this data byte
507
507
parse->bytesRemaining -= 1 ;
@@ -510,12 +510,12 @@ void rtcmReadData(PARSE_STATE *parse, uint8_t data)
510
510
if (parse->bytesRemaining <= 0 )
511
511
{
512
512
parse->bytesRemaining = 3 ;
513
- parse->state = PARSE_STATE_RTCM_CRC ;
513
+ parse->state = UNICORE_PARSE_STATE_RTCM_CRC ;
514
514
}
515
515
}
516
516
517
517
// Read the CRC
518
- void rtcmReadCrc (PARSE_STATE *parse, uint8_t data)
518
+ void um980RtcmReadCrc (UNICORE_PARSE_STATE *parse, uint8_t data)
519
519
{
520
520
// Account for this data byte
521
521
parse->bytesRemaining -= 1 ;
@@ -556,5 +556,5 @@ void rtcmReadCrc(PARSE_STATE *parse, uint8_t data)
556
556
557
557
// Search for another preamble byte
558
558
parse->length = 0 ;
559
- parse->state = PARSE_STATE_WAITING_FOR_PREAMBLE ;
559
+ parse->state = UNICORE_PARSE_STATE_WAITING_FOR_PREAMBLE ;
560
560
}
0 commit comments