summaryrefslogtreecommitdiffstats
path: root/positioning_base_library/library/src/_pbOSCtrl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'positioning_base_library/library/src/_pbOSCtrl.cpp')
-rw-r--r--positioning_base_library/library/src/_pbOSCtrl.cpp417
1 files changed, 3 insertions, 414 deletions
diff --git a/positioning_base_library/library/src/_pbOSCtrl.cpp b/positioning_base_library/library/src/_pbOSCtrl.cpp
index 575caf91..c38016a7 100644
--- a/positioning_base_library/library/src/_pbOSCtrl.cpp
+++ b/positioning_base_library/library/src/_pbOSCtrl.cpp
@@ -1,5 +1,5 @@
/*
- * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,16 +44,11 @@ static u_int8 file_buf[FILE_OUT_LINE][1024];
static u_int16 line_size_buf[FILE_OUT_LINE];
/* Log destination selection (Activate the one you want to output.) */
-#define POS_GPS_R_LOGFILE_PATH "/nv/log/frameworkunifiedlog/Test_Pos_gps_read_data.txt"
-#define POS_GPS_W_LOGFILE_PATH "/nv/log/frameworkunifiedlog/Test_Pos_gps_write_data.txt"
+#define POS_GPS_R_LOGFILE_PATH "/nv/BS/vs/positioning_base_library/rwdata/Test_Pos_gps_read_data.txt"
+#define POS_GPS_W_LOGFILE_PATH "/nv/BS/vs/positioning_base_library/rwdata/Test_Pos_gps_write_data.txt"
#endif /* GPS_FUNC_DEBUG_MSG__CWORD71__FILE */
-static BOOL ReadFile_CWORD82_(HANDLE h_file, LPVOID lp_buffer, DWORD n_number_of_bytes_to_read, \
- LPDWORD lp_number_of_bytes_read, LPOVERLAPPED lp_overlapped);
-static BOOL ReadFileUblox(HANDLE h_file, LPVOID lp_buffer, DWORD n_number_of_bytes_to_read, \
- LPDWORD lp_number_of_bytes_read, LPOVERLAPPED lp_overlapped);
-
/* For CreateFile--> */
#define BAUDRATE B9600
#define MODEMDEVICE "/dev/tty.gps"
@@ -361,412 +356,6 @@ BOOL CloseFile(HANDLE h_object) { // LCOV_EXCL_START 8:dead code
}
// LCOV_EXCL_STOP
-#define MAX_READ_SIZE 2048
-/**
- * @brief
- *
- * Read file
- *
- * Read data from a file (Wrapper Function)
- *
- * @param[in] h_file Handle
- * @param[in] lp_buffer Buffer for reading
- * @param[out] n_number_of_bytes_to_read Maximum read size
- * @param[out] lp_number_of_bytes_read Read size
- * @param lp_overlapped Not used
- *
- * @return Processing result
- * @retval TRUE Processing succeeded
- * @retval FALSE Processing failed
- */
-BOOL ReadFile(HANDLE h_file, LPVOID lp_buffer, DWORD n_number_of_bytes_to_read, LPDWORD lp_number_of_bytes_read, LPOVERLAPPED lp_overlapped) { // LCOV_EXCL_START 8:dead code // NOLINT(whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- BOOL ret = 0;
- UNIT_TYPE e_type = UNIT_TYPE_NONE; /* Supported HW configuration type */
-
- e_type = PbGetEnvSupportInfo();
- if (UNIT_TYPE_GRADE1 == e_type) {
- ret = ReadFileUblox(h_file, lp_buffer, n_number_of_bytes_to_read, lp_number_of_bytes_read, lp_overlapped);
- } else if (UNIT_TYPE_GRADE2 == e_type) {
- /*
- * Note.
- * This feature branches processing depending on the unit type.
- */
- ret = ReadFile_CWORD82_(h_file, lp_buffer, n_number_of_bytes_to_read, lp_number_of_bytes_read, lp_overlapped);
- } else {
- ret = FALSE;
- }
-
- return ret;
-}
-// LCOV_EXCL_STOP
-
-/**
- * @brief
- *
- * Read file
- *
- * Read data from a file(Implementation Functions for _CWORD82_)
- *
- * @param[in] h_file Handle
- * @param[in] lp_buffer Read buffer
- * @param[out] n_number_of_bytes_to_read Maximum read size
- * @param[out] lp_number_of_bytes_read Read size
- * @param lp_overlapped Not used
- *
- * @return Processing result
- * @retval TRUE Processing succeeded
- * @retval FALSE Processing failed
- */
-BOOL ReadFile_CWORD82_(HANDLE h_file, LPVOID lp_buffer, DWORD n_number_of_bytes_to_read, LPDWORD lp_number_of_bytes_read, LPOVERLAPPED lp_overlapped) { // LCOV_EXCL_START 8:dead code // NOLINT(whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- BOOL ret = 0;
- static int res = 0;
- DWORD fdw_comm_mask; /* Communication event storage area */
-
- static u_int8 ret_buf[MAX_READ_SIZE] = {0}; /* Buffer for return */
- static u_int8 *wp = ret_buf;
-
- static u_int8 work_buf[MAX_READ_SIZE];
-
- static u_int8 key = 0; /* Primary key */
- static BOOL is_set_key = FALSE; /* Key is set or not */
- static u_int8 key2 = 0; /* Secondary key */
- static BOOL is_set_key2 = FALSE; /* Key2 is set or not */
- static int32 work_bufcnt = 0; /* Backup read pointer of work_buf */
-
- int32 i;
- int32 j;
- u_int8 val;
- BOOL ret_flg = FALSE;
- static BOOL is_detect_err = FALSE;
-
-#if GPS_FUNC_DEBUG_MSG__CWORD71__FILE
- static u_int16 file_line_size = 0;
- static FILE* fp = NULL; /* For debugging */
- u_int16 line_size = 0;
- u_int16 file_loop;
- u_int16 file_loop2;
-#endif /* GPS_FUNC_DEBUG_MSG__CWORD71__FILE */
-
- for (i = 0; i < MAX_READ_SIZE; i++) {
- if (work_bufcnt == 0) /* Last read completed */ {
- res = -1;
- if (WaitCommEvent(h_file, (LPDWORD)&fdw_comm_mask, NULL) != FALSE) {
- /* h_file is FD, and less than INT_MAX(0x7fffffff) */
- res = static_cast<int>(read(static_cast<int>((long)h_file), work_buf, // NOLINT(runtime/int)
- n_number_of_bytes_to_read));
- }
- }
-
- if (res == -1) {
- break;
- } else {
- for (j = work_bufcnt; j < res; j++) {
- val = *(work_buf + j);
- *wp = val;
-
- if (is_detect_err == TRUE) {
- /* If any errors are detected, skip the 1-byte so that the system can be restored to normal */
- is_detect_err = FALSE;
- } else {
- if ((key == val) && (is_set_key == TRUE)) {
- ret_flg = TRUE;
- *lp_number_of_bytes_read = (wp - ret_buf) + 1; /* calculate total read size */
-
- key = 0;
- is_set_key = FALSE;
- wp = ret_buf;
- ret = TRUE;
- break;
- } else if ((val == 0x24) &&
- ((key != 0xDA) || (is_set_key == FALSE)) &&
- ((key2 != 0xBF) || (is_set_key2 == FALSE))) {
- key = 0x0A; /* End of NEMA sentence */
- is_set_key = TRUE;
- wp++;
- } else if ((val == 0xB0) &&
- ((key != 0x0A) || (is_set_key == FALSE))) {
- key2 = 0xBF;
- is_set_key2 = TRUE;
- wp++;
- } else if ((key2 == val) && (is_set_key2 == TRUE)) {
- key = 0xDA; /* End of _CWORD82_ Binary */
- is_set_key = TRUE;
- is_set_key2 = FALSE;
- wp++;
- } else if ((is_set_key == TRUE) || (is_set_key2 == TRUE)) {
- wp++;
- } else {
- /* nothing */
- }
-
- /* PastModel008 Fix reset problem + */
- if ((wp - ret_buf) + 1 >= MAX_READ_SIZE) {
- ret_flg = TRUE;
- *lp_number_of_bytes_read = (wp - ret_buf) + 1; /* calculate total read size */
- wp = ret_buf;
-// fprintf(fp, "detect buffer ret_buf full!! size = %d\n", *lp_number_of_bytes_read);
- break;
- }
- /* PastModel008 Fix reset probrem - */
- }
- }
-
- if (j == res) /* When break was not performed during work_buf analysis */ {
- work_bufcnt = 0;
- }
-
- if (ret_flg == TRUE) {
- work_bufcnt = j;
- break;
- }
- }
- }
-
-
-// if ((i == MAX_READ_SIZE) || ((wp - ret_buf) + 1 > MAX_READ_SIZE)) {
- if ((i == MAX_READ_SIZE) || (*lp_number_of_bytes_read >= MAX_READ_SIZE)) { /* detect error */
- /* detect error */
- key = 0;
- is_set_key = FALSE;
- is_set_key2 = FALSE;
- is_detect_err = TRUE;
- } else {
- if (ret_flg == TRUE) {
- /* PastModel008 Fix reset problem + */
- if (*lp_number_of_bytes_read >= MAX_READ_SIZE) { /* PastModel008 Fix reset problem */
- ret = FALSE;
- } else {
- memcpy(lp_buffer, ret_buf, *lp_number_of_bytes_read);
- }
- /* PastModel008 Fix reset problem - */
- }
- }
-
-#if GPS_FUNC_DEBUG_MSG__CWORD71__FILE
- for (file_loop = 0; file_loop < *lp_number_of_bytes_read; file_loop++) {
- file_buf[file_line_size][line_size++] = *(ret_buf + file_loop);
- }
-
- line_size_buf[file_line_size] = line_size;
- file_line_size++;
-
- if (file_line_size >= FILE_OUT_LINE) {
- if (fp == NULL) {
- /* File initialization */
- fp = fopen(POS_GPS_R_LOGFILE_PATH, "w+");
- } else {
- fp = fopen(POS_GPS_R_LOGFILE_PATH, "a+");
- }
-
- for (file_loop = 0; file_loop < FILE_OUT_LINE; file_loop++) {
- for (file_loop2 = 0; file_loop2 < line_size_buf[file_loop]; file_loop2++) {
- fprintf(fp, "%02x ", file_buf[file_loop][file_loop2]);
- }
- fprintf(fp, "\n");
- }
- fclose(fp);
- file_line_size = 0;
- }
-#endif /* GPS_FUNC_DEBUG_MSG__CWORD71__FILE */
-
- return ret;
-}
-// LCOV_EXCL_STOP
-
-/**
- * @brief
- *
- * Read file
- *
- * Read data from a file(Implemented Function for ublox)
- *
- * @param[in] h_file Handle
- * @param[in] lp_buffer Read buffer
- * @param[out] n_number_of_bytes_to_read Maximum read size
- * @param[out] lp_number_of_bytes_read Read size
- * @param lp_overlapped Not used
- *
- * @return Processing result
- * @retval TRUE processing succeeded
- * @retval FALSE Processing failed
- */
-BOOL ReadFileUblox(HANDLE h_file, LPVOID lp_buffer, DWORD n_number_of_bytes_to_read, LPDWORD lp_number_of_bytes_read, LPOVERLAPPED lp_overlapped) { // LCOV_EXCL_START 8:dead code NOLINT(whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- BOOL ret = 0;
- static int res = 0;
- DWORD fdw_comm_mask; /* Communication event storage area */
-
- static u_int8 ret_buf[MAX_READ_SIZE] = {0}; /* Buffer for return */
- static u_int8 *wp = ret_buf;
-
- static u_int8 work_buf[MAX_READ_SIZE];
-
- static u_int8 key = 0; /* Primary key */
- static BOOL is_set_key = FALSE; /* Key is set or not */
- static BOOL is_set_key2 = FALSE; /* Key2 is set or not */
-
- int32 i;
- int32 j;
- u_int8 val;
- BOOL ret_flg = FALSE;
- static BOOL is_detect_err = FALSE;
- static int32 ubx_size = 0; /* Support when Sentence span more than one read() */
- static int32 ubx_count = 0; /* Support when Sentence span more than one read() */
- static int32 work_bufcnt = 0; /* Backup the read pointer of work_buf */
-
-#if GPS_FUNC_DEBUG_MSG__CWORD71__FILE
- static u_int16 file_line_size = 0;
- static FILE* fp = NULL; /* For debugging */
- u_int16 line_size = 0;
- u_int16 file_loop;
- u_int16 file_loop2;
-#endif /* GPS_FUNC_DEBUG_MSG__CWORD71__FILE */
-
- for (i = 0; i < MAX_READ_SIZE; i++) {
- if (work_bufcnt == 0) /* Last read completed */ {
- res = -1;
- if (WaitCommEvent(h_file, (LPDWORD)&fdw_comm_mask, NULL) != FALSE) {
- /* h_file is FD, and less than INT_MAX(0x7fffffff) */
- res = static_cast<int>(read(static_cast<int>((long)h_file), work_buf, // NOLINT(runtime/int)
- n_number_of_bytes_to_read));
- }
- }
-
- if (res == -1) {
- break;
- } else {
- for (j = work_bufcnt; j < res; j++) {
- val = *(work_buf + j);
- *wp = val;
-
- if (is_detect_err == TRUE) {
- /* If any errors are detected, skip the 1Byte so that the system can be restored to normal */
- is_detect_err = FALSE;
- } else {
- if (((key == val) && (is_set_key == TRUE))
- || ((ubx_count >= (7 + ubx_size)) && (is_set_key2 == TRUE))) {
- /* At the end of the sentence */
- ret_flg = TRUE;
- *lp_number_of_bytes_read = (wp - ret_buf) + 1; /* calculate total read size */
-
-// fprintf(fp, "fixed UBX sentence ubx_size = %d, ubx_count = %d, *lp_number_of_bytes_read = %d,
-// wp = %x, ret_buf = %x\n", ubx_size, ubx_count, *lpNumberOfBytesRead, wp, retBuf);
- key = 0;
- ubx_size = 0; /* Clear when end of ubx is judged */
- ubx_count = 0; /* Clear when end of ubx is judged */
- is_set_key = FALSE;
- is_set_key2 = FALSE;
- ret = TRUE;
- wp = ret_buf;
- break;
- } else if ((val == 0x24) && (is_set_key == FALSE) && (is_set_key2 == FALSE)) {
- /* At the beginning of the NMEA */
- key = 0x0A; /* End of NEMA sentence */
- is_set_key = TRUE;
- wp++;
- } else if ((val == 0xB5) && (is_set_key == FALSE) && (is_set_key2 == FALSE)) {
- /* At the beginning of the UBX */
- is_set_key2 = TRUE;
- wp++;
- } else if ((ubx_count == 4) && (is_set_key2 == TRUE)) {
- /* Payload size of the UBX(Lower byte) */
- ubx_size = val;
- wp++;
- } else if ((ubx_count == 5) && (is_set_key2 == TRUE)) {
- /* Payload size of the UBX(Upper byte) */
- ubx_size += (val << 8);
- wp++;
- } else if ((is_set_key == TRUE) || (is_set_key2 == TRUE)) {
- wp++;
- } else {
- /* nothing */
- }
-
- /* PastModel008 Fix reset problem + */
- if ((wp - ret_buf) + 1 >= MAX_READ_SIZE) {
- ret_flg = TRUE;
- *lp_number_of_bytes_read = (wp - ret_buf) + 1; /* calculate total read size */
- wp = ret_buf;
-// fprintf(fp, "detect buffer ret_buf full!! size = %d\n", *lp_number_of_bytes_read);
- break;
- }
- /* PastModel008 Fix reset problem - */
-
- if (((ubx_count == 5) && (is_set_key2 == TRUE)) &&
- ((ubx_size < 0) || (ubx_size > MAX_READ_SIZE))) {
- is_set_key2 = FALSE;
- }
- }
- if (is_set_key2 == TRUE) {
- ubx_count++;
- }
- }
- /* When break was not performed during work_buf analysis */
- if (j == res) {
- work_bufcnt = 0;
- }
- if (ret_flg == TRUE) {
- work_bufcnt = j + 1;
- break;
- }
- }
- }
-
- /* detect error */
-
-// if ((i == MAX_READ_SIZE) || ((wp - ret_buf) + 1 > MAX_READ_SIZE)) {
- if ((i == MAX_READ_SIZE) || (*lp_number_of_bytes_read >= MAX_READ_SIZE)) { /* detect error */ /* PastModel008 Fix reset problem */ // NOLINT(whitespace/line_length)
- key = 0;
- ubx_count = 0;
- ubx_size = 0;
- is_set_key = FALSE;
- is_set_key2 = FALSE;
- is_detect_err = TRUE;
- } else {
- if (ret_flg == TRUE) {
- /* PastModel008 Fix reset problem + */
- if (*lp_number_of_bytes_read >= MAX_READ_SIZE) { /* PastModel008 Fix reset problem */
- ret = FALSE;
- } else {
- memcpy(lp_buffer, ret_buf, *lp_number_of_bytes_read);
- }
- /* PastModel008 Fix reset problem - */
- }
- }
-
-#if GPS_FUNC_DEBUG_MSG__CWORD71__FILE
- for (file_loop = 0; file_loop < *lp_number_of_bytes_read; file_loop++) {
- file_buf[file_line_size][line_size++] = *(ret_buf + file_loop);
- }
-
- line_size_buf[file_line_size] = line_size;
- file_line_size++;
-
- if (file_line_size >= FILE_OUT_LINE) {
- if (fp == NULL) {
- /* File initialization */
- fp = fopen(POS_GPS_R_LOGFILE_PATH, "w+");
- } else {
- fp = fopen(POS_GPS_R_LOGFILE_PATH, "a+");
- }
-
- for (file_loop = 0; file_loop < FILE_OUT_LINE; file_loop++) {
- for (file_loop2 = 0; file_loop2 < line_size_buf[file_loop]; file_loop2++) {
- fprintf(fp, "%02x ", file_buf[file_loop][file_loop2]);
- }
- fprintf(fp, "\n");
- }
- fclose(fp);
- file_line_size = 0;
- }
-#endif /* GPS_FUNC_DEBUG_MSG__CWORD71__FILE */
-
- return ret;
-}
-// LCOV_EXCL_STOP
-
/**
* @brief
*