From a59955000d275d7486ec107ebd26f5da434ce3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Wed, 27 Dec 2017 18:00:00 +0100 Subject: [PATCH] added settings manipulation functions --- gex/Client.py | 12 ++++++++++++ main.py | 10 +++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/gex/Client.py b/gex/Client.py index 27d4ecf..2e5486d 100644 --- a/gex/Client.py +++ b/gex/Client.py @@ -38,6 +38,18 @@ class Client: 'type': type, } + def ini_read(self): + """ Read the settings INI file """ + buffer = self.bulk_read(cs=None, cmd=gex.MSG_INI_READ) + return buffer.decode('utf-8') + + def ini_write(self, buffer): + """ Read the settings INI file """ + if type(buffer) == str: + buffer = buffer.encode('utf-8') + + self.bulk_write(cs=None, cmd=gex.MSG_INI_WRITE, bulk=buffer) + def get_callsign(self, name, type = None): """ Find unit by name and type """ u = self.unit_lu[name] diff --git a/main.py b/main.py index c0b432d..8298047 100644 --- a/main.py +++ b/main.py @@ -5,10 +5,14 @@ import gex client = gex.Client() -buf = client.bulk_read(None, gex.MSG_INI_READ) -print(buf.decode('utf-8')) +s = client.ini_read() +client.ini_write(s) -client.bulk_write(None, gex.MSG_INI_WRITE, buf) +if False: + buf = client.bulk_read(None, gex.MSG_INI_READ) + print(buf.decode('utf-8')) + + client.bulk_write(None, gex.MSG_INI_WRITE, buf) if False: led = gex.Pin(client, 'LED')