ublox: parse +UGCNTRD stats as unsigned 64bit values

[1551646332.583651] (ttyACM2): --> 'AT+UGCNTRD<CR>'
  [1551646332.626567] (ttyACM2): <-- '<CR><LF>+UGCNTRD: 1,0,0,0,0<CR><LF><CR><LF>+UGCNTRD: 2,1397316870,113728263578,1397316870,113728263578<CR><LF><CR><LF>OK<CR><LF>'
  [1551646332.627120] Reloading stats failed: Couldn't load primary PDP context 2 statistics: Error parsing session RX bytes
This commit is contained in:
Aleksander Morgado
2019-03-29 10:07:29 +00:00
committed by Aleksander Morgado
parent 7330f6d581
commit 0944e59252
4 changed files with 34 additions and 27 deletions
+2 -3
View File
@@ -748,8 +748,8 @@ ugcntrd_ready (MMBaseModem *modem,
MMBroadbandBearerUblox *self;
const gchar *response;
GError *error = NULL;
guint tx_bytes = 0;
guint rx_bytes = 0;
guint64 tx_bytes = 0;
guint64 rx_bytes = 0;
guint cid;
self = MM_BROADBAND_BEARER_UBLOX (g_task_get_source_object (task));
@@ -775,7 +775,6 @@ ugcntrd_ready (MMBaseModem *modem,
result->bytes_tx = tx_bytes;
g_task_return_pointer (task, result, g_free);
}
g_object_unref (task);
}
+12 -12
View File
@@ -1958,19 +1958,19 @@ out:
gboolean
mm_ublox_parse_ugcntrd_response_for_cid (const gchar *response,
guint in_cid,
guint *out_session_tx_bytes,
guint *out_session_rx_bytes,
guint *out_total_tx_bytes,
guint *out_total_rx_bytes,
guint64 *out_session_tx_bytes,
guint64 *out_session_rx_bytes,
guint64 *out_total_tx_bytes,
guint64 *out_total_rx_bytes,
GError **error)
{
GRegex *r;
GMatchInfo *match_info = NULL;
GError *inner_error = NULL;
guint session_tx_bytes = 0;
guint session_rx_bytes = 0;
guint total_tx_bytes = 0;
guint total_rx_bytes = 0;
guint64 session_tx_bytes = 0;
guint64 session_rx_bytes = 0;
guint64 total_tx_bytes = 0;
guint64 total_rx_bytes = 0;
gboolean matched = FALSE;
/* Response may be e.g.:
@@ -1997,22 +1997,22 @@ mm_ublox_parse_ugcntrd_response_for_cid (const gchar *response,
continue;
}
if (out_session_tx_bytes && !mm_get_uint_from_match_info (match_info, 2, &session_tx_bytes)) {
if (out_session_tx_bytes && !mm_get_u64_from_match_info (match_info, 2, &session_tx_bytes)) {
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Error parsing session TX bytes");
goto out;
}
if (out_session_rx_bytes && !mm_get_uint_from_match_info (match_info, 3, &session_rx_bytes)) {
if (out_session_rx_bytes && !mm_get_u64_from_match_info (match_info, 3, &session_rx_bytes)) {
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Error parsing session RX bytes");
goto out;
}
if (out_total_tx_bytes && !mm_get_uint_from_match_info (match_info, 4, &total_tx_bytes)) {
if (out_total_tx_bytes && !mm_get_u64_from_match_info (match_info, 4, &total_tx_bytes)) {
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Error parsing total TX bytes");
goto out;
}
if (out_total_rx_bytes && !mm_get_uint_from_match_info (match_info, 5, &total_rx_bytes)) {
if (out_total_rx_bytes && !mm_get_u64_from_match_info (match_info, 5, &total_rx_bytes)) {
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Error parsing total RX bytes");
goto out;
}
+4 -4
View File
@@ -197,10 +197,10 @@ MMUbloxBearerAllowedAuth mm_ublox_parse_uauthreq_test (const char *response,
gboolean mm_ublox_parse_ugcntrd_response_for_cid (const gchar *response,
guint in_cid,
guint *session_tx_bytes,
guint *session_rx_bytes,
guint *total_tx_bytes,
guint *total_rx_bytes,
guint64 *session_tx_bytes,
guint64 *session_rx_bytes,
guint64 *total_tx_bytes,
guint64 *total_rx_bytes,
GError **error);
#endif /* MM_MODEM_HELPERS_UBLOX_H */
+16 -8
View File
@@ -909,10 +909,10 @@ test_uauthreq_less_fields (void)
typedef struct {
const gchar *str;
guint cid;
guint session_tx_bytes;
guint session_rx_bytes;
guint total_tx_bytes;
guint total_rx_bytes;
guint64 session_tx_bytes;
guint64 session_rx_bytes;
guint64 total_tx_bytes;
guint64 total_rx_bytes;
} UgcntrdResponseTest;
static const UgcntrdResponseTest ugcntrd_response_tests[] = {
@@ -949,6 +949,14 @@ static const UgcntrdResponseTest ugcntrd_response_tests[] = {
.session_rx_bytes = 1819,
.total_tx_bytes = 2724,
.total_rx_bytes = 1839
},
{
.str = "+UGCNTRD: 2,1397316870,113728263578,1397316870,113728263578\r\n",
.cid = 2,
.session_tx_bytes = 1397316870ULL,
.session_rx_bytes = 113728263578ULL,
.total_tx_bytes = 1397316870ULL,
.total_rx_bytes = 113728263578ULL
}
};
@@ -960,10 +968,10 @@ test_ugcntrd_response (void)
for (i = 0; i < G_N_ELEMENTS (ugcntrd_response_tests); i++) {
GError *error = NULL;
gboolean success;
guint session_tx_bytes = G_MAXUINT;
guint session_rx_bytes = G_MAXUINT;
guint total_tx_bytes = G_MAXUINT;
guint total_rx_bytes = G_MAXUINT;
guint64 session_tx_bytes = 0;
guint64 session_rx_bytes = 0;
guint64 total_tx_bytes = 0;
guint64 total_rx_bytes = 0;
success = mm_ublox_parse_ugcntrd_response_for_cid (ugcntrd_response_tests[i].str,
ugcntrd_response_tests[i].cid,