[PATCH] libmm-glib,sms: fix get|dup_data() introspection annotations

Colin Helliwell colin.helliwell at ln-systems.com
Wed Sep 27 11:54:44 UTC 2017


> On 26 September 2017 at 18:54 Aleksander Morgado <aleksander at aleksander.es> wrote:
> 
....

> > > > I haven't yet explored parsing that response format, but another
> > > > example follows. Can you sanity-check? At first glance it looks a
> > > > little odd.
> > > > 
> > > > mmcli -m 0 -s 1
> > > > 
> > > > SMS '/org/freedesktop/ModemManager1/SMS/1'
> > > > 
> > > > -----------------------------------
> > > >  Content | number: '+447979116437'
> > > >  | data:
> > > > 
> > > > '079144872000302311000C914477310412820000AA08506215442DCFE9'
> > > > 
> > > > -----------------------------------
> > > >  Properties | PDU type: 'deliver'
> > > >  | state: 'received'
> > > >  | storage: 'me'
> > > >  | smsc: '+447785016005'
> > > >  | timestamp: '170925124043+01'
> > > > 
> > > > > > > m=rcvd[1]
> > > > > > > print m.get_number(), m.get_timestamp(), '"%s"' % m.get_text()
> > > > 
> > > > +447979999999 170925124043+01 "None"
> > > > 
> > > > > > > m.get_data()
> > > > 
> > > > '\x07\x91D\x87
> > > > \x000#\x11\x00\x0c\x91Dw1\x04\x12\x82\x00\x00\xaa\x08Pb\x15D-
> > > > \xcf\xe9'
.....

> 
> I believe you're trying to print the contents of the returned array as
> if it were a string. As long as I understand it after googling a bit,
> in python 2.x the "bytes" type is equivalent to "str", but we cannot
> just blindly try to print it as ascii as it really isn't anything
> related to ascii. Can you try to explicitly print the contents of the
> string as hex? see
> https://stackoverflow.com/questions/12214801/print-a-string-as-hex-bytes
>

Ah!

>>> m.get_data().encode('hex')
'079144872000302311000c914477310412820000aa08506215442dcfe9'


More information about the ModemManager-devel mailing list