From 6e0f29b08a040d14576d7053c1206a8439936570 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期二, 24 十一月 2020 14:18:03 +0800
Subject: [PATCH] 坐标
---
lib/src/main/cpp/rtk_module/rtk.cpp | 68 +++++++++++++++++++++++++--------
1 files changed, 51 insertions(+), 17 deletions(-)
diff --git a/lib/src/main/cpp/rtk_module/rtk.cpp b/lib/src/main/cpp/rtk_module/rtk.cpp
index a5c75d3..244c0b3 100644
--- a/lib/src/main/cpp/rtk_module/rtk.cpp
+++ b/lib/src/main/cpp/rtk_module/rtk.cpp
@@ -18,6 +18,8 @@
#include "../common/apptimer.h"
#include "../rtk_platform/platform.h"
#include "../native-lib.h"
+#include "virtual_rtk.h"
+#include "../mcu/mcu_if.h"
#define DEBUG(fmt, args...) LOGD("<rtk> <%s>: " fmt, __func__, ##args)
@@ -37,12 +39,25 @@
static gpsStatus_t gpsStatus;
+static int (*WriteRtk)(int id, const void *buf, int len);
+
static rtk_info CurrRTKInfo;
static bool needSetPjk = false;
+
static void CheckPjkParam(void);
static void CheckPjkParamTimeout(union sigval sig);
+static int WriteBluetooth(int id, const void *buf, int len);
static void *UartThread(void *p);
+
+void RtkCommModeSel(int mode)
+{
+ if (mode == 0) {
+ WriteRtk = WriteSerialPort;
+ } else {
+ WriteRtk = WriteBluetooth;
+ }
+}
void ConfigRTKModule(void)
{
@@ -55,7 +70,9 @@
memset(&gpsStatus, 0, sizeof(gpsStatus));
gpsStatus.hh = -1;
- static struct serial_config serialConfig;
+ RtkCommModeSel(1);
+
+ /*static struct serial_config serialConfig;
strcpy(serialConfig.name, "/dev/ttyHSL0");
serialConfig.baud = 115200;
@@ -68,17 +85,23 @@
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);//detached
- pthread_create(&pid, &attr, UartThread, &serialConfig);
+ pthread_create(&pid, &attr, UartThread, &serialConfig);*/
+}
+
+void ConfigRTKModuleLater(void)
+{
+ AppTimer_delete(CheckPjkParamTimeout);
+ AppTimer_add(CheckPjkParamTimeout, D_SEC(1));
}
void FactorySettings(void)
{
- WriteSerialPort(RTK_MODULE_UART, FACTORY, strlen(FACTORY));
+ WriteRtk(RTK_MODULE_UART, FACTORY, strlen(FACTORY));
}
void RebootModule(void)
{
- WriteSerialPort(RTK_MODULE_UART, REBOOT, strlen(REBOOT));
+ WriteRtk(RTK_MODULE_UART, REBOOT, strlen(REBOOT));
}
void handleRTKRebootComp(const struct nmea *s)
@@ -88,6 +111,7 @@
}
void handlePJKParam(const struct nmea *s) {
+ DEBUG("handlePJKParam");
//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;
@@ -140,8 +164,8 @@
void SetAYFactoryParam(int freq)
{
- WriteSerialPort(RTK_MODULE_UART, UNLOGALL, strlen(UNLOGALL));
- WriteSerialPort(RTK_MODULE_UART, IFCOM2, strlen(IFCOM2));
+ WriteRtk(RTK_MODULE_UART, UNLOGALL, strlen(UNLOGALL));
+ WriteRtk(RTK_MODULE_UART, IFCOM2, strlen(IFCOM2));
if (freq == 0)
freq = 5;
@@ -149,13 +173,13 @@
for (int i = 0; i < sizeof(PJKITEMS)/ sizeof(PJKITEMS[0]); ++i) {
char cmd[64];
sprintf(cmd, "log com1 %s ontime %0.1f\r\n", PJKITEMS[i], 1.0/(double)freq);
- WriteSerialPort(RTK_MODULE_UART, cmd, strlen(cmd));
+ WriteRtk(RTK_MODULE_UART, cmd, strlen(cmd));
}
for (int i = 0; i < sizeof(GPSITEMS)/ sizeof(GPSITEMS[0]); ++i) {
char cmd[64];
sprintf(cmd, "log com1 %s ontime %0.1f\r\n", GPSITEMS[i], 1.0/(double)freq);
- WriteSerialPort(RTK_MODULE_UART, cmd, strlen(cmd));
+ WriteRtk(RTK_MODULE_UART, cmd, strlen(cmd));
}
// WriteSerialPort(RTK_MODULE_UART, AY_PJKPARAM, strlen(AY_PJKPARAM));
@@ -168,7 +192,7 @@
sprintf(buff, "set pjkpara 6378137 298.257223563 0 %d 0 500000\r\n", centLon);
- WriteSerialPort(RTK_MODULE_UART, buff, strlen(buff));
+ WriteRtk(RTK_MODULE_UART, buff, strlen(buff));
DEBUG("%s", buff);
}
@@ -215,13 +239,17 @@
if (RxBufLen > 0) {
#if 1
- const uint8_t *ptr = parseGPS(RxBuf, RxBuf + RxBufLen);
- if(ptr != RxBuf) {
- memcpy(RxBuf, ptr, RxBufLen - (ptr - RxBuf));
- RxBufLen -= ptr - RxBuf;
- } else if(RxBufLen == PARSE_BUFF_SIZE) { //濉弧浜嗭紝涓旀病鏈変竴涓猏r锛岄兘鎶涘純
- DEBUG("Parse GPS error");
+ if (VirtualIsConnected()) { //PC妯℃嫙鐢ㄦ椂
RxBufLen = 0;
+ } else {
+ const uint8_t *ptr = parseGPS(RxBuf, RxBuf + RxBufLen);
+ if (ptr != RxBuf) {
+ memcpy(RxBuf, ptr, RxBufLen - (ptr - RxBuf));
+ RxBufLen -= ptr - RxBuf;
+ } else if (RxBufLen == PARSE_BUFF_SIZE) { //濉弧浜嗭紝涓旀病鏈変竴涓猏r锛岄兘鎶涘純
+ DEBUG("Parse GPS error");
+ RxBufLen = 0;
+ }
}
#else
RxBufLen = 0; //PC妯℃嫙鐢ㄦ椂
@@ -233,7 +261,6 @@
}
pthread_exit(NULL);
}
-
void handleUnrecognisedNMEA(const uint8_t *data, uint16_t length) {
// char buff[4096] = {0};
@@ -464,7 +491,7 @@
static void CheckPjkParam(void)
{
- int n = WriteSerialPort(RTK_MODULE_UART, INQ_PJK_PARAM, strlen(INQ_PJK_PARAM));
+ int n = WriteRtk(RTK_MODULE_UART, INQ_PJK_PARAM, strlen(INQ_PJK_PARAM));
DEBUG("CN = %d", n);
AppTimer_delete(CheckPjkParamTimeout);
AppTimer_add(CheckPjkParamTimeout, D_SEC(3));
@@ -479,3 +506,10 @@
CheckPjkParam();
}
+
+static int WriteBluetooth(int id, const void *buf, int len)
+{
+// SendToBluetooth((uint8_t *)buf, len);
+ SendMcuCommand(0x000B, (uint8_t *)buf, len);
+ return len;
+}
--
Gitblit v1.8.0