From 1a6d45cc1c8b40f7b6aaf073cf7bdd7bde1cb593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Fri, 16 Feb 2018 23:01:23 +0100 Subject: [PATCH] sipo fixes and demo --- gex/Client.py | 4 ++++ gex/units/SIPO.py | 4 +++- omicron_mb_test.py | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 omicron_mb_test.py diff --git a/gex/Client.py b/gex/Client.py index 0797de5..d8be75c 100644 --- a/gex/Client.py +++ b/gex/Client.py @@ -96,6 +96,7 @@ class Client: self.unit_lu = {} + callsigns = [] for n in range(0,count): cs = pp.u8() name = pp.str() @@ -106,6 +107,9 @@ class Client: 'callsign': cs, 'type': type, } + if cs in callsigns: + raise Exception("Duplicate callsign! Wrong GEX config!") + callsigns.append(cs) def ini_read(self) -> str: """ Read the settings INI file """ diff --git a/gex/units/SIPO.py b/gex/units/SIPO.py index b98abbf..4161139 100644 --- a/gex/units/SIPO.py +++ b/gex/units/SIPO.py @@ -16,12 +16,14 @@ class SIPO(gex.Unit): def _type(self): return 'SIPO' - def load(self, buffers, confirm=True): + def load(self, buffers, end=0x0000, confirm=True): """ Load data - buffers is a list of lists or byte arrays """ if type(buffers[0]) == int: buffers = [buffers] pb = gex.PayloadBuilder() + pb.u16(end) + for b in buffers: pb.blob(b) diff --git a/omicron_mb_test.py b/omicron_mb_test.py new file mode 100644 index 0000000..bf02683 --- /dev/null +++ b/omicron_mb_test.py @@ -0,0 +1,19 @@ +import time + +import gex + +with gex.Client(gex.TrxRawUSB()) as client: + sipo = gex.SIPO(client, 'sipo') + d4 = gex.DOut(client, 'd4') + + # Jort the lights + sipo.load([ + [0x0a, 0x0f], + [0xF8, 0xFC], + [0x00, 0x00], + [0x02, 0x00], + ], end=0x04) + + d4.write(1) + # sipo.set_data(0x04) + # sipo.store()