From bcdc839abbd62d3442f706779476e84834085461 Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Wed, 6 Oct 2021 01:54:11 +0200 Subject: [PATCH] gnss: don't overload the modem during upload By instructing sendfile() to send the whole content of the assistance data at once results in a big data transfer (> 4kb) first followed by a huge amount of small transfers (64 or 128b). This "overloads" the modem which needs to process smaller chunks of data and have more time to do so (experimentation shows that 1kb need 100ms for processing, or the upload will subsequently fail). This commit sets the transfer size to 256b and increase the timeout between each transfer to 25ms. --- src/gnss.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gnss.c b/src/gnss.c index d95f071..502612c 100644 --- a/src/gnss.c +++ b/src/gnss.c @@ -14,7 +14,7 @@ #include #define BUFFER_SIZE 256 -#define UPLOAD_DELAY_US 10000 +#define UPLOAD_DELAY_US 25000 #define UPLOAD_TIMEOUT_S 10 #define RESCHEDULE_IN_SECS 30 @@ -342,7 +342,7 @@ static void upload_assistance_data(struct EG25Manager *manager) do { errno = 0; /* Copy downloaded XTRA assistance data to the modem over serial */ - ret = sendfile(manager->at_fd, manager->gnss_assistance_fd, &written_total, sb.st_size); + ret = sendfile(manager->at_fd, manager->gnss_assistance_fd, &written_total, BUFFER_SIZE); error = errno; usleep(UPLOAD_DELAY_US); } while ((!error && written_total < sb.st_size) || (ret == -1 && error == EAGAIN)); @@ -376,13 +376,13 @@ static void finish_assistance_data_upload(struct EG25Manager *manager) /* Configure GNSS assistance clock to current system time (UTC) */ datetime = g_date_time_new_now_utc(); - timestring = g_date_time_format(datetime, "0,\"%Y/%m/%d,%H:%M:%S\"\r\n"); + timestring = g_date_time_format(datetime, "0,\"%Y/%m/%d,%H:%M:%S\""); g_message("Setting GNSS assistance UTC clock to: %s", timestring); at_append_command(manager, "QGPSXTRATIME", NULL, timestring, NULL, at_process_result); /* Configure GNSS engine to use uploaded GNSS assistance data */ - g_snprintf(value, BUFFER_SIZE, "\"RAM:%s\"\r\n", + g_snprintf(value, BUFFER_SIZE, "\"RAM:%s\"", manager->gnss_assistance_file); g_message("Setting GNSS assistance file to: %s", value); at_append_command(manager, "QGPSXTRADATA", NULL, value, NULL,