Hi,

when using sigrok-cli (see version below) with a binary input file and
the SPI decoder it fails. When using it with an sr-file it works fine. I
used the following command line:

$ sigrok-cli -i ./somefile.bin -I
"binary:samplerate=10000000:numchannels=16" -P
"spi:clk=4:miso=5:mosi=6:cs=7"

The output is:
spi-1: 0
spi-1: 0
spi-1: 0
spi-1: 0
spi-1: 0
spi-1: 0
spi-1: 0
spi-1: 0
spi-1: 1
spi-1: 0
spi-1: 0
spi-1: 0
spi-1: 0
spi-1: 0
spi-1: 0
spi-1: 1
spi-1: 00
spi-1: 81
sr: srd: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
AttributeError: Protocol decoder instance spi-1: : 'Decoder' object has
no attribute 'out_bitrate'
sr: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
sr: session: sr_session_stop: session was NULL
(afterwards a lot more lines of the last one)

I figured out that the problem is within the SPI decoder.
self.out_bitrate is not set and it crashes. I believe the metadata() and
start() functions are called in the wrong order. The offending commit
seems to be fa7fdc54764d574446002c12d328b6f8bbb7e803.

I changed the metadata() function to

    def metadata(self, key, value):
        if key == srd.SRD_CONF_SAMPLERATE:
            self.samplerate = value
            self.out_bitrate = self.register(srd.OUTPUT_META,
                    meta=(int, 'Bitrate', 'Bitrate during transfers'))

and this seems to fix the problem (however I am not sure this the
correct approach, so I do not provide a patch here).

$ sigrok-cli --version
sigrok-cli 0.7.0-git-e67157c

Libraries and features:
- libsigrok 0.5.0/4:0:0 (rt: 0.5.0/4:0:0).
 - Libs:
  - glib 2.52.3 (rt: 2.52.3/5203:3)
  - libzip 1.2.0
  - libserialport 0.1.1/1:0:1 (rt: 0.1.1/1:0:1)
  - libusb-1.0 1.0.21.11156
  - libftdi 1.3
  - Host: x86_64-pc-linux-gnu, little-endian.
  - SCPI backends: TCP, RPC, serial, USBTMC.
- libsigrokdecode 0.5.0/4:0:0 (rt: 0.5.0/4:0:0).
 - Libs:
  - glib 2.52.2 (rt: 2.52.3/5203:3)
  - Python 3.6.1 / 0x30601f0 (API 1013, ABI 3)
  - Host: x86_64-pc-linux-gnu, little-endian.

Kind Regards,
Yannic Schröder

-- 
Yannic Schröder, M.Sc.

Technische Universität Braunschweig
Institut für Betriebssysteme und Rechnerverbund
Mühlenpfordtstr. 23
38106 Braunschweig

Fon: +49 (531) 391 - 3249
Fax: +49 (531) 391 - 5936
E-Mail: schroe...@ibr.cs.tu-bs.de

------------------------------------------------------------------------------
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

Reply via email to