From: Uwe Hermann Date: Mon, 24 Mar 2014 15:11:45 +0000 (+0100) Subject: A few more random 'probe' to 'channel' changes. X-Git-Tag: libsigrok-0.3.0~104 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=fca75cbb741ae756bf50eaf1cdc6d4d53fcc60cd A few more random 'probe' to 'channel' changes. This fixes parts of bug #259. --- diff --git a/filter.c b/filter.c index 46467543..8e74b10d 100644 --- a/filter.c +++ b/filter.c @@ -29,39 +29,39 @@ /** * @file * - * Helper functions to filter out unused probes from samples. + * Helper functions to filter out unused channels from samples. */ /** - * @defgroup grp_filter Probe filter + * @defgroup grp_filter Channel filter * - * Helper functions to filter out unused probes from samples. + * Helper functions to filter out unused channels from samples. * * @{ */ /** - * Remove unused probes from samples. + * Remove unused channels from samples. * - * Convert sample from maximum probes -- the way the hardware driver sent + * Convert sample from maximum channels -- the way the hardware driver sent * it -- to a sample taking up only as much space as required, with - * unused probes removed. + * unused channels removed. * - * The "unit size" is the number of bytes used to store probe values. + * The "unit size" is the number of bytes used to store channel values. * For example, a unit size of 1 means one byte is used (which can store - * 8 probe values, each of them is 1 bit). A unit size of 2 means we can - * store 16 probe values, 3 means we can store 24 probe values, and so on. + * 8 channel values, each of them is 1 bit). A unit size of 2 means we can + * store 16 channel values, 3 means we can store 24 channel values, and so on. * * If the data coming from the logic analyzer has a unit size of 4 for - * example (as the device has 32 probes), but only 2 of them are actually + * example (as the device has 32 channels), but only 2 of them are actually * used in an acquisition, this function can convert the samples to only * use up 1 byte per sample (unit size = 1) instead of 4 bytes per sample. * - * The output will contain the probe values in the order specified via the - * probelist. For example, if in_unitsize = 4, probelist = [5, 16, 30], and + * The output will contain the channel values in the order specified via the + * channellist. For example, if in_unitsize = 4, channellist = [5, 16, 30], and * out_unitsize = 1, then the output samples (each of them one byte in size) - * will have the following format: bit 0 = value of probe 5, bit 1 = value - * of probe 16, bit 2 = value of probe 30. Unused bit(s) in the output byte(s) + * will have the following format: bit 0 = value of channel 5, bit 1 = value + * of channel 16, bit 2 = value of channel 30. Unused bit(s) in the output byte(s) * are zero. * * The caller must make sure that length_in is not bigger than the memory @@ -72,8 +72,8 @@ * @param out_unitsize The unit size (>= 1) the output shall have (data_out). * The requested unit size must be big enough to hold as * much data as is specified by the number of enabled - * probes in 'probelist'. - * @param probe_array Pointer to a list of probe numbers, numbered starting + * channels in 'channellist'. + * @param channel_array Pointer to a list of channel numbers, numbered starting * from 0. The list is terminated with -1. * @param data_in Pointer to the input data buffer. Must not be NULL. * @param length_in The input data length (>= 1), in number of bytes. @@ -92,20 +92,20 @@ * @since 0.2.0 */ SR_API int sr_filter_channels(unsigned int in_unitsize, unsigned int out_unitsize, - const GArray *probe_array, const uint8_t *data_in, + const GArray *channel_array, const uint8_t *data_in, uint64_t length_in, uint8_t **data_out, uint64_t *length_out) { unsigned int in_offset, out_offset; - int *probelist, out_bit; + int *channellist, out_bit; unsigned int i; uint8_t *sample_in, *sample_out; - if (!probe_array) { - sr_err("%s: probe_array was NULL", __func__); + if (!channel_array) { + sr_err("%s: channel_array was NULL", __func__); return SR_ERR_ARG; } - probelist = (int *)probe_array->data; + channellist = (int *)channel_array->data; if (!data_in) { sr_err("%s: data_in was NULL", __func__); @@ -122,10 +122,10 @@ SR_API int sr_filter_channels(unsigned int in_unitsize, unsigned int out_unitsiz return SR_ERR_ARG; } - /* Are there more probes than the target unit size supports? */ - if (probe_array->len > out_unitsize * 8) { - sr_err("%s: too many probes (%d) for the target unit " - "size (%d)", __func__, probe_array->len, out_unitsize); + /* Are there more channels than the target unit size supports? */ + if (channel_array->len > out_unitsize * 8) { + sr_err("%s: too many channels (%d) for the target unit " + "size (%d)", __func__, channel_array->len, out_unitsize); return SR_ERR_ARG; } @@ -134,22 +134,22 @@ SR_API int sr_filter_channels(unsigned int in_unitsize, unsigned int out_unitsiz return SR_ERR_MALLOC; } - if (probe_array->len == in_unitsize * 8) { - /* All probes are used -- no need to compress anything. */ + if (channel_array->len == in_unitsize * 8) { + /* All channels are used -- no need to compress anything. */ memcpy(*data_out, data_in, length_in); *length_out = length_in; return SR_OK; } - /* If we reached this point, not all probes are used, so "compress". */ + /* If we reached this point, not all channels are used, so "compress". */ in_offset = out_offset = 0; while (in_offset <= length_in - in_unitsize) { sample_in = (uint8_t *)data_in + in_offset; sample_out = (*data_out) + out_offset; memset(sample_out, 0, out_unitsize); out_bit = 0; - for (i = 0; i < probe_array->len; i++) { - if (sample_in[probelist[i]>>3] & (1 << (probelist[i]&7))) + for (i = 0; i < channel_array->len; i++) { + if (sample_in[channellist[i]>>3] & (1 << (channellist[i]&7))) sample_out[out_bit>>3] |= (1 << (out_bit&7)); out_bit++; } diff --git a/hardware/chronovu-la8/protocol.c b/hardware/chronovu-la8/protocol.c index 587849e9..6f8738bc 100644 --- a/hardware/chronovu-la8/protocol.c +++ b/hardware/chronovu-la8/protocol.c @@ -24,7 +24,7 @@ #include "libsigrok-internal.h" #include "protocol.h" -/* Probes are numbered 0-7. */ +/* Channels are numbered 0-7. */ SR_PRIV const char *chronovu_la8_channel_names[NUM_CHANNELS + 1] = { "0", "1", "2", "3", "4", "5", "6", "7", NULL, diff --git a/hardware/link-mso19/api.c b/hardware/link-mso19/api.c index 384b52c4..80f48f41 100644 --- a/hardware/link-mso19/api.c +++ b/hardware/link-mso19/api.c @@ -101,7 +101,7 @@ static GSList *scan(GSList *options) GSList *l; struct sr_config *src; struct udev *udev; - int ptype; + int chtype; for (l = options; l; l = l->next) { src = l->data; @@ -218,8 +218,8 @@ static GSList *scan(GSList *options) for (i = 0; i < NUM_CHANNELS; i++) { struct sr_channel *ch; - ptype = (i == 0) ? SR_CHANNEL_ANALOG : SR_CHANNEL_LOGIC; - if (!(ch = sr_channel_new(i, ptype, TRUE, + chtype = (i == 0) ? SR_CHANNEL_ANALOG : SR_CHANNEL_LOGIC; + if (!(ch = sr_channel_new(i, chtype, TRUE, mso19_channel_names[i]))) return 0; sdi->channels = g_slist_append(sdi->channels, ch); diff --git a/hwdriver.c b/hwdriver.c index ee13d6e5..4728cb07 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -96,10 +96,10 @@ static struct sr_config_info sr_config_info_data[] = { "Power off", NULL}, {SR_CONF_DATA_SOURCE, SR_T_CHAR, "data_source", "Data source", NULL}, - {SR_CONF_NUM_LOGIC_CHANNELS, SR_T_INT32, "logic_probes", - "Number of logic probes", NULL}, - {SR_CONF_NUM_ANALOG_CHANNELS, SR_T_INT32, "analog_probes", - "Number of analog probes", NULL}, + {SR_CONF_NUM_LOGIC_CHANNELS, SR_T_INT32, "logic_channels", + "Number of logic channels", NULL}, + {SR_CONF_NUM_ANALOG_CHANNELS, SR_T_INT32, "analog_channels", + "Number of analog channels", NULL}, {SR_CONF_OUTPUT_VOLTAGE, SR_T_FLOAT, "output_voltage", "Current output voltage", NULL}, {SR_CONF_OUTPUT_VOLTAGE_MAX, SR_T_FLOAT, "output_voltage_max", diff --git a/libsigrok-internal.h b/libsigrok-internal.h index 60c35b83..89bedde1 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -226,9 +226,9 @@ SR_PRIV int sr_err(const char *format, ...); /** Values for the changes argument of sr_dev_driver.config_channel_set. */ enum { - /** The enabled state of the probe has been changed. */ + /** The enabled state of the channel has been changed. */ SR_CHANNEL_SET_ENABLED = 1 << 0, - /** The trigger setup of the probe has been changed. */ + /** The trigger setup of the channel has been changed. */ SR_CHANNEL_SET_TRIGGER = 1 << 1, }; diff --git a/libsigrok.h b/libsigrok.h index 8df2f396..49703757 100644 --- a/libsigrok.h +++ b/libsigrok.h @@ -597,12 +597,12 @@ struct sr_output_format { int (*cleanup) (struct sr_output *o); }; -/** Constants for probe type. */ +/** Constants for channel type. */ enum { - /** Probe type is logic probe. */ - SR_CHANNEL_LOGIC = 10000, - /** Probe type is analog probe. */ - SR_CHANNEL_ANALOG, + /** Channel type is logic channel. */ + SR_CHANNEL_LOGIC = 10000, + /** Channel type is analog channel. */ + SR_CHANNEL_ANALOG, }; /** Information on single channel. */ @@ -803,10 +803,10 @@ enum { */ SR_CONF_CENTER_FREQUENCY, - /** The device supports setting the number of logic probes. */ + /** The device supports setting the number of logic channels. */ SR_CONF_NUM_LOGIC_CHANNELS, - /** The device supports setting the number of analog probes. */ + /** The device supports setting the number of analog channels. */ SR_CONF_NUM_ANALOG_CHANNELS, /** Output voltage. */ @@ -992,7 +992,7 @@ struct sr_dev_driver { int (*config_set) (int id, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg); - /** Probe status change. + /** Channel status change. * @see sr_dev_channel_enable(), sr_dev_trigger_set(). */ int (*config_channel_set) (const struct sr_dev_inst *sdi, struct sr_channel *ch, unsigned int changes); diff --git a/output/text/ascii.c b/output/text/ascii.c index 7ad3fec3..3b3bcc72 100644 --- a/output/text/ascii.c +++ b/output/text/ascii.c @@ -46,7 +46,7 @@ SR_PRIV int data_ascii(struct sr_output *o, const uint8_t *data_in, max_linelen = SR_MAX_CHANNELNAME_LEN + 3 + ctx->samples_per_line + ctx->samples_per_line / 8; /* - * Calculate space needed for probes. Set aside 512 bytes for + * Calculate space needed for channels. Set aside 512 bytes for * extra output, e.g. trigger. */ outsize = 512 + (1 + (length_in / ctx->unitsize) / ctx->samples_per_line) diff --git a/output/text/bits.c b/output/text/bits.c index 7eafecdf..4ab59253 100644 --- a/output/text/bits.c +++ b/output/text/bits.c @@ -46,7 +46,7 @@ SR_PRIV int data_bits(struct sr_output *o, const uint8_t *data_in, max_linelen = SR_MAX_CHANNELNAME_LEN + 3 + ctx->samples_per_line + ctx->samples_per_line / 8; /* - * Calculate space needed for probes. Set aside 512 bytes for + * Calculate space needed for channels. Set aside 512 bytes for * extra output, e.g. trigger. */ outsize = 512 + (1 + (length_in / ctx->unitsize) / ctx->samples_per_line) diff --git a/proto.h b/proto.h index 2b5dd6ed..16bc269b 100644 --- a/proto.h +++ b/proto.h @@ -46,10 +46,10 @@ SR_API char *sr_log_logdomain_get(void); /*--- device.c --------------------------------------------------------------*/ SR_API int sr_dev_channel_name_set(const struct sr_dev_inst *sdi, - int probenum, const char *name); -SR_API int sr_dev_channel_enable(const struct sr_dev_inst *sdi, int probenum, + int channelnum, const char *name); +SR_API int sr_dev_channel_enable(const struct sr_dev_inst *sdi, int channelnum, gboolean state); -SR_API int sr_dev_trigger_set(const struct sr_dev_inst *sdi, int probenum, +SR_API int sr_dev_trigger_set(const struct sr_dev_inst *sdi, int channelnum, const char *trigger); SR_API gboolean sr_dev_has_option(const struct sr_dev_inst *sdi, int key); SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver); @@ -60,7 +60,7 @@ SR_API int sr_dev_close(struct sr_dev_inst *sdi); /*--- filter.c --------------------------------------------------------------*/ SR_API int sr_filter_channels(unsigned int in_unitsize, unsigned int out_unitsize, - const GArray *probe_array, const uint8_t *data_in, + const GArray *channel_array, const uint8_t *data_in, uint64_t length_in, uint8_t **data_out, uint64_t *length_out); @@ -110,7 +110,7 @@ SR_API int sr_session_stop(void); SR_API int sr_session_save(const char *filename, const struct sr_dev_inst *sdi, unsigned char *buf, int unitsize, int units); SR_API int sr_session_save_init(const char *filename, uint64_t samplerate, - char **probes); + char **channels); SR_API int sr_session_append(const char *filename, unsigned char *buf, int unitsize, int units); SR_API int sr_session_source_add(int fd, int events, int timeout, diff --git a/session_driver.c b/session_driver.c index 36e5c0c2..fe0db3e6 100644 --- a/session_driver.c +++ b/session_driver.c @@ -41,7 +41,7 @@ struct session_vdev { int bytes_read; uint64_t samplerate; int unitsize; - int num_probes; + int num_channels; int cur_chunk; gboolean finished; }; @@ -260,7 +260,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, vdev->unitsize = g_variant_get_uint64(data); break; case SR_CONF_NUM_LOGIC_CHANNELS: - vdev->num_probes = g_variant_get_uint64(data); + vdev->num_channels = g_variant_get_uint64(data); break; default: return SR_ERR_NA; diff --git a/tests/check_input_binary.c b/tests/check_input_binary.c index f69c7374..9b40f1ef 100644 --- a/tests/check_input_binary.c +++ b/tests/check_input_binary.c @@ -34,7 +34,7 @@ static struct sr_context *sr_ctx; static uint64_t df_packet_counter = 0, sample_counter = 0; static gboolean have_seen_df_end = FALSE; -static GArray *logic_probelist = NULL; +static GArray *logic_channellist = NULL; static int check_to_perform; static uint64_t expected_samples; static uint64_t *expected_samplerate; @@ -123,10 +123,10 @@ static void datafeed_in(const struct sr_dev_inst *sdi, // g_debug("Received SR_DF_HEADER."); // fail_unless(p != NULL, "SR_DF_HEADER payload was NULL."); - logic_probelist = srtest_get_enabled_logic_probes(sdi); - fail_unless(logic_probelist != NULL); - fail_unless(logic_probelist->len != 0); - // g_debug("Enabled probes: %d.", logic_probelist->len); + logic_channellist = srtest_get_enabled_logic_channels(sdi); + fail_unless(logic_channellist != NULL); + fail_unless(logic_channellist->len != 0); + // g_debug("Enabled channels: %d.", logic_channellist->len); break; case SR_DF_META: // g_debug("Received SR_DF_META."); @@ -208,7 +208,7 @@ static void check_buf(const char *filename, GHashTable *param, /* Initialize global variables for this run. */ df_packet_counter = sample_counter = 0; have_seen_df_end = FALSE; - logic_probelist = NULL; + logic_channellist = NULL; check_to_perform = check; expected_samples = samples; expected_samplerate = samplerate; diff --git a/tests/lib.c b/tests/lib.c index fa823c7a..ad0b3e1f 100644 --- a/tests/lib.c +++ b/tests/lib.c @@ -211,21 +211,21 @@ void srtest_buf_to_file(const char *filename, const uint8_t *buf, uint64_t len) fclose(f); } -GArray *srtest_get_enabled_logic_probes(const struct sr_dev_inst *sdi) +GArray *srtest_get_enabled_logic_channels(const struct sr_dev_inst *sdi) { struct sr_channel *ch; - GArray *probes; + GArray *channels; GSList *l; - probes = g_array_new(FALSE, FALSE, sizeof(int)); - for (l = sdi->probes; l; l = l->next) { - probe = l->data; - if (probe->type != SR_CHANNEL_LOGIC) + channels = g_array_new(FALSE, FALSE, sizeof(int)); + for (l = sdi->channels; l; l = l->next) { + ch = l->data; + if (ch->type != SR_CHANNEL_LOGIC) continue; - if (probe->enabled != TRUE) + if (ch->enabled != TRUE) continue; - g_array_append_val(probes, probe->index); + g_array_append_val(channels, ch->index); } - return probes; + return channels; } diff --git a/tests/lib.h b/tests/lib.h index edb32d75..e2e607e3 100644 --- a/tests/lib.h +++ b/tests/lib.h @@ -39,7 +39,7 @@ void srtest_check_samplerate(struct sr_context *sr_ctx, const char *drivername, uint64_t samplerate); void srtest_buf_to_file(const char *filename, const uint8_t *buf, uint64_t len); -GArray *srtest_get_enabled_logic_probes(const struct sr_dev_inst *sdi); +GArray *srtest_get_enabled_logic_channels(const struct sr_dev_inst *sdi); Suite *suite_core(void); Suite *suite_driver_all(void);