Sigrok Protocol Decoders
I am using with Sigrok the following devices:
- USBee AX clone or Salea Logic clone, Logic Analyzer, 8 bit wide (12 - 16 EUR)
- Saleae Logic16 clone, Logic Analyzer, 16 bit wide
1st working sigrok installation on Ubuntu 14.04-32 LTS, with PPA
2nd working sigrok installation on Mac OSX 10.11.6 El Capitan.
3rd working sigrok installation on Windows 7-64 -> VirtualBox 5.1.4 -> Ubuntu 14.04-32 LTS with PPA
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.
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.
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).
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.
Above you will see a screen shot of Winpdb program window shrinked to a size (883 pixel horizontal), to fit in the wiki.
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:
A Homebrew installation before El Capitan 10.11.6 must be updated, in the Terminal:
# 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.
- USBee AX clone - working at the first test
Saleae Logic16 clone - does not work first, select the device from the list in Pulseview, search for the device, and sya OK. Then it worked.
Please enter your Email address, if you expect an answer.
The entered Email address will not be published, or given away.
List of pages in this category:
-- RudolfReuter 2016-09-07 11:20:45