Terminal/Custom Code: modem.connection instead of ec2x?

As some others here, I observed that none of the ec2x command work (except ec2x.help).
I’ve also confirmed that at least some of them can be substituted with modem.connection (at least in the Terminal).
For example, to get a current GPS location, instead of ec2x.gnss_location (which times out), I can use:
modem.connection execute AT$GPSACP
Which returns:

  data: >-
  _stamp: '2023-04-09T05:12:56.290650'

Per Telit’s documentation, these are:


That’s exactly what I want!
My issue is: how to correctly use this in the Custom Code?
Currently, there is:
__salt__['ec2x.gnss_location'](*[], **{})
Which doesn’t work.

Can I use something like:
__salt__['modem.connection'](*[],**{'execute': 'AT$GPSACP'})

1 Like

I’ll leave this here for anyone who may be searching in the future…
Solved it by trial-and-error :grinning:

The following code works:

  modconn = __salt__['modem.connection']('execute', 'AT$GPSACP', **{})['data']
  modconn = modconn.replace(':',' ').replace(',',' ').split()
  location = {'lat':modconn[2], 'lon':modconn[3], 'cog':float(modconn[7]), 'sog_km':float(modconn[8])}

This topic was automatically closed 33 days after the last reply. New replies are no longer allowed.