aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xxmm.py36
1 files changed, 34 insertions, 2 deletions
diff --git a/xmm.py b/xmm.py
index 6548639..60944cb 100755
--- a/xmm.py
+++ b/xmm.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
+import configparser
import os
import re
import serial
@@ -25,10 +26,12 @@ EX_USAGE = 64
def usage(progname):
print("Usage:")
- print("{} commands list ".format(progname)
+ print("{} commands list ".format(progname)
+ "# list available AT commands")
- print("{} commands help ".format(progname)
+ print("{} commands help ".format(progname)
+ "# list usage of available AT commands")
+ print("{} dump <path/to/file> ".format(progname)
+ + "# dump the state for later comparison")
sys.exit(EX_USAGE)
def print_header(string):
@@ -207,9 +210,35 @@ class UART(object):
for line in usage:
print (line)
+ def get_cmds_status(self):
+ results = {}
+ for command in self.list_commands():
+ # Don't reset the modem
+ if command == 'ATE':
+ continue
+ if command.startswith('AT+'):
+ # Scans the networks: it takes a very long time and it's not
+ # very useful to understand better AT commands settings
+ if command == 'AT+COPS':
+ continue
+ # TODO: for some reasons this makes many commands fails
+ if command == 'AT+FCLASS':
+ continue
+ print(command)
+ results[command] = self.get_cmd_status(command)
+ return results
+
def close(self):
self.port.close()
+def dump_status(path):
+ config = configparser.ConfigParser()
+ for tty in get_ttys():
+ uart = UART(tty)
+ config['state@' + tty] = uart.get_cmds_status()
+ with open(path, 'w') as configfile:
+ config.write(configfile)
+
def get_ttys():
usb = USB()
if not usb.has_modem():
@@ -272,5 +301,8 @@ if __name__ == '__main__':
print_header(tty_header)
uart = UART(tty)
uart.get_cmds_usage()
+ elif len(sys.argv) == 3 and sys.argv[1] == "dump":
+ path = sys.argv[2]
+ dump_status(path)
else:
usage(sys.argv[0])