And here is the updated SCS decoder, now stacked on the UART decoder.

On Tue, Sep 29, 2020 at 6:16 PM Michael Stapelberg <
michael+sig...@stapelberg.ch> wrote:

>
>
> On Tue, Sep 29, 2020 at 1:42 PM Gerhard Sittig <gerhard.sit...@gmx.net>
> wrote:
>
>> On Tue, 2020-09-29 at 08:57 +0200, Michael Stapelberg wrote:
>> >
>> > Thanks for the quick review.
>> >
>> > I’ll try and grab another capture and update the decoder as time permits
>> > over the next few days.
>> >
>> > Unfortunately, I’m not aware of any more documentation than what I
>> > reference in
>> >
>> https://michael.stapelberg.ch/posts/2020-09-28-nuki-scs-bticino-decoding/
>> > at the very end.
>> > Maybe adding a link to that article would be a good first step, though?
>>
>> Are you aware that the UART decoder extracts the bytes for you
>> when you move the sample point away from the center of the bit
>> time towards the start of it? See the attachment (assuming that
>> I don't forget to attach it).
>>
>
> Ah, great, thanks for the tip! It looks like you added this option in
> commit
>
> https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=commitdiff;h=bd50ceb314e4607e596c98c534aafcfe142a73b6
> but that commit is not yet included in any released version of
> libsigrokdecode.
>
> Maybe it’s time to do a new release? :)
>
> By the way: in your screenshot, I see that you seem to have loaded
> my 2020-09-27-anlern-02-klingel-PUR-filtered.srzip into pulseview,
> but when I try to do that and add the UART decoder,
> the decoder reports the following error:
>
> srd: Traceback (most recent call last):
>   File "/usr/share/libsigrokdecode/decoders/uart/pd.py", line 517, in
> decode
>     raise SamplerateError('Cannot decode without samplerate.')
> uart.pd.SamplerateError: Cannot decode without samplerate.
>
> Is there a trick you used to correct the samplerate?
> I found out that I can also specify the samplerate when doing the CSV
> import,
> but I’m curious regardless.
>
>
>> Which suggests that SCS could and probably should stack on top
>> of UART, very much like MIDI, DMX, LIN and others do.
>>
>
> Yes, that will make things simpler.
>
>
>>
>> And I do agree that before any decoder implementation it's
>> essential to have documentation/references/details on the
>> protocol, and captures for demonstration. I consider this even
>> more important than any implementation itself, since the
>> information is need to create a proper decoder in the first
>> place, and maintain it later on.
>>
>
> I can definitely take another capture or two.
>
> Are you saying we need more than the captures to get this patch merged?
>
> I don’t know whether bTicino/Legrand is willing to share any documentation.
> What has been your success rate if you have asked companies to share such
> docs?
>
>
>>
>> Is the SCS protocol comparable to other home automation setups
>> like KNX or EIB? Searching the 'Net suggests that "simplified
>> wiring" is rather generic a term, brings up boats, motor bikes,
>> and houses.
>>
>
> I have not worked with KNX or EIB before,
> but have read the terms a few times while trying to find details about SCS.
> In particular, http://guidopic.altervista.org/alter/eibscsgt.html talks
> about “KNXGATE/SCSGATE”,
> implying that they are similar to a certain extent.
>
>
>>
>>
>> virtually yours
>> Gerhard Sittig
>> --
>>      If you don't understand or are scared by any of the above
>>              ask your parents or an adult to help you.
>> _______________________________________________
>> sigrok-devel mailing list
>> sigrok-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/sigrok-devel
>>
>
From 2cbb786d85f09b5b07f2bed5167b5c3ae92c9ffc Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <stapelb...@google.com>
Date: Mon, 28 Sep 2020 08:25:52 +0200
Subject: [PATCH] add decoder for the SCS bus (Sistema Cablaggio Semplificato)

---
 decoders/scs/__init__.py | 26 ++++++++++++++
 decoders/scs/pd.py       | 77 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 103 insertions(+)
 create mode 100644 decoders/scs/__init__.py
 create mode 100644 decoders/scs/pd.py

diff --git a/decoders/scs/__init__.py b/decoders/scs/__init__.py
new file mode 100644
index 0000000..bba605b
--- /dev/null
+++ b/decoders/scs/__init__.py
@@ -0,0 +1,26 @@
+##
+## This file is part of the libsigrokdecode project.
+##
+## Copyright (C) 2020 Michael Stapelberg
+##
+## 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 <http://www.gnu.org/licenses/>.
+##
+
+'''
+Decoder for the SCS bus (Sistema Cablaggio Semplificato, i.e. Simplified Cable
+Solution), a fieldbus network protocol for home automation, used by bTicino and
+Legrand.
+'''
+
+from .pd import Decoder
diff --git a/decoders/scs/pd.py b/decoders/scs/pd.py
new file mode 100644
index 0000000..9774e23
--- /dev/null
+++ b/decoders/scs/pd.py
@@ -0,0 +1,77 @@
+##
+## This file is part of the libsigrokdecode project.
+##
+## Copyright (C) 2020 Michael Stapelberg
+##
+## 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 <http://www.gnu.org/licenses/>.
+##
+
+import sigrokdecode as srd
+
+class Decoder(srd.Decoder):
+    api_version = 3
+    id = 'scs'
+    name = 'SCS'
+    longname = 'Sistema Cablaggio Semplificato (Simplified Cable Solution)'
+    desc = 'fieldbus network protocol for home automation, used by bTicino and Legrand'
+    license = 'gplv2+'
+    inputs = ['uart']
+    outputs = []
+    tags = ['Embedded/industrial', 'Networking']
+    channels = (
+        {'id': 'data', 'name': 'Data', 'desc': 'Data line'},
+    )
+    annotations = (
+        ('scs', 'SCS'),
+    )
+    options = ()
+
+    def __init__(self):
+        self.reset()
+
+    def reset(self):
+        self.telegram_idx = 0
+
+    # called before beginning of decoding
+    def start(self):
+        self.out_ann = self.register(srd.OUTPUT_ANN)
+
+    # called to start decoding
+    def decode(self, startsample, endsample, data):
+        ptype, rxtx, pdata = data
+        if ptype != 'DATA':
+            return
+        val = pdata[0]
+        if self.telegram_idx == 0 and val == 0xa8:
+            self.put(startsample, endsample, self.out_ann, [0, ['init']])
+        elif self.telegram_idx == 1:
+            self.crc = val
+            self.put(startsample, endsample, self.out_ann, [0, ['addr']])
+        elif self.telegram_idx == 2:
+            self.crc ^= val
+            self.put(startsample, endsample, self.out_ann, [0, ['??']])
+        elif self.telegram_idx == 3:
+            self.crc ^= val
+            self.put(startsample, endsample, self.out_ann, [0, ['request']])
+        elif self.telegram_idx == 4:
+            self.crc ^= val
+            self.put(startsample, endsample, self.out_ann, [0, ['??']])
+        elif self.telegram_idx == 5:
+            crc = 'good' if self.crc == val else 'bad'
+            self.put(startsample, endsample, self.out_ann, [0, ['%s crc' % crc]])
+        elif self.telegram_idx == 6:
+            self.put(startsample, endsample, self.out_ann, [0, ['term']])
+            self.telegram_idx = 0
+
+        self.telegram_idx += 1
-- 
2.28.0

_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to