| | |
| | | static gpsStatus_t gpsStatus; |
| | | |
| | | static rtk_info CurrRTKInfo; |
| | | |
| | | static bool needSetPjk = false; |
| | | static void CheckPjkParam(void); |
| | | static void CheckPjkParamTimeout(union sigval sig); |
| | | |
| | |
| | | void handleRTKRebootComp(const struct nmea *s) |
| | | { |
| | | DEBUG("RTK Reboot complete!!"); |
| | | SetAYFactoryParam(5); |
| | | CheckPjkParam(); |
| | | } |
| | | |
| | | void handlePJKParam(const struct nmea *s) { |
| | | //PJK Parameter: A:6378137.000, 1/F:298.257223563, B0:0.000000deg, L0:120.000000, N0:0.000, E0:500000.000. |
| | | //PJK Parameter: A:6378137.000, 1/F:298.257223563, B0:29.512453deg, L0:106.455336, N0:0.000, E0:0.000. |
| | | bool setparam = true; |
| | | |
| | | const char DP1[] = "A:6378137.000"; |
| | | const char DP2[] = "1/F:298.257223563"; |
| | | const char DP3[] = "B0:29.512453deg"; |
| | | const char DP4[] = "L0:106.455336"; |
| | | const char DP5[] = "N0:0.000"; |
| | | const char DP6[] = "E0:0.000"; |
| | | // bool setparam = true; |
| | | // |
| | | // const char DP1[] = "A:6378137.000"; |
| | | // const char DP2[] = "1/F:298.257223563"; |
| | | // const char DP3[] = "B0:29.512453deg"; |
| | | // const char DP4[] = "L0:106.455336"; |
| | | // const char DP5[] = "N0:0.000"; |
| | | // const char DP6[] = "E0:0.000"; |
| | | |
| | | AppTimer_delete(CheckPjkParamTimeout); |
| | | |
| | | for (int i = 0; i < s->nmea_num; ++i) { |
| | | char out[64] = {0}; |
| | | // for (int i = 0; i < s->nmea_num; ++i) { |
| | | // char out[64] = {0}; |
| | | // |
| | | // memcpy(out, s->nmea_value[i].data, s->nmea_value[i].length); |
| | | // |
| | | // DEBUG("handlePJKParam = %s", out); |
| | | // } |
| | | // |
| | | // if (s->nmea_num != 6) return; |
| | | // |
| | | // if (memcmp(s->nmea_value[0].data, DP1, strlen(DP1))) { |
| | | // setparam = true; |
| | | // } |
| | | // if (memcmp(s->nmea_value[1].data, DP2, strlen(DP2))) { |
| | | // setparam = true; |
| | | // } |
| | | // if (memcmp(s->nmea_value[2].data, DP3, strlen(DP3))) { |
| | | // setparam = true; |
| | | // } |
| | | // if (memcmp(s->nmea_value[3].data, DP4, strlen(DP4))) { |
| | | // setparam = true; |
| | | // } |
| | | // if (memcmp(s->nmea_value[4].data, DP5, strlen(DP5))) { |
| | | // setparam = true; |
| | | // } |
| | | // if (memcmp(s->nmea_value[5].data, DP6, strlen(DP6))) { |
| | | // setparam = true; |
| | | // } |
| | | // |
| | | // if (setparam) { |
| | | // SetAYFactoryParam(5); |
| | | // } |
| | | |
| | | memcpy(out, s->nmea_value[i].data, s->nmea_value[i].length); |
| | | |
| | | DEBUG("handlePJKParam = %s", out); |
| | | } |
| | | |
| | | if (s->nmea_num != 6) return; |
| | | |
| | | if (memcmp(s->nmea_value[0].data, DP1, strlen(DP1))) { |
| | | setparam = true; |
| | | } |
| | | if (memcmp(s->nmea_value[1].data, DP2, strlen(DP2))) { |
| | | setparam = true; |
| | | } |
| | | if (memcmp(s->nmea_value[2].data, DP3, strlen(DP3))) { |
| | | setparam = true; |
| | | } |
| | | if (memcmp(s->nmea_value[3].data, DP4, strlen(DP4))) { |
| | | setparam = true; |
| | | } |
| | | if (memcmp(s->nmea_value[4].data, DP5, strlen(DP5))) { |
| | | setparam = true; |
| | | } |
| | | if (memcmp(s->nmea_value[5].data, DP6, strlen(DP6))) { |
| | | setparam = true; |
| | | } |
| | | |
| | | if (setparam) { |
| | | SetAYFactoryParam(5); |
| | | } |
| | | SetAYFactoryParam(5); |
| | | needSetPjk = true; |
| | | } |
| | | |
| | | void SetAYFactoryParam(int freq) |
| | |
| | | WriteSerialPort(RTK_MODULE_UART, cmd, strlen(cmd)); |
| | | } |
| | | |
| | | WriteSerialPort(RTK_MODULE_UART, AY_PJKPARAM, strlen(AY_PJKPARAM)); |
| | | // WriteSerialPort(RTK_MODULE_UART, AY_PJKPARAM, strlen(AY_PJKPARAM)); |
| | | // WriteSerialPort(RTK_MODULE_UART, SAVECONFIG, strlen(SAVECONFIG)); |
| | | } |
| | | |
| | | void SetPjkPara(int centLon) |
| | | { |
| | | char buff[64]; |
| | | |
| | | sprintf(buff, "set pjkpara 6378137 298.257223563 0 %d 0 500000\r\n", centLon); |
| | | |
| | | WriteSerialPort(RTK_MODULE_UART, buff, strlen(buff)); |
| | | |
| | | DEBUG("%s", buff); |
| | | } |
| | | |
| | | void GetGpsStatus(gpsStatus_t &data) |
| | |
| | | |
| | | void handleGPGGA(const struct nmea *s) |
| | | { |
| | | static uint32_t qfCnt = 0; |
| | | |
| | | DEBUG("handleGPGGA num = %d", s->nmea_num); |
| | | if (s->nmea_num >= 10) { |
| | | gpsStatus.gps_status = str2int(s->nmea_value[5].data, s->nmea_value[5].length); |
| | |
| | | gpsStatus.mm = mm; |
| | | gpsStatus.ss = ss; |
| | | gpsStatus.mss = mss; |
| | | |
| | | // 计算中央子午线 |
| | | int qf = str2int(s->nmea_value[5].data, s->nmea_value[5].length); |
| | | if (qf > 0) { |
| | | qfCnt++; |
| | | if (needSetPjk && qfCnt >= 3) { |
| | | needSetPjk = false; |
| | | SetPjkPara(((int) (lon1 / 3.0 + 0.5)) * 3); |
| | | } |
| | | } else { |
| | | qfCnt = 0; |
| | | } |
| | | } |
| | | } |
| | | |