From: Bert Vermeulen Date: Mon, 10 Mar 2014 11:23:38 +0000 (+0100) Subject: Probes, optional probes and annotations now take a tuple. X-Git-Tag: libsigrokdecode-0.3.0~60 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=da9bcbd9f45b0153465c55ec726a0d76f6d7f01e;p=libsigrokdecode.git Probes, optional probes and annotations now take a tuple. Annotation entries also consist of a tuple, not a list. --- diff --git a/decoder.c b/decoder.c index 18b0b58..fd76a1c 100644 --- a/decoder.c +++ b/decoder.c @@ -102,19 +102,19 @@ static int get_probes(const struct srd_decoder *d, const char *attr, return SRD_OK; py_probelist = PyObject_GetAttrString(d->py_dec, attr); - if (!PyList_Check(py_probelist)) { - srd_err("Protocol decoder %s %s attribute is not a list.", + if (!PyTuple_Check(py_probelist)) { + srd_err("Protocol decoder %s %s attribute is not a tuple.", d->name, attr); return SRD_ERR_PYTHON; } - if ((num_probes = PyList_Size(py_probelist)) == 0) + if ((num_probes = PyTuple_Size(py_probelist)) == 0) /* Empty probelist. */ return SRD_OK; ret = SRD_OK; for (i = 0; i < num_probes; i++) { - py_entry = PyList_GetItem(py_probelist, i); + py_entry = PyTuple_GetItem(py_probelist, i); if (!PyDict_Check(py_entry)) { srd_err("Protocol decoder %s %s attribute is not " "a list with dict elements.", d->name, attr); @@ -429,16 +429,16 @@ SRD_API int srd_decoder_load(const char *module_name) d->annotations = NULL; if (PyObject_HasAttrString(d->py_dec, "annotations")) { py_annlist = PyObject_GetAttrString(d->py_dec, "annotations"); - if (!PyList_Check(py_annlist)) { + if (!PyTuple_Check(py_annlist)) { srd_err("Protocol decoder %s annotations should " - "be a list.", module_name); + "be a tuple.", module_name); goto err_out; } - for (i = 0; i < PyList_Size(py_annlist); i++) { - py_ann = PyList_GetItem(py_annlist, i); - if (!PyList_Check(py_ann) || PyList_Size(py_ann) != 2) { + for (i = 0; i < PyTuple_Size(py_annlist); i++) { + py_ann = PyTuple_GetItem(py_annlist, i); + if (!PyTuple_Check(py_ann) || PyTuple_Size(py_ann) != 2) { srd_err("Protocol decoder %s annotation %d should " - "be a list with two elements.", module_name, i + 1); + "be a tuple with two elements.", module_name, i + 1); goto err_out; } diff --git a/decoders/avr_isp/pd.py b/decoders/avr_isp/pd.py index 8f3e128..42ac48b 100644 --- a/decoders/avr_isp/pd.py +++ b/decoders/avr_isp/pd.py @@ -32,21 +32,21 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['spi', 'logic'] outputs = ['avr_isp'] - optional_probes = [ + optional_probes = ( {'id': 'reset', 'name': 'RESET#', 'desc': 'Target AVR MCU reset'}, - ] - annotations = [ - ['pe', 'Programming enable'], - ['rsb0', 'Read signature byte 0'], - ['rsb1', 'Read signature byte 1'], - ['rsb2', 'Read signature byte 2'], - ['ce', 'Chip erase'], - ['rfb', 'Read fuse bits'], - ['rhfb', 'Read high fuse bits'], - ['refb', 'Read extended fuse bits'], - ['warnings', 'Warnings'], - ['dev', 'Device'], - ] + ) + annotations = ( + ('pe', 'Programming enable'), + ('rsb0', 'Read signature byte 0'), + ('rsb1', 'Read signature byte 1'), + ('rsb2', 'Read signature byte 2'), + ('ce', 'Chip erase'), + ('rfb', 'Read fuse bits'), + ('rhfb', 'Read high fuse bits'), + ('refb', 'Read extended fuse bits'), + ('warnings', 'Warnings'), + ('dev', 'Device'), + ) annotation_rows = ( ('bits', 'Bits', ()), ('commands', 'Commands', tuple(range(7 + 1))), diff --git a/decoders/can/pd.py b/decoders/can/pd.py index ff60a90..3f27c30 100644 --- a/decoders/can/pd.py +++ b/decoders/can/pd.py @@ -29,32 +29,32 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['can'] - probes = [ + probes = ( {'id': 'can_rx', 'name': 'CAN RX', 'desc': 'CAN bus line'}, - ] + ) options = ( {'id': 'bitrate', 'desc': 'Bitrate', 'default': 1000000}, # 1Mbit/s {'id': 'sample_point', 'desc': 'Sample point', 'default': 70}, # 70% ) - annotations = [ - ['data', 'CAN payload data'], - ['sof', 'Start of frame'], - ['eof', 'End of frame'], - ['id', 'Identifier'], - ['ext-id', 'Extended identifier'], - ['full-id', 'Full identifier'], - ['ide', 'Identifier extension bit'], - ['reserved-bit', 'Reserved bit 0 and 1'], - ['rtr', 'Remote transmission request'], - ['srr', 'Substitute remote request'], - ['dlc', 'Data length count'], - ['crc-sequence', 'CRC sequence'], - ['crc-delimiter', 'CRC delimiter'], - ['ack-slot', 'ACK slot'], - ['ack-delimiter', 'ACK delimiter'], - ['stuff-bit', 'Stuff bit'], - ['warnings', 'Human-readable warnings'], - ] + annotations = ( + ('data', 'CAN payload data'), + ('sof', 'Start of frame'), + ('eof', 'End of frame'), + ('id', 'Identifier'), + ('ext-id', 'Extended identifier'), + ('full-id', 'Full identifier'), + ('ide', 'Identifier extension bit'), + ('reserved-bit', 'Reserved bit 0 and 1'), + ('rtr', 'Remote transmission request'), + ('srr', 'Substitute remote request'), + ('dlc', 'Data length count'), + ('crc-sequence', 'CRC sequence'), + ('crc-delimiter', 'CRC delimiter'), + ('ack-slot', 'ACK slot'), + ('ack-delimiter', 'ACK delimiter'), + ('stuff-bit', 'Stuff bit'), + ('warnings', 'Human-readable warnings'), + ) def __init__(self, **kwargs): self.samplerate = None diff --git a/decoders/dcf77/pd.py b/decoders/dcf77/pd.py index 94f5d2c..7cc85f6 100644 --- a/decoders/dcf77/pd.py +++ b/decoders/dcf77/pd.py @@ -34,31 +34,31 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['dcf77'] - probes = [ + probes = ( {'id': 'data', 'name': 'DATA', 'desc': 'DATA line'}, - ] - annotations = [ - ['start-of-minute', 'Start of minute'], - ['special-bits', 'Special bits (civil warnings, weather forecast)'], - ['call-bit', 'Call bit'], - ['summer-time', 'Summer time announcement'], - ['cest', 'CEST bit'], - ['cet', 'CET bit'], - ['leap-second', 'Leap second bit'], - ['start-of-time', 'Start of encoded time'], - ['minute', 'Minute'], - ['minute-parity', 'Minute parity bit'], - ['hour', 'Hour'], - ['hour-parity', 'Hour parity bit'], - ['day', 'Day of month'], - ['day-of-week', 'Day of week'], - ['month', 'Month'], - ['year', 'Year'], - ['date-parity', 'Date parity bit'], - ['raw-bits', 'Raw bits'], - ['unknown-bits', 'Unknown bits'], - ['warnings', 'Human-readable warnings'], - ] + ) + annotations = ( + ('start-of-minute', 'Start of minute'), + ('special-bits', 'Special bits (civil warnings, weather forecast)'), + ('call-bit', 'Call bit'), + ('summer-time', 'Summer time announcement'), + ('cest', 'CEST bit'), + ('cet', 'CET bit'), + ('leap-second', 'Leap second bit'), + ('start-of-time', 'Start of encoded time'), + ('minute', 'Minute'), + ('minute-parity', 'Minute parity bit'), + ('hour', 'Hour'), + ('hour-parity', 'Hour parity bit'), + ('day', 'Day of month'), + ('day-of-week', 'Day of week'), + ('month', 'Month'), + ('year', 'Year'), + ('date-parity', 'Date parity bit'), + ('raw-bits', 'Raw bits'), + ('unknown-bits', 'Unknown bits'), + ('warnings', 'Human-readable warnings'), + ) annotation_rows = ( ('bits', 'Bits', (17, 18)), ('fields', 'Fields', tuple(range(0, 16 + 1))), diff --git a/decoders/ds1307/pd.py b/decoders/ds1307/pd.py index 6c36f04..48649bf 100644 --- a/decoders/ds1307/pd.py +++ b/decoders/ds1307/pd.py @@ -44,9 +44,9 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['i2c'] outputs = ['ds1307'] - annotations = [ - ['text', 'Human-readable text'], - ] + annotations = ( + ('text', 'Human-readable text'), + ) def __init__(self, **kwargs): self.state = 'IDLE' diff --git a/decoders/edid/pd.py b/decoders/edid/pd.py index f27cf93..41b7903 100644 --- a/decoders/edid/pd.py +++ b/decoders/edid/pd.py @@ -81,10 +81,10 @@ class Decoder(srd.Decoder): license = 'gplv3+' inputs = ['i2c'] outputs = ['edid'] - annotations = [ - ['fields', 'EDID structure fields'], - ['sections', 'EDID structure sections'], - ] + annotations = ( + ('fields', 'EDID structure fields'), + ('sections', 'EDID structure sections'), + ) def __init__(self, **kwargs): self.state = None diff --git a/decoders/guess_bitrate/pd.py b/decoders/guess_bitrate/pd.py index 8d28444..84cf6a1 100644 --- a/decoders/guess_bitrate/pd.py +++ b/decoders/guess_bitrate/pd.py @@ -29,12 +29,12 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['guess_bitrate'] - probes = [ + probes = ( {'id': 'data', 'name': 'Data', 'desc': 'Data line'}, - ] - annotations = [ - ['bitrate', 'Bitrate / baudrate'], - ] + ) + annotations = ( + ('bitrate', 'Bitrate / baudrate'), + ) def putx(self, data): self.put(self.ss_edge, self.samplenum, self.out_ann, data) diff --git a/decoders/i2c/pd.py b/decoders/i2c/pd.py index 97614ae..1770838 100644 --- a/decoders/i2c/pd.py +++ b/decoders/i2c/pd.py @@ -72,27 +72,27 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['i2c'] - probes = [ + probes = ( {'id': 'scl', 'name': 'SCL', 'desc': 'Serial clock line'}, {'id': 'sda', 'name': 'SDA', 'desc': 'Serial data line'}, - ] + ) options = ( {'id': 'address_format', 'desc': 'Displayed slave address format', 'default': 'shifted', 'values': ('shifted', 'unshifted')}, ) - annotations = [ - ['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'], - ] + annotations = ( + ('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', (5,)), ('addr-data', 'Address/Data', (0, 1, 2, 3, 4, 6, 7, 8, 9)), diff --git a/decoders/i2cdemux/pd.py b/decoders/i2cdemux/pd.py index dd773b5..bfa10db 100644 --- a/decoders/i2cdemux/pd.py +++ b/decoders/i2cdemux/pd.py @@ -29,7 +29,6 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['i2c'] outputs = [] # TODO: Only known at run-time. - annotations = [] def __init__(self, **kwargs): self.packets = [] # Local cache of I²C packets diff --git a/decoders/i2cfilter/pd.py b/decoders/i2cfilter/pd.py index 9156803..8be7828 100644 --- a/decoders/i2cfilter/pd.py +++ b/decoders/i2cfilter/pd.py @@ -37,7 +37,6 @@ class Decoder(srd.Decoder): {'id': 'direction', 'desc': 'Direction to filter', 'default': 'both', 'values': ('read', 'write', 'both')} ) - annotations = [] def __init__(self, **kwargs): self.state = None diff --git a/decoders/i2s/pd.py b/decoders/i2s/pd.py index 1d1a7a4..af2af41 100644 --- a/decoders/i2s/pd.py +++ b/decoders/i2s/pd.py @@ -42,16 +42,16 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['i2s'] - probes = [ + probes = ( {'id': 'sck', 'name': 'SCK', 'desc': 'Bit clock line'}, {'id': 'ws', 'name': 'WS', 'desc': 'Word select line'}, {'id': 'sd', 'name': 'SD', 'desc': 'Serial data line'}, - ] - annotations = [ - ['left', 'Left channel'], - ['right', 'Right channel'], - ['warnings', 'Warnings'], - ] + ) + annotations = ( + ('left', 'Left channel'), + ('right', 'Right channel'), + ('warnings', 'Warnings'), + ) binary = ( ('wav', 'WAV file'), ) diff --git a/decoders/ir_rc5/pd.py b/decoders/ir_rc5/pd.py index a42c86f..dddf937 100644 --- a/decoders/ir_rc5/pd.py +++ b/decoders/ir_rc5/pd.py @@ -30,25 +30,24 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['ir_rc5'] - probes = [ + probes = ( {'id': 'ir', 'name': 'IR', 'desc': 'IR data line'}, - ] - optional_probes = [] + ) options = ( {'id': 'polarity', 'desc': 'Polarity', 'default': 'active-low', 'values': ('active-low', 'active-high')}, {'id': 'protocol', 'desc': 'Protocol type', 'default': 'standard', 'values': ('standard', 'extended')}, ) - annotations = [ - ['bit', 'Bit'], - ['startbit1', 'Startbit 1'], - ['startbit2', 'Startbit 2'], - ['togglebit-0', 'Toggle bit 0'], - ['togglebit-1', 'Toggle bit 1'], - ['address', 'Address'], - ['command', 'Command'], - ] + annotations = ( + ('bit', 'Bit'), + ('startbit1', 'Startbit 1'), + ('startbit2', 'Startbit 2'), + ('togglebit-0', 'Toggle bit 0'), + ('togglebit-1', 'Toggle bit 1'), + ('address', 'Address'), + ('command', 'Command'), + ) annotation_rows = ( ('bits', 'Bits', (0,)), ('fields', 'Fields', (1, 2, 3, 4, 5, 6)), diff --git a/decoders/jtag/pd.py b/decoders/jtag/pd.py index 0bb4069..fec75d6 100644 --- a/decoders/jtag/pd.py +++ b/decoders/jtag/pd.py @@ -62,18 +62,18 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['jtag'] - probes = [ + probes = ( {'id': 'tdi', 'name': 'TDI', 'desc': 'Test data input'}, {'id': 'tdo', 'name': 'TDO', 'desc': 'Test data output'}, {'id': 'tck', 'name': 'TCK', 'desc': 'Test clock'}, {'id': 'tms', 'name': 'TMS', 'desc': 'Test mode select'}, - ] - optional_probes = [ + ) + optional_probes = ( {'id': 'trst', 'name': 'TRST#', 'desc': 'Test reset'}, {'id': 'srst', 'name': 'SRST#', 'desc': 'System reset'}, {'id': 'rtck', 'name': 'RTCK', 'desc': 'Return clock signal'}, - ] - annotations = [[s.lower(), s] for s in jtag_states] + ) + annotations = tuple([tuple([s.lower(), s]) for s in jtag_states]) def __init__(self, **kwargs): # self.state = 'TEST-LOGIC-RESET' diff --git a/decoders/jtag_stm32/pd.py b/decoders/jtag_stm32/pd.py index cc298d6..0acedc8 100644 --- a/decoders/jtag_stm32/pd.py +++ b/decoders/jtag_stm32/pd.py @@ -127,9 +127,9 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['jtag'] outputs = ['jtag_stm32'] - annotations = [ - ['text', 'Human-readable text'], - ] + annotations = ( + ('text', 'Human-readable text'), + ) def __init__(self, **kwargs): self.state = 'IDLE' diff --git a/decoders/lm75/pd.py b/decoders/lm75/pd.py index c492c4b..1fe03a6 100644 --- a/decoders/lm75/pd.py +++ b/decoders/lm75/pd.py @@ -48,24 +48,24 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['i2c'] outputs = ['lm75'] - optional_probes = [ + optional_probes = ( {'id': 'os', 'name': 'OS', 'desc': 'Overtemperature shutdown'}, {'id': 'a0', 'name': 'A0', 'desc': 'I²C slave address input 0'}, {'id': 'a1', 'name': 'A1', 'desc': 'I²C slave address input 1'}, {'id': 'a2', 'name': 'A2', 'desc': 'I²C slave address input 2'}, - ] + ) options = ( {'id': 'sensor', 'desc': 'Sensor type', 'default': 'lm75'}, {'id': 'resolution', 'desc': 'Resolution', 'default': 9, 'values': (9, 10, 11, 12)}, ) - annotations = [ - ['celsius', 'Temperature in degrees Celsius'], - ['kelvin', 'Temperature in Kelvin'], - ['text-verbose', 'Human-readable text (verbose)'], - ['text', 'Human-readable text'], - ['warnings', 'Human-readable warnings'], - ] + annotations = ( + ('celsius', 'Temperature in degrees Celsius'), + ('kelvin', 'Temperature in Kelvin'), + ('text-verbose', 'Human-readable text (verbose)'), + ('text', 'Human-readable text'), + ('warnings', 'Human-readable warnings'), + ) def __init__(self, **kwargs): self.state = 'IDLE' diff --git a/decoders/lpc/pd.py b/decoders/lpc/pd.py index ef782e0..2a12710 100644 --- a/decoders/lpc/pd.py +++ b/decoders/lpc/pd.py @@ -104,15 +104,15 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['lpc'] - probes = [ + probes = ( {'id': 'lframe', 'name': 'LFRAME#', 'desc': 'Frame'}, {'id': 'lclk', 'name': 'LCLK', 'desc': 'Clock'}, {'id': 'lad0', 'name': 'LAD[0]', 'desc': 'Addr/control/data 0'}, {'id': 'lad1', 'name': 'LAD[1]', 'desc': 'Addr/control/data 1'}, {'id': 'lad2', 'name': 'LAD[2]', 'desc': 'Addr/control/data 2'}, {'id': 'lad3', 'name': 'LAD[3]', 'desc': 'Addr/control/data 3'}, - ] - optional_probes = [ + ) + optional_probes = ( {'id': 'lreset', 'name': 'LRESET#', 'desc': 'Reset'}, {'id': 'ldrq', 'name': 'LDRQ#', 'desc': 'Encoded DMA / bus master request'}, {'id': 'serirq', 'name': 'SERIRQ', 'desc': 'Serialized IRQ'}, @@ -120,17 +120,17 @@ class Decoder(srd.Decoder): {'id': 'lpme', 'name': 'LPME#', 'desc': 'LPC power management event'}, {'id': 'lpcpd', 'name': 'LPCPD#', 'desc': 'Power down'}, {'id': 'lsmi', 'name': 'LSMI#', 'desc': 'System Management Interrupt'}, - ] - annotations = [ - ['warnings', 'Warnings'], - ['start', 'Start'], - ['cycle-type', 'Cycle-type/direction'], - ['addr', 'Address'], - ['tar1', 'Turn-around cycle 1'], - ['sync', 'Sync'], - ['data', 'Data'], - ['tar2', 'Turn-around cycle 2'], - ] + ) + annotations = ( + ('warnings', 'Warnings'), + ('start', 'Start'), + ('cycle-type', 'Cycle-type/direction'), + ('addr', 'Address'), + ('tar1', 'Turn-around cycle 1'), + ('sync', 'Sync'), + ('data', 'Data'), + ('tar2', 'Turn-around cycle 2'), + ) annotation_rows = ( ('data', 'Data', (1, 2, 3, 4, 5, 6, 7)), ('warnings', 'Warnings', (0,)), diff --git a/decoders/maxim_ds28ea00/pd.py b/decoders/maxim_ds28ea00/pd.py index 312475e..2492c6b 100644 --- a/decoders/maxim_ds28ea00/pd.py +++ b/decoders/maxim_ds28ea00/pd.py @@ -44,15 +44,15 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['onewire_network'] outputs = ['maxim_ds28ea00'] - optional_probes = [ + optional_probes = ( {'id': 'pioa', 'name': 'PIOA/DONE#', 'desc': 'PIOA channel and chain output'}, {'id': 'piob', 'name': 'PIOB/EN#', 'desc': 'PIOB channel and chain output'}, - ] - annotations = [ - ['text', 'Human-readable text'], - ] + ) + annotations = ( + ('text', 'Human-readable text'), + ) def __init__(self, **kwargs): self.trn_beg = 0 diff --git a/decoders/midi/pd.py b/decoders/midi/pd.py index b6cbd60..5845e03 100644 --- a/decoders/midi/pd.py +++ b/decoders/midi/pd.py @@ -33,9 +33,9 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['uart'] outputs = ['midi'] - annotations = [ - ['text-verbose', 'Human-readable text (verbose)'], - ] + annotations = ( + ('text-verbose', 'Human-readable text (verbose)'), + ) def __init__(self, **kwargs): self.cmd = [] diff --git a/decoders/mlx90614/pd.py b/decoders/mlx90614/pd.py index aa63458..fec3334 100644 --- a/decoders/mlx90614/pd.py +++ b/decoders/mlx90614/pd.py @@ -29,10 +29,10 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['i2c'] outputs = ['mlx90614'] - annotations = [ - ['celsius', 'Temperature in degrees Celsius'], - ['kelvin', 'Temperature in Kelvin'], - ] + annotations = ( + ('celsius', 'Temperature in degrees Celsius'), + ('kelvin', 'Temperature in Kelvin'), + ) def __init__(self, **kwargs): self.state = 'IGNORE START REPEAT' diff --git a/decoders/mx25lxx05d/pd.py b/decoders/mx25lxx05d/pd.py index c7dbd20..2a4fa61 100644 --- a/decoders/mx25lxx05d/pd.py +++ b/decoders/mx25lxx05d/pd.py @@ -55,7 +55,7 @@ device_name = { } def cmd_annotation_classes(): - return [[cmd[0].lower(), cmd[1]] for cmd in cmds.values()] + return tuple([tuple([cmd[0].lower(), cmd[1]]) for cmd in cmds.values()]) def decode_status_reg(data): # TODO: Additional per-bit(s) self.put() calls with correct start/end. @@ -91,15 +91,15 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['spi', 'logic'] outputs = ['mx25lxx05d'] - optional_probes = [ + optional_probes = ( {'id': 'hold', 'name': 'HOLD#', 'desc': 'Pause device w/o deselecting it'}, {'id': 'wp_acc', 'name': 'WP#/ACC', 'desc': 'Write protect'}, - ] - annotations = cmd_annotation_classes() + [ - ['bits', 'Bits'], - ['bits2', 'Bits2'], - ['warnings', 'Warnings'], - ] + ) + annotations = cmd_annotation_classes() + ( + ('bits', 'Bits'), + ('bits2', 'Bits2'), + ('warnings', 'Warnings'), + ) annotation_rows = ( ('bits', 'Bits', (24, 25)), ('commands', 'Commands', tuple(range(23 + 1))), diff --git a/decoders/mxc6225xu/pd.py b/decoders/mxc6225xu/pd.py index c236070..c1a2a81 100644 --- a/decoders/mxc6225xu/pd.py +++ b/decoders/mxc6225xu/pd.py @@ -68,12 +68,12 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['i2c'] outputs = ['mxc6225xu'] - optional_probes = [ + optional_probes = ( {'id': 'int', 'name': 'INT', 'desc': 'DTOS interrupt output pin'}, - ] - annotations = [ - ['text', 'Human-readable text'], - ] + ) + annotations = ( + ('text', 'Human-readable text'), + ) def __init__(self, **kwargs): self.state = 'IDLE' diff --git a/decoders/nunchuk/pd.py b/decoders/nunchuk/pd.py index 5fd01d2..dfe9abe 100644 --- a/decoders/nunchuk/pd.py +++ b/decoders/nunchuk/pd.py @@ -29,11 +29,11 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['i2c'] outputs = ['nunchuck'] - annotations = [ - ['text-verbose', 'Human-readable text (verbose)'], - ['text', 'Human-readable text'], - ['warnings', 'Human-readable warnings'], - ] + annotations = ( + ('text-verbose', 'Human-readable text (verbose)'), + ('text', 'Human-readable text'), + ('warnings', 'Human-readable warnings'), + ) def __init__(self, **kwargs): self.state = 'IDLE' diff --git a/decoders/onewire_link/pd.py b/decoders/onewire_link/pd.py index 38ef8cc..d603dba 100644 --- a/decoders/onewire_link/pd.py +++ b/decoders/onewire_link/pd.py @@ -29,12 +29,12 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['onewire_link'] - probes = [ + probes = ( {'id': 'owr', 'name': 'OWR', 'desc': '1-Wire signal line'}, - ] - optional_probes = [ + ) + optional_probes = ( {'id': 'pwr', 'name': 'PWR', 'desc': '1-Wire power supply pin'}, - ] + ) options = ( {'id': 'overdrive', 'desc': 'Overdrive mode', @@ -65,13 +65,13 @@ class Decoder(srd.Decoder): 'desc': 'Overdrive mode reset time (μs)', 'default': 48}, ) - annotations = [ - ['bit', 'Bit'], - ['warnings', 'Warnings'], - ['reset', 'Reset'], - ['presence', 'Presence'], - ['overdrive', 'Overdrive mode notifications'], - ] + annotations = ( + ('bit', 'Bit'), + ('warnings', 'Warnings'), + ('reset', 'Reset'), + ('presence', 'Presence'), + ('overdrive', 'Overdrive mode notifications'), + ) annotation_rows = ( ('bits', 'Bits', (0, 2, 3)), ('info', 'Info', (4,)), diff --git a/decoders/onewire_network/pd.py b/decoders/onewire_network/pd.py index 3064481..a916572 100644 --- a/decoders/onewire_network/pd.py +++ b/decoders/onewire_network/pd.py @@ -41,9 +41,9 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['onewire_link'] outputs = ['onewire_network'] - annotations = [ - ['text', 'Human-readable text'], - ] + annotations = ( + ('text', 'Human-readable text'), + ) def __init__(self, **kwargs): self.beg = 0 diff --git a/decoders/pan1321/pd.py b/decoders/pan1321/pd.py index e7ccd60..9278ba0 100644 --- a/decoders/pan1321/pd.py +++ b/decoders/pan1321/pd.py @@ -33,11 +33,11 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['uart'] outputs = ['pan1321'] - annotations = [ - ['text-verbose', 'Human-readable text (verbose)'], - ['text', 'Human-readable text'], - ['warnings', 'Human-readable warnings'], - ] + annotations = ( + ('text-verbose', 'Human-readable text (verbose)'), + ('text', 'Human-readable text'), + ('warnings', 'Human-readable warnings'), + ) def __init__(self, **kwargs): self.cmd = ['', ''] diff --git a/decoders/parallel/pd.py b/decoders/parallel/pd.py index 43c5d54..cae269f 100644 --- a/decoders/parallel/pd.py +++ b/decoders/parallel/pd.py @@ -59,7 +59,7 @@ def probe_list(num_probes): for i in range(num_probes): d = {'id': 'd%d' % i, 'name': 'D%d' % i, 'desc': 'Data line %d' % i} l.append(d) - return l + return tuple(l) class Decoder(srd.Decoder): api_version = 1 @@ -79,10 +79,10 @@ class Decoder(srd.Decoder): {'id': 'endianness', 'desc': 'Endianness of the data', 'default': 'little', 'values': ('little', 'big')}, ) - annotations = [ - ['items', 'Items'], - ['words', 'Words'], - ] + annotations = ( + ('items', 'Items'), + ('words', 'Words'), + ) def __init__(self): self.oldclk = None diff --git a/decoders/rgb_led_spi/pd.py b/decoders/rgb_led_spi/pd.py index 1c61122..6840164 100644 --- a/decoders/rgb_led_spi/pd.py +++ b/decoders/rgb_led_spi/pd.py @@ -29,9 +29,9 @@ class Decoder(srd.Decoder): license = 'gplv2' inputs = ['spi'] outputs = ['rgb_led_spi'] - annotations = [ - ['rgb', 'RGB values'], - ] + annotations = ( + ('rgb', 'RGB values'), + ) def __init__(self, **kwargs): self.cmd_ss, self.cmd_es = 0, 0 diff --git a/decoders/rtc8564/pd.py b/decoders/rtc8564/pd.py index 6108c26..41cff0d 100644 --- a/decoders/rtc8564/pd.py +++ b/decoders/rtc8564/pd.py @@ -24,6 +24,13 @@ import sigrokdecode as srd def bcd2int(b): return (b & 0x0f) + ((b >> 4) * 10) +def reg_list(): + l = [] + for i in range(8 + 1): + l.append(('reg-0x%02x' % i, 'Register 0x%02x' % i)) + + return tuple(l) + class Decoder(srd.Decoder): api_version = 1 id = 'rtc8564' @@ -33,21 +40,20 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['i2c'] outputs = ['rtc8564'] - optional_probes = [ + optional_probes = ( {'id': 'clkout', 'name': 'CLKOUT', 'desc': 'Clock output'}, {'id': 'clkoe', 'name': 'CLKOE', 'desc': 'Clock output enable'}, {'id': 'int', 'name': 'INT#', 'desc': 'Interrupt'}, - ] - annotations = \ - [['reg-0x%02x' % i, 'Register 0x%02x' % i] for i in range(8 + 1)] + [ - ['read', 'Read date/time'], - ['write', 'Write date/time'], - ['bit-reserved', 'Reserved bit'], - ['bit-vl', 'VL bit'], - ['bit-century', 'Century bit'], - ['reg-read', 'Register read'], - ['reg-write', 'Register write'], - ] + ) + annotations = reg_list() + ( + ('read', 'Read date/time'), + ('write', 'Write date/time'), + ('bit-reserved', 'Reserved bit'), + ('bit-vl', 'VL bit'), + ('bit-century', 'Century bit'), + ('reg-read', 'Register read'), + ('reg-write', 'Register write'), + ) annotation_rows = ( ('bits', 'Bits', tuple(range(0, 8 + 1)) + (11, 12, 13)), ('regs', 'Register access', (14, 15)), diff --git a/decoders/sdcard_spi/pd.py b/decoders/sdcard_spi/pd.py index c61c8c2..f10e4a0 100644 --- a/decoders/sdcard_spi/pd.py +++ b/decoders/sdcard_spi/pd.py @@ -69,6 +69,13 @@ cmd_name = { 51: 'SEND_SCR', } +def cmd_list(): + l = [] + for i in range(63 + 1): + l.append(('cmd%d' % i, 'CMD%d' % i)) + + return tuple(l) + class Decoder(srd.Decoder): api_version = 1 id = 'sdcard_spi' @@ -78,17 +85,16 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['spi'] outputs = ['sdcard_spi'] - annotations = \ - [['cmd%d' % i, 'CMD%d' % i] for i in range(63 + 1)] + [ - ['cmd-desc', 'Command description'], - ['r1', 'R1 reply'], - ['r1b', 'R1B reply'], - ['r2', 'R2 reply'], - ['r3', 'R3 reply'], - ['r7', 'R7 reply'], - ['bits', 'Bits'], - ['bit-warnings', 'Bit warnings'], - ] + annotations = cmd_list() + ( + ('cmd-desc', 'Command description'), + ('r1', 'R1 reply'), + ('r1b', 'R1B reply'), + ('r2', 'R2 reply'), + ('r3', 'R3 reply'), + ('r7', 'R7 reply'), + ('bits', 'Bits'), + ('bit-warnings', 'Bit warnings'), + ) annotation_rows = ( ('bits', 'Bits', (70, 71)), ('cmd-reply', 'Commands/replies', diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py index 6a2b5fa..d0e3409 100644 --- a/decoders/spi/pd.py +++ b/decoders/spi/pd.py @@ -69,14 +69,14 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['spi'] - probes = [ + probes = ( {'id': 'clk', 'name': 'CLK', 'desc': 'Clock'}, - ] - optional_probes = [ + ) + optional_probes = ( {'id': 'miso', 'name': 'MISO', 'desc': 'Master in, slave out'}, {'id': 'mosi', 'name': 'MOSI', 'desc': 'Master out, slave in'}, {'id': 'cs', 'name': 'CS#', 'desc': 'Chip-select'}, - ] + ) options = ( {'id': 'cs_polarity', 'desc': 'CS# polarity', 'default': 'active-low', 'values': ('active-low', 'active-high')}, @@ -88,13 +88,13 @@ class Decoder(srd.Decoder): 'default': 'msb-first', 'values': ('msb-first', 'lsb-first')}, {'id': 'wordsize', 'desc': 'Word size of SPI data', 'default': 8}, ) - annotations = [ - ['miso-data', 'MISO data'], - ['mosi-data', 'MOSI data'], - ['miso-bits', 'MISO bits'], - ['mosi-bits', 'MOSI bits'], - ['warnings', 'Human-readable warnings'], - ] + annotations = ( + ('miso-data', 'MISO data'), + ('mosi-data', 'MOSI data'), + ('miso-bits', 'MISO bits'), + ('mosi-bits', 'MOSI bits'), + ('warnings', 'Human-readable warnings'), + ) annotation_rows = ( ('miso-data', 'MISO data', (0,)), ('miso-bits', 'MISO bits', (2,)), diff --git a/decoders/tlc5620/pd.py b/decoders/tlc5620/pd.py index b9a5223..6fedf5d 100644 --- a/decoders/tlc5620/pd.py +++ b/decoders/tlc5620/pd.py @@ -36,21 +36,21 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['tlc5620'] - probes = [ + probes = ( {'id': 'clk', 'name': 'CLK', 'desc': 'Serial interface clock'}, {'id': 'data', 'name': 'DATA', 'desc': 'Serial interface data'}, - ] - optional_probes = [ + ) + optional_probes = ( {'id': 'load', 'name': 'LOAD', 'desc': 'Serial interface load control'}, {'id': 'ldac', 'name': 'LDAC', 'desc': 'Load DAC'}, - ] - annotations = [ - ['dac-select', 'DAC select'], - ['gain', 'Gain'], - ['value', 'DAC value'], - ['data-latch', 'Data latch point'], - ['ldac-fall', 'LDAC falling edge'], - ] + ) + annotations = ( + ('dac-select', 'DAC select'), + ('gain', 'Gain'), + ('value', 'DAC value'), + ('data-latch', 'Data latch point'), + ('ldac-fall', 'LDAC falling edge'), + ) def __init__(self, **kwargs): self.oldpins = self.oldclk = self.oldload = self.oldldac = None diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py index 0dd7eb0..6119b8e 100644 --- a/decoders/uart/pd.py +++ b/decoders/uart/pd.py @@ -78,12 +78,12 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['uart'] - optional_probes = [ + optional_probes = ( # Allow specifying only one of the signals, e.g. if only one data # direction exists (or is relevant). {'id': 'rx', 'name': 'RX', 'desc': 'UART receive line'}, {'id': 'tx', 'name': 'TX', 'desc': 'UART transmit line'}, - ] + ) options = ( {'id': 'baudrate', 'desc': 'Baud rate', 'default': 115200}, {'id': 'num_data_bits', 'desc': 'Data bits', 'default': 8, @@ -100,22 +100,22 @@ class Decoder(srd.Decoder): 'values': ('ascii', 'dec', 'hex', 'oct', 'bin')}, # TODO: Options to invert the signal(s). ) - annotations = [ - ['rx-data', 'RX data'], - ['tx-data', 'TX data'], - ['rx-start', 'RX start bits'], - ['tx-start', 'TX start bits'], - ['rx-parity-ok', 'RX parity OK bits'], - ['tx-parity-ok', 'TX parity OK bits'], - ['rx-parity-err', 'RX parity error bits'], - ['tx-parity-err', 'TX parity error bits'], - ['rx-stop', 'RX stop bits'], - ['tx-stop', 'TX stop bits'], - ['rx-warnings', 'RX warnings'], - ['tx-warnings', 'TX warnings'], - ['rx-data-bits', 'RX data bits'], - ['tx-data-bits', 'TX data bits'], - ] + annotations = ( + ('rx-data', 'RX data'), + ('tx-data', 'TX data'), + ('rx-start', 'RX start bits'), + ('tx-start', 'TX start bits'), + ('rx-parity-ok', 'RX parity OK bits'), + ('tx-parity-ok', 'TX parity OK bits'), + ('rx-parity-err', 'RX parity error bits'), + ('tx-parity-err', 'TX parity error bits'), + ('rx-stop', 'RX stop bits'), + ('tx-stop', 'TX stop bits'), + ('rx-warnings', 'RX warnings'), + ('tx-warnings', 'TX warnings'), + ('rx-data-bits', 'RX data bits'), + ('tx-data-bits', 'TX data bits'), + ) annotation_rows = ( ('rx-data', 'RX', (0, 2, 4, 6, 8)), ('rx-data-bits', 'RX bits', (12,)), diff --git a/decoders/usb_packet/pd.py b/decoders/usb_packet/pd.py index 82e5eee..61acd4f 100644 --- a/decoders/usb_packet/pd.py +++ b/decoders/usb_packet/pd.py @@ -154,37 +154,37 @@ class Decoder(srd.Decoder): options = ( {'id': 'signalling', 'desc': 'Signalling', 'default': 'full-speed'}, ) - annotations = [ - ['sync-ok', 'SYNC'], - ['sync-err', 'SYNC (error)'], - ['pid', 'PID'], - ['framenum', 'FRAMENUM'], - ['addr', 'ADDR'], - ['ep', 'EP'], - ['crc5-ok', 'CRC5'], - ['crc5-err', 'CRC5 (error)'], - ['data', 'DATA'], - ['crc16-ok', 'CRC16'], - ['crc16-err', 'CRC16 (error)'], - ['packet-out', 'Packet: OUT'], - ['packet-in', 'Packet: IN'], - ['packet-sof', 'Packet: SOF'], - ['packet-setup', 'Packet: SETUP'], - ['packet-data0', 'Packet: DATA0'], - ['packet-data1', 'Packet: DATA1'], - ['packet-data2', 'Packet: DATA2'], - ['packet-mdata', 'Packet: MDATA'], - ['packet-ack', 'Packet: ACK'], - ['packet-nak', 'Packet: NAK'], - ['packet-stall', 'Packet: STALL'], - ['packet-nyet', 'Packet: NYET'], - ['packet-pre', 'Packet: PRE'], - ['packet-err', 'Packet: ERR'], - ['packet-split', 'Packet: SPLIT'], - ['packet-ping', 'Packet: PING'], - ['packet-reserved', 'Packet: Reserved'], - ['packet-invalid', 'Packet: Invalid'], - ] + annotations = ( + ('sync-ok', 'SYNC'), + ('sync-err', 'SYNC (error)'), + ('pid', 'PID'), + ('framenum', 'FRAMENUM'), + ('addr', 'ADDR'), + ('ep', 'EP'), + ('crc5-ok', 'CRC5'), + ('crc5-err', 'CRC5 (error)'), + ('data', 'DATA'), + ('crc16-ok', 'CRC16'), + ('crc16-err', 'CRC16 (error)'), + ('packet-out', 'Packet: OUT'), + ('packet-in', 'Packet: IN'), + ('packet-sof', 'Packet: SOF'), + ('packet-setup', 'Packet: SETUP'), + ('packet-data0', 'Packet: DATA0'), + ('packet-data1', 'Packet: DATA1'), + ('packet-data2', 'Packet: DATA2'), + ('packet-mdata', 'Packet: MDATA'), + ('packet-ack', 'Packet: ACK'), + ('packet-nak', 'Packet: NAK'), + ('packet-stall', 'Packet: STALL'), + ('packet-nyet', 'Packet: NYET'), + ('packet-pre', 'Packet: PRE'), + ('packet-err', 'Packet: ERR'), + ('packet-split', 'Packet: SPLIT'), + ('packet-ping', 'Packet: PING'), + ('packet-reserved', 'Packet: Reserved'), + ('packet-invalid', 'Packet: Invalid'), + ) annotation_rows = ( ('fields', 'Packet fields', tuple(range(11 + 1))), ('packet', 'Packets', tuple(range(12, 28 + 1))), diff --git a/decoders/usb_signalling/pd.py b/decoders/usb_signalling/pd.py index 823d625..8b98b7e 100644 --- a/decoders/usb_signalling/pd.py +++ b/decoders/usb_signalling/pd.py @@ -75,21 +75,21 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['usb_signalling'] - probes = [ + probes = ( {'id': 'dp', 'name': 'D+', 'desc': 'USB D+ signal'}, {'id': 'dm', 'name': 'D-', 'desc': 'USB D- signal'}, - ] + ) options = ( {'id': 'signalling', 'desc': 'Signalling', 'default': 'full-speed', 'values': ('full-speed', 'low-speed')}, ) - annotations = [ - ['sym', 'Symbol'], - ['sop', 'Start of packet (SOP)'], - ['eop', 'End of packet (EOP)'], - ['bit', 'Bit'], - ['stuffbit', 'Stuff bit'], - ] + annotations = ( + ('sym', 'Symbol'), + ('sop', 'Start of packet (SOP)'), + ('eop', 'End of packet (EOP)'), + ('bit', 'Bit'), + ('stuffbit', 'Stuff bit'), + ) annotation_rows = ( ('bits', 'Bits', (1, 2, 3, 4)), ('symbols', 'Symbols', (0,)), diff --git a/decoders/xfp/pd.py b/decoders/xfp/pd.py index 63e8aec..975215a 100644 --- a/decoders/xfp/pd.py +++ b/decoders/xfp/pd.py @@ -199,10 +199,10 @@ class Decoder(srd.Decoder): license = 'gplv3+' inputs = ['i2c'] outputs = ['xfp'] - annotations = [ - ['fieldnames-and-values', 'XFP structure field names and values'], - ['fields', 'XFP structure fields'], - ] + annotations = ( + ('fieldnames-and-values', 'XFP structure field names and values'), + ('fields', 'XFP structure fields'), + ) def __init__(self, **kwargs): # Received data items, used as an index into samplenum/data diff --git a/decoders/z80/pd.py b/decoders/z80/pd.py index 130b147..f07b76c 100644 --- a/decoders/z80/pd.py +++ b/decoders/z80/pd.py @@ -72,32 +72,36 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['z80'] - probes = [ - {'id': 'd%d' % i, 'name': 'D%d' % i, 'desc': 'Data bus line %d' % i} - for i in range(8) - ] + [ + probes = tuple({ + 'id': 'd%d' % i, + 'name': 'D%d' % i, + 'desc': 'Data bus line %d' % i + } for i in range(8) + ) + ( {'id': 'm1', 'name': '/M1', 'desc': 'Machine cycle 1'}, {'id': 'rd', 'name': '/RD', 'desc': 'Memory or I/O read'}, {'id': 'wr', 'name': '/WR', 'desc': 'Memory or I/O write'}, - ] - optional_probes = [ + ) + optional_probes = ( {'id': 'mreq', 'name': '/MREQ', 'desc': 'Memory request'}, {'id': 'iorq', 'name': '/IORQ', 'desc': 'I/O request'}, - ] + [ - {'id': 'a%d' % i, 'name': 'A%d' % i, 'desc': 'Address bus line %d' % i} - for i in range(16) - ] - annotations = [ - ['addr', 'Memory or I/O address'], - ['memrd', 'Byte read from memory'], - ['memwr', 'Byte written to memory'], - ['iord', 'Byte read from I/O port'], - ['iowr', 'Byte written to I/O port'], - ['instr', 'Z80 CPU instruction'], - ['rop', 'Value of input operand'], - ['wop', 'Value of output operand'], - ['warn', 'Warning message'], - ] + ) + tuple({ + 'id': 'a%d' % i, + 'name': 'A%d' % i, + 'desc': 'Address bus line %d' % i + } for i in range(16) + ) + annotations = ( + ('addr', 'Memory or I/O address'), + ('memrd', 'Byte read from memory'), + ('memwr', 'Byte written to memory'), + ('iord', 'Byte read from I/O port'), + ('iowr', 'Byte written to I/O port'), + ('instr', 'Z80 CPU instruction'), + ('rop', 'Value of input operand'), + ('wop', 'Value of output operand'), + ('warn', 'Warning message'), + ) annotation_rows = ( ('addrbus', 'Address bus', (Ann.ADDR,)), ('databus', 'Data bus', (Ann.MEMRD, Ann.MEMWR, Ann.IORD, Ann.IOWR)),