nmeatknzr.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * =====================================================================================
  3. *
  4. * Filename: nmeatknzr.h
  5. *
  6. * Description: Nmea Tokenizer head file
  7. *
  8. * Version: 1.0
  9. * Created: 2018/8/15 17:12:45
  10. * Revision: none
  11. * Compiler: gcc
  12. *
  13. * Author: Jarod Lee
  14. * Organization:
  15. *
  16. * =====================================================================================
  17. */
  18. #ifndef __NMEA_TKNZR_H
  19. #define __NMEA_TKNZR_H
  20. /*
  21. * NMEA token is the bytes splitted by ','
  22. * For NMEA sentence:
  23. * $GNGGA ,061407.000 ,3011.1363 ,N ,12009.2925 ,E ,1,05,5.5,17.3,M,0.0,M,,*44
  24. * --------------------------------------------------------------------------------------------
  25. * |token0 |token1 |token2 |token3 |token4 |token5 |......
  26. * |p end|p end|p end|p end|p end|p end|......
  27. * --------------------------------------------------------------------------------------------
  28. * @p is the ptr to the first byte.
  29. * @end is the prt to the last byte.
  30. * For "GNGGA,"(token0), @p points to first 'G' and @end points to ','
  31. */
  32. struct token {
  33. char *p;
  34. char *end;
  35. };
  36. #define MAX_NMEA_TOKENS 1024
  37. /*
  38. * NMEA token table
  39. * One NMEA tokenizer presents one NMEA sentence
  40. * @count: the token's count
  41. * @tokens: array of token
  42. */
  43. struct nmea_tokenizer {
  44. int count;
  45. struct token tokens[MAX_NMEA_TOKENS];
  46. };
  47. struct token nmea_tokenizer_get(struct nmea_tokenizer *t, int index); // get the token at @index from NMEA tokenizer @t
  48. int nmea_tokenizer_init(struct nmea_tokenizer *t, char *p, char *end); // init NMEA tokenizer from buffer between @p and @end
  49. #endif