From 37b9848f0a759d5d732c5ca9ea6b55f2b666e53b Mon Sep 17 00:00:00 2001 From: Livox-SDK Date: Tue, 28 Apr 2020 18:16:18 +0800 Subject: [PATCH] fix : GNRMC format parse failed. --- README.md | 1 - sdk_core/src/command_handler/command_impl.cpp | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7f2faeb..48cf068 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[中文版本使用说明]() # 1 Introduction Livox SDK is the software development kit designed for all Livox products. It is developed based on C/C++ following Livox SDK Communication Protocol, and provides easy-to-use C style API. With Livox SDK, users can quickly connect to Livox products and receive point cloud data. diff --git a/sdk_core/src/command_handler/command_impl.cpp b/sdk_core/src/command_handler/command_impl.cpp index 99a9ebc..4fff16c 100644 --- a/sdk_core/src/command_handler/command_impl.cpp +++ b/sdk_core/src/command_handler/command_impl.cpp @@ -162,12 +162,22 @@ bool ParseRmcTime(const char* rmc, uint16_t rmc_len, LidarSetUtcSyncTimeRequest* memset(utc_time_req, 0, sizeof(LidarSetUtcSyncTimeRequest)); - if (4 != sscanf(rmc_begin, + int num = sscanf(rmc_begin, "$G%*[NP]RMC,%[^,],%*C,%*f,%*C,%*f,%*C,%*f,%*f,%2hhu%2hhu%[^,],%*f,", &utc_hms_buff[0], &(utc_time_req->day), &(utc_time_req->month), - &utc_yy_buff[0])) { + &utc_yy_buff[0]); + if (num != 4) { + num = sscanf(rmc_begin, + "$G%*[NP]RMC,%[^,],%*C,%*f,%*C,%*f,%*C,%*f,,%2hhu%2hhu%[^,],%*f,", + &utc_hms_buff[0], + &(utc_time_req->day), + &(utc_time_req->month), + &utc_yy_buff[0]); + } + + if (num != 4) { return false; }