Re: Unexpected COPS format
Hey Colin, On Mon, Mar 20, 2017 at 9:17 AM, Colin Helliwell wrote: > >> On 17 March 2017 at 19:56 Aleksander Morgado >> wrote: >> >> On Fri, Mar 17, 2017 at 6:40 PM, Dan Williams wrote: >> >> > I ended up with something like: >> > >> > void >> > mm_3gpp_normalize_operator_id (gchar **id, >> > MMModemCharset cur_charset) >> > { >> > g_assert (id); >> > >> > /* Some modems return the operator name as a hexadecimal string of the >> > >> > * bytes of the operator name as encoded by the current character set. >> > */ >> > >> > if (*id && !mm_3gpp_parse_operator_id (id, NULL, NULL, NULL)) { >> > *id = mm_charset_take_and_convert_to_utf8 (*id, cur_charset); >> > if (!mm_3gpp_parse_operator_id (id, NULL, NULL, NULL)) >> > g_clear_pointer (id, g_free); >> > } >> > } >> > >> > but didn't get as far as writing testcases for it in src/tests/test- >> > modem-helpers.c. Testcases would be great, obviously. >> >> This would be very similar to mm_3gpp_normalize_operator_name() >> already; maybe we could just have a single method for both? >> > > Happy to submit the patch below. Unsure about a testcase - I'm cross-building > for a different target and haven't looked at building native and running > tests. If it helps, the modem is giving > '+COPS: 0,2,"00320033003400310030",2' > for '23410' > Any chance you can provide the patch in a way I can just "git am" it? i.e. "git send-email" or "git format-patch" > >> Colin, what's the AT+CSCS? return value that you're getting before any >> of this happens? Are you getting it reported as UCS2? >> > > The CSCS exchanges are: > --> 'AT+CSCS=?' > <-- '+CSCS: ("GSM","UCS2")' > <-- 'OK' > --> 'AT+CSCS="UCS2"' > <-- 'OK' > --> 'AT+CSCS?' > <-- '+CSCS: "UCS2"' > <-- 'OK' > > > diff -Nur a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c > --- a/src/mm-broadband-modem.c 2017-03-20 06:36:45.210171801 + > +++ b/src/mm-broadband-modem.c 2017-03-20 07:12:16.865399207 + > @@ -3484,7 +3484,9 @@ > error)) > return NULL; > > -mm_dbg ("loaded Operator Code: %s", operator_code); > +mm_3gpp_normalize_operator_string (&operator_code, MM_BROADBAND_MODEM > (self)->priv->modem_current_charset); > +if (operator_code) > +mm_dbg ("loaded Operator Code: %s", operator_code); > return operator_code; > } > > @@ -3525,7 +3527,7 @@ > error)) > return NULL; > > -mm_3gpp_normalize_operator_name (&operator_name, MM_BROADBAND_MODEM > (self)->priv->modem_current_charset); > +mm_3gpp_normalize_operator_string (&operator_name, MM_BROADBAND_MODEM > (self)->priv->modem_current_charset); > if (operator_name) > mm_dbg ("loaded Operator Name: %s", operator_name); > return operator_name; > diff -Nur a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c > --- a/src/mm-modem-helpers.c2017-03-20 06:36:44.890171799 + > +++ b/src/mm-modem-helpers.c2017-03-20 08:00:34.426196108 + > @@ -2980,12 +2980,12 @@ > /*/ > > void > -mm_3gpp_normalize_operator_name (gchar **operator, > - MMModemCharset cur_charset) > +mm_3gpp_normalize_operator_string (gchar **operator_string, > + MMModemCharset cur_charset) > { > -g_assert (operator); > +g_assert (operator_string); > > -if (*operator == NULL) > +if (*operator_string == NULL) > return; > > /* Some modems (Option & HSO) return the operator name as a hexadecimal > @@ -2994,19 +2994,19 @@ > */ > if (cur_charset == MM_MODEM_CHARSET_UCS2) { > /* In this case we're already checking UTF-8 validity */ > -*operator = mm_charset_take_and_convert_to_utf8 (*operator, > MM_MODEM_CHARSET_UCS2); > +*operator_string = mm_charset_take_and_convert_to_utf8 > (*operator_string, MM_MODEM_CHARSET_UCS2); > } > /* Ensure the operator name is valid UTF-8 so that we can send it > * through D-Bus and such. > */ > -else if (!g_utf8_validate (*operator, -1, NULL)) > -g_clear_pointer (operator, g_free); > +else if (!g_utf8_validate (*operator_string, -1, NULL)) > +g_clear_pointer (operator_string, g_free); > > /* Some modems (Novatel LTE) return the operator name as "Unknown" when > * it fails to obtain the operator name. Return NULL in such case. > */ > -if (*operator && g_ascii_strcasecmp (*operator, "unknown") == 0) > -g_clear_pointer (operator, g_free); > +if (*operator_string && g_ascii_strcasecmp (*operator_string, "unknown") > == 0) > +g_clear_pointer (operator_string, g_free); > } > > /*/ > diff -Nur a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h > --- a/src/mm-modem-helpers.h2017-03-20 06:36:44.890171799 + > +++ b/
Re: Unexpected COPS format
> On 17 March 2017 at 19:56 Aleksander Morgado wrote: > > On Fri, Mar 17, 2017 at 6:40 PM, Dan Williams wrote: > > > I ended up with something like: > > > > void > > mm_3gpp_normalize_operator_id (gchar **id, > > MMModemCharset cur_charset) > > { > > g_assert (id); > > > > /* Some modems return the operator name as a hexadecimal string of the > > > > * bytes of the operator name as encoded by the current character set. > > */ > > > > if (*id && !mm_3gpp_parse_operator_id (id, NULL, NULL, NULL)) { > > *id = mm_charset_take_and_convert_to_utf8 (*id, cur_charset); > > if (!mm_3gpp_parse_operator_id (id, NULL, NULL, NULL)) > > g_clear_pointer (id, g_free); > > } > > } > > > > but didn't get as far as writing testcases for it in src/tests/test- > > modem-helpers.c. Testcases would be great, obviously. > > This would be very similar to mm_3gpp_normalize_operator_name() > already; maybe we could just have a single method for both? > Happy to submit the patch below. Unsure about a testcase - I'm cross-building for a different target and haven't looked at building native and running tests. If it helps, the modem is giving '+COPS: 0,2,"00320033003400310030",2' for '23410' > Colin, what's the AT+CSCS? return value that you're getting before any > of this happens? Are you getting it reported as UCS2? > The CSCS exchanges are: --> 'AT+CSCS=?' <-- '+CSCS: ("GSM","UCS2")' <-- 'OK' --> 'AT+CSCS="UCS2"' <-- 'OK' --> 'AT+CSCS?' <-- '+CSCS: "UCS2"' <-- 'OK' diff -Nur a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c --- a/src/mm-broadband-modem.c 2017-03-20 06:36:45.210171801 + +++ b/src/mm-broadband-modem.c 2017-03-20 07:12:16.865399207 + @@ -3484,7 +3484,9 @@ error)) return NULL; -mm_dbg ("loaded Operator Code: %s", operator_code); +mm_3gpp_normalize_operator_string (&operator_code, MM_BROADBAND_MODEM (self)->priv->modem_current_charset); +if (operator_code) +mm_dbg ("loaded Operator Code: %s", operator_code); return operator_code; } @@ -3525,7 +3527,7 @@ error)) return NULL; -mm_3gpp_normalize_operator_name (&operator_name, MM_BROADBAND_MODEM (self)->priv->modem_current_charset); +mm_3gpp_normalize_operator_string (&operator_name, MM_BROADBAND_MODEM (self)->priv->modem_current_charset); if (operator_name) mm_dbg ("loaded Operator Name: %s", operator_name); return operator_name; diff -Nur a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c --- a/src/mm-modem-helpers.c2017-03-20 06:36:44.890171799 + +++ b/src/mm-modem-helpers.c2017-03-20 08:00:34.426196108 + @@ -2980,12 +2980,12 @@ /*/ void -mm_3gpp_normalize_operator_name (gchar **operator, - MMModemCharset cur_charset) +mm_3gpp_normalize_operator_string (gchar **operator_string, + MMModemCharset cur_charset) { -g_assert (operator); +g_assert (operator_string); -if (*operator == NULL) +if (*operator_string == NULL) return; /* Some modems (Option & HSO) return the operator name as a hexadecimal @@ -2994,19 +2994,19 @@ */ if (cur_charset == MM_MODEM_CHARSET_UCS2) { /* In this case we're already checking UTF-8 validity */ -*operator = mm_charset_take_and_convert_to_utf8 (*operator, MM_MODEM_CHARSET_UCS2); +*operator_string = mm_charset_take_and_convert_to_utf8 (*operator_string, MM_MODEM_CHARSET_UCS2); } /* Ensure the operator name is valid UTF-8 so that we can send it * through D-Bus and such. */ -else if (!g_utf8_validate (*operator, -1, NULL)) -g_clear_pointer (operator, g_free); +else if (!g_utf8_validate (*operator_string, -1, NULL)) +g_clear_pointer (operator_string, g_free); /* Some modems (Novatel LTE) return the operator name as "Unknown" when * it fails to obtain the operator name. Return NULL in such case. */ -if (*operator && g_ascii_strcasecmp (*operator, "unknown") == 0) -g_clear_pointer (operator, g_free); +if (*operator_string && g_ascii_strcasecmp (*operator_string, "unknown") == 0) +g_clear_pointer (operator_string, g_free); } /*/ diff -Nur a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h --- a/src/mm-modem-helpers.h2017-03-20 06:36:44.890171799 + +++ b/src/mm-modem-helpers.h2017-03-20 08:01:06.514196263 + @@ -291,8 +291,8 @@ MMModemAccessTechnology mm_string_to_access_tech (const gchar *string); -void mm_3gpp_normalize_operator_name (gchar **operator, - MMModemCharset cur_charset); +void mm_3gpp_normalize_operator_string (gchar **operator_string, +
Re: Unexpected COPS format
On Fri, Mar 17, 2017 at 6:40 PM, Dan Williams wrote: > I ended up with something like: > > void > mm_3gpp_normalize_operator_id (gchar **id, >MMModemCharset cur_charset) > { > g_assert (id); > > /* Some modems return the operator name as a hexadecimal string of the > * bytes of the operator name as encoded by the current character set. > */ > > if (*id && !mm_3gpp_parse_operator_id (id, NULL, NULL, NULL)) { > *id = mm_charset_take_and_convert_to_utf8 (*id, cur_charset); > if (!mm_3gpp_parse_operator_id (id, NULL, NULL, NULL)) > g_clear_pointer (id, g_free); > } > } > > but didn't get as far as writing testcases for it in src/tests/test- > modem-helpers.c. Testcases would be great, obviously. This would be very similar to mm_3gpp_normalize_operator_name() already; maybe we could just have a single method for both? Colin, what's the AT+CSCS? return value that you're getting before any of this happens? Are you getting it reported as UCS2? -- Aleksander https://aleksander.es ___ ModemManager-devel mailing list ModemManager-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
Re: Unexpected COPS format
On Fri, 2017-03-17 at 16:13 +, Colin Helliwell wrote: > > On 17 March 2017 at 15:02 Colin Helliwell > ms.com> wrote: > > > > > On 17 March 2017 at 14:16 colin.helliw...@ln-systems.com wrote: > > > > > > I’m reviewing the info fetched on my modems, and one of them is > > > giving an unusual format for “AT+COPS=3,2;+COPS?” : > > > > > > +COPS: 0,2,"00320033003400310035",0 > > > > > > This seems to be some sort of ‘wide char’ hex representation of > > > “23415” [which is what I’d expect]. > > > > > > The modem’s AT spec doesn’t say anything about it coming back in > > > the form, but I just wondered if it was a format anyone had > > > encountered elsewhere? > > > > Doing a bit of comparison between them: > > > > BGS2 - > > [src/mm-broadband-modem.c:3496] modem_3gpp_load_operator_code(): > > loading Operator Code... > > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): --> > > 'AT+COPS=3,2;+COPS?' > > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS: > > 0,2,"23415"OK' > > [src/mm-broadband-modem.c:3487] > > modem_3gpp_load_operator_code_finish(): loaded Operator Code: 23415 > > [src/mm-broadband-modem.c:3539] modem_3gpp_load_operator_name(): > > loading Operator Name... > > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): --> > > 'AT+COPS=3,0;+COPS?' > > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS: > > 0,0,"vodafone UK"OK' > > [src/mm-broadband-modem.c:3530] > > modem_3gpp_load_operator_name_finish(): loaded Operator Name: > > vodafone UK > > > > EHS5 - > > > > [src/mm-broadband-modem.c:3496] modem_3gpp_load_operator_code(): > > loading Operator Code... > > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): --> > > 'AT+COPS=3,2;+COPS?' > > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS: > > 0,2,"00320033003400310035",0' > > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- 'OK' > > [src/mm-broadband-modem.c:3487] > > modem_3gpp_load_operator_code_finish(): loaded Operator Code: > > 00320033003400310035 > > [src/mm-iface-modem-3gpp.c:874] parse_mcc_mnc(): Unexpected MCC/MNC > > string '00320033003400310035' > > [src/mm-broadband-modem.c:3539] modem_3gpp_load_operator_name(): > > loading Operator Name... > > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): --> > > 'AT+COPS=3,0;+COPS?' > > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS: > > 0,0,"0076006F006400610066006F006E006500200055004B",0OK' > > [src/mm-broadband-modem.c:3530] > > modem_3gpp_load_operator_name_finish(): loaded Operator Name: > > vodafone UK > > > > I notice that modem_3gpp_load_operator_name_finish() has a > > 'mm_3gpp_normalize_operator_name()' step; maybe same needed on > > modem_3gpp_load_operator_code_finish()? > > > > As a quick test, utilizing that function appears to work with the > above case. A neater patch would be to refactor it a bit more > generically - e.g. "mm_3gpp_normalize_operator_string". Any > objections/issues (or, more importantly, risk of adverse > consequences) with me submitting such a patch? No objections with you submitting a patch; I was looking at doing the same thing but since you touched it, you can own it! :) I ended up with something like: void mm_3gpp_normalize_operator_id (gchar **id, MMModemCharset cur_charset) { g_assert (id); /* Some modems return the operator name as a hexadecimal string of the * bytes of the operator name as encoded by the current character set. */ if (*id && !mm_3gpp_parse_operator_id (id, NULL, NULL, NULL)) { *id = mm_charset_take_and_convert_to_utf8 (*id, cur_charset); if (!mm_3gpp_parse_operator_id (id, NULL, NULL, NULL)) g_clear_pointer (id, g_free); } } but didn't get as far as writing testcases for it in src/tests/test- modem-helpers.c. Testcases would be great, obviously. Dan ___ ModemManager-devel mailing list ModemManager-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
Re: Unexpected COPS format
On Fri, 17 Mar 2017 14:16:50 - wrote: > I'm reviewing the info fetched on my modems, and one of them is giving an > unusual format for "AT+COPS=3,2;+COPS?" : > >+COPS: 0,2,"00320033003400310035",0 > > > > This seems to be some sort of 'wide char' hex representation of "23415" > [which is what I'd expect]. > > The modem's AT spec doesn't say anything about it coming back in the form, > but I just wondered if it was a format anyone had encountered elsewhere? > Hi Colin, That's in UCS2 format. Various AT commands (depending manufacturer) return strings in it. It's usually controlled modally by the 'AT+CSCS=' command, but some modems can ignore that (even if it's set to IRA or GSM) for certain commands and return things in UCS2 format. Things like network name etc which they may expect to contain rich characters etc are prime candidates. -- Andrew Bird ___ ModemManager-devel mailing list ModemManager-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
Re: Unexpected COPS format
> On 17 March 2017 at 15:02 Colin Helliwell > wrote: > > > On 17 March 2017 at 14:16 colin.helliw...@ln-systems.com wrote: > > > > I’m reviewing the info fetched on my modems, and one of them is giving an > > unusual format for “AT+COPS=3,2;+COPS?” : > > > > +COPS: 0,2,"00320033003400310035",0 > > > > This seems to be some sort of ‘wide char’ hex representation of “23415” > > [which is what I’d expect]. > > > > The modem’s AT spec doesn’t say anything about it coming back in the form, > > but I just wondered if it was a format anyone had encountered elsewhere? > > Doing a bit of comparison between them: > > BGS2 - > [src/mm-broadband-modem.c:3496] modem_3gpp_load_operator_code(): loading > Operator Code... > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): --> 'AT+COPS=3,2;+COPS?' > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS: > 0,2,"23415"OK' > [src/mm-broadband-modem.c:3487] modem_3gpp_load_operator_code_finish(): > loaded Operator Code: 23415 > [src/mm-broadband-modem.c:3539] modem_3gpp_load_operator_name(): loading > Operator Name... > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): --> 'AT+COPS=3,0;+COPS?' > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS: > 0,0,"vodafone UK"OK' > [src/mm-broadband-modem.c:3530] modem_3gpp_load_operator_name_finish(): > loaded Operator Name: vodafone UK > > EHS5 - > > [src/mm-broadband-modem.c:3496] modem_3gpp_load_operator_code(): loading > Operator Code... > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): --> 'AT+COPS=3,2;+COPS?' > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS: > 0,2,"00320033003400310035",0' > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- 'OK' > [src/mm-broadband-modem.c:3487] modem_3gpp_load_operator_code_finish(): > loaded Operator Code: 00320033003400310035 > [src/mm-iface-modem-3gpp.c:874] parse_mcc_mnc(): Unexpected MCC/MNC string > '00320033003400310035' > [src/mm-broadband-modem.c:3539] modem_3gpp_load_operator_name(): loading > Operator Name... > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): --> 'AT+COPS=3,0;+COPS?' > [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS: > 0,0,"0076006F006400610066006F006E006500200055004B",0OK' > [src/mm-broadband-modem.c:3530] modem_3gpp_load_operator_name_finish(): > loaded Operator Name: vodafone UK > > I notice that modem_3gpp_load_operator_name_finish() has a > 'mm_3gpp_normalize_operator_name()' step; maybe same needed on > modem_3gpp_load_operator_code_finish()? > As a quick test, utilizing that function appears to work with the above case. A neater patch would be to refactor it a bit more generically - e.g. "mm_3gpp_normalize_operator_string". Any objections/issues (or, more importantly, risk of adverse consequences) with me submitting such a patch? ___ ModemManager-devel mailing list ModemManager-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
Re: Unexpected COPS format
> On 17 March 2017 at 14:16 colin.helliw...@ln-systems.com wrote: > > I’m reviewing the info fetched on my modems, and one of them is giving an > unusual format for “AT+COPS=3,2;+COPS?” : > > +COPS: 0,2,"00320033003400310035",0 > > This seems to be some sort of ‘wide char’ hex representation of “23415” > [which is what I’d expect]. > > The modem’s AT spec doesn’t say anything about it coming back in the form, > but I just wondered if it was a format anyone had encountered elsewhere? > > Doing a bit of comparison between them: BGS2 - [src/mm-broadband-modem.c:3496] modem_3gpp_load_operator_code(): loading Operator Code... [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): --> 'AT+COPS=3,2;+COPS?' [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS: 0,2,"23415"OK' [src/mm-broadband-modem.c:3487] modem_3gpp_load_operator_code_finish(): loaded Operator Code: 23415 [src/mm-broadband-modem.c:3539] modem_3gpp_load_operator_name(): loading Operator Name... [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): --> 'AT+COPS=3,0;+COPS?' [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS: 0,0,"vodafone UK"OK' [src/mm-broadband-modem.c:3530] modem_3gpp_load_operator_name_finish(): loaded Operator Name: vodafone UK EHS5 - [src/mm-broadband-modem.c:3496] modem_3gpp_load_operator_code(): loading Operator Code... [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): --> 'AT+COPS=3,2;+COPS?' [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS: 0,2,"00320033003400310035",0' [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- 'OK' [src/mm-broadband-modem.c:3487] modem_3gpp_load_operator_code_finish(): loaded Operator Code: 00320033003400310035 [src/mm-iface-modem-3gpp.c:874] parse_mcc_mnc(): Unexpected MCC/MNC string '00320033003400310035' [src/mm-broadband-modem.c:3539] modem_3gpp_load_operator_name(): loading Operator Name... [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): --> 'AT+COPS=3,0;+COPS?' [src/mm-port-serial-at.c:459] debug_log(): (ttyMux1): <-- '+COPS: 0,0,"0076006F006400610066006F006E006500200055004B",0OK' [src/mm-broadband-modem.c:3530] modem_3gpp_load_operator_name_finish(): loaded Operator Name: vodafone UK I notice that modem_3gpp_load_operator_name_finish() has a 'mm_3gpp_normalize_operator_name()' step; maybe same needed on modem_3gpp_load_operator_code_finish()? ___ ModemManager-devel mailing list ModemManager-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel