[PATCH] qmicli: fix PLMN printing

Dan Williams dcbw at redhat.com
Mon Feb 8 16:44:22 CET 2016


On Mon, 2016-02-08 at 14:18 +0100, Bjørn Mork wrote:
> BCD PLMNs with 2 digit MNCs will have an 'F' digit between
> the MCC and the MNC.  This maps to \0, which would cause
> a truncated result string with only the MCC.
> 
> Signed-off-by: Bjørn Mork <bjorn at mork.no>
> ---

Pushed to master and qmi-1-12, thanks!  Looks like it should do the
right thing and give us "24201".

Dan

> Completely untested.  And not exactly sure this is the nicest way
> to fix this.  But I just stumbled across this in the
>  --nas-get-cell-location-info output, where the 42:F2:10 in here:
> 
> 
> > > > > > >   translated = SUCCESS
> > > > > > > TLV:
> > > > > > >   type       = "Intrafrequency LTE Info" (0x13)
> > > > > > >   length     = 39
> > > > > > >   value      =
> > > > > > > 00:42:F2:10:BF:78:0A:88:05:01:AA:05:2B:01:00:00:00:00:02:
> > > > > > > 2B:01:C2:FF:B9:FD:BD:FE:00:00:2C:01:D0:FF:28:FD:B0:FD:00:
> > > > > > > 00
> 
> is truncated into 242 here:
> 
> [/dev/cdc-wdm0] Successfully got cell location info
> Intrafrequency LTE Info
>         UE In Idle: 'no'
>         PLMN: '242'
>         Tracking Area Code: '30911'
> .. etc
> 
> 
> 
> Bjørn
> 
>  src/qmicli/qmicli-nas.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/qmicli/qmicli-nas.c b/src/qmicli/qmicli-nas.c
> index 9d43d46..c774bf4 100644
> --- a/src/qmicli/qmicli-nas.c
> +++ b/src/qmicli/qmicli-nas.c
> @@ -2233,8 +2233,12 @@ str_from_bcd_plmn (const gchar *bcd)
>  
>      str = g_malloc (7);
>      for (i = 0, j = 0 ; i < 3; i++) {
> -        str[j++] = bcd_chars[bcd[i] & 0xF];
> -        str[j++] = bcd_chars[(bcd[i] >> 4) & 0xF];
> +        str[j] = bcd_chars[bcd[i] & 0xF];
> +        if (str[j])
> +            j++;
> +        str[j] = bcd_chars[(bcd[i] >> 4) & 0xF];
> +        if (str[j])
> +            j++;
>      }
>      str[j] = '\0';
>  


More information about the libqmi-devel mailing list