From 8e6c58aa91028964dab2a2721f39e62798abb884 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sun, 14 Jan 2018 00:41:59 +0000 Subject: [PATCH] Sasem Remote Controller LCD --- decoders/sasem/__init__.py | 24 +++++++++++++ decoders/sasem/pd.py | 90 ++++++++++++++++++++++++++++++++++++++++++++++ decoders/sasem/run.sh | 1 + 3 files changed, 115 insertions(+) create mode 100644 decoders/sasem/__init__.py create mode 100644 decoders/sasem/pd.py create mode 100644 decoders/sasem/run.sh diff --git a/decoders/sasem/__init__.py b/decoders/sasem/__init__.py new file mode 100644 index 0000000..46a55ca --- /dev/null +++ b/decoders/sasem/__init__.py @@ -0,0 +1,24 @@ +## +## This file is part of the libsigrokdecode project. +## +## Copyright (C) 2014 Gump Yang +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, see . +## + +''' +Sasem Remote Controller decoder +''' + +from .pd import Decoder diff --git a/decoders/sasem/pd.py b/decoders/sasem/pd.py new file mode 100644 index 0000000..f5c20c4 --- /dev/null +++ b/decoders/sasem/pd.py @@ -0,0 +1,90 @@ +## +## This file is part of the libsigrokdecode project. +## +## Copyright (C) 2018 Sean Young +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, see . +## + +import sigrokdecode as srd + +class Decoder(srd.Decoder): + api_version = 3 + id = 'sasem' + name = 'Sasem LCD' + longname = 'Sasem LCD' + desc = 'Sasem Remote Controller decoder.' + license = 'gplv2+' + inputs = ['logic'] + outputs = ['sasem'] + channels = ( + {'id': 'db0', 'name': 'DB0', 'desc': 'Parallel Data 0'}, + {'id': 'db1', 'name': 'DB1', 'desc': 'Parallel Data 1'}, + {'id': 'db2', 'name': 'DB2', 'desc': 'Parallel Data 2'}, + {'id': 'db3', 'name': 'DB3', 'desc': 'Parallel Data 3'}, + {'id': 'rs', 'name': 'RS', 'desc': 'Register Select'}, + {'id': 'e', 'name': 'E', 'desc': 'Enable'}, + ) + options = ( + ) + annotations = ( + ('data', 'Stream data'), + ('cmd', 'Command Type'), + ) + annotation_rows = ( + ('data', 'Stream data', (0,)), + ('cmd', 'Command Type', (1,)), + ) + + def __init__(self): + self.reset() + + def start(self): + self.out_python = self.register(srd.OUTPUT_PYTHON) + self.out_ann = self.register(srd.OUTPUT_ANN) + + def reset(self): + self.first = False + + def decode(self): + first_e = 0 + first_b = 0 + while True: + # Wait for failing edge + (d0, d1, d2, d3, rs, e) = self.wait({5: 'r'}) + + b = d0 + d1 * 2 + d2 * 4 + d3 * 8; + + if self.first and e != first_e: + self.first = False + + if self.first: + if rs: + cmd = 'data' + else: + cmd = 'reg' + + c = b + 16 * first_b + if c >= 32 and c < 127 and rs: + str = ('0x%02X' % c) + ' ' + chr(c) + else: + str = ('0x%02X' % c) + self.put(first_samplenum, self.samplenum, self.out_ann, [0, [str]]); + self.put(first_samplenum, self.samplenum, self.out_ann, [1, [cmd]]); + else: + first_b = b + first_e = e + first_samplenum = self.samplenum + + self.first = not self.first diff --git a/decoders/sasem/run.sh b/decoders/sasem/run.sh new file mode 100644 index 0000000..86da222 --- /dev/null +++ b/decoders/sasem/run.sh @@ -0,0 +1 @@ +SIGROKDECODE_DIR=/home/sean/git/libsigrokdecode/decoders/ sigrok-cli -d saleae-logic16 --config "samplerate=2 MHz" --continuous -P sasem -- 2.14.3