diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2014-04-13 19:57:43 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2014-04-13 22:00:26 +0200 |
commit | 6a15597a7b3f901b566b7bfc8c484a14e0fb6a11 (patch) | |
tree | ee7241fa022b1b77f61affd373ff8baddb92d404 | |
parent | 486858f7208207fb12a281640c5f6e9be4e4626f (diff) | |
download | libsigrokdecode-6a15597a7b3f901b566b7bfc8c484a14e0fb6a11.tar.gz libsigrokdecode-6a15597a7b3f901b566b7bfc8c484a14e0fb6a11.zip |
Rename 'probe' to 'channel' everywhere.
Variables of type 'struct srd_channel *' are consistently named 'pdch' to
make them easily distinguishable from libsigrok's 'struct sr_channel *'
variables that are consistently named 'ch'.
31 files changed, 238 insertions, 237 deletions
@@ -90,31 +90,31 @@ SRD_API struct srd_decoder *srd_decoder_get_by_id(const char *id) return NULL; } -static int get_probes(const struct srd_decoder *d, const char *attr, - GSList **pl) +static int get_channels(const struct srd_decoder *d, const char *attr, + GSList **pdchl) { - PyObject *py_probelist, *py_entry; - struct srd_probe *p; - int ret, num_probes, i; + PyObject *py_channellist, *py_entry; + struct srd_channel *pdch; + int ret, num_channels, i; if (!PyObject_HasAttrString(d->py_dec, attr)) - /* No probes of this type specified. */ + /* No channels of this type specified. */ return SRD_OK; - py_probelist = PyObject_GetAttrString(d->py_dec, attr); - if (!PyTuple_Check(py_probelist)) { + py_channellist = PyObject_GetAttrString(d->py_dec, attr); + if (!PyTuple_Check(py_channellist)) { srd_err("Protocol decoder %s %s attribute is not a tuple.", d->name, attr); return SRD_ERR_PYTHON; } - if ((num_probes = PyTuple_Size(py_probelist)) == 0) - /* Empty probelist. */ + if ((num_channels = PyTuple_Size(py_channellist)) == 0) + /* Empty channellist. */ return SRD_OK; ret = SRD_OK; - for (i = 0; i < num_probes; i++) { - py_entry = PyTuple_GetItem(py_probelist, i); + for (i = 0; i < num_channels; i++) { + py_entry = PyTuple_GetItem(py_channellist, i); if (!PyDict_Check(py_entry)) { srd_err("Protocol decoder %s %s attribute is not " "a list with dict elements.", d->name, attr); @@ -122,30 +122,30 @@ static int get_probes(const struct srd_decoder *d, const char *attr, break; } - if (!(p = g_try_malloc(sizeof(struct srd_probe)))) { - srd_err("Failed to g_malloc() struct srd_probe."); + if (!(pdch = g_try_malloc(sizeof(struct srd_channel)))) { + srd_err("Failed to g_malloc() struct srd_channel."); ret = SRD_ERR_MALLOC; break; } - if ((py_dictitem_as_str(py_entry, "id", &p->id)) != SRD_OK) { + if ((py_dictitem_as_str(py_entry, "id", &pdch->id)) != SRD_OK) { ret = SRD_ERR_PYTHON; break; } - if ((py_dictitem_as_str(py_entry, "name", &p->name)) != SRD_OK) { + if ((py_dictitem_as_str(py_entry, "name", &pdch->name)) != SRD_OK) { ret = SRD_ERR_PYTHON; break; } - if ((py_dictitem_as_str(py_entry, "desc", &p->desc)) != SRD_OK) { + if ((py_dictitem_as_str(py_entry, "desc", &pdch->desc)) != SRD_OK) { ret = SRD_ERR_PYTHON; break; } - p->order = i; + pdch->order = i; - *pl = g_slist_append(*pl, p); + *pdchl = g_slist_append(*pdchl, pdch); } - Py_DecRef(py_probelist); + Py_DecRef(py_channellist); return ret; } @@ -302,7 +302,7 @@ SRD_API int srd_decoder_load(const char *module_name) struct srd_decoder *d; int ret, i, j; char **ann, **bin, *ann_row_id, *ann_row_desc; - struct srd_probe *p; + struct srd_channel *pdch; GSList *l, *ann_classes; struct srd_decoder_annotation_row *ann_row; @@ -404,25 +404,25 @@ SRD_API int srd_decoder_load(const char *module_name) if (get_options(d) != SRD_OK) goto err_out; - /* Check and import required probes. */ - if (get_probes(d, "probes", &d->probes) != SRD_OK) + /* Check and import required channels. */ + if (get_channels(d, "channels", &d->channels) != SRD_OK) goto err_out; - /* Check and import optional probes. */ - if (get_probes(d, "optional_probes", &d->opt_probes) != SRD_OK) + /* Check and import optional channels. */ + if (get_channels(d, "optional_channels", &d->opt_channels) != SRD_OK) goto err_out; /* - * Fix order numbers for the optional probes. + * Fix order numbers for the optional channels. * * Example: - * Required probes: r1, r2, r3. Optional: o1, o2, o3, o4. - * 'order' fields in the d->probes list = 0, 1, 2. - * 'order' fields in the d->opt_probes list = 3, 4, 5, 6. + * Required channels: r1, r2, r3. Optional: o1, o2, o3, o4. + * 'order' fields in the d->channels list = 0, 1, 2. + * 'order' fields in the d->opt_channels list = 3, 4, 5, 6. */ - for (l = d->opt_probes; l; l = l->next) { - p = l->data; - p->order += g_slist_length(d->probes); + for (l = d->opt_channels; l; l = l->next) { + pdch = l->data; + pdch->order += g_slist_length(d->channels); } /* Convert annotation class attribute to GSList of char **. */ @@ -587,22 +587,22 @@ SRD_API char *srd_decoder_doc_get(const struct srd_decoder *dec) return doc; } -static void free_probes(GSList *probelist) +static void free_channels(GSList *channellist) { GSList *l; - struct srd_probe *p; + struct srd_channel *pdch; - if (probelist == NULL) + if (channellist == NULL) return; - for (l = probelist; l; l = l->next) { - p = l->data; - g_free(p->id); - g_free(p->name); - g_free(p->desc); - g_free(p); + for (l = channellist; l; l = l->next) { + pdch = l->data; + g_free(pdch->id); + g_free(pdch->name); + g_free(pdch->desc); + g_free(pdch); } - g_slist_free(probelist); + g_slist_free(channellist); } /** @@ -648,8 +648,8 @@ SRD_API int srd_decoder_unload(struct srd_decoder *dec) } g_slist_free(dec->options); - free_probes(dec->probes); - free_probes(dec->opt_probes); + free_channels(dec->channels); + free_channels(dec->opt_channels); g_free(dec->id); g_free(dec->name); g_free(dec->longname); diff --git a/decoders/can/pd.py b/decoders/can/pd.py index af8168c..bcc4361 100644 --- a/decoders/can/pd.py +++ b/decoders/can/pd.py @@ -29,7 +29,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['can'] - probes = ( + channels = ( {'id': 'can_rx', 'name': 'CAN RX', 'desc': 'CAN bus line'}, ) options = ( diff --git a/decoders/dcf77/pd.py b/decoders/dcf77/pd.py index 7cc85f6..69783c6 100644 --- a/decoders/dcf77/pd.py +++ b/decoders/dcf77/pd.py @@ -34,7 +34,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['dcf77'] - probes = ( + channels = ( {'id': 'data', 'name': 'DATA', 'desc': 'DATA line'}, ) annotations = ( diff --git a/decoders/edid/test/test.conf b/decoders/edid/test/test.conf index aff116c..2f3eb4c 100644 --- a/decoders/edid/test/test.conf +++ b/decoders/edid/test/test.conf @@ -1,5 +1,5 @@ test tv - protocol-decoder i2c probe scl=0 probe sda=1 + protocol-decoder i2c channel scl=0 channel sda=1 protocol-decoder edid stack i2c edid input i2c/edid/samsung_le46b620r3p.sr diff --git a/decoders/guess_bitrate/__init__.py b/decoders/guess_bitrate/__init__.py index 86f9466..9c7e6a4 100644 --- a/decoders/guess_bitrate/__init__.py +++ b/decoders/guess_bitrate/__init__.py @@ -20,7 +20,7 @@ ''' This protocol decoder tries to guess the bitrate / baudrate of the -communication on the specified probe. Typically this will be used to +communication on the specified channel. Typically this will be used to guess / detect the baudrate used in a UART communication snippet, but it could also be used to guess bitrates of certain other protocols or buses. @@ -29,9 +29,9 @@ and that there are various cases in practice where the detection of the bitrate or baudrate will not necessarily have the expected result. The precision of the estimated bitrate / baudrate will also depend on the -samplerate used to sample the respective probe. For good results it is +samplerate used to sample the respective channel. For good results it is recommended to use a logic analyzer samplerate that is much higher than -the expected bitrate/baudrate that might be used on the probe. +the expected bitrate/baudrate that might be used on the channel. ''' from .pd import * diff --git a/decoders/guess_bitrate/pd.py b/decoders/guess_bitrate/pd.py index 84cf6a1..d2d7c39 100644 --- a/decoders/guess_bitrate/pd.py +++ b/decoders/guess_bitrate/pd.py @@ -29,7 +29,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['guess_bitrate'] - probes = ( + channels = ( {'id': 'data', 'name': 'Data', 'desc': 'Data line'}, ) annotations = ( diff --git a/decoders/i2c/pd.py b/decoders/i2c/pd.py index 1770838..6bf12b9 100644 --- a/decoders/i2c/pd.py +++ b/decoders/i2c/pd.py @@ -72,7 +72,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['i2c'] - probes = ( + channels = ( {'id': 'scl', 'name': 'SCL', 'desc': 'Serial clock line'}, {'id': 'sda', 'name': 'SDA', 'desc': 'Serial data line'}, ) diff --git a/decoders/i2c/test/test.conf b/decoders/i2c/test/test.conf index 880f360..bd1068b 100644 --- a/decoders/i2c/test/test.conf +++ b/decoders/i2c/test/test.conf @@ -1,5 +1,5 @@ test rtc - protocol-decoder i2c probe scl=0 probe sda=1 + protocol-decoder i2c channel scl=0 channel sda=1 input i2c/rtc_dallas_ds1307/rtc_ds1307_200khz.sr output i2c annotation class data-read match rtc_ds1307_200khz_data_read.output output i2c annotation class data-write match rtc_ds1307_200khz_data_write.output @@ -7,13 +7,13 @@ test rtc output i2c python match rtc_ds1307_200khz.python test motherboard - protocol-decoder i2c probe scl=0 probe sda=3 + protocol-decoder i2c channel scl=0 channel sda=3 input i2c/gigabyte_6vle-vxl_i2c/gigabyte_6vle_vxl_i2c.sr output i2c annotation match gigabyte_6vle_vxl_i2c.output output i2c python match gigabyte_6vle_vxl_i2c.python test xfp - protocol-decoder i2c probe scl=0 probe sda=1 + protocol-decoder i2c channel scl=0 channel sda=1 input i2c/network-transceivers/xfp.sr output i2c binary class data-read match xfp_data_read.binary output i2c binary class data-write match xfp_data_write.binary diff --git a/decoders/i2s/pd.py b/decoders/i2s/pd.py index af2af41..eb6a560 100644 --- a/decoders/i2s/pd.py +++ b/decoders/i2s/pd.py @@ -42,7 +42,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['i2s'] - probes = ( + channels = ( {'id': 'sck', 'name': 'SCK', 'desc': 'Bit clock line'}, {'id': 'ws', 'name': 'WS', 'desc': 'Word select line'}, {'id': 'sd', 'name': 'SD', 'desc': 'Serial data line'}, diff --git a/decoders/ir_nec/pd.py b/decoders/ir_nec/pd.py index b01af9e..53246dd 100644 --- a/decoders/ir_nec/pd.py +++ b/decoders/ir_nec/pd.py @@ -30,7 +30,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['ir_nec'] - probes = ( + channels = ( {'id': 'ir', 'name': 'IR', 'desc': 'Data line'}, ) options = ( diff --git a/decoders/ir_rc5/pd.py b/decoders/ir_rc5/pd.py index dddf937..1962459 100644 --- a/decoders/ir_rc5/pd.py +++ b/decoders/ir_rc5/pd.py @@ -30,7 +30,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['ir_rc5'] - probes = ( + channels = ( {'id': 'ir', 'name': 'IR', 'desc': 'IR data line'}, ) options = ( diff --git a/decoders/jtag/pd.py b/decoders/jtag/pd.py index fec75d6..21bd44b 100644 --- a/decoders/jtag/pd.py +++ b/decoders/jtag/pd.py @@ -62,13 +62,13 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['jtag'] - probes = ( + channels = ( {'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_channels = ( {'id': 'trst', 'name': 'TRST#', 'desc': 'Test reset'}, {'id': 'srst', 'name': 'SRST#', 'desc': 'System reset'}, {'id': 'rtck', 'name': 'RTCK', 'desc': 'Return clock signal'}, @@ -200,7 +200,7 @@ class Decoder(srd.Decoder): self.oldpins = pins # Get individual pin values into local variables. - # Unused probes will have a value of > 1. + # Unused channels will have a value of > 1. (tdi, tdo, tck, tms, trst, srst, rtck) = pins # We only care about TCK edges (either rising or falling). diff --git a/decoders/lpc/pd.py b/decoders/lpc/pd.py index 2a12710..2ca6be1 100644 --- a/decoders/lpc/pd.py +++ b/decoders/lpc/pd.py @@ -104,7 +104,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['lpc'] - probes = ( + channels = ( {'id': 'lframe', 'name': 'LFRAME#', 'desc': 'Frame'}, {'id': 'lclk', 'name': 'LCLK', 'desc': 'Clock'}, {'id': 'lad0', 'name': 'LAD[0]', 'desc': 'Addr/control/data 0'}, @@ -112,7 +112,7 @@ class Decoder(srd.Decoder): {'id': 'lad2', 'name': 'LAD[2]', 'desc': 'Addr/control/data 2'}, {'id': 'lad3', 'name': 'LAD[3]', 'desc': 'Addr/control/data 3'}, ) - optional_probes = ( + optional_channels = ( {'id': 'lreset', 'name': 'LRESET#', 'desc': 'Reset'}, {'id': 'ldrq', 'name': 'LDRQ#', 'desc': 'Encoded DMA / bus master request'}, {'id': 'serirq', 'name': 'SERIRQ', 'desc': 'Serialized IRQ'}, diff --git a/decoders/mx25lxx05d/test/test.conf b/decoders/mx25lxx05d/test/test.conf index 20162fd..0541903 100644 --- a/decoders/mx25lxx05d/test/test.conf +++ b/decoders/mx25lxx05d/test/test.conf @@ -1,5 +1,5 @@ test probe - protocol-decoder spi probe cs=0 probe miso=1 probe clk=2 probe mosi=3 + protocol-decoder spi channel cs=0 channel miso=1 channel clk=2 channel mosi=3 protocol-decoder mx25lxx05d stack spi mx25lxx05d input spi/mx25l1605d/mx25l1605d_probe.sr diff --git a/decoders/onewire_link/__init__.py b/decoders/onewire_link/__init__.py index 5bd6c55..d153f93 100644 --- a/decoders/onewire_link/__init__.py +++ b/decoders/onewire_link/__init__.py @@ -37,7 +37,7 @@ overdrive communication speed. The following minimal values should be used: - overdrive available: 2MHz minimum, 5MHz suggested - overdrive not available: 400kHz minimum, 1MHz suggested -Probes: +Channels: 1-Wire requires a single signal, but some master implementations might have a separate signal used to deliver power to the bus during temperature conversion as an example. This power signal is currently not used. diff --git a/decoders/onewire_link/pd.py b/decoders/onewire_link/pd.py index ceb5da2..aa1cb2e 100644 --- a/decoders/onewire_link/pd.py +++ b/decoders/onewire_link/pd.py @@ -29,10 +29,10 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['onewire_link'] - probes = ( + channels = ( {'id': 'owr', 'name': 'OWR', 'desc': '1-Wire signal line'}, ) - optional_probes = ( + optional_channels = ( {'id': 'pwr', 'name': 'PWR', 'desc': '1-Wire power supply pin'}, ) options = ( diff --git a/decoders/parallel/__init__.py b/decoders/parallel/__init__.py index ea55077..cc1f3d1 100644 --- a/decoders/parallel/__init__.py +++ b/decoders/parallel/__init__.py @@ -20,14 +20,14 @@ ''' This protocol decoder can decode synchronous parallel buses with various -number of data bits/probes and one (optional) clock line. +number of data bits/channels and one (optional) clock line. If no clock line is supplied, the decoder works slightly differently in -that it interprets every transition on any of the supplied data probes +that it interprets every transition on any of the supplied data channels like there had been a clock transition. -It is required to use the lowest data probes, and use consecutive ones. -For example, for a 4-bit sync parallel bus, probes D0/D1/D2/D3 (and CLK) +It is required to use the lowest data channels, and use consecutive ones. +For example, for a 4-bit sync parallel bus, channels D0/D1/D2/D3 (and CLK) should be used. Using combinations like D7/D12/D3/D15 is not supported. For an 8-bit bus you should use D0-D7, for a 16-bit bus use D0-D15 and so on. ''' diff --git a/decoders/parallel/pd.py b/decoders/parallel/pd.py index 330d514..094b12a 100644 --- a/decoders/parallel/pd.py +++ b/decoders/parallel/pd.py @@ -54,9 +54,9 @@ Packet: word <worditemcount> is 7, and so on. ''' -def probe_list(num_probes): +def channel_list(num_channels): l = [{'id': 'clk', 'name': 'CLK', 'desc': 'Clock line'}] - for i in range(num_probes): + for i in range(num_channels): d = {'id': 'd%d' % i, 'name': 'D%d' % i, 'desc': 'Data line %d' % i} l.append(d) return tuple(l) @@ -70,7 +70,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['parallel'] - optional_probes = probe_list(8) + optional_channels = channel_list(8) options = ( {'id': 'clock_edge', 'desc': 'Clock edge to sample on', 'default': 'rising', 'values': ('rising', 'falling')}, diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py index 7d84b3d..b1a8704 100644 --- a/decoders/spi/pd.py +++ b/decoders/spi/pd.py @@ -31,7 +31,7 @@ Commands: - 'DATA': <data1> contains the MISO data, <data2> contains the MOSI data. The data is _usually_ 8 bits (but can also be fewer or more bits). Both data items are Python numbers (not strings), or None if the respective - probe was not supplied. + channel was not supplied. - 'BITS': <data1>/<data2> contain a list of bit values in this MISO/MOSI data item, and for each of those also their respective start-/endsample numbers. - 'CS CHANGE': <data1> is the old CS# pin value, <data2> is the new value. @@ -69,10 +69,10 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['spi'] - probes = ( + channels = ( {'id': 'clk', 'name': 'CLK', 'desc': 'Clock'}, ) - optional_probes = ( + optional_channels = ( {'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'}, diff --git a/decoders/spi/test/test.conf b/decoders/spi/test/test.conf index d5531b1..e08b788 100644 --- a/decoders/spi/test/test.conf +++ b/decoders/spi/test/test.conf @@ -1,11 +1,11 @@ test atmega32_00 - protocol-decoder spi probe cs=0 probe mosi=1 probe clk=2 + protocol-decoder spi channel cs=0 channel mosi=1 channel clk=2 input spi/spi_atmega32/spi_atmega32_00.sr output spi annotation class mosi-data match atmega32_00_mosi.output output spi annotation class miso-data match atmega32_00_miso.output test mx25l1605d_probe - protocol-decoder spi probe cs=0 probe miso=1 probe clk=2 probe mosi=3 + protocol-decoder spi channel cs=0 channel miso=1 channel clk=2 channel mosi=3 input spi/mx25l1605d/mx25l1605d_probe.sr output spi annotation class mosi-data match mx25l1605d_probe_mosi.output output spi annotation class miso-data match mx25l1605d_probe_miso.output diff --git a/decoders/tlc5620/pd.py b/decoders/tlc5620/pd.py index 6fedf5d..7961154 100644 --- a/decoders/tlc5620/pd.py +++ b/decoders/tlc5620/pd.py @@ -36,11 +36,11 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['tlc5620'] - probes = ( + channels = ( {'id': 'clk', 'name': 'CLK', 'desc': 'Serial interface clock'}, {'id': 'data', 'name': 'DATA', 'desc': 'Serial interface data'}, ) - optional_probes = ( + optional_channels = ( {'id': 'load', 'name': 'LOAD', 'desc': 'Serial interface load control'}, {'id': 'ldac', 'name': 'LDAC', 'desc': 'Load DAC'}, ) diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py index 6119b8e..57031d7 100644 --- a/decoders/uart/pd.py +++ b/decoders/uart/pd.py @@ -78,7 +78,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['uart'] - optional_probes = ( + optional_channels = ( # 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'}, diff --git a/decoders/uart/test/test.conf b/decoders/uart/test/test.conf index b5f0f0d..f15b04b 100644 --- a/decoders/uart/test/test.conf +++ b/decoders/uart/test/test.conf @@ -1,5 +1,5 @@ test trekstor_ebr30_a - protocol-decoder uart probe rx=1 + protocol-decoder uart channel rx=1 input uart/trekstor_ebr30_a/trekstor_ebr30_a_uart.sr output uart annotation class rx-data match trekstor_rx.output output uart annotation class tx-data match trekstor_tx.output diff --git a/decoders/usb_signalling/pd.py b/decoders/usb_signalling/pd.py index deecf1a..e63817e 100644 --- a/decoders/usb_signalling/pd.py +++ b/decoders/usb_signalling/pd.py @@ -82,7 +82,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['usb_signalling'] - probes = ( + channels = ( {'id': 'dp', 'name': 'D+', 'desc': 'USB D+ signal'}, {'id': 'dm', 'name': 'D-', 'desc': 'USB D- signal'}, ) diff --git a/decoders/z80/pd.py b/decoders/z80/pd.py index f6bafb1..299a20e 100644 --- a/decoders/z80/pd.py +++ b/decoders/z80/pd.py @@ -56,7 +56,7 @@ ann_data_cycle_map = { def reduce_bus(bus): if 0xFF in bus: - return None # unassigned bus probes + return None # unassigned bus channels else: return reduce(lambda a, b: (a << 1) | b, reversed(bus)) @@ -72,7 +72,7 @@ class Decoder(srd.Decoder): license = 'gplv3+' inputs = ['logic'] outputs = ['z80'] - probes = tuple({ + channels = tuple({ 'id': 'd%d' % i, 'name': 'D%d' % i, 'desc': 'Data bus line %d' % i @@ -82,7 +82,7 @@ class Decoder(srd.Decoder): {'id': 'rd', 'name': '/RD', 'desc': 'Memory or I/O read'}, {'id': 'wr', 'name': '/WR', 'desc': 'Memory or I/O write'}, ) - optional_probes = ( + optional_channels = ( {'id': 'mreq', 'name': '/MREQ', 'desc': 'Memory request'}, {'id': 'iorq', 'name': '/IORQ', 'desc': 'I/O request'}, ) + tuple({ @@ -169,122 +169,123 @@ err_out: return ret; } -/* Helper GComparefunc for g_slist_find_custom() in srd_inst_probe_set_all() */ -static gint compare_probe_id(const struct srd_probe *a, const char *probe_id) +/* Helper GComparefunc for g_slist_find_custom() in srd_inst_channel_set_all() */ +static gint compare_channel_id(const struct srd_channel *pdch, + const char *channel_id) { - return strcmp(a->id, probe_id); + return strcmp(pdch->id, channel_id); } /** - * Set all probes in a decoder instance. + * Set all channels in a decoder instance. * - * This function sets _all_ probes for the specified decoder instance, i.e., - * it overwrites any probes that were already defined (if any). + * This function sets _all_ channels for the specified decoder instance, i.e., + * it overwrites any channels that were already defined (if any). * * @param di Decoder instance. - * @param new_probes A GHashTable of probes to set. Key is probe name, value is - * the probe number. Samples passed to this instance will be - * arranged in this order. + * @param new_channels A GHashTable of channels to set. Key is channel name, + * value is the channel number. Samples passed to this + * instance will be arranged in this order. * @param unit_size Number of bytes per sample in the data stream to be passed - * to the decoder. The highest probe index specified in the - * probe map must lie within a sample unit. + * to the decoder. The highest channel index specified in the + * channel map must lie within a sample unit. * * @return SRD_OK upon success, a (negative) error code otherwise. * * @since 0.1.0 */ -SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di, - GHashTable *new_probes, int unit_size) +SRD_API int srd_inst_channel_set_all(struct srd_decoder_inst *di, + GHashTable *new_channels, int unit_size) { - GVariant *probe_val; + GVariant *channel_val; GList *l; GSList *sl; - struct srd_probe *p; - int *new_probemap, new_probenum, num_required_probes, i; - char *probe_id; + struct srd_channel *pdch; + int *new_channelmap, new_channelnum, num_required_channels, i; + char *channel_id; - srd_dbg("set probes called for instance %s with list of %d probes", - di->inst_id, g_hash_table_size(new_probes)); + srd_dbg("set channels called for instance %s with list of %d channels", + di->inst_id, g_hash_table_size(new_channels)); - if (g_hash_table_size(new_probes) == 0) - /* No probes provided. */ + if (g_hash_table_size(new_channels) == 0) + /* No channels provided. */ return SRD_OK; - if (di->dec_num_probes == 0) { - /* Decoder has no probes. */ - srd_err("Protocol decoder %s has no probes to define.", + if (di->dec_num_channels == 0) { + /* Decoder has no channels. */ + srd_err("Protocol decoder %s has no channels to define.", di->decoder->name); return SRD_ERR_ARG; } - new_probemap = NULL; + new_channelmap = NULL; - if (!(new_probemap = g_try_malloc(sizeof(int) * di->dec_num_probes))) { - srd_err("Failed to g_malloc() new probe map."); + if (!(new_channelmap = g_try_malloc(sizeof(int) * di->dec_num_channels))) { + srd_err("Failed to g_malloc() new channel map."); return SRD_ERR_MALLOC; } /* - * For now, map all indexes to probe -1 (can be overridden later). - * This -1 is interpreted as an unspecified probe later. + * For now, map all indexes to channel -1 (can be overridden later). + * This -1 is interpreted as an unspecified channel later. */ - for (i = 0; i < di->dec_num_probes; i++) - new_probemap[i] = -1; - - for (l = g_hash_table_get_keys(new_probes); l; l = l->next) { - probe_id = l->data; - probe_val = g_hash_table_lookup(new_probes, probe_id); - if (!g_variant_is_of_type(probe_val, G_VARIANT_TYPE_INT32)) { - /* Probe name was specified without a value. */ - srd_err("No probe number was specified for %s.", - probe_id); - g_free(new_probemap); + for (i = 0; i < di->dec_num_channels; i++) + new_channelmap[i] = -1; + + for (l = g_hash_table_get_keys(new_channels); l; l = l->next) { + channel_id = l->data; + channel_val = g_hash_table_lookup(new_channels, channel_id); + if (!g_variant_is_of_type(channel_val, G_VARIANT_TYPE_INT32)) { + /* Channel name was specified without a value. */ + srd_err("No channel number was specified for %s.", + channel_id); + g_free(new_channelmap); return SRD_ERR_ARG; } - new_probenum = g_variant_get_int32(probe_val); - if (new_probenum >= 8 * unit_size) { - srd_err("Probe index %d not within data unit (%d bit).", - new_probenum, 8 * unit_size); - g_free(new_probemap); + new_channelnum = g_variant_get_int32(channel_val); + if (new_channelnum >= 8 * unit_size) { + srd_err("Channel index %d not within data unit (%d bit).", + new_channelnum, 8 * unit_size); + g_free(new_channelmap); return SRD_ERR_ARG; } - if (!(sl = g_slist_find_custom(di->decoder->probes, probe_id, - (GCompareFunc)compare_probe_id))) { - /* Fall back on optional probes. */ - if (!(sl = g_slist_find_custom(di->decoder->opt_probes, - probe_id, (GCompareFunc) compare_probe_id))) { - srd_err("Protocol decoder %s has no probe " - "'%s'.", di->decoder->name, probe_id); - g_free(new_probemap); + if (!(sl = g_slist_find_custom(di->decoder->channels, channel_id, + (GCompareFunc)compare_channel_id))) { + /* Fall back on optional channels. */ + if (!(sl = g_slist_find_custom(di->decoder->opt_channels, + channel_id, (GCompareFunc) compare_channel_id))) { + srd_err("Protocol decoder %s has no channel " + "'%s'.", di->decoder->name, channel_id); + g_free(new_channelmap); return SRD_ERR_ARG; } } - p = sl->data; - new_probemap[p->order] = new_probenum; - srd_dbg("Setting probe mapping: %s (index %d) = probe %d.", - p->id, p->order, new_probenum); + pdch = sl->data; + new_channelmap[pdch->order] = new_channelnum; + srd_dbg("Setting channel mapping: %s (index %d) = channel %d.", + pdch->id, pdch->order, new_channelnum); } di->data_unitsize = unit_size; - srd_dbg("Final probe map:"); - num_required_probes = g_slist_length(di->decoder->probes); - for (i = 0; i < di->dec_num_probes; i++) { - srd_dbg(" - index %d = probe %d (%s)", i, new_probemap[i], - (i < num_required_probes) ? "required" : "optional"); + srd_dbg("Final channel map:"); + num_required_channels = g_slist_length(di->decoder->channels); + for (i = 0; i < di->dec_num_channels; i++) { + srd_dbg(" - index %d = channel %d (%s)", i, new_channelmap[i], + (i < num_required_channels) ? "required" : "optional"); } - /* Report an error if not all required probes were specified. */ - for (i = 0; i < num_required_probes; i++) { - if (new_probemap[i] != -1) + /* Report an error if not all required channels were specified. */ + for (i = 0; i < num_required_channels; i++) { + if (new_channelmap[i] != -1) continue; - p = g_slist_nth(di->decoder->probes, i)->data; - srd_err("Required probe '%s' (index %d) was not specified.", - p->id, i); + pdch = g_slist_nth(di->decoder->channels, i)->data; + srd_err("Required channel '%s' (index %d) was not specified.", + pdch->id, i); return SRD_ERR; } - g_free(di->dec_probemap); - di->dec_probemap = new_probemap; + g_free(di->dec_channelmap); + di->dec_channelmap = new_channelmap; return SRD_OK; } @@ -337,28 +338,28 @@ SRD_API struct srd_decoder_inst *srd_inst_new(struct srd_session *sess, di->inst_id = g_strdup(decoder_id); /* - * Prepare a default probe map, where samples come in the + * Prepare a default channel map, where samples come in the * order in which the decoder class defined them. */ - di->dec_num_probes = g_slist_length(di->decoder->probes) + - g_slist_length(di->decoder->opt_probes); - if (di->dec_num_probes) { - if (!(di->dec_probemap = - g_try_malloc(sizeof(int) * di->dec_num_probes))) { - srd_err("Failed to g_malloc() probe map."); + di->dec_num_channels = g_slist_length(di->decoder->channels) + + g_slist_length(di->decoder->opt_channels); + if (di->dec_num_channels) { + if (!(di->dec_channelmap = + g_try_malloc(sizeof(int) * di->dec_num_channels))) { + srd_err("Failed to g_malloc() channel map."); g_free(di); return NULL; } - for (i = 0; i < di->dec_num_probes; i++) - di->dec_probemap[i] = i; - di->data_unitsize = (di->dec_num_probes + 7) / 8; + for (i = 0; i < di->dec_num_channels; i++) + di->dec_channelmap[i] = i; + di->data_unitsize = (di->dec_num_channels + 7) / 8; /* * Will be used to prepare a sample at every iteration * of the instance's decode() method. */ - if (!(di->probe_samples = g_try_malloc(di->dec_num_probes))) { + if (!(di->channel_samples = g_try_malloc(di->dec_num_channels))) { srd_err("Failed to g_malloc() sample buffer."); - g_free(di->dec_probemap); + g_free(di->dec_channelmap); g_free(di); return NULL; } @@ -369,13 +370,13 @@ SRD_API struct srd_decoder_inst *srd_inst_new(struct srd_session *sess, if (PyErr_Occurred()) srd_exception_catch("failed to create %s instance: ", decoder_id); - g_free(di->dec_probemap); + g_free(di->dec_channelmap); g_free(di); return NULL; } if (options && srd_inst_option_set(di, options) != SRD_OK) { - g_free(di->dec_probemap); + g_free(di->dec_channelmap); g_free(di); return NULL; } @@ -624,7 +625,7 @@ SRD_PRIV void srd_inst_free(struct srd_decoder_inst *di) Py_DecRef(di->py_inst); g_free(di->inst_id); - g_free(di->dec_probemap); + g_free(di->dec_channelmap); g_slist_free(di->next_di); for (l = di->pd_output; l; l = l->next) { pdo = l->data; diff --git a/libsigrokdecode.h b/libsigrokdecode.h index f07e1ee..4476f79 100644 --- a/libsigrokdecode.h +++ b/libsigrokdecode.h @@ -156,11 +156,11 @@ struct srd_decoder { */ char *license; - /** List of probes required by this decoder. */ - GSList *probes; + /** List of channels required by this decoder. */ + GSList *channels; - /** List of optional probes for this decoder. */ - GSList *opt_probes; + /** List of optional channels for this decoder. */ + GSList *opt_channels; /** * List of NULL-terminated char[], containing descriptions of the @@ -191,17 +191,17 @@ struct srd_decoder { }; /** - * Structure which contains information about one protocol decoder probe. - * For example, I2C has two probes, SDA and SCL. + * Structure which contains information about one protocol decoder channel. + * For example, I2C has two channels, SDA and SCL. */ -struct srd_probe { - /** The ID of the probe. Must be non-NULL. */ +struct srd_channel { + /** The ID of the channel. Must be non-NULL. */ char *id; - /** The name of the probe. Must not be NULL. */ + /** The name of the channel. Must not be NULL. */ char *name; - /** The description of the probe. Must not be NULL. */ + /** The description of the channel. Must not be NULL. */ char *desc; - /** The index of the probe, i.e. its order in the list of probes. */ + /** The index of the channel, i.e. its order in the list of channels. */ int order; }; @@ -224,10 +224,10 @@ struct srd_decoder_inst { PyObject *py_inst; char *inst_id; GSList *pd_output; - int dec_num_probes; - int *dec_probemap; + int dec_num_channels; + int *dec_channelmap; int data_unitsize; - uint8_t *probe_samples; + uint8_t *channel_samples; GSList *next_di; }; @@ -312,8 +312,8 @@ SRD_API int srd_decoder_unload_all(void); /* instance.c */ SRD_API int srd_inst_option_set(struct srd_decoder_inst *di, GHashTable *options); -SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di, - GHashTable *probes, int unit_size); +SRD_API int srd_inst_channel_set_all(struct srd_decoder_inst *di, + GHashTable *channels, int unit_size); SRD_API struct srd_decoder_inst *srd_inst_new(struct srd_session *sess, const char *id, GHashTable *options); SRD_API int srd_inst_stack(struct srd_session *sess, @@ -209,13 +209,13 @@ SRD_API int srd_session_metadata_set(struct srd_session *sess, int key, /** * Send a chunk of logic sample data to a running decoder session. * - * If no probe map has been set up, the logic samples must be arranged - * in probe order, in the least amount of space possible. The default - * probe set consists of all required probes + all optional probes. + * If no channel map has been set up, the logic samples must be arranged + * in channel order, in the least amount of space possible. The default + * channel set consists of all required channels + all optional channels. * * The size of a sample in inbuf is the unit size passed to - * srd_inst_probe_set_all(). If no probe map has been configured, it is - * the minimum number of bytes needed to store the default probes. + * srd_inst_channel_set_all(). If no channel map has been configured, it is + * the minimum number of bytes needed to store the default channels. * * @param sess The session to use. * @param start_samplenum The sample number of the first sample in this chunk. diff --git a/tests/pdtest b/tests/pdtest index ebfcb28..57a8b54 100755 --- a/tests/pdtest +++ b/tests/pdtest @@ -110,7 +110,7 @@ def parse_testfile(path, pd, tc, op_type, op_class): raise E_syntax pd_spec = { 'name': f.pop(0), - 'probes': [], + 'channels': [], 'options': [], } while len(f): @@ -122,12 +122,12 @@ def parse_testfile(path, pd, tc, op_type, op_class): if '=' not in b: raise E_syntax opt, val = b.split('=') - if a == 'probe': + if a == 'channel': try: val = int(val) except: raise E_syntax - pd_spec['probes'].append([opt, val]) + pd_spec['channels'].append([opt, val]) elif a == 'option': pd_spec['options'].append([opt, val]) else: @@ -314,8 +314,8 @@ def run_tests(tests, fix=False): # Set up PD stack for this test. for spd in tc['pdlist']: args.extend(['-P', spd['name']]) - for label, probe in spd['probes']: - args.extend(['-p', "%s=%d" % (label, probe)]) + for label, channel in spd['channels']: + args.extend(['-p', "%s=%d" % (label, channel)]) for option, value in spd['options']: args.extend(['-o', "%s=%s" % (option, value)]) args.extend(['-i', os.path.join(dumps_dir, tc['input'])]) @@ -448,8 +448,8 @@ def show_tests(tests): print("Testcase: %s/%s" % (tc['pd'], tc['name'])) for pd in tc['pdlist']: print(" Protocol decoder: %s" % pd['name']) - for label, probe in pd['probes']: - print(" Probe %s=%d" % (label, probe)) + for label, channel in pd['channels']: + print(" Channel %s=%d" % (label, channel)) for option, value in pd['options']: print(" Option %s=%d" % (option, value)) if 'stack' in tc: diff --git a/tests/runtc.c b/tests/runtc.c index af1e3fb..25b4e38 100644 --- a/tests/runtc.c +++ b/tests/runtc.c @@ -41,9 +41,9 @@ int debug = FALSE; int statistics = FALSE; char *coverage_report; -struct probe { +struct channel { char *name; - int probe; + int channel; }; struct option { @@ -53,7 +53,7 @@ struct option { struct pd { char *name; - GSList *probes; + GSList *channels; GSList *options; }; @@ -140,8 +140,8 @@ static void usage(char *msg) printf("Usage: runtc [-dPpoiOf]\n"); printf(" -d Debug\n"); printf(" -P <protocol decoder>\n"); - printf(" -p <probename=probenum> (optional)\n"); - printf(" -o <probeoption=value> (optional)\n"); + printf(" -p <channelname=channelnum> (optional)\n"); + printf(" -o <channeloption=value> (optional)\n"); printf(" -i <input file>\n"); printf(" -O <output-pd:output-type[:output-class]>\n"); printf(" -f <output file> (optional)\n"); @@ -329,13 +329,13 @@ static int run_testcase(char *infile, GSList *pdlist, struct output *op) struct srd_decoder_inst *di, *prev_di; srd_pd_output_callback_t cb; struct pd *pd; - struct probe *probe; + struct channel *channel; struct option *option; GVariant *gvar; - GHashTable *probes, *opts; + GHashTable *channels, *opts; GSList *pdl, *l; int idx; - int max_probe; + int max_channel; char **decoder_class; if (op->outfile) { @@ -385,23 +385,23 @@ static int run_testcase(char *infile, GSList *pdlist, struct output *op) return FALSE; g_hash_table_destroy(opts); - /* Map probes. */ - if (pd->probes) { - probes = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, + /* Map channels. */ + if (pd->channels) { + channels = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)g_variant_unref); - max_probe = 0; - for (l = pd->probes; l; l = l->next) { - probe = l->data; - if (probe->probe > max_probe) - max_probe = probe->probe; - gvar = g_variant_new_int32(probe->probe); + max_channel = 0; + for (l = pd->channels; l; l = l->next) { + channel = l->data; + if (channel->channel > max_channel) + max_channel = channel->channel; + gvar = g_variant_new_int32(channel->channel); g_variant_ref_sink(gvar); - g_hash_table_insert(probes, probe->name, gvar); + g_hash_table_insert(channels, channel->name, gvar); } - if (srd_inst_probe_set_all(di, probes, - (max_probe + 8) / 8) != SRD_OK) + if (srd_inst_channel_set_all(di, channels, + (max_channel + 8) / 8) != SRD_OK) return FALSE; - g_hash_table_destroy(probes); + g_hash_table_destroy(channels); } /* If this is not the first decoder in the list, stack it @@ -685,7 +685,7 @@ int main(int argc, char **argv) PyObject *coverage; GSList *pdlist; struct pd *pd; - struct probe *probe; + struct channel *channel; struct option *option; struct output *op; int ret; @@ -710,7 +710,7 @@ int main(int argc, char **argv) case 'P': pd = g_malloc(sizeof(struct pd)); pd->name = g_strdup(optarg); - pd->probes = pd->options = NULL; + pd->channels = pd->options = NULL; pdlist = g_slist_append(pdlist, pd); break; case 'p': @@ -728,11 +728,11 @@ int main(int argc, char **argv) usage(NULL); } if (c == 'p') { - probe = malloc(sizeof(struct probe)); - probe->name = g_strdup(kv[0]); - probe->probe = strtoul(kv[1], 0, 10); + channel = malloc(sizeof(struct channel)); + channel->name = g_strdup(kv[0]); + channel->channel = strtoul(kv[1], 0, 10); /* Apply to last PD. */ - pd->probes = g_slist_append(pd->probes, probe); + pd->channels = g_slist_append(pd->channels, channel); } else { option = malloc(sizeof(struct option)); option->key = g_strdup(kv[0]); diff --git a/type_logic.c b/type_logic.c index 367ff1d..4367680 100644 --- a/type_logic.c +++ b/type_logic.c @@ -45,16 +45,16 @@ static PyObject *srd_logic_iternext(PyObject *self) * and 0x00 values, so the PD doesn't need to do any bitshifting. */ sample_pos = logic->inbuf + logic->itercnt * logic->di->data_unitsize; - for (i = 0; i < logic->di->dec_num_probes; i++) { - /* A probemap value of -1 means "unused optional probe". */ - if (logic->di->dec_probemap[i] == -1) { - /* Value of unused probe is 0xff, instead of 0 or 1. */ - logic->di->probe_samples[i] = 0xff; + for (i = 0; i < logic->di->dec_num_channels; i++) { + /* A channelmap value of -1 means "unused optional channel". */ + if (logic->di->dec_channelmap[i] == -1) { + /* Value of unused channel is 0xff, instead of 0 or 1. */ + logic->di->channel_samples[i] = 0xff; } else { - byte_offset = logic->di->dec_probemap[i] / 8; - bit_offset = logic->di->dec_probemap[i] % 8; + byte_offset = logic->di->dec_channelmap[i] / 8; + bit_offset = logic->di->dec_channelmap[i] % 8; sample = *(sample_pos + byte_offset) & (1 << bit_offset) ? 1 : 0; - logic->di->probe_samples[i] = sample; + logic->di->channel_samples[i] = sample; } } @@ -63,8 +63,8 @@ static PyObject *srd_logic_iternext(PyObject *self) PyLong_FromUnsignedLongLong(logic->start_samplenum + logic->itercnt); PyList_SetItem(logic->sample, 0, py_samplenum); - py_samples = PyBytes_FromStringAndSize((const char *)logic->di->probe_samples, - logic->di->dec_num_probes); + py_samples = PyBytes_FromStringAndSize((const char *)logic->di->channel_samples, + logic->di->dec_num_channels); PyList_SetItem(logic->sample, 1, py_samples); Py_INCREF(logic->sample); logic->itercnt++; |