This fixes parts of bug #259.
/**
* @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
* @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.
* @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__);
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;
}
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++;
}
#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,
GSList *l;
struct sr_config *src;
struct udev *udev;
- int ptype;
+ int chtype;
for (l = options; l; l = l->next) {
src = l->data;
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);
"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",
/** 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,
};
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. */
*/
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. */
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);
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)
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)
/*--- 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);
/*--- 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);
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,
int bytes_read;
uint64_t samplerate;
int unitsize;
- int num_probes;
+ int num_channels;
int cur_chunk;
gboolean finished;
};
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;
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;
// 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.");
/* 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;
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;
}
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);