首页 > 解决方案 > GPS 模块数据 - 解决方案?

问题描述

以下是我们从 GNSS 模块收到的数据:

在此处输入图像描述

#include <stdio.h>
#include <stdlib.h>

//$GPGLL,,,,,,V,N*64
//$GaabL,,,,,,V,N*5D
char Received[] = { "Odetnij to jak mozesz$GaabL,,,,,,V,N*5D" };

int main(void)
{
    int i = 0;

    int b;
    int c;
    int super_atoi;
    int wynik;
    int xor = 0;

    while (Received[i] != '$')
    {
        printf("%c", Received[i]);
        i++;
    }
    i++;
    printf("%c\n ");
    while (Received[i] != '*')
    {
        printf("%c", Received[i]);
        xor ^= Received[i];
        i++;
    }

    printf("\n XOR      = %d", xor);
    printf("\n XOR w hex    = %#02x  ", xor);
    printf("\n XOR w dec    = %d ", xor);

    if (Received[i] == '*')
    {
        i++;
        b = Received[i];
        printf("\n 1 znak w kodzie za * =  %c", b);
        i++;
        c = Received[i];
        printf("\n 2 znak w kodzie za * =  %c", c);
    }
    char a[3] = { b, c };
    super_atoi = atoi(a);
    super_atoi = strtol(a, NULL, 16);
    printf("\n ATOI      = %s  ", a, super_atoi);

    if (xor == super_atoi)
    {
        printf("%c\n ");
        printf("\n WORKING!");
    }
    else
    {
        printf("%c\n ");
        printf("\n not working");
    }
    return 0;
}

要计算每个的 sumcheck,我们必须在 "$" 和 "*" 之间对字符进行异或运算。我的计划是:

演示

基本上,我们检查每个字符是否为“$”,然后对元素进行异或,直到我们收到 *。但是我有一个小问题......我需要检查每一行数据 - NEO-7 在每个特定时间段传输 [280]+ 字符包,其中包括 11"$: 和 11 *。有两种方法检查我能想到的一切:

  1. 检查每一个字节(char),在出现“$”时开始计数,在出现*时结束,将结果与“*”后的2个元素进行比较。
  2. (更适合我的程序)从 GPS 模块接收数组 [35],创建单独的数组,我将在其中包含上一次 sumcheck 剩下的内容,放入来自 GPS 的下一组数据,重复。你能告诉我什么更好吗?还有如何创建这些解决方案?

标签: cgpsstm32

解决方案


推荐阅读