I now have a bit of code hacked to take a CSV generated by the Rigol into the binary format required by sigrok. After a bit of frustration, I finally got sigrok to read the file and generate an I2C decode. However the result isn't very useable as is. If I convert the binary format to sigrok's format using sigrok-cli and open it in sigrok's PulseView app, then it's decoded well, but it only appears to be available visually, not in a table format.
So, I think I'll go back to square one and write a direct conversion program from Rigol's CSV to I2C.
Don't do that!
True, Pulseview can't handle all the protocol decoder functionality yet, but let's take a look with sigrok-cli. There's an input module for CSV:
sumner: ./sigrok-cli -I csv --show
ID: csv
Name: CSV
Description: Comma-separated values
Options:
single-column: Enable/specify single column (default 0)
numchannels: Number of channels (default 0)
delimiter: Column delimiter (default ',')
format: Numeric format (default 'bin')
comment: Comment prefix character (default ';')
samplerate: Samplerate used during capture (default 0)
first-channel: Column number of first channel (default 0)
header: Treat first line as header with channel names (default false)
startline: Line number at which to start processing samples (default 1)
Let's convert an existing sigrok save file to CSV, for demonstration purposes (there is also an output module for CSV):
sumner: ./sigrok-cli -i xfp.sr -O csv -o xfp.csv
sumner: ls -l xfp*
-rw-rw-r-- 1 bert bert 3976675 Oct 25 00:18 xfp.csv
-rw-rw-r-- 1 bert bert 5718 Oct 25 00:18 xfp.sr
sumner: head -5 xfp.csv
; CSV, generated by libsigrok 0.3.0 on Sat Oct 25 00:18:28 2014
; Channels (2/8): SCL, SDA
; Samplerate: 1 MHz
0,0
0,1
Now let's read that into sigrok-cli, decode as I2C, and pipe that into xxd to get a hexdump of the raw I2C payload:
sumner: ./sigrok-cli -I csv:samplerate=1000000 -i xfp.csv -P i2c -B i2c=data-read | xxd
0000000: 0600 5000 f100 4b00 f600 0000 0000 0000 ..P...K.........
0000010: 0000 c350 0000 9c40 0000 3de8 04ea 2710 ...P...@..=...'.
0000020: 07cb 4576 0000 372d 0119 0000 0000 0000 ..Ev..7-........
0000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000040: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000050: 0080 0080 a200 0000 0000 0000 0000 0000 ................
0000060: 23cb 0000 0000 0000 55dc 8151 0000 b0a0 #.......U..Q....
0000070: 0000 0000 0000 0000 0000 0000 0000 0001 ................
0000080: 0658 0744 0000 0000 0000 0090 646c 0a00 .X.D........dl..
0000090: 0000 0040 5375 6d69 746f 6d6f 456c 6563 ...@SumitomoElec
00000a0: 7472 6963 f000 0a1d 5358 5033 3130 314c tric....SXP3101L
00000b0: 582d 4134 2020 2020 4120 6658 0fa0 468c X-A4 A fX..F.
00000c0: 7d96 0800 3833 3330 3132 4130 3033 3838 }...833012A00388
00000d0: 2020 2020 3038 3033 3231 4135 0860 708c 080321A5.`p.
00000e0: 3348 4530 3035 3634 4141 4141 3031 2020 3HE00564AAAA01
00000f0: 414c 4120 2049 5055 4941 5252 4441 4154 ALA IPUIARRDAAT
The I2C protocol decoder needs the samplerate to work, but the CSV input module doesn't parse comments, so we pass it in as an option to the input module. The -B option specifies binary ("raw") output, "data-read" is the annotation we want to see (the I2C payload being read in the session being decoded).
The above is an EEPROM dump of a real XFP module by the way, The sigrok XFP protocol decoder stacks on top of this:
sumner: ./sigrok-cli -I csv:samplerate=1000000 -i xfp.csv -P i2c,xfp -A xfp=fieldnames-and-values | grep Link
Link length (SMF): 10 km
Link length (extended, 50?m MMF): (standard)
Link length (50?m MMF): (standard)
Link length (62.5?m MMF): (standard)
Link length (copper): (unknown)
On a side note, is there any centralised documentation on the various settings for the sigrok decoders?
The protocol decoders are self-documenting, at least as far as options and such are concerned:
sumner: ./sigrok-cli -P i2c --show
ID: i2c
Name: I²C
Long name: Inter-Integrated Circuit
Description: Two-wire, multi-master, serial bus.
License: gplv2+
Annotation classes:
- start: Start condition
- repeat-start: Repeat start condition
- stop: Stop condition
- ack: ACK
- nack: NACK
- bit: Data/address bit
- address-read: Address read
- address-write: Address write
- data-read: Data read
- data-write: Data write
- warnings: Human-readable warnings
Annotation rows:
- bits (Bits): bit
- addr-data (Address/Data): start, repeat-start, stop, ack, nack, address-read, address-write, data-read, data-write
- warnings (Warnings): warnings
Required channels:
- scl (SCL): Serial clock line
- sda (SDA): Serial data line
Optional channels:
None.
Options:
- address_format: Displayed slave address format ('shifted', 'unshifted', default 'shifted')
Documentation:
I²C (Inter-Integrated Circuit) is a bidirectional, multi-master
bus using two signals (SCL = serial clock line, SDA = serial data line).
That is of course a little cryptic if you're not used to it, so we're trying to make pages on the wiki for all of these:
http://sigrok.org/wiki/Protocol_decoder:I2cWe have more protocol decoders than documentation pages though -- help is always welcome.
In my brief experience of sigrok, the documentation I've seen seems to be mostly written for programmers interested in modifying and developing sigrok rather than for end users.
Well you're right there -- we're a lot better at writing code than we are at documenting it, and writing super-easy clients etc. But at least the functionality is all there, as the above shows. As always help is welcome.