Here are protocol decoders for DALI and DSI alog with some test files.
Regards,
Jeremy.
From 01be65fc2d03700c5e20f15ec492241506c2b650 Mon Sep 17 00:00:00 2001
From: Jeremy Swanson <jnswans...@gmail.com>
Date: Thu, 16 Feb 2017 16:29:47 +0000
Subject: [PATCH] Added DALI and DSI protocol decoders.
---
decoders/DALI/__init__.py | 25 +++++
decoders/DALI/lists.py | 99 +++++++++++++++++
decoders/DALI/pd.py | 266 ++++++++++++++++++++++++++++++++++++++++++++++
decoders/DSI/__init__.py | 25 +++++
decoders/DSI/pd.py | 169 +++++++++++++++++++++++++++++
5 files changed, 584 insertions(+)
create mode 100644 decoders/DALI/__init__.py
create mode 100644 decoders/DALI/lists.py
create mode 100644 decoders/DALI/pd.py
create mode 100644 decoders/DSI/__init__.py
create mode 100644 decoders/DSI/pd.py
diff --git a/decoders/DALI/__init__.py b/decoders/DALI/__init__.py
new file mode 100644
index 0000000..2e30920
--- /dev/null
+++ b/decoders/DALI/__init__.py
@@ -0,0 +1,25 @@
+##
+## This file is part of the libsigrokdecode project.
+##
+## Copyright (C) 2015 Jeremy Swanson <jer...@rakocontrols.com>
+##
+## 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, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+##
+
+'''
+DALI is a biphase/manchester based lighting control protocol.
+'''
+
+from .pd import Decoder
diff --git a/decoders/DALI/lists.py b/decoders/DALI/lists.py
new file mode 100644
index 0000000..bac8541
--- /dev/null
+++ b/decoders/DALI/lists.py
@@ -0,0 +1,99 @@
+##
+## This file is part of the libsigrokdecode project.
+##
+## Copyright (C) 2015 Jeremy Swanson <jer...@rakocontrols.com>
+##
+## 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, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+##
+
+# DALI Extended commands
+extendedCommands = {
+ 0xA1: ['Terminate special processes', 'Terminate'],
+ 0xA3: ['DTR = DATA', 'DTR'],
+ 0xA5: ['INITIALISE', 'INIT'],
+ 0xA7: ['RANDOMISE', 'RAND'],
+ 0xA9: ['COMPARE', 'COMP'],
+ 0xAB: ['WITHDRAW', 'WDRAW'],
+ 0xB1: ['SET SEARCH H', 'SAH'],
+ 0xB3: ['SET SEARCH M', 'SAM'],
+ 0xB5: ['SET SEARCH L', 'SAL'],
+ 0xB7: ['Program Short Address', 'ProgSA'],
+ 0xB9: ['Verify Short Address', 'VfySA'],
+ 0xBB: ['Query Short Address', 'QryShort'],
+ 0xBD: ['Physical Selection', 'PysSel'],
+ 0xC1: ['Enable Device Type X', 'EnTyp'],
+ 0xC3: ['DTR1 = DATA', 'DTR1'],
+ 0xC5: ['DTR2 = DATA', 'DTR2'],
+ 0xC7: ['Write Memory Location', 'WRI'],
+}
+
+# list of commands
+DALICommands = {
+ 0x00: ['Immediate Off', 'IOFF'],
+ 0x01: ['Up 200ms', 'Up'],
+ 0x02: ['Down 200ms', 'Down'],
+ 0x03: ['Step Up', 'Step+'],
+ 0x04: ['Step Down', 'Step-'],
+ 0x05: ['Recall Maximum Level', 'Recall Max'],
+ 0x06: ['Recall Minimum Level', 'Recall Min'],
+ 0x07: ['Step down and off', 'Down Off'],
+ 0x08: ['Step ON and UP', 'On Up'],
+ 0x20: ['Reset', 'Rst'],
+ 0x21: ['Store Dim Level in DTR', 'Level -> DTR'],
+ 0x2A: ['Store DTR as Max Level', 'DTR->Max'],
+ 0x2B: ['Store DTR as Min Level', 'DTR->Min'],
+ 0x2C: ['Store DTR as Fail Level', 'DTR->Fail'],
+ 0x2D: ['Store DTR as Power On Level', 'DTR->Poweron'],
+ 0x2E: ['Store DTR as Fade Time', 'DTR->Fade'],
+ 0x2F: ['Store DTR as Fade Rate', 'DTR->Rate'],
+ 0x80: ['Store DTR as Short Address', 'DTR->Add'],
+ 0x81: ['Enable Memory Write', 'WEn'],
+ 0x90: ['Query Status', 'Status'],
+ 0x91: ['Query Ballast', 'Ballast'],
+ 0x92: ['Query Lamp Failure', 'LmpFail'],
+ 0x93: ['Query Power On', 'Power On'],
+ 0x94: ['Query Limit Error', 'Limit Err'],
+ 0x95: ['Query Reset', 'Reset State'],
+ 0x96: ['Query Missing Short Address', 'NoSrt'],
+ 0x97: ['Query Version', 'Ver'],
+ 0x98: ['Query DTR', 'GetDTR'],
+ 0x99: ['Query Device Type', 'Type'],
+ 0x9A: ['Query Physical Minimum', 'PhysMin'],
+ 0x9B: ['Query Power Fail', 'PowerFailed'],
+ 0x9C: ['Query DTR1', 'GetDTR1'],
+ 0x9D: ['Query DTR2', 'GetDTR2'],
+ 0xA0: ['Query Level', 'GetLevel'],
+ 0xA1: ['Query Max Level', 'GetMax'],
+ 0xA2: ['Query Min Level', 'GetMin'],
+ 0xA3: ['Query Power On', 'GetPwrOn'],
+ 0xA4: ['Query Fail Level', 'GetFail'],
+ 0xA5: ['Query Fade Rate', 'GetRate'],
+ 0xA6: ['Query Power Fail', 'PwrFail'],
+ 0xC0: ['Query Groups 0-7', 'GetGrpsL'],
+ 0xC1: ['Query Groups 7-15', 'GetGrpsH'],
+ 0xC2: ['Query BRNH', 'BRNH'],
+ 0xC3: ['Query BRNM', 'BRNM'],
+ 0xC4: ['Query BRNL', 'BRNL'],
+ 0xC5: ['Query Memory', 'GetMem'],
+}
+
+# DALI device type 8
+DALIDeviceType8 = {
+ 0xE0: ['Set Temp X-Y Coordinate','Set X-Y'],
+ 0xE2: ['Activate Colour Set point','Activate SetPoint'],
+ 0xE7: ['Set Colour Temperature Tc','DTRs->ColTemp'],
+ 0xF9: ['Query Features','QryFeats'],
+ 0xFA: ['Query Current Setpoint Colour', 'GetSetPoint'],
+}
diff --git a/decoders/DALI/pd.py b/decoders/DALI/pd.py
new file mode 100644
index 0000000..c2b700b
--- /dev/null
+++ b/decoders/DALI/pd.py
@@ -0,0 +1,266 @@
+##
+## This file is part of the libsigrokdecode project.
+##
+
+## Copyright (C) 2015 Jeremy Swanson <jer...@rakocontrols.com>
+##
+## 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, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+##
+
+import sigrokdecode as srd
+from .lists import *
+
+class SamplerateError(Exception):
+ pass
+
+class Decoder(srd.Decoder):
+ api_version = 2
+ id = 'DALI'
+
+ name = 'DALI'
+ longname = 'Digital Addressable Lighting Interface'
+ desc = 'DALI Lighting control protocol.'
+ license = 'gplv2+'
+ inputs = ['logic']
+ outputs = ['DALI']
+ channels = (
+ {'id': 'dali', 'name': 'DALI', 'desc': 'DALI data line'},
+ )
+ options = (
+ {'id': 'polarity', 'desc': 'Polarity', 'default': 'active-low',
+ 'values': ('active-low', 'active-high')},
+ )
+ annotations = (
+ ('bit', 'Bit'),
+ ('startbit', 'Startbit'),
+ ('Sbit', 'Select bit'),
+ ('Ybit', 'Individual or Group'),
+ ('address', 'Address'),
+ ('command', 'Command'),
+ ('reply', 'Reply Data'),
+ ('raw', 'Raw Data'),
+ )
+ annotation_rows = (
+ ('bits', 'Bits', (0,)),
+ ('raw', 'Raw Data',(7,)),
+ ('fields', 'Fields', (1,2,3,4,5,6,)),
+ )
+
+ def __init__(self, **kwargs):
+ self.samplerate = None
+ self.samplenum = None
+ self.edges, self.bits, self.ss_es_bits = [], [], []
+ self.state = 'IDLE'
+ self.nextSamplePoint = None
+ self.nextSample = None
+ self.devType = None
+
+ def start(self):
+ self.out_ann = self.register(srd.OUTPUT_ANN)
+ self.old_ir = 1 if self.options['polarity'] == 'active-low' else 0
+
+ def metadata(self, key, value):
+ if key == srd.SRD_CONF_SAMPLERATE:
+ self.samplerate = value
+ # One bit: 833.33us (one half low, one half high).
+ # this is how may sample are in 1TE
+ self.halfbit = int((self.samplerate * 0.0008333) / 2.0)
+
+ def putb(self, bit1, bit2, data):
+ ss, es = self.ss_es_bits[bit1][0], self.ss_es_bits[bit2][1]
+ self.put(ss, es, self.out_ann, data)
+
+ def handle_bits(self, length):
+ a, c, f, g, b = 0, 0, 0, 0, self.bits
+ # Individual raw bits.
+ for i in range(length):
+ if i == 0:
+ ss = max(0, self.bits[0][0] )
+ else:
+ ss = self.ss_es_bits[i - 1][1]
+ es = self.bits[i][0] + (self.halfbit * 2)
+ self.ss_es_bits.append([ss, es])
+ self.putb(i, i, [0, ['%d' % self.bits[i][1]]])
+ # Bits[0:0]: Startbit
+ s = ['Startbit: %d' % b[0][1], 'ST: %d' % b[0][1], 'ST', 'S', 'S']
+ self.putb(0, 0, [1, s])
+ self.putb(0, 0, [7, s])
+ #bits [1:8]
+ for i in range(8):
+ f |= (b[1 + i][1] << (7 - i))
+ if length == 9: # BACKWARD Frame
+ s = ['Reply: %02X' % f , 'Rply: %02X' % f ,
+ 'Rep: %02X' % f, 'R: %02X' % f, 'R']
+ self.putb(1, 8, [7, s])
+ s = ['Reply: %d' % f , 'Rply: %d' % f ,
+ 'Rep: %d' % f, 'R: %d' % f, 'R']
+ self.putb(1, 8, [6, s])
+ return
+
+ # FORWARD FRAME
+ # Bits[9:16]: Command/Data (MSB-first)
+ for i in range(8):
+ c |= (b[9 + i][1] << (7 - i))
+ # raw output
+ s = ['Raw Data: %02X' % f , 'Raw: %02X' % f ,
+ 'Raw: %02X' % f, 'R: %02X' % f, 'R']
+ self.putb(1, 8, [7, s])
+ s = ['Raw Data: %02X' % c , 'Raw: %02X' % c ,
+ 'Raw: %02X' % c, 'R: %02X' % c, 'R']
+ self.putb(9, 16, [7, s])
+
+ # Bits[8:8]: Select bit
+ # s = ['Selectbit: %d' % b[8][1], 'SEL: %d' % b[8][1], 'SEL', 'SE',
'S']
+ if b[8][1] == 1:
+ s = ['Command' , 'Comd' , 'COM', 'CO', 'C']
+ else:
+ s = ['Arc Power Level' , 'Arc Pwr' , 'ARC', 'AC', 'A']
+ self.putb(8, 8, [1, s])
+
+ #f &= 254 # clear the select bit
+ if f >= 254: # BROADCAST
+ s = ['BROADCAST', 'Brdcast', 'BC', 'B', 'B']
+ self.putb(1,7, [5, s])
+ elif f >= 160: # extended command 0b10100000
+ if f == 0xC1: # DALI_ENABLE_DEVICE_TYPE_X
+ self.devType = -1
+ x = extendedCommands.get( f , ['Unknown', 'Unk'])
+ s = ['Extended Command: %02X (%s)' % (f,x[0]) , 'XC: %02X (%s)' %
(f,x[1]) ,
+ 'XC: %02X' % f, 'X: %02X' % f, 'X']
+ self.putb(1,8, [5, s])
+ elif f >= 128: # group
+ # Bits[1:1]: Ybit
+ s = ['YBit: %d' % b[1][1], 'YB: %d' % b[1][1], 'YB', 'Y', 'Y']
+ self.putb(1, 1, [3, s])
+ g = (f & 127) >> 1
+ s = ['Group Address: %d' % g , 'Group: %d' % g ,
+ 'GP: %d' % g, 'G: %d' % g, 'G']
+ self.putb(2,7, [4, s])
+ else: #Short address
+ # Bits[1:1]: Ybit
+ s = ['YBit: %d' % b[1][1], 'YB: %d' % b[1][1], 'YB', 'Y', 'Y']
+ self.putb(1, 1, [3, s])
+ a = f>>1
+ #x = system.get(a, ['Unknown', 'Unk'])
+ s = ['Short Address: %d' % a , 'Addr: %d' % a ,
+ 'Addr: %d' % a, 'A: %d' % a, 'A']
+ self.putb(2, 7, [4, s])
+
+ # Bits[9:16]: Command/Data (MSB-first)
+ if f >= 160 and f < 254:
+ if self.devType == -1:
+ self.devType = c
+ s = ['Type: %d' % c, 'Typ: %d' % c,
+ 'Typ: %d' % c, 'T: %d' % c, 'D']
+ else:
+ self.devType=None
+ s = ['Data: %d' % c, 'Dat: %d' % c,
+ 'Dat: %d' % c, 'D: %d' % c, 'D']
+ elif b[8][1] == 1:
+ un = c & 0xF0
+ ln = c & 0x0F
+ if un == 0x10: # set scene command
+ x = ['Recall Scene %d' % ln,'SC %d' % ln]
+ elif un == 0x40:
+ x = ['Store DTR as Scene %d' % ln,'SC %d = DTR' % ln]
+ elif un == 0x50:
+ x = ['Delete Scene %d' % ln,'DEL SC %d' % ln]
+ elif un == 0x60:
+ x = ['Add to Group %d' % ln,'Grp %d Add' % ln]
+ elif un == 0x70:
+ x = ['Remove from Group %d' % ln,'Grp %d Del' % ln]
+ elif un == 0xB0:
+ x = ['Query Scene %d Level' % ln,'Sc %d Level' % ln]
+ elif c >= 224: # application specific commands
+ if self.devType == 8:
+ x = DALIDeviceType8.get(c , ['Unknown App', 'Unk'])
+ else:
+ x = ['Application Specific Command %d' % c,'App Cmd %d' %
c]
+ else:
+ x = DALICommands.get(c , ['Unknown', 'Unk'])
+ s = ['Command: %d (%s)' % (c, x[0]), 'Com: %d (%s)' % (c, x[1]),
+ 'Com: %d' % c, 'C: %d' % c, 'C']
+ else:
+ s = ['Arc Power Level: %d' % c, 'Level: %d' % c,
+ 'Lev: %d' % c, 'L: %d' % c, 'L']
+ self.putb(9, 16, [5, s])
+
+ def reset_decoder_state(self):
+ self.edges, self.bits, self.ss_es_bits = [], [], []
+ self.state = 'IDLE'
+ #self.devType = None
+
+ def decode(self, ss, es, data):
+ if not self.samplerate:
+ raise SamplerateError('Cannot decode without samplerate.')
+ bit = 0;
+ for (self.samplenum, pins) in data:
+ self.ir = pins[0]
+ #data.itercnt += 1
+ #data.logic_mask = 1
+ #data.cur_pos = self.samplenum
+ #data.edge_index = -1
+ if self.options['polarity'] == 'active-high':
+ self.ir ^= 1 # invert
+
+ # Wait for any edge (rising or falling).
+
+ # State machine.
+ if self.state == 'IDLE':
+ #Wait for any edge (rising or falling).
+ if self.old_ir == self.ir:
+ #data.exp_logic = self.exp_logic
+ #data.logic_mask = 1
+ #logic.cur_pos = self.samplenum
+ continue
+ self.edges.append(self.samplenum)
+ self.state = 'PHASE0'
+ self.old_ir = self.ir
+ # get the next sample point
+ #self.nextSamplePoint = self.samplenum + int(self.halfbit / 2)
+ self.old_ir = self.ir
+ #bit = self.ir
+ #data.itercnt += int((self.halfbit-1) * 0.5)
+ continue
+
+ #if(self.samplenum == self.nextSamplePoint):
+ # bit = self.ir
+ # continue
+
+ if(self.old_ir != self.ir):
+ self.edges.append(self.samplenum)
+ elif(self.samplenum == (self.edges[-1] + int(self.halfbit * 1.5))):
+ self.edges.append(self.samplenum - int(self.halfbit * 0.5))
+ else:
+ continue
+
+ bit = self.old_ir
+ if(self.state == 'PHASE0'):
+ self.phase0 = bit
+ self.state = 'PHASE1'
+ elif(self.state == 'PHASE1'):
+ if((bit == 1) and (self.phase0 == 1)): #stop bit
+ if (len(self.bits) == 17 or len(self.bits) == 9): #
Forward or Backward
+ self.handle_bits(len(self.bits))
+ self.reset_decoder_state() # Reset state machine upon
errors.
+ continue
+ else:
+ self.bits.append([self.edges[-3], bit])
+ self.state = 'PHASE0'
+
+ #self.nextSamplePoint = self.edges[-1] + int(self.halfbit / 2)
+
+ self.old_ir = self.ir
+
diff --git a/decoders/DSI/__init__.py b/decoders/DSI/__init__.py
new file mode 100644
index 0000000..52353c3
--- /dev/null
+++ b/decoders/DSI/__init__.py
@@ -0,0 +1,25 @@
+##
+## This file is part of the libsigrokdecode project.
+##
+## Copyright (C) 2015 Jeremy Swanson <jer...@rakocontrols.com>
+##
+## 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, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+##
+
+'''
+DSI is a biphase/manchester based lighting control protocol.
+'''
+
+from .pd import Decoder
diff --git a/decoders/DSI/pd.py b/decoders/DSI/pd.py
new file mode 100644
index 0000000..221e3d5
--- /dev/null
+++ b/decoders/DSI/pd.py
@@ -0,0 +1,169 @@
+##
+## This file is part of the libsigrokdecode project.
+##
+
+## Copyright (C) 2015 Jeremy Swanson <jer...@rakocontrols.com>
+##
+## 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, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+##
+
+import sigrokdecode as srd
+
+class SamplerateError(Exception):
+ pass
+
+class Decoder(srd.Decoder):
+ api_version = 2
+ id = 'DSI'
+
+ name = 'DSI'
+ longname = 'Digital Serial Interface Lighting protocol'
+ desc = 'DSI Lighting control protocol.'
+ license = 'gplv2+'
+ inputs = ['logic']
+ outputs = ['DSI']
+ channels = (
+ {'id': 'dsi', 'name': 'DSI', 'desc': 'DSI data line'},
+ )
+ options = (
+ {'id': 'polarity', 'desc': 'Polarity', 'default': 'active-high',
+ 'values': ('active-low', 'active-high')},
+ )
+ annotations = (
+ ('bit', 'Bit'),
+ ('startbit', 'Startbit'),
+ ('Level', 'Dimmer Level'),
+ ('raw', 'Raw Data'),
+ )
+ annotation_rows = (
+ ('bits', 'Bits', (0,)),
+ ('raw', 'Raw Data',(3,)),
+ ('fields', 'Fields', (1,2,)),
+ )
+
+ def __init__(self, **kwargs):
+ self.samplerate = None
+ self.samplenum = None
+ self.edges, self.bits, self.ss_es_bits = [], [], []
+ self.state = 'IDLE'
+ self.nextSamplePoint = None
+ self.nextSample = None
+
+ def start(self):
+ self.out_ann = self.register(srd.OUTPUT_ANN)
+ self.old_ir = 1 if self.options['polarity'] == 'active-low' else 0
+
+ def metadata(self, key, value):
+ if key == srd.SRD_CONF_SAMPLERATE:
+ self.samplerate = value
+ # One bit: 1666.7us (one half low, one half high).
+ # this is how may sample are in 1TE
+ self.halfbit = int((self.samplerate * 0.0016667) / 2.0)
+
+ def putb(self, bit1, bit2, data):
+ ss, es = self.ss_es_bits[bit1][0], self.ss_es_bits[bit2][1]
+ self.put(ss, es, self.out_ann, data)
+
+ def handle_bits(self, length):
+ a, c, f, g, b = 0, 0, 0, 0, self.bits
+ # Individual raw bits.
+ for i in range(length):
+ if i == 0:
+ ss = max(0, self.bits[0][0] )
+ else:
+ ss = self.ss_es_bits[i - 1][1]
+ es = self.bits[i][0] + (self.halfbit * 2)
+ self.ss_es_bits.append([ss, es])
+ self.putb(i, i, [0, ['%d' % self.bits[i][1]]])
+ # Bits[0:0]: Startbit
+ s = ['Startbit: %d' % b[0][1], 'ST: %d' % b[0][1], 'ST', 'S', 'S']
+ self.putb(0, 0, [1, s])
+ self.putb(0, 0, [3, s])
+ #bits [1:8]
+ for i in range(8):
+ f |= (b[1 + i][1] << (7 - i))
+ g = f/2.55
+ if length == 9: # BACKWARD Frame
+ s = ['Data: %02X' % f , 'Dat: %02X' % f ,
+ 'Dat: %02X' % f, 'D: %02X' % f, 'D']
+ self.putb(1, 8, [3, s])
+ s = ['Level: %d%%' % g , 'Lev: %d%%' % g ,
+ 'Lev: %d%%' % g, 'L: %d' % g, 'D']
+ self.putb(1, 8, [2, s])
+ return
+
+ def reset_decoder_state(self):
+ self.edges, self.bits, self.ss_es_bits = [], [], []
+ self.state = 'IDLE'
+
+ def decode(self, ss, es, data):
+ if not self.samplerate:
+ raise SamplerateError('Cannot decode without samplerate.')
+ bit = 0;
+ for (self.samplenum, pins) in data:
+ self.ir = pins[0]
+ #data.itercnt += 1
+ if self.options['polarity'] == 'active-high':
+ self.ir ^= 1 # invert
+
+ # Wait for any edge (rising or falling).
+
+ # State machine.
+ if self.state == 'IDLE':
+ #Wait for any edge (rising or falling).
+ if self.old_ir == self.ir:
+ continue
+ #add in the first half of the start bit
+ self.edges.append(self.samplenum - int(self.halfbit))
+ self.edges.append(self.samplenum)
+ # start bit is 0->1
+ self.phase0 = (self.ir ^ 1)
+ self.state = 'PHASE1'
+ self.old_ir = self.ir
+ # get the next sample point
+ #self.nextSamplePoint = self.samplenum + int(self.halfbit / 2)
+ self.old_ir = self.ir
+ #bit = self.ir
+ continue
+
+ #if(self.samplenum == self.nextSamplePoint):
+ # bit = self.ir
+ # continue
+
+ if(self.old_ir != self.ir):
+ self.edges.append(self.samplenum)
+ elif(self.samplenum == (self.edges[-1] + int(self.halfbit * 1.5))):
+ self.edges.append(self.samplenum - int(self.halfbit * 0.5))
+ else:
+ continue
+
+ bit = self.old_ir
+ if(self.state == 'PHASE0'):
+ self.phase0 = bit
+ self.state = 'PHASE1'
+ elif(self.state == 'PHASE1'):
+ if((bit == 1) and (self.phase0 == 1)): #stop bit
+ if (len(self.bits) == 17 or len(self.bits) == 9): #
Forward or Backward
+ self.handle_bits(len(self.bits))
+ self.reset_decoder_state() # Reset state machine upon
errors.
+ continue
+ else:
+ self.bits.append([self.edges[-3], bit])
+ self.state = 'PHASE0'
+
+ #self.nextSamplePoint = self.edges[-1] + int(self.halfbit / 2)
+
+ self.old_ir = self.ir
+
--
2.11.0.windows.1
From ff2e29624b5225645a3de289bae209d3ea667099 Mon Sep 17 00:00:00 2001
From: Jeremy Swanson <jnswans...@gmail.com>
Date: Thu, 16 Feb 2017 17:11:58 +0000
Subject: [PATCH] DALI and DSI examples.
---
DALI/rako_rsrdali/README | 21 +++++++++++++++++++++
DALI/rako_rsrdali/dali_query_ballast.sr | Bin 0 -> 848 bytes
DSI/rako_wda-600/README | 21 +++++++++++++++++++++
DSI/rako_wda-600/dsi_example.sr | Bin 0 -> 1265 bytes
4 files changed, 42 insertions(+)
create mode 100644 DALI/rako_rsrdali/README
create mode 100644 DALI/rako_rsrdali/dali_query_ballast.sr
create mode 100644 DSI/rako_wda-600/README
create mode 100644 DSI/rako_wda-600/dsi_example.sr
diff --git a/DALI/rako_rsrdali/README b/DALI/rako_rsrdali/README
new file mode 100644
index 0000000..827da56
--- /dev/null
+++ b/DALI/rako_rsrdali/README
@@ -0,0 +1,21 @@
+RAKO Controls RSR-DALI controller
+
+These captures were grabbed from a running Dream Source Labs DSLogic unit.
+To generate logic levels the following circuit was used:
+
+ ___
+DALI o--|___|----|<---o----o---------o LOGIC
+ | |
+ | |
+ .-. |
+ | | -
+ | | ^
+ '-' |
+ | |
+ | |
+ Ov o----------------o----o---------o Ov
+
+ Diodes=5V1 Zenner
+ Resistors=10K
+
+
diff --git a/DALI/rako_rsrdali/dali_query_ballast.sr
b/DALI/rako_rsrdali/dali_query_ballast.sr
new file mode 100644
index
0000000000000000000000000000000000000000..3b3b8e0d536978af7f289717f14021a0a686de4c
GIT binary patch
literal 848
zcmWIWW@Zs#U|`^2Xsdkg!MpFO6f=;=2*m6_T$Wl?oSC0z%)}6YqVCzRw%yf0`H4Wx
z0mQkfC5b7CC5gJH4fzf$@Gu;>yZ!;Qi(24ny?a()_ygJ6cb(v3Wl?dCyT9sHoq79=
z@IG!6Ueo+%6K<KPA9`rCfcKVemHy)r<{9&gR){|q`w;Uh?&;D%jb{t)S-sd<Y_jxO
zsMJnvle*~|Q+H2rHo5)ykFeh#+m;WT``&R>U%K~2MCu_kssk&RtrS@S^o5HpBLgSU
zfjRl<naR3_x`uD>HcmXOAi(VKVt;0MW4cQ2Hpb^Yh6TU=*op&{b?y0;Q}@2-^_?}T
zhdj<#NS*&vy36|6mv4cUYhv4uEe+&UId{`~x9-)~wcM-cy^3T9+OT1c`ozT()j{y0
za%uS!iL=hn7G8~tTF+Eol)fZ>-F*F{Q!KvqhyqP7uv?$3=D%pQ`o;|(#J>x1-?Mq9
znE&zI&7l9x*UD#>UAe@#N`2;|dr{s%V;_9+4)+go4nHqDU47!!g5!H-pWZs-T&0k3
zd}a1(<@HsorbpU7F9RBCargB7>8BiC*qxfZVyWG_o&`3Yl^H+le*dp;*t>f5<k$dP
z|F)DaQIP#FV_UA)Zn5b+)1Bj2y(_`ERn0#sR>A+#&5NrUe*4HqZC;_%@@lK9=bAc@
zW6!DkD?wq>lGl$<OrFu6Qfy=0ux?Yle?jT0<yAYgOY+r$D!<4*^^93+)0xv}(`nN=
zZwJr;Cw5$MX8axgH`!AtlH;oP*@j4Fpr3$NmH0i6n|CCC?~BK?E}wOttA57q>7&{1
z&zUFuoxndKZbIA*DeX^N7!K6i1$Z+ui7?|%nLvBNU|S=If~He+P3XxKqJ@EBTcZY$
i2}`u-y3o@OLf1(k6P}U+yjj^mQp`ZO2uROh0`UM$Tta04
literal 0
HcmV?d00001
diff --git a/DSI/rako_wda-600/README b/DSI/rako_wda-600/README
new file mode 100644
index 0000000..719ed6f
--- /dev/null
+++ b/DSI/rako_wda-600/README
@@ -0,0 +1,21 @@
+RAKO Controls WDA-600 controller
+
+These captures were grabbed from a running Dream Source Labs DSLogic unit.
+To generate logic levels the following circuit was used:
+
+ ___
+DSI o--|___|----|<---o----o---------o LOGIC
+ | |
+ | |
+ .-. |
+ | | -
+ | | ^
+ '-' |
+ | |
+ | |
+ Ov o----------------o----o---------o Ov
+
+ Diodes=5V1 Zenner
+ Resistors=10K
+
+
diff --git a/DSI/rako_wda-600/dsi_example.sr b/DSI/rako_wda-600/dsi_example.sr
new file mode 100644
index
0000000000000000000000000000000000000000..18caf749263ea3e3be4390596221a17de6d1ba5d
GIT binary patch
literal 1265
zcmZ`(4NOy46uzZ}Lb5(xAek8oY=kZ@fdKXKvu;GQO*?B@1A<C6qzbYYEJ`2kQe**Y
zwz25|T@1X|Fd3_91<3@dEef3j+eM1v<2kcY$;j5xZ9oDI6*k?@1vWFYz2?4mdw#$3
zopY~T%H>5N{E&6>oq_@OSq|*+;=|IGRBDtJ>QwofRrrck-E?n8HE5e*g~K{rLMe(B
zlp^tF3Smfo3OT*qZhpOK=k28XF9p_p_*IASk|gp|URdFqc~yhaua1aZ5!Uxl?a@dq
zbfn^2-8+Uf@w>BgjiE)yZk{VVVRSCsU3~uI?dMty`d>f$>Bd-j!mXTd1oEYx*Edfb
z-`Kuy|IcklrskeI-c}WO?cV7=>-pP)q<;haBdqwMl#9?-0T)F8!19Vx<-x?1#FUxu
z$C`(d!$Y?fK6)dP+qTsv+OV&%!yzqsP~Jo~(t`z7i}{Sos%+z;md5cd_6rs>ty&i3
z<jNAgH#o=_&zR}aZ7Q(p28Gp<fNGcAKVHN}SV*f>{xkw5$F`<j-VHu1yvT=PmI!p^
zq$oC%ZvhiX@dX`Ydkdk}Kq3cr*8dhqa?q}$hYpbJZsz0%^lW3NeaYP)foh}Il~P!^
zCs&pplkX*RB9SwyRG6PDE8S0eV}AgQH3TZsrVm>nvPy3nyJoyED^o)a8J~ml41gN=
znz)`FREMCJw6kLvRWLP1ERm8d4`Q7M6TRuhYsU8s<ALZ7bA=ccWmOWX_6z=`QTlhm
zC7;%jXS>yv3F6dEP(y#l3)EG}F=r-q&+tK-!@O;x)h~D2C*we7W4at9AMM(ay+K7!
zu+*f&bGD`nbd&K=<LUk-iHu|edo|?4_Ufyxvr`C->=+$TS^X!}o|!n(o3K|SmdKE^
zSD97W1B}g1b=raK28fv)t6URo>M+ylG{B!c+}glW)y19~vdaNoDOeVSpd;2Tm<`SP
zMLRt}$B5k(>rw6I(M*Y~QPZSjWc9A>;32&T7&n?T$jcNl&-VVJb&xj901p)j^BIrX
zmFYJ6y#aNBM(m|wAV}}9(!UWWdIi_6V<tGLs50G!^IM0EeovqZ!eWxa(&9f#%&YaH
zE`YwQD$pP&Rh$KLRHo)DJkS9tZucw{{iQFv?Cu0Hf6ot1BT&mHCc`*o?e%E^dpgta
zpPL%zp%K~_PqNf@+lq0P&G*0ofEr*b4tiK>ahS+qCWn_|I7p~lXkH-<`042;gX~Z+
z96675z{r*1F+Jd6dkqLJH2-;B&Kx%3g2(U3>d7Fk`ny%qnn)P6NiF2V&HaeEGxIdi
z2v8s8$p)ukZl`tTD`9deCnSpd|5pbbyOpP}4u94zlE+T}eUq%ZAk<eUgzew=%9CDC
b9`DCqF4+Ea*yYmDFs$OjuN}UbJpAu3g4`Be
literal 0
HcmV?d00001
--
2.11.0.windows.1
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel