Sigrok Protocol Decoders

I am using with Sigrok the following devices:

For GPIB (General Purpose Interface Bus, or HPIB, or IEEE488; 16 bits parallel) analysis with a Saleae Logic16 clone, I need a Sigrok decoder (Linux only). It is planned, but I like to use it now. So, I try to program it myself.

Not so easy, after the first look. The decoder HowTo describes it on a high level, but misses a lot of details. So, I am trying to understand the logic at the example ir_nec.

Sigrok Decoder IR_NEC2_

Unfortunately for the sample print on the sigrok wiki page I could not found the matching session file .sr. Therefore I had to make my own sample session file ir_nec_tv_matsui_av_hold.sr. Please see below a sample print of a IR (InfraRed remote control) decoding.

attachment:sigrok_decoder_ir_nec2.png

When you collect a data stream with sigrok (command line), or pulseview (sigrok with GUI), you have the possibility to save the data to a session file with the extension xxx.sr. In order to test decoder software, you can replay the collected data with the command line option -i file-name.

Software Analysis with WinPDB

In order to understand how the decoder software works, it is very time consuming to do that with Python print() statements. A better method is to use the Python GUI debugger WinPDB. An additional benefit is to use remote debugging, which allows to use 2 displays, one for Sigrok Pulseview, and the other one for the debugger. Here the OS Windows7 (R) is used.

For a Tutorial please see in the Links

Even, if WinPDB runs with Python 2.7 only, the remote debugger part (rpdb2.py) allows the use of Python 3, as I read in a Blog. The installation procedure is also described there.

Here I will give some hints for the usage of winpdb.

After you have downloaded winpdb-1.4.8.zip and extracted, copy file rpdb2.py to the Python3 library:

# OS: Ubuntu 14.04-32 Bit
$ cd winpdb-1.4.8

# copy rpdb2.py to Python 3 library, for use under Python3
$ sudo cp rpdb2.py /usr/lib/python3/dist-packages/

For easier handling, I have copied the original decoder software to a user folder, and renamed to "ir_nec2":

# OS: Ununtu 14.04-32 Bit
# make a local decoder folder
$ mkdir -p ~/.local/share/libsigrokdecode/decoders/

# make a work copy of ir_nec to local folder
$ sudo cp -R /usr/share/libsigrokdecode2/decoders/ir_nec ~/.local/share/libsigrokdecode/decoders/ir_nec2

# change owner to <user name>, e.g. rudi
$ sudo chown -R rudi:rudi ~/.local/share/libsigrokdecode/decoders/ir_nec2

$ cd ~/.local/share/libsigrokdecode/decoders/ir_nec2

# edit pd.py
# change:
    id = 'ir_nec2'
    name = 'IR_NEC2'

# insert the remote debugger statement, use a simple password "1".
# flag "fAllowRemote=True" allows remote network access.
# insert after line 168:
    b = self.samplenum - self.ss_bit
    import rpdb2; rpdb2.start_embedded_debugger('1', fAllowRemote=True)

# save your changed file pd.py

Next step is to start program Sigrok pulseview with the test session. In the pulseview window click on the decoder icon in the menu bar (right of the Run button), select IR_NEC2 from the pop up list, which starts the decoder. The program pd.py will stop at the rpdb2 statement and wait for 5 minutes to the winpdb connect (attach).

attachment:winpdb_attach.PNG

On the winpdb computer start the program winpdb and do the following procedure:

1. start winpdb with winpdb.bat

2. Set password with menu File->Password to "1"

3. Click on menu File->Attach

4. Enter in field "host:" the IP number of your computer with "pulseview" and "decoder" running "rpdb2.py"

5. Click on "Refresh", after a short delay you should see in the field below the remote address of the debugged Python program

6. Click on the remote address to highlight it

7. Start the decoder, as explained in the chapter "Decoder IR_NEC2".

8. Click on button OK to connect to the target computer debugger helper rpdb2.py

9. The windows of winpdb will be filled with data

On the right side you will see a screen shot of the Attach dialog, just before number 7 of the procedure.

Winpdb use

attachment:winpdb_decoder_ir_nec2.PNG

winpdb_decoder_ir_nec2.PNG

Above you will see a screen shot of Winpdb program window shrinked to a size (883 pixel horizontal), to fit in the wiki.

attachment:sigrok_decoder_ir_nec_options.png

Decoder IR_NEC2

Attached is the decoder program pd.py. With a right click on the link, you can open the program in a new TAB of the web browser, and you see the Python text color printed with line numbers.

On the right you can see a screen shot of the options window of the decoder ir_nec2.

Most important is the selection of the right pin of the logic probe for the data decoding. In this case it is pin IR Toy IRRX.

Next important is the data polarity, in this case the default was set to active-low.

Before you start, edit file pd.py and add the debug text (import rpdb2; ...) as mentioned before.

The type in the terminal:

# Change folder to "sigrok", 
# which must contain the "session file"
$ cd sigrok

# example command line, with session file as parameter
$ pulseview -i ir_nec_tv_matsui_av_hold.sr

# Click on the menu button "Zoom to fit"

# Click on the menu line on the "decoder" icon and select "IR_NEC2"
# Now you just see the label "IR_NEC2" of the decoder.

# Spread with menu "+" the data field and center with the mouse in the data field 
# with hold left button the pulses, as seen in the first sample print. 

# Click on the label "IR_NEC2" and select for the "data line" the pin "IR Toy IRRX"
# You will see now a gray bar in the data field.
# That is the time, when "rpdb2.py" has taken over the program control.

# Now "Attach" winpdb to the host IP address.

# With many clicks on the "Go" button, you can see how the gray bar is filled with the decoded data.

With setting a breakpoint (key F9, or click on the line number in the source window) in an interesting function it is possible to follow the decoding process.

Sigrok Installation on Mac OS

The Sigrok installation for Mac OS X El Capitan is described on the Sigrok page. Unfortunately a few information are missing, which I will describe following:

# fix user rights
$ sudo chown -R $(whoami):admin /usr/local

# reset brew to actual version
$ cd $(brew --prefix) && git fetch origin && git reset --hard origin/master

# path to the installation: /usr/local/Cellar/

Next the missing firmware folder must be created and filled:

$ mkdir ~/.local/share/sigrok-firmware/

Copy firmware files from a Linux or Windows installation, or see at sigrok.

  1. winpdb tutorial

  2. visualizing latency between two digital signals in real time with sigrok and matplotlib, sigrok decoder explained

  3. Convert Rigol DS1102E I2C CSV for sigrok

  4. Pulseview on windows 32/64 Bit with 8 Bit Logic Analyzer

  5. USBee AX with Pulseview and decoder UART explained

  6. Pulseview with UART decoder and SPI and stacking nRF24L01

  7. sigrok Saleae Logic16 support

  8. sigrok RSS feed, news

  9. sigrok, session file format

  10. sigrok, Input Output formats

  11. sigrok, session example dumps, xxx.sr

  12. sigrok decoder explained at a i2c example, with stacking

  13. File: sigrok_Ubuntu1604-32_git-test.txt

Contact Email

Please enter your Email address, if you expect an answer.

/!\ The entered Email address will not be published, or given away.

Comment this page
Name:
Comment:
Are you human?

List of pages in this category:

-- RudolfReuter 2016-09-07 11:20:45


Go back to CategoryLogicAnalyzer or FrontPage

SigrokDecoder (last edited 2017-10-10 04:34:02 by RudolfReuter)