Merge "[Bugfix][bug-view-1697]Resolve the issue of deinit getting stuck and not returning"
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
index 8979e97..f16a2eb 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
@@ -1129,7 +1129,6 @@
return -1;
}
gnss_log("curent dev: %s, fd: %d \n", dev, fd);
- printf("curent dev: %s, fd: %d \n", dev, fd);
if(baudrate) {
gnss_log("set baudrate: %d \n", baudrate);
ret = set_baudrate(fd, baudrate);
@@ -1188,9 +1187,26 @@
return -1;
}
-static int mopen_gnss_read(int fd, char* buf, unsigned int buf_len)
+static int mopen_gnss_read(int fd, char* buf, unsigned int buf_len, int timeout_ms)
{
buf_len=(buf_len > MBTK_UART_RECV_BUFFER_SIZE ? MBTK_UART_RECV_BUFFER_SIZE : buf_len);
+ fd_set read_fds;
+ struct timeval tv;
+ int retval;
+
+ tv.tv_sec = timeout_ms / 1000;
+ FD_ZERO(&read_fds);
+ FD_SET(fd, &read_fds);
+ retval = select(fd + 1, &read_fds, NULL, NULL, &tv);
+
+ if (retval == -1)
+ return -1;
+ else if (retval == 0)
+ {
+ ALOGE("read timeout\n");
+ return -2;
+ }
+
return read(fd, buf, buf_len);
}
@@ -1287,7 +1303,9 @@
if(nmea_state == 1)
{
nmea_reading = 1;
- ret = mopen_gnss_read(gnss_handle->dev_fd, buf, MBTK_UART_RECV_BUFFER_SIZE);
+ ret = mopen_gnss_read(gnss_handle->dev_fd, buf, MBTK_UART_RECV_BUFFER_SIZE,5000);
+ if (ret == -2)
+ continue;
if(gnsslog_state)
{
//write_gnss_log(buf, ret);
@@ -1501,6 +1519,7 @@
memset(mbtk_gnss_handle, 0, sizeof(struct mbtk_gnss_handle_t));
memset(&mopen_gnss_device_info, 0, sizeof(mopen_gnss_device_info));
mbtk_gnss_handle->dev_fd = mopen_gnss_open(MBTK_GNSS_DEV, B115200);
+
mbtk_gnss_handle->rb = (char*)malloc(MBTK_UART_RECV_BUFFER_SIZE);
if(NULL == mbtk_gnss_handle->rb)
{
@@ -1543,11 +1562,12 @@
{
int ret;
- if (kill) {
- ALOGE("GNSS hardware issues\n");
- ret = pthread_cancel(pid);
- pthread_join(pid, NULL);
- }
+ // if (kill) {
+ // ALOGE("GNSS hardware issues\n");
+ // ret = pthread_cancel(pid);
+ // pthread_join(pid, NULL);
+ // return 0;
+ // }
do{
ret = pthread_kill(pid, 0);
if(ret == ESRCH)