Replace 'probe' with 'channel' in most places.

Also, consistently use 'ch' for channel variables. This matches how we
consistently use sdi, devc, and so on all over the code-base.

This fixes parts of bug #259.
This commit is contained in:
Uwe Hermann 2014-03-24 21:34:20 +01:00
parent 91aea754aa
commit ba7dd8bbb8
96 changed files with 1129 additions and 1129 deletions

112
device.c
View File

@ -51,32 +51,32 @@
SR_PRIV struct sr_channel *sr_probe_new(int index, int type, SR_PRIV struct sr_channel *sr_probe_new(int index, int type,
gboolean enabled, const char *name) gboolean enabled, const char *name)
{ {
struct sr_channel *probe; struct sr_channel *ch;
if (!(probe = g_try_malloc0(sizeof(struct sr_channel)))) { if (!(ch = g_try_malloc0(sizeof(struct sr_channel)))) {
sr_err("Probe malloc failed."); sr_err("Channel malloc failed.");
return NULL; return NULL;
} }
probe->index = index; ch->index = index;
probe->type = type; ch->type = type;
probe->enabled = enabled; ch->enabled = enabled;
if (name) if (name)
probe->name = g_strdup(name); ch->name = g_strdup(name);
return probe; return ch;
} }
/** /**
* Set the name of the specified probe in the specified device. * Set the name of the specified channel in the specified device.
* *
* If the probe already has a different name assigned to it, it will be * If the channel already has a different name assigned to it, it will be
* removed, and the new name will be saved instead. * removed, and the new name will be saved instead.
* *
* @param sdi The device instance the probe is connected to. * @param sdi The device instance the channel is connected to.
* @param[in] probenum The number of the probe whose name to set. * @param[in] channelnum The number of the channel whose name to set.
* Note that the probe numbers start at 0. * Note that the channel numbers start at 0.
* @param[in] name The new name that the specified probe should get. A copy * @param[in] name The new name that the specified channel should get. A copy
* of the string is made. * of the string is made.
* *
* @return SR_OK on success, or SR_ERR_ARG on invalid arguments. * @return SR_OK on success, or SR_ERR_ARG on invalid arguments.
@ -84,10 +84,10 @@ SR_PRIV struct sr_channel *sr_probe_new(int index, int type,
* @since 0.2.0 * @since 0.2.0
*/ */
SR_API int sr_dev_probe_name_set(const struct sr_dev_inst *sdi, SR_API int sr_dev_probe_name_set(const struct sr_dev_inst *sdi,
int probenum, const char *name) int channelnum, const char *name)
{ {
GSList *l; GSList *l;
struct sr_channel *probe; struct sr_channel *ch;
int ret; int ret;
if (!sdi) { if (!sdi) {
@ -96,11 +96,11 @@ SR_API int sr_dev_probe_name_set(const struct sr_dev_inst *sdi,
} }
ret = SR_ERR_ARG; ret = SR_ERR_ARG;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (probe->index == probenum) { if (ch->index == channelnum) {
g_free(probe->name); g_free(ch->name);
probe->name = g_strdup(name); ch->name = g_strdup(name);
ret = SR_OK; ret = SR_OK;
break; break;
} }
@ -110,23 +110,23 @@ SR_API int sr_dev_probe_name_set(const struct sr_dev_inst *sdi,
} }
/** /**
* Enable or disable a probe on the specified device. * Enable or disable a channel on the specified device.
* *
* @param sdi The device instance the probe is connected to. * @param sdi The device instance the channel is connected to.
* @param probenum The probe number, starting from 0. * @param channelnum The channel number, starting from 0.
* @param state TRUE to enable the probe, FALSE to disable. * @param state TRUE to enable the channel, FALSE to disable.
* *
* @return SR_OK on success or SR_ERR on failure. In case of invalid * @return SR_OK on success or SR_ERR on failure. In case of invalid
* arguments, SR_ERR_ARG is returned and the probe enabled state * arguments, SR_ERR_ARG is returned and the channel enabled state
* remains unchanged. * remains unchanged.
* *
* @since 0.2.0 * @since 0.2.0
*/ */
SR_API int sr_dev_probe_enable(const struct sr_dev_inst *sdi, int probenum, SR_API int sr_dev_probe_enable(const struct sr_dev_inst *sdi, int channelnum,
gboolean state) gboolean state)
{ {
GSList *l; GSList *l;
struct sr_channel *probe; struct sr_channel *ch;
int ret; int ret;
gboolean was_enabled; gboolean was_enabled;
@ -134,19 +134,19 @@ SR_API int sr_dev_probe_enable(const struct sr_dev_inst *sdi, int probenum,
return SR_ERR_ARG; return SR_ERR_ARG;
ret = SR_ERR_ARG; ret = SR_ERR_ARG;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (probe->index == probenum) { if (ch->index == channelnum) {
was_enabled = probe->enabled; was_enabled = ch->enabled;
probe->enabled = state; ch->enabled = state;
ret = SR_OK; ret = SR_OK;
if (!state != !was_enabled && sdi->driver if (!state != !was_enabled && sdi->driver
&& sdi->driver->config_probe_set) { && sdi->driver->config_probe_set) {
ret = sdi->driver->config_probe_set( ret = sdi->driver->config_probe_set(
sdi, probe, SR_PROBE_SET_ENABLED); sdi, ch, SR_PROBE_SET_ENABLED);
/* Roll back change if it wasn't applicable. */ /* Roll back change if it wasn't applicable. */
if (ret == SR_ERR_ARG) if (ret == SR_ERR_ARG)
probe->enabled = was_enabled; ch->enabled = was_enabled;
} }
break; break;
} }
@ -156,13 +156,13 @@ SR_API int sr_dev_probe_enable(const struct sr_dev_inst *sdi, int probenum,
} }
/** /**
* Add a trigger to the specified device (and the specified probe). * Add a trigger to the specified device (and the specified channel).
* *
* If the specified probe of this device already has a trigger, it will * If the specified channel of this device already has a trigger, it will
* be silently replaced. * be silently replaced.
* *
* @param[in,out] sdi Pointer to the device instance; must not be NULL. * @param[in,out] sdi Pointer to the device instance; must not be NULL.
* @param[in] probenum Number of probe, starting at 0. * @param[in] channelnum Number of channel, starting at 0.
* @param[in] trigger Trigger string, in the format used by sigrok-cli * @param[in] trigger Trigger string, in the format used by sigrok-cli
* *
* @return SR_OK on success or SR_ERR on failure. In case of invalid * @return SR_OK on success or SR_ERR on failure. In case of invalid
@ -171,11 +171,11 @@ SR_API int sr_dev_probe_enable(const struct sr_dev_inst *sdi, int probenum,
* *
* @since 0.2.0 * @since 0.2.0
*/ */
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) const char *trigger)
{ {
GSList *l; GSList *l;
struct sr_channel *probe; struct sr_channel *ch;
char *old_trigger; char *old_trigger;
int ret; int ret;
@ -183,23 +183,23 @@ SR_API int sr_dev_trigger_set(const struct sr_dev_inst *sdi, int probenum,
return SR_ERR_ARG; return SR_ERR_ARG;
ret = SR_ERR_ARG; ret = SR_ERR_ARG;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (probe->index == probenum) { if (ch->index == channelnum) {
old_trigger = probe->trigger; old_trigger = ch->trigger;
ret = SR_OK; ret = SR_OK;
if (g_strcmp0(trigger, old_trigger) == 0) if (g_strcmp0(trigger, old_trigger) == 0)
break; break;
/* Set new trigger if it has changed. */ /* Set new trigger if it has changed. */
probe->trigger = g_strdup(trigger); ch->trigger = g_strdup(trigger);
if (sdi->driver && sdi->driver->config_probe_set) { if (sdi->driver && sdi->driver->config_probe_set) {
ret = sdi->driver->config_probe_set( ret = sdi->driver->config_probe_set(
sdi, probe, SR_PROBE_SET_TRIGGER); sdi, ch, SR_PROBE_SET_TRIGGER);
/* Roll back change if it wasn't applicable. */ /* Roll back change if it wasn't applicable. */
if (ret == SR_ERR_ARG) { if (ret == SR_ERR_ARG) {
g_free(probe->trigger); g_free(ch->trigger);
probe->trigger = old_trigger; ch->trigger = old_trigger;
break; break;
} }
} }
@ -284,7 +284,7 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
sdi->vendor = vendor ? g_strdup(vendor) : NULL; sdi->vendor = vendor ? g_strdup(vendor) : NULL;
sdi->model = model ? g_strdup(model) : NULL; sdi->model = model ? g_strdup(model) : NULL;
sdi->version = version ? g_strdup(version) : NULL; sdi->version = version ? g_strdup(version) : NULL;
sdi->probes = NULL; sdi->channels = NULL;
sdi->channel_groups = NULL; sdi->channel_groups = NULL;
sdi->conn = NULL; sdi->conn = NULL;
sdi->priv = NULL; sdi->priv = NULL;
@ -298,16 +298,16 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
*/ */
SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi) SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi)
{ {
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
g_free(probe->name); g_free(ch->name);
g_free(probe->trigger); g_free(ch->trigger);
g_free(probe); g_free(ch);
} }
g_slist_free(sdi->probes); g_slist_free(sdi->channels);
if (sdi->channel_groups) if (sdi->channel_groups)
g_slist_free(sdi->channel_groups); g_slist_free(sdi->channel_groups);

View File

@ -72,7 +72,7 @@ static GSList *scan(GSList *options)
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_config *src; struct sr_config *src;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
GSList *l, *devices; GSList *l, *devices;
int len, i; int len, i;
@ -141,9 +141,9 @@ static GSList *scan(GSList *options)
sdi->conn = serial; sdi->conn = serial;
sdi->priv = devc; sdi->priv = devc;
sdi->driver = di; sdi->driver = di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);
break; break;

View File

@ -266,7 +266,7 @@ static int recv_fetc(const struct sr_dev_inst *sdi, GMatchInfo *match)
analog.mq = devc->cur_mq; analog.mq = devc->cur_mq;
analog.unit = devc->cur_unit; analog.unit = devc->cur_unit;
analog.mqflags = devc->cur_mqflags; analog.mqflags = devc->cur_mqflags;
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = 1; analog.num_samples = 1;
analog.data = &fvalue; analog.data = &fvalue;
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;

View File

@ -255,9 +255,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
return SR_ERR; return SR_ERR;
} }
sr_dbg("Setting audio channel count to %d.", devc->num_probes); sr_dbg("Setting audio channel count to %d.", devc->num_channels);
ret = snd_pcm_hw_params_set_channels(devc->capture_handle, ret = snd_pcm_hw_params_set_channels(devc->capture_handle,
devc->hw_params, devc->num_probes); devc->hw_params, devc->num_channels);
if (ret < 0) { if (ret < 0) {
sr_err("Can't set channel count: %s.", snd_strerror(ret)); sr_err("Can't set channel count: %s.", snd_strerror(ret));
return SR_ERR; return SR_ERR;

View File

@ -63,7 +63,7 @@ static void alsa_scan_handle_dev(GSList **devices,
struct drv_context *drvc = NULL; struct drv_context *drvc = NULL;
struct sr_dev_inst *sdi = NULL; struct sr_dev_inst *sdi = NULL;
struct dev_context *devc = NULL; struct dev_context *devc = NULL;
struct sr_channel *probe; struct sr_channel *ch;
int ret; int ret;
unsigned int i, offset, channels, minrate, maxrate, rate; unsigned int i, offset, channels, minrate, maxrate, rate;
uint64_t hwrates[ARRAY_SIZE(rates)]; uint64_t hwrates[ARRAY_SIZE(rates)];
@ -76,7 +76,7 @@ static void alsa_scan_handle_dev(GSList **devices,
/* /*
* Get hardware parameters: * Get hardware parameters:
* The number of channels, for example, are our sigrok probes. Getting * The number of channels, for example, are our sigrok channels. Getting
* this information needs a detour. We need to open the device, then * this information needs a detour. We need to open the device, then
* query it and/or test different parameters. A side-effect of is that * query it and/or test different parameters. A side-effect of is that
* we create a snd_pcm_hw_params_t object. We take advantage of the * we create a snd_pcm_hw_params_t object. We take advantage of the
@ -149,7 +149,7 @@ static void alsa_scan_handle_dev(GSList **devices,
} }
devc->hwdev = g_strdup(alsaname); devc->hwdev = g_strdup(alsaname);
devc->num_probes = channels; devc->num_channels = channels;
devc->hw_params = hw_params; devc->hw_params = hw_params;
memcpy(devrates, hwrates, offset * sizeof(uint64_t)); memcpy(devrates, hwrates, offset * sizeof(uint64_t));
devc->samplerates = devrates; devc->samplerates = devrates;
@ -157,11 +157,11 @@ static void alsa_scan_handle_dev(GSList **devices,
sdi->priv = devc; sdi->priv = devc;
sdi->driver = di; sdi->driver = di;
for (i = 0; i < devc->num_probes; i++) { for (i = 0; i < devc->num_channels; i++) {
snprintf(p_name, sizeof(p_name), "Ch_%d", i); snprintf(p_name, sizeof(p_name), "Ch_%d", i);
if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, p_name))) if (!(ch = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, p_name)))
goto scan_error_cleanup; goto scan_error_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
@ -202,8 +202,8 @@ scan_error_cleanup:
* *
* We don't currently look at alsa subdevices. We only use subdevice 0. * We don't currently look at alsa subdevices. We only use subdevice 0.
* Every input device will have its own channels (left, right, etc). Each of * Every input device will have its own channels (left, right, etc). Each of
* those channels gets mapped to a different sigrok probe. A device with 4 * those channels gets mapped to a different sigrok channel. A device with 4
* channels will have 4 probes from sigrok's perspective. * channels will have 4 channels from sigrok's perspective.
*/ */
SR_PRIV GSList *alsa_scan(GSList *options, struct sr_dev_driver *di) SR_PRIV GSList *alsa_scan(GSList *options, struct sr_dev_driver *di)
{ {
@ -357,7 +357,7 @@ SR_PRIV int alsa_receive_data(int fd, int revents, void *cb_data)
sr_spew("Only got %d/%d samples.", count, samples_to_get); sr_spew("Only got %d/%d samples.", count, samples_to_get);
} }
analog.data = g_try_malloc0(count * sizeof(float) * devc->num_probes); analog.data = g_try_malloc0(count * sizeof(float) * devc->num_channels);
if (!analog.data) { if (!analog.data) {
sr_err("Failed to malloc sample buffer."); sr_err("Failed to malloc sample buffer.");
return FALSE; return FALSE;
@ -372,15 +372,15 @@ SR_PRIV int alsa_receive_data(int fd, int revents, void *cb_data)
* audio data as a normalized float, and let the frontend or user worry * audio data as a normalized float, and let the frontend or user worry
* about the calibration. * about the calibration.
*/ */
for (i = 0; i < count; i += devc->num_probes) { for (i = 0; i < count; i += devc->num_channels) {
for (x = 0; x < devc->num_probes; x++) { for (x = 0; x < devc->num_channels; x++) {
tmp16 = inbuf[i + x]; tmp16 = inbuf[i + x];
analog.data[offset++] = tmp16 * s16norm; analog.data[offset++] = tmp16 * s16norm;
} }
} }
/* Send a sample packet with the analog values. */ /* Send a sample packet with the analog values. */
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = count; analog.num_samples = count;
analog.mq = SR_MQ_VOLTAGE; /* FIXME */ analog.mq = SR_MQ_VOLTAGE; /* FIXME */
analog.unit = SR_UNIT_VOLT; /* FIXME */ analog.unit = SR_UNIT_VOLT; /* FIXME */

View File

@ -35,7 +35,7 @@ struct dev_context {
uint64_t cur_samplerate; uint64_t cur_samplerate;
uint64_t limit_samples; uint64_t limit_samples;
uint64_t num_samples; uint64_t num_samples;
uint8_t num_probes; uint8_t num_channels;
uint64_t *samplerates; uint64_t *samplerates;
char *hwdev; char *hwdev;
snd_pcm_t *capture_handle; snd_pcm_t *capture_handle;

View File

@ -52,7 +52,7 @@ static GSList *scan(GSList *options)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_config *src; struct sr_config *src;
GSList *devices, *l; GSList *devices, *l;
const char *conn, *serialcomm; const char *conn, *serialcomm;
@ -111,12 +111,12 @@ static GSList *scan(GSList *options)
sdi->priv = devc; sdi->priv = devc;
sdi->driver = di; sdi->driver = di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "T1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "T1")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "T2"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "T2")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);

View File

@ -69,13 +69,13 @@ static uint64_t appa_55ii_flags(const uint8_t *buf)
return flags; return flags;
} }
static float appa_55ii_temp(const uint8_t *buf, int probe) static float appa_55ii_temp(const uint8_t *buf, int ch)
{ {
const uint8_t *ptr; const uint8_t *ptr;
int16_t temp; int16_t temp;
uint8_t flags; uint8_t flags;
ptr = buf + 4 + 14 + 3 * probe; ptr = buf + 4 + 14 + 3 * ch;
temp = RL16(ptr); temp = RL16(ptr);
flags = ptr[2]; flags = ptr[2];
@ -92,7 +92,7 @@ static void appa_55ii_live_data(struct sr_dev_inst *sdi, const uint8_t *buf)
struct dev_context *devc; struct dev_context *devc;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog; struct sr_datafeed_analog analog;
struct sr_channel *probe; struct sr_channel *ch;
float values[APPA_55II_NUM_PROBES], *val_ptr; float values[APPA_55II_NUM_PROBES], *val_ptr;
int i; int i;
@ -110,17 +110,17 @@ static void appa_55ii_live_data(struct sr_dev_inst *sdi, const uint8_t *buf)
analog.data = values; analog.data = values;
for (i = 0; i < APPA_55II_NUM_PROBES; i++) { for (i = 0; i < APPA_55II_NUM_PROBES; i++) {
probe = g_slist_nth_data(sdi->probes, i); ch = g_slist_nth_data(sdi->channels, i);
if (!probe->enabled) if (!ch->enabled)
continue; continue;
analog.probes = g_slist_append(analog.probes, probe); analog.channels = g_slist_append(analog.channels, ch);
*val_ptr++ = appa_55ii_temp(buf, i); *val_ptr++ = appa_55ii_temp(buf, i);
} }
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
sr_session_send(devc->session_cb_data, &packet); sr_session_send(devc->session_cb_data, &packet);
g_slist_free(analog.probes); g_slist_free(analog.channels);
devc->num_samples++; devc->num_samples++;
} }
@ -138,7 +138,7 @@ static void appa_55ii_log_data_parse(struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog; struct sr_datafeed_analog analog;
struct sr_channel *probe; struct sr_channel *ch;
float values[APPA_55II_NUM_PROBES], *val_ptr; float values[APPA_55II_NUM_PROBES], *val_ptr;
const uint8_t *buf; const uint8_t *buf;
int16_t temp; int16_t temp;
@ -162,17 +162,17 @@ static void appa_55ii_log_data_parse(struct sr_dev_inst *sdi)
for (i = 0; i < APPA_55II_NUM_PROBES; i++) { for (i = 0; i < APPA_55II_NUM_PROBES; i++) {
temp = RL16(buf + 12 + 2 * i); temp = RL16(buf + 12 + 2 * i);
probe = g_slist_nth_data(sdi->probes, i); ch = g_slist_nth_data(sdi->channels, i);
if (!probe->enabled) if (!ch->enabled)
continue; continue;
analog.probes = g_slist_append(analog.probes, probe); analog.channels = g_slist_append(analog.channels, ch);
*val_ptr++ = temp == 0x7FFF ? INFINITY : (float)temp / 10; *val_ptr++ = temp == 0x7FFF ? INFINITY : (float)temp / 10;
} }
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
sr_session_send(devc->session_cb_data, &packet); sr_session_send(devc->session_cb_data, &packet);
g_slist_free(analog.probes); g_slist_free(analog.channels);
devc->num_samples++; devc->num_samples++;
devc->log_buf_len -= 20; devc->log_buf_len -= 20;

View File

@ -58,11 +58,11 @@ static const uint64_t samplerates[] = {
}; };
/* /*
* Probe numbers seem to go from 1-16, according to this image: * Channel numbers seem to go from 1-16, according to this image:
* http://tools.asix.net/img/sigma_sigmacab_pins_720.jpg * http://tools.asix.net/img/sigma_sigmacab_pins_720.jpg
* (the cable has two additional GND pins, and a TI and TO pin) * (the cable has two additional GND pins, and a TI and TO pin)
*/ */
static const char *probe_names[NUM_PROBES + 1] = { static const char *channel_names[NUM_PROBES + 1] = {
"1", "2", "3", "4", "5", "6", "7", "8", "1", "2", "3", "4", "5", "6", "7", "8",
"9", "10", "11", "12", "13", "14", "15", "16", "9", "10", "11", "12", "13", "14", "15", "16",
NULL, NULL,
@ -402,7 +402,7 @@ static int init(struct sr_context *sr_ctx)
static GSList *scan(GSList *options) static GSList *scan(GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
GSList *devices; GSList *devices;
@ -450,7 +450,7 @@ static GSList *scan(GSList *options)
devc->period_ps = 0; devc->period_ps = 0;
devc->limit_msec = 0; devc->limit_msec = 0;
devc->cur_firmware = -1; devc->cur_firmware = -1;
devc->num_probes = 0; devc->num_channels = 0;
devc->samples_per_event = 0; devc->samples_per_event = 0;
devc->capture_ratio = 50; devc->capture_ratio = 50;
devc->use_triggers = 0; devc->use_triggers = 0;
@ -463,11 +463,11 @@ static GSList *scan(GSList *options)
} }
sdi->driver = di; sdi->driver = di;
for (i = 0; probe_names[i]; i++) { for (i = 0; channel_names[i]; i++) {
if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, if (!(ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE,
probe_names[i]))) channel_names[i])))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);
@ -624,20 +624,20 @@ static int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate)
if (samplerate <= SR_MHZ(50)) { if (samplerate <= SR_MHZ(50)) {
ret = upload_firmware(0, devc); ret = upload_firmware(0, devc);
devc->num_probes = 16; devc->num_channels = 16;
} }
if (samplerate == SR_MHZ(100)) { if (samplerate == SR_MHZ(100)) {
ret = upload_firmware(1, devc); ret = upload_firmware(1, devc);
devc->num_probes = 8; devc->num_channels = 8;
} }
else if (samplerate == SR_MHZ(200)) { else if (samplerate == SR_MHZ(200)) {
ret = upload_firmware(2, devc); ret = upload_firmware(2, devc);
devc->num_probes = 4; devc->num_channels = 4;
} }
devc->cur_samplerate = samplerate; devc->cur_samplerate = samplerate;
devc->period_ps = 1000000000000ULL / samplerate; devc->period_ps = 1000000000000ULL / samplerate;
devc->samples_per_event = 16 / devc->num_probes; devc->samples_per_event = 16 / devc->num_channels;
devc->state.state = SIGMA_IDLE; devc->state.state = SIGMA_IDLE;
return ret; return ret;
@ -646,26 +646,26 @@ static int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate)
/* /*
* In 100 and 200 MHz mode, only a single pin rising/falling can be * In 100 and 200 MHz mode, only a single pin rising/falling can be
* set as trigger. In other modes, two rising/falling triggers can be set, * set as trigger. In other modes, two rising/falling triggers can be set,
* in addition to value/mask trigger for any number of probes. * in addition to value/mask trigger for any number of channels.
* *
* The Sigma supports complex triggers using boolean expressions, but this * The Sigma supports complex triggers using boolean expressions, but this
* has not been implemented yet. * has not been implemented yet.
*/ */
static int configure_probes(const struct sr_dev_inst *sdi) static int configure_channels(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc = sdi->priv; struct dev_context *devc = sdi->priv;
const struct sr_channel *probe; const struct sr_channel *ch;
const GSList *l; const GSList *l;
int trigger_set = 0; int trigger_set = 0;
int probebit; int channelbit;
memset(&devc->trigger, 0, sizeof(struct sigma_trigger)); memset(&devc->trigger, 0, sizeof(struct sigma_trigger));
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = (struct sr_channel *)l->data; ch = (struct sr_channel *)l->data;
probebit = 1 << (probe->index); channelbit = 1 << (ch->index);
if (!probe->enabled || !probe->trigger) if (!ch->enabled || !ch->trigger)
continue; continue;
if (devc->cur_samplerate >= SR_MHZ(100)) { if (devc->cur_samplerate >= SR_MHZ(100)) {
@ -675,10 +675,10 @@ static int configure_probes(const struct sr_dev_inst *sdi)
"200MHz mode is supported."); "200MHz mode is supported.");
return SR_ERR; return SR_ERR;
} }
if (probe->trigger[0] == 'f') if (ch->trigger[0] == 'f')
devc->trigger.fallingmask |= probebit; devc->trigger.fallingmask |= channelbit;
else if (probe->trigger[0] == 'r') else if (ch->trigger[0] == 'r')
devc->trigger.risingmask |= probebit; devc->trigger.risingmask |= channelbit;
else { else {
sr_err("Only rising/falling trigger in 100 " sr_err("Only rising/falling trigger in 100 "
"and 200MHz mode is supported."); "and 200MHz mode is supported.");
@ -688,20 +688,20 @@ static int configure_probes(const struct sr_dev_inst *sdi)
++trigger_set; ++trigger_set;
} else { } else {
/* Simple trigger support (event). */ /* Simple trigger support (event). */
if (probe->trigger[0] == '1') { if (ch->trigger[0] == '1') {
devc->trigger.simplevalue |= probebit; devc->trigger.simplevalue |= channelbit;
devc->trigger.simplemask |= probebit; devc->trigger.simplemask |= channelbit;
} }
else if (probe->trigger[0] == '0') { else if (ch->trigger[0] == '0') {
devc->trigger.simplevalue &= ~probebit; devc->trigger.simplevalue &= ~channelbit;
devc->trigger.simplemask |= probebit; devc->trigger.simplemask |= channelbit;
} }
else if (probe->trigger[0] == 'f') { else if (ch->trigger[0] == 'f') {
devc->trigger.fallingmask |= probebit; devc->trigger.fallingmask |= channelbit;
++trigger_set; ++trigger_set;
} }
else if (probe->trigger[0] == 'r') { else if (ch->trigger[0] == 'r') {
devc->trigger.risingmask |= probebit; devc->trigger.risingmask |= channelbit;
++trigger_set; ++trigger_set;
} }
@ -945,8 +945,8 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
for (k = 0; k < devc->samples_per_event; ++k) { for (k = 0; k < devc->samples_per_event; ++k) {
cur_sample = 0; cur_sample = 0;
/* For each probe. */ /* For each channel. */
for (l = 0; l < devc->num_probes; ++l) for (l = 0; l < devc->num_channels; ++l)
cur_sample |= (!!(event[j] & (1 << (l * cur_sample |= (!!(event[j] & (1 << (l *
devc->samples_per_event + k)))) << l; devc->samples_per_event + k)))) << l;
@ -1099,14 +1099,14 @@ static void build_lut_entry(uint16_t value, uint16_t mask, uint16_t *entry)
{ {
int i, j, k, bit; int i, j, k, bit;
/* For each quad probe. */ /* For each quad channel. */
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
entry[i] = 0xffff; entry[i] = 0xffff;
/* For each bit in LUT. */ /* For each bit in LUT. */
for (j = 0; j < 16; ++j) for (j = 0; j < 16; ++j)
/* For each probe in quad. */ /* For each channel in quad. */
for (k = 0; k < 4; ++k) { for (k = 0; k < 4; ++k) {
bit = 1 << (i * 4 + k); bit = 1 << (i * 4 + k);
@ -1265,8 +1265,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
devc = sdi->priv; devc = sdi->priv;
if (configure_probes(sdi) != SR_OK) { if (configure_channels(sdi) != SR_OK) {
sr_err("Failed to configure probes."); sr_err("Failed to configure channels.");
return SR_ERR; return SR_ERR;
} }
@ -1319,10 +1319,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
/* Set clock select register. */ /* Set clock select register. */
if (devc->cur_samplerate == SR_MHZ(200)) if (devc->cur_samplerate == SR_MHZ(200))
/* Enable 4 probes. */ /* Enable 4 channels. */
sigma_set_register(WRITE_CLOCK_SELECT, 0xf0, devc); sigma_set_register(WRITE_CLOCK_SELECT, 0xf0, devc);
else if (devc->cur_samplerate == SR_MHZ(100)) else if (devc->cur_samplerate == SR_MHZ(100))
/* Enable 8 probes. */ /* Enable 8 channels. */
sigma_set_register(WRITE_CLOCK_SELECT, 0x00, devc); sigma_set_register(WRITE_CLOCK_SELECT, 0x00, devc);
else { else {
/* /*
@ -1333,7 +1333,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
clockselect.async = 0; clockselect.async = 0;
clockselect.fraction = frac; clockselect.fraction = frac;
clockselect.disabled_probes = 0; clockselect.disabled_channels = 0;
sigma_write_register(WRITE_CLOCK_SELECT, sigma_write_register(WRITE_CLOCK_SELECT,
(uint8_t *) &clockselect, (uint8_t *) &clockselect,

View File

@ -79,7 +79,7 @@ enum sigma_read_register {
struct clockselect_50 { struct clockselect_50 {
uint8_t async; uint8_t async;
uint8_t fraction; uint8_t fraction;
uint16_t disabled_probes; uint16_t disabled_channels;
}; };
/* The effect of all these are still a bit unclear. */ /* The effect of all these are still a bit unclear. */
@ -126,7 +126,7 @@ struct triggerlut {
/* Trigger configuration */ /* Trigger configuration */
struct sigma_trigger { struct sigma_trigger {
/* Only two probes can be used in mask. */ /* Only two channels can be used in mask. */
uint16_t risingmask; uint16_t risingmask;
uint16_t fallingmask; uint16_t fallingmask;
@ -183,7 +183,7 @@ struct dev_context {
uint64_t limit_msec; uint64_t limit_msec;
struct timeval start_tv; struct timeval start_tv;
int cur_firmware; int cur_firmware;
int num_probes; int num_channels;
int samples_per_event; int samples_per_event;
int capture_ratio; int capture_ratio;
struct sigma_trigger trigger; struct sigma_trigger trigger;

View File

@ -87,7 +87,7 @@ static GSList *scan(GSList *options, int modelid)
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_config *src; struct sr_config *src;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_channel_group *cg; struct sr_channel_group *cg;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
GSList *l, *devices; GSList *l, *devices;
@ -126,7 +126,7 @@ static GSList *scan(GSList *options, int modelid)
return NULL; return NULL;
serial_flush(serial); serial_flush(serial);
/* This is how the vendor software probes for hardware. */ /* This is how the vendor software channels for hardware. */
memset(packet, 0, PACKET_SIZE); memset(packet, 0, PACKET_SIZE);
packet[0] = 0xaa; packet[0] = 0xaa;
packet[1] = 0xaa; packet[1] = 0xaa;
@ -167,11 +167,11 @@ static GSList *scan(GSList *options, int modelid)
sdi->conn = serial; sdi->conn = serial;
for (i = 0; i < MAX_CHANNELS; i++) { for (i = 0; i < MAX_CHANNELS; i++) {
snprintf(channel, 10, "CH%d", i + 1); snprintf(channel, 10, "CH%d", i + 1);
probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, channel); ch = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, channel);
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
cg = g_malloc(sizeof(struct sr_channel_group)); cg = g_malloc(sizeof(struct sr_channel_group));
cg->name = g_strdup(channel); cg->name = g_strdup(channel);
cg->channels = g_slist_append(NULL, probe); cg->channels = g_slist_append(NULL, ch);
cg->priv = NULL; cg->priv = NULL;
sdi->channel_groups = g_slist_append(sdi->channel_groups, cg); sdi->channel_groups = g_slist_append(sdi->channel_groups, cg);
} }
@ -209,7 +209,7 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
int channel, ret; int channel, ret;
if (!sdi) if (!sdi)
@ -232,8 +232,8 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi,
} }
} else { } else {
/* We only ever have one channel per channel group in this driver. */ /* We only ever have one channel per channel group in this driver. */
probe = cg->channels->data; ch = cg->channels->data;
channel = probe->index; channel = ch->index;
switch (key) { switch (key) {
case SR_CONF_OUTPUT_VOLTAGE: case SR_CONF_OUTPUT_VOLTAGE:
@ -278,7 +278,7 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
gdouble dval; gdouble dval;
int channel, ret, ival; int channel, ret, ival;
const char *sval; const char *sval;
@ -323,8 +323,8 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
} else { } else {
/* Channel group specified: per-channel options. */ /* Channel group specified: per-channel options. */
/* We only ever have one channel per channel group in this driver. */ /* We only ever have one channel per channel group in this driver. */
probe = cg->channels->data; ch = cg->channels->data;
channel = probe->index; channel = ch->index;
switch (key) { switch (key) {
case SR_CONF_OUTPUT_VOLTAGE_MAX: case SR_CONF_OUTPUT_VOLTAGE_MAX:
@ -362,7 +362,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
GVariant *gvar; GVariant *gvar;
GVariantBuilder gvb; GVariantBuilder gvb;
int channel, ret, i; int channel, ret, i;
@ -403,8 +403,8 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
if (!sdi) if (!sdi)
return SR_ERR_ARG; return SR_ERR_ARG;
/* We only ever have one channel per channel group in this driver. */ /* We only ever have one channel per channel group in this driver. */
probe = cg->channels->data; ch = cg->channels->data;
channel = probe->index; channel = ch->index;
switch (key) { switch (key) {
case SR_CONF_DEVICE_OPTIONS: case SR_CONF_DEVICE_OPTIONS:
@ -473,7 +473,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
serial_source_add(serial, G_IO_IN, 50, atten_pps3xxx_receive_data, (void *)sdi); serial_source_add(serial, G_IO_IN, 50, atten_pps3xxx_receive_data, (void *)sdi);
std_session_send_df_header(cb_data, LOG_PREFIX); std_session_send_df_header(cb_data, LOG_PREFIX);
/* Send a "probe" configuration packet now. */ /* Send a "channel" configuration packet now. */
memset(packet, 0, PACKET_SIZE); memset(packet, 0, PACKET_SIZE);
packet[0] = 0xaa; packet[0] = 0xaa;
packet[1] = 0xaa; packet[1] = 0xaa;

View File

@ -45,7 +45,7 @@ static void handle_packet(const struct sr_dev_inst *sdi)
dump_packet("received", devc->packet); dump_packet("received", devc->packet);
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = 1; analog.num_samples = 1;
analog.mq = SR_MQ_VOLTAGE; analog.mq = SR_MQ_VOLTAGE;

View File

@ -48,7 +48,7 @@ static GSList *scan(GSList *options)
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
struct sr_config *src; struct sr_config *src;
struct sr_channel *probe; struct sr_channel *ch;
const char *conn; const char *conn;
drvc = di->priv; drvc = di->priv;
@ -86,12 +86,12 @@ static GSList *scan(GSList *options)
sdi->priv = devc; sdi->priv = devc;
sdi->driver = di; sdi->driver = di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P2"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P2")))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
sdi->inst_type = SR_INST_USB; sdi->inst_type = SR_INST_USB;
sdi->conn = usb; sdi->conn = usb;

View File

@ -208,22 +208,22 @@ static void brymen_bm86x_handle_packet(const struct sr_dev_inst *sdi,
/* Got a measurement. */ /* Got a measurement. */
analog[0].num_samples = 1; analog[0].num_samples = 1;
analog[0].data = &floatval[0]; analog[0].data = &floatval[0];
analog[0].probes = g_slist_append(NULL, sdi->probes->data); analog[0].channels = g_slist_append(NULL, sdi->channels->data);
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog[0]; packet.payload = &analog[0];
sr_session_send(devc->session_cb_data, &packet); sr_session_send(devc->session_cb_data, &packet);
g_slist_free(analog[0].probes); g_slist_free(analog[0].channels);
} }
if (analog[1].mq != -1) { if (analog[1].mq != -1) {
/* Got a measurement. */ /* Got a measurement. */
analog[1].num_samples = 1; analog[1].num_samples = 1;
analog[1].data = &floatval[1]; analog[1].data = &floatval[1];
analog[1].probes = g_slist_append(NULL, sdi->probes->next->data); analog[1].channels = g_slist_append(NULL, sdi->channels->next->data);
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog[1]; packet.payload = &analog[1];
sr_session_send(devc->session_cb_data, &packet); sr_session_send(devc->session_cb_data, &packet);
g_slist_free(analog[1].probes); g_slist_free(analog[1].channels);
} }
if (analog[0].mq != -1 || analog[1].mq != -1) if (analog[0].mq != -1 || analog[1].mq != -1)

View File

@ -44,7 +44,7 @@ static GSList *brymen_scan(const char *conn, const char *serialcomm)
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct dev_context *devc; struct dev_context *devc;
struct drv_context *drvc; struct drv_context *drvc;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
GSList *devices; GSList *devices;
int ret; int ret;
@ -89,10 +89,10 @@ static GSList *brymen_scan(const char *conn, const char *serialcomm)
sdi->priv = devc; sdi->priv = devc;
sdi->driver = di; sdi->driver = di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);

View File

@ -35,7 +35,7 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi)
return; return;
analog.data = &floatval; analog.data = &floatval;
analog.probes = sdi->probes; analog.channels = sdi->channels;
if (analog.mq != -1) { if (analog.mq != -1) {
/* Got a measurement. */ /* Got a measurement. */

View File

@ -79,7 +79,7 @@ static GSList *scan(GSList *options)
struct sr_config *src; struct sr_config *src;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
GSList *l, *devices; GSList *l, *devices;
gint64 start; gint64 start;
const char *conn; const char *conn;
@ -126,9 +126,9 @@ static GSList *scan(GSList *options)
sdi->inst_type = SR_INST_SERIAL; sdi->inst_type = SR_INST_SERIAL;
sdi->priv = devc; sdi->priv = devc;
sdi->driver = di; sdi->driver = di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "SPL"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "SPL")))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);
break; break;

View File

@ -134,7 +134,7 @@ static void process_mset(const struct sr_dev_inst *sdi)
analog.mq = SR_MQ_SOUND_PRESSURE_LEVEL; analog.mq = SR_MQ_SOUND_PRESSURE_LEVEL;
analog.mqflags = devc->cur_mqflags; analog.mqflags = devc->cur_mqflags;
analog.unit = SR_UNIT_DECIBEL_SPL; analog.unit = SR_UNIT_DECIBEL_SPL;
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = 1; analog.num_samples = 1;
analog.data = &devc->last_spl; analog.data = &devc->last_spl;
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
@ -193,7 +193,7 @@ static void send_data(const struct sr_dev_inst *sdi, unsigned char *data,
analog.mq = SR_MQ_SOUND_PRESSURE_LEVEL; analog.mq = SR_MQ_SOUND_PRESSURE_LEVEL;
analog.mqflags = devc->cur_mqflags; analog.mqflags = devc->cur_mqflags;
analog.unit = SR_UNIT_DECIBEL_SPL; analog.unit = SR_UNIT_DECIBEL_SPL;
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = num_samples; analog.num_samples = num_samples;
analog.data = fbuf; analog.data = fbuf;
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;

View File

@ -32,7 +32,7 @@ static const int32_t hwcaps[] = {
SR_CONF_CONTINUOUS, SR_CONF_CONTINUOUS,
}; };
static const char *probe_names[] = { static const char *channel_names[] = {
"T1", "T2", "T3", "T4", "T1", "T2", "T3", "T4",
NULL, NULL,
}; };
@ -71,7 +71,7 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
GSList *devices; GSList *devices;
@ -103,10 +103,10 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
sdi->driver = center_devs[idx].di; sdi->driver = center_devs[idx].di;
for (i = 0; i < center_devs[idx].num_channels; i++) { for (i = 0; i < center_devs[idx].num_channels; i++) {
if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, if (!(ch = sr_probe_new(i, SR_PROBE_ANALOG,
TRUE, probe_names[i]))) TRUE, channel_names[i])))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);

View File

@ -136,7 +136,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
return SR_ERR; return SR_ERR;
} }
/* Common values for all 4 probes. */ /* Common values for all 4 channels. */
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
analog.mq = SR_MQ_TEMPERATURE; analog.mq = SR_MQ_TEMPERATURE;
@ -146,8 +146,8 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
/* Send the values for T1 - T4. */ /* Send the values for T1 - T4. */
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
l = NULL; l = NULL;
l = g_slist_append(l, g_slist_nth_data(sdi->probes, i)); l = g_slist_append(l, g_slist_nth_data(sdi->channels, i));
analog.probes = l; analog.channels = l;
analog.data = &(info.temp[i]); analog.data = &(info.temp[i]);
sr_session_send(devc->cb_data, &packet); sr_session_send(devc->cb_data, &packet);
g_slist_free(l); g_slist_free(l);

View File

@ -79,7 +79,7 @@ static int init(struct sr_context *sr_ctx)
static GSList *scan(GSList *options) static GSList *scan(GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
GSList *devices; GSList *devices;
@ -107,7 +107,7 @@ static GSList *scan(GSList *options)
memset(devc->mangled_buf, 0, BS); memset(devc->mangled_buf, 0, BS);
devc->final_buf = NULL; devc->final_buf = NULL;
devc->trigger_pattern = 0x00; /* Value irrelevant, see trigger_mask. */ devc->trigger_pattern = 0x00; /* Value irrelevant, see trigger_mask. */
devc->trigger_mask = 0x00; /* All probes are "don't care". */ devc->trigger_mask = 0x00; /* All channels are "don't care". */
devc->trigger_timeout = 10; /* Default to 10s trigger timeout. */ devc->trigger_timeout = 10; /* Default to 10s trigger timeout. */
devc->trigger_found = 0; devc->trigger_found = 0;
devc->done = 0; devc->done = 0;
@ -153,11 +153,11 @@ static GSList *scan(GSList *options)
sdi->driver = di; sdi->driver = di;
sdi->priv = devc; sdi->priv = devc;
for (i = 0; chronovu_la8_probe_names[i]; i++) { for (i = 0; chronovu_la8_channel_names[i]; i++) {
if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, if (!(ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE,
chronovu_la8_probe_names[i]))) chronovu_la8_channel_names[i])))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);
@ -446,8 +446,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
return SR_ERR; return SR_ERR;
} }
if (configure_probes(sdi) != SR_OK) { if (configure_channels(sdi) != SR_OK) {
sr_err("Failed to configure probes."); sr_err("Failed to configure channels.");
return SR_ERR; return SR_ERR;
} }

View File

@ -25,7 +25,7 @@
#include "protocol.h" #include "protocol.h"
/* Probes are numbered 0-7. */ /* Probes are numbered 0-7. */
SR_PRIV const char *chronovu_la8_probe_names[NUM_PROBES + 1] = { SR_PRIV const char *chronovu_la8_channel_names[NUM_PROBES + 1] = {
"0", "1", "2", "3", "4", "5", "6", "7", "0", "1", "2", "3", "4", "5", "6", "7",
NULL, NULL,
}; };
@ -284,46 +284,46 @@ SR_PRIV int la8_reset(struct dev_context *devc)
return SR_OK; return SR_OK;
} }
SR_PRIV int configure_probes(const struct sr_dev_inst *sdi) SR_PRIV int configure_channels(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; struct dev_context *devc;
const struct sr_channel *probe; const struct sr_channel *ch;
const GSList *l; const GSList *l;
uint8_t probe_bit; uint8_t channel_bit;
char *tc; char *tc;
devc = sdi->priv; devc = sdi->priv;
devc->trigger_pattern = 0; devc->trigger_pattern = 0;
devc->trigger_mask = 0; /* Default to "don't care" for all probes. */ devc->trigger_mask = 0; /* Default to "don't care" for all channels. */
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = (struct sr_channel *)l->data; ch = (struct sr_channel *)l->data;
if (!probe) { if (!ch) {
sr_err("%s: probe was NULL.", __func__); sr_err("%s: channel was NULL.", __func__);
return SR_ERR; return SR_ERR;
} }
/* Skip disabled probes. */ /* Skip disabled channels. */
if (!probe->enabled) if (!ch->enabled)
continue; continue;
/* Skip (enabled) probes with no configured trigger. */ /* Skip (enabled) channels with no configured trigger. */
if (!probe->trigger) if (!ch->trigger)
continue; continue;
/* Note: Must only be run if probe->trigger != NULL. */ /* Note: Must only be run if ch->trigger != NULL. */
if (probe->index < 0 || probe->index > 7) { if (ch->index < 0 || ch->index > 7) {
sr_err("%s: Invalid probe index %d, must be " sr_err("%s: Invalid channel index %d, must be "
"between 0 and 7.", __func__, probe->index); "between 0 and 7.", __func__, ch->index);
return SR_ERR; return SR_ERR;
} }
probe_bit = (1 << (probe->index)); channel_bit = (1 << (ch->index));
/* Configure the probe's trigger mask and trigger pattern. */ /* Configure the channel's trigger mask and trigger pattern. */
for (tc = probe->trigger; tc && *tc; tc++) { for (tc = ch->trigger; tc && *tc; tc++) {
devc->trigger_mask |= probe_bit; devc->trigger_mask |= channel_bit;
/* Sanity check, LA8 only supports low/high trigger. */ /* Sanity check, LA8 only supports low/high trigger. */
if (*tc != '0' && *tc != '1') { if (*tc != '0' && *tc != '1') {
@ -333,7 +333,7 @@ SR_PRIV int configure_probes(const struct sr_dev_inst *sdi)
} }
if (*tc == '1') if (*tc == '1')
devc->trigger_pattern |= probe_bit; devc->trigger_pattern |= channel_bit;
} }
} }

View File

@ -74,7 +74,7 @@ struct dev_context {
/** /**
* Trigger pattern (MSB = channel 7, LSB = channel 0). * Trigger pattern (MSB = channel 7, LSB = channel 0).
* A 1 bit matches a high signal, 0 matches a low signal on a probe. * A 1 bit matches a high signal, 0 matches a low signal on a channel.
* Only low/high triggers (but not e.g. rising/falling) are supported. * Only low/high triggers (but not e.g. rising/falling) are supported.
*/ */
uint8_t trigger_pattern; uint8_t trigger_pattern;
@ -107,7 +107,7 @@ struct dev_context {
/* protocol.c */ /* protocol.c */
extern const int32_t chronovu_la8_hwcaps[]; extern const int32_t chronovu_la8_hwcaps[];
extern uint64_t chronovu_la8_samplerates[]; extern uint64_t chronovu_la8_samplerates[];
extern SR_PRIV const char *chronovu_la8_probe_names[]; extern SR_PRIV const char *chronovu_la8_channel_names[];
SR_PRIV void fill_supported_samplerates_if_needed(void); SR_PRIV void fill_supported_samplerates_if_needed(void);
SR_PRIV int is_valid_samplerate(uint64_t samplerate); SR_PRIV int is_valid_samplerate(uint64_t samplerate);
SR_PRIV uint8_t samplerate_to_divcount(uint64_t samplerate); SR_PRIV uint8_t samplerate_to_divcount(uint64_t samplerate);
@ -116,7 +116,7 @@ SR_PRIV int la8_read(struct dev_context *devc, uint8_t *buf, int size);
SR_PRIV int la8_close(struct dev_context *devc); SR_PRIV int la8_close(struct dev_context *devc);
SR_PRIV int la8_close_usb_reset_sequencer(struct dev_context *devc); SR_PRIV int la8_close_usb_reset_sequencer(struct dev_context *devc);
SR_PRIV int la8_reset(struct dev_context *devc); SR_PRIV int la8_reset(struct dev_context *devc);
SR_PRIV int configure_probes(const struct sr_dev_inst *sdi); SR_PRIV int configure_channels(const struct sr_dev_inst *sdi);
SR_PRIV int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate); SR_PRIV int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate);
SR_PRIV int la8_read_block(struct dev_context *devc); SR_PRIV int la8_read_block(struct dev_context *devc);
SR_PRIV void send_block_to_session_bus(struct dev_context *devc, int block); SR_PRIV void send_block_to_session_bus(struct dev_context *devc, int block);

View File

@ -56,7 +56,7 @@ static GSList *scan(GSList *options)
struct dev_context *devc; struct dev_context *devc;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_config *src; struct sr_config *src;
struct sr_channel *probe; struct sr_channel *ch;
GSList *devices, *l; GSList *devices, *l;
const char *conn, *serialcomm; const char *conn, *serialcomm;
@ -97,9 +97,9 @@ static GSList *scan(GSList *options)
sdi->inst_type = SR_INST_SERIAL; sdi->inst_type = SR_INST_SERIAL;
sdi->priv = devc; sdi->priv = devc;
sdi->driver = di; sdi->driver = di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);

View File

@ -74,7 +74,7 @@ static void process_packet(const struct sr_dev_inst *sdi)
memset(&analog, 0, sizeof(struct sr_datafeed_analog)); memset(&analog, 0, sizeof(struct sr_datafeed_analog));
analog.mq = SR_MQ_SOUND_PRESSURE_LEVEL; analog.mq = SR_MQ_SOUND_PRESSURE_LEVEL;
analog.unit = SR_UNIT_DECIBEL_SPL; analog.unit = SR_UNIT_DECIBEL_SPL;
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = 1; analog.num_samples = 1;
analog.data = &fvalue; analog.data = &fvalue;

View File

@ -52,7 +52,7 @@ static GSList *scan(GSList *options)
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
struct sr_config *src; struct sr_config *src;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
GSList *l, *devices; GSList *l, *devices;
const char *conn, *serialcomm; const char *conn, *serialcomm;
@ -101,9 +101,9 @@ static GSList *scan(GSList *options)
sdi->conn = serial; sdi->conn = serial;
sdi->priv = NULL; sdi->priv = NULL;
sdi->driver = di; sdi->driver = di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "CH1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "CH1")))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);

View File

@ -48,26 +48,26 @@
/* Logic patterns we can generate. */ /* Logic patterns we can generate. */
enum { enum {
/** /**
* Spells "sigrok" across 8 probes using '0's (with '1's as * Spells "sigrok" across 8 channels using '0's (with '1's as
* "background") when displayed using the 'bits' output format. * "background") when displayed using the 'bits' output format.
* The pattern is repeasted every 8 probes, shifted to the right * The pattern is repeasted every 8 channels, shifted to the right
* in time by one bit. * in time by one bit.
*/ */
PATTERN_SIGROK, PATTERN_SIGROK,
/** Pseudo-random values on all probes. */ /** Pseudo-random values on all channels. */
PATTERN_RANDOM, PATTERN_RANDOM,
/** /**
* Incrementing number across 8 probes. The pattern is repeasted * Incrementing number across 8 channels. The pattern is repeasted
* every 8 probes, shifted to the right in time by one bit. * every 8 channels, shifted to the right in time by one bit.
*/ */
PATTERN_INC, PATTERN_INC,
/** All probes have a low logic state. */ /** All channels have a low logic state. */
PATTERN_ALL_LOW, PATTERN_ALL_LOW,
/** All probes have a high logic state. */ /** All channels have a high logic state. */
PATTERN_ALL_HIGH, PATTERN_ALL_HIGH,
}; };
@ -116,13 +116,13 @@ struct dev_context {
int64_t starttime; int64_t starttime;
uint64_t step; uint64_t step;
/* Logic */ /* Logic */
int32_t num_logic_probes; int32_t num_logic_channels;
unsigned int logic_unitsize; unsigned int logic_unitsize;
/* There is only ever one logic channel group, so its pattern goes here. */ /* There is only ever one logic channel group, so its pattern goes here. */
uint8_t logic_pattern; uint8_t logic_pattern;
unsigned char logic_data[LOGIC_BUFSIZE]; unsigned char logic_data[LOGIC_BUFSIZE];
/* Analog */ /* Analog */
int32_t num_analog_probes; int32_t num_analog_channels;
GSList *analog_channel_groups; GSList *analog_channel_groups;
}; };
@ -255,26 +255,26 @@ static GSList *scan(GSList *options)
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_channel_group *cg; struct sr_channel_group *cg;
struct sr_config *src; struct sr_config *src;
struct analog_gen *ag; struct analog_gen *ag;
GSList *devices, *l; GSList *devices, *l;
int num_logic_probes, num_analog_probes, pattern, i; int num_logic_channels, num_analog_channels, pattern, i;
char probe_name[16]; char channel_name[16];
drvc = di->priv; drvc = di->priv;
num_logic_probes = DEFAULT_NUM_LOGIC_PROBES; num_logic_channels = DEFAULT_NUM_LOGIC_PROBES;
num_analog_probes = DEFAULT_NUM_ANALOG_PROBES; num_analog_channels = DEFAULT_NUM_ANALOG_PROBES;
for (l = options; l; l = l->next) { for (l = options; l; l = l->next) {
src = l->data; src = l->data;
switch (src->key) { switch (src->key) {
case SR_CONF_NUM_LOGIC_PROBES: case SR_CONF_NUM_LOGIC_PROBES:
num_logic_probes = g_variant_get_int32(src->data); num_logic_channels = g_variant_get_int32(src->data);
break; break;
case SR_CONF_NUM_ANALOG_PROBES: case SR_CONF_NUM_ANALOG_PROBES:
num_analog_probes = g_variant_get_int32(src->data); num_analog_channels = g_variant_get_int32(src->data);
break; break;
} }
} }
@ -295,47 +295,47 @@ static GSList *scan(GSList *options)
devc->limit_samples = 0; devc->limit_samples = 0;
devc->limit_msec = 0; devc->limit_msec = 0;
devc->step = 0; devc->step = 0;
devc->num_logic_probes = num_logic_probes; devc->num_logic_channels = num_logic_channels;
devc->logic_unitsize = (devc->num_logic_probes + 7) / 8; devc->logic_unitsize = (devc->num_logic_channels + 7) / 8;
devc->logic_pattern = PATTERN_SIGROK; devc->logic_pattern = PATTERN_SIGROK;
devc->num_analog_probes = num_analog_probes; devc->num_analog_channels = num_analog_channels;
devc->analog_channel_groups = NULL; devc->analog_channel_groups = NULL;
/* Logic probes, all in one channel group. */ /* Logic channels, all in one channel group. */
if (!(cg = g_try_malloc(sizeof(struct sr_channel_group)))) if (!(cg = g_try_malloc(sizeof(struct sr_channel_group))))
return NULL; return NULL;
cg->name = g_strdup("Logic"); cg->name = g_strdup("Logic");
cg->channels = NULL; cg->channels = NULL;
cg->priv = NULL; cg->priv = NULL;
for (i = 0; i < num_logic_probes; i++) { for (i = 0; i < num_logic_channels; i++) {
sprintf(probe_name, "D%d", i); sprintf(channel_name, "D%d", i);
if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, probe_name))) if (!(ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, channel_name)))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
cg->channels = g_slist_append(cg->channels, probe); cg->channels = g_slist_append(cg->channels, ch);
} }
sdi->channel_groups = g_slist_append(NULL, cg); sdi->channel_groups = g_slist_append(NULL, cg);
/* Analog probes, channel groups and pattern generators. */ /* Analog channels, channel groups and pattern generators. */
pattern = 0; pattern = 0;
for (i = 0; i < num_analog_probes; i++) { for (i = 0; i < num_analog_channels; i++) {
sprintf(probe_name, "A%d", i); sprintf(channel_name, "A%d", i);
if (!(probe = sr_probe_new(i + num_logic_probes, if (!(ch = sr_probe_new(i + num_logic_channels,
SR_PROBE_ANALOG, TRUE, probe_name))) SR_PROBE_ANALOG, TRUE, channel_name)))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
/* Every analog probe gets its own channel group. */ /* Every analog channel gets its own channel group. */
if (!(cg = g_try_malloc(sizeof(struct sr_channel_group)))) if (!(cg = g_try_malloc(sizeof(struct sr_channel_group))))
return NULL; return NULL;
cg->name = g_strdup(probe_name); cg->name = g_strdup(channel_name);
cg->channels = g_slist_append(NULL, probe); cg->channels = g_slist_append(NULL, ch);
/* Every channel group gets a generator struct. */ /* Every channel group gets a generator struct. */
if (!(ag = g_try_malloc(sizeof(struct analog_gen)))) if (!(ag = g_try_malloc(sizeof(struct analog_gen))))
return NULL; return NULL;
ag->packet.probes = cg->channels; ag->packet.channels = cg->channels;
ag->packet.mq = 0; ag->packet.mq = 0;
ag->packet.mqflags = 0; ag->packet.mqflags = 0;
ag->packet.unit = SR_UNIT_VOLT; ag->packet.unit = SR_UNIT_VOLT;
@ -385,7 +385,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
struct analog_gen *ag; struct analog_gen *ag;
int pattern; int pattern;
@ -406,11 +406,11 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
case SR_CONF_PATTERN_MODE: case SR_CONF_PATTERN_MODE:
if (!cg) if (!cg)
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
probe = cg->channels->data; ch = cg->channels->data;
if (probe->type == SR_PROBE_LOGIC) { if (ch->type == SR_PROBE_LOGIC) {
pattern = devc->logic_pattern; pattern = devc->logic_pattern;
*data = g_variant_new_string(logic_pattern_str[pattern]); *data = g_variant_new_string(logic_pattern_str[pattern]);
} else if (probe->type == SR_PROBE_ANALOG) { } else if (ch->type == SR_PROBE_ANALOG) {
ag = cg->priv; ag = cg->priv;
pattern = ag->pattern; pattern = ag->pattern;
*data = g_variant_new_string(analog_pattern_str[pattern]); *data = g_variant_new_string(analog_pattern_str[pattern]);
@ -418,10 +418,10 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
return SR_ERR_BUG; return SR_ERR_BUG;
break; break;
case SR_CONF_NUM_LOGIC_PROBES: case SR_CONF_NUM_LOGIC_PROBES:
*data = g_variant_new_int32(devc->num_logic_probes); *data = g_variant_new_int32(devc->num_logic_channels);
break; break;
case SR_CONF_NUM_ANALOG_PROBES: case SR_CONF_NUM_ANALOG_PROBES:
*data = g_variant_new_int32(devc->num_analog_probes); *data = g_variant_new_int32(devc->num_analog_channels);
break; break;
default: default:
return SR_ERR_NA; return SR_ERR_NA;
@ -435,7 +435,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
{ {
struct dev_context *devc; struct dev_context *devc;
struct analog_gen *ag; struct analog_gen *ag;
struct sr_channel *probe; struct sr_channel *ch;
int pattern, ret; int pattern, ret;
unsigned int i; unsigned int i;
const char *stropt; const char *stropt;
@ -465,9 +465,9 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
if (!cg) if (!cg)
return SR_ERR_CHANNEL_GROUP; return SR_ERR_CHANNEL_GROUP;
stropt = g_variant_get_string(data, NULL); stropt = g_variant_get_string(data, NULL);
probe = cg->channels->data; ch = cg->channels->data;
pattern = -1; pattern = -1;
if (probe->type == SR_PROBE_LOGIC) { if (ch->type == SR_PROBE_LOGIC) {
for (i = 0; i < ARRAY_SIZE(logic_pattern_str); i++) { for (i = 0; i < ARRAY_SIZE(logic_pattern_str); i++) {
if (!strcmp(stropt, logic_pattern_str[i])) { if (!strcmp(stropt, logic_pattern_str[i])) {
pattern = i; pattern = i;
@ -485,7 +485,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
memset(devc->logic_data, 0xff, LOGIC_BUFSIZE); memset(devc->logic_data, 0xff, LOGIC_BUFSIZE);
sr_dbg("Setting logic pattern to %s", sr_dbg("Setting logic pattern to %s",
logic_pattern_str[pattern]); logic_pattern_str[pattern]);
} else if (probe->type == SR_PROBE_ANALOG) { } else if (ch->type == SR_PROBE_ANALOG) {
for (i = 0; i < ARRAY_SIZE(analog_pattern_str); i++) { for (i = 0; i < ARRAY_SIZE(analog_pattern_str); i++) {
if (!strcmp(stropt, analog_pattern_str[i])) { if (!strcmp(stropt, analog_pattern_str[i])) {
pattern = i; pattern = i;
@ -511,7 +511,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
struct sr_channel *probe; struct sr_channel *ch;
GVariant *gvar; GVariant *gvar;
GVariantBuilder gvb; GVariantBuilder gvb;
@ -543,17 +543,17 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
return SR_ERR_NA; return SR_ERR_NA;
} }
} else { } else {
probe = cg->channels->data; ch = cg->channels->data;
switch (key) { switch (key) {
case SR_CONF_DEVICE_OPTIONS: case SR_CONF_DEVICE_OPTIONS:
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(int32_t)); devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(int32_t));
break; break;
case SR_CONF_PATTERN_MODE: case SR_CONF_PATTERN_MODE:
if (probe->type == SR_PROBE_LOGIC) if (ch->type == SR_PROBE_LOGIC)
*data = g_variant_new_strv(logic_pattern_str, *data = g_variant_new_strv(logic_pattern_str,
ARRAY_SIZE(logic_pattern_str)); ARRAY_SIZE(logic_pattern_str));
else if (probe->type == SR_PROBE_ANALOG) else if (ch->type == SR_PROBE_ANALOG)
*data = g_variant_new_strv(analog_pattern_str, *data = g_variant_new_strv(analog_pattern_str,
ARRAY_SIZE(analog_pattern_str)); ARRAY_SIZE(analog_pattern_str));
else else
@ -638,7 +638,7 @@ static int prepare_data(int fd, int revents, void *cb_data)
while (logic_todo || analog_todo) { while (logic_todo || analog_todo) {
/* Logic */ /* Logic */
if (devc->num_logic_probes > 0 && logic_todo > 0) { if (devc->num_logic_channels > 0 && logic_todo > 0) {
sending_now = MIN(logic_todo, sending_now = MIN(logic_todo,
LOGIC_BUFSIZE / devc->logic_unitsize); LOGIC_BUFSIZE / devc->logic_unitsize);
logic_generator(sdi, sending_now * devc->logic_unitsize); logic_generator(sdi, sending_now * devc->logic_unitsize);
@ -652,8 +652,8 @@ static int prepare_data(int fd, int revents, void *cb_data)
devc->logic_counter += sending_now; devc->logic_counter += sending_now;
} }
/* Analog, one probe at a time */ /* Analog, one channel at a time */
if (devc->num_analog_probes > 0 && analog_todo > 0) { if (devc->num_analog_channels > 0 && analog_todo > 0) {
sending_now = 0; sending_now = 0;
for (l = devc->analog_channel_groups; l; l = l->next) { for (l = devc->analog_channel_groups; l; l = l->next) {
cg = l->data; cg = l->data;

View File

@ -69,7 +69,7 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
GSList *devices; GSList *devices;
int retry, len, i, s; int retry, len, i, s;
@ -135,9 +135,9 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
sdi->conn = serial; sdi->conn = serial;
sdi->priv = devc; sdi->priv = devc;
sdi->driver = di; sdi->driver = di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);
break; break;

View File

@ -63,7 +63,7 @@ static struct sr_datafeed_analog *handle_qm_18x(const struct sr_dev_inst *sdi,
return NULL; return NULL;
if (!(analog->data = g_try_malloc(sizeof(float)))) if (!(analog->data = g_try_malloc(sizeof(float))))
return NULL; return NULL;
analog->probes = sdi->probes; analog->channels = sdi->channels;
analog->num_samples = 1; analog->num_samples = 1;
if (is_oor) if (is_oor)
*analog->data = NAN; *analog->data = NAN;
@ -174,7 +174,7 @@ static struct sr_datafeed_analog *handle_qm_28x(const struct sr_dev_inst *sdi,
return NULL; return NULL;
if (!(analog->data = g_try_malloc(sizeof(float)))) if (!(analog->data = g_try_malloc(sizeof(float))))
return NULL; return NULL;
analog->probes = sdi->probes; analog->channels = sdi->channels;
analog->num_samples = 1; analog->num_samples = 1;
*analog->data = fvalue; *analog->data = fvalue;
analog->mq = -1; analog->mq = -1;
@ -396,7 +396,7 @@ static void handle_qm_19x_data(const struct sr_dev_inst *sdi, char **tokens)
fvalue = 1.0; fvalue = 1.0;
} }
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = 1; analog.num_samples = 1;
analog.data = &fvalue; analog.data = &fvalue;
analog.mq = devc->mq; analog.mq = devc->mq;

View File

@ -87,7 +87,7 @@ static const int32_t hwcaps[] = {
SR_CONF_CONTINUOUS, SR_CONF_CONTINUOUS,
}; };
static const char *probe_names[] = { static const char *channel_names[] = {
"0", "1", "2", "3", "4", "5", "6", "7", "0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "11", "12", "13", "14", "15", "8", "9", "10", "11", "12", "13", "14", "15",
NULL, NULL,
@ -126,13 +126,13 @@ static GSList *scan(GSList *options)
struct dev_context *devc; struct dev_context *devc;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_config *src; struct sr_config *src;
const struct fx2lafw_profile *prof; const struct fx2lafw_profile *prof;
GSList *l, *devices, *conn_devices; GSList *l, *devices, *conn_devices;
struct libusb_device_descriptor des; struct libusb_device_descriptor des;
libusb_device **devlist; libusb_device **devlist;
int devcnt, num_logic_probes, ret, i, j; int devcnt, num_logic_channels, ret, i, j;
const char *conn; const char *conn;
drvc = di->priv; drvc = di->priv;
@ -194,13 +194,13 @@ static GSList *scan(GSList *options)
return NULL; return NULL;
sdi->driver = di; sdi->driver = di;
/* Fill in probelist according to this device's profile. */ /* Fill in channellist according to this device's profile. */
num_logic_probes = prof->dev_caps & DEV_CAPS_16BIT ? 16 : 8; num_logic_channels = prof->dev_caps & DEV_CAPS_16BIT ? 16 : 8;
for (j = 0; j < num_logic_probes; j++) { for (j = 0; j < num_logic_channels; j++) {
if (!(probe = sr_probe_new(j, SR_PROBE_LOGIC, TRUE, if (!(ch = sr_probe_new(j, SR_PROBE_LOGIC, TRUE,
probe_names[j]))) channel_names[j])))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
devc = fx2lafw_dev_new(); devc = fx2lafw_dev_new();
@ -477,8 +477,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
usb = sdi->conn; usb = sdi->conn;
/* Configures devc->trigger_* and devc->sample_wide */ /* Configures devc->trigger_* and devc->sample_wide */
if (fx2lafw_configure_probes(sdi) != SR_OK) { if (fx2lafw_configure_channels(sdi) != SR_OK) {
sr_err("Failed to configure probes."); sr_err("Failed to configure channels.");
return SR_ERR; return SR_ERR;
} }

View File

@ -292,12 +292,12 @@ SR_PRIV int fx2lafw_dev_open(struct sr_dev_inst *sdi, struct sr_dev_driver *di)
return SR_OK; return SR_OK;
} }
SR_PRIV int fx2lafw_configure_probes(const struct sr_dev_inst *sdi) SR_PRIV int fx2lafw_configure_channels(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
int probe_bit, stage, i; int channel_bit, stage, i;
char *tc; char *tc;
devc = sdi->priv; devc = sdi->priv;
@ -307,23 +307,23 @@ SR_PRIV int fx2lafw_configure_probes(const struct sr_dev_inst *sdi)
} }
stage = -1; stage = -1;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = (struct sr_channel *)l->data; ch = (struct sr_channel *)l->data;
if (probe->enabled == FALSE) if (ch->enabled == FALSE)
continue; continue;
if (probe->index > 7) if (ch->index > 7)
devc->sample_wide = TRUE; devc->sample_wide = TRUE;
probe_bit = 1 << (probe->index); channel_bit = 1 << (ch->index);
if (!(probe->trigger)) if (!(ch->trigger))
continue; continue;
stage = 0; stage = 0;
for (tc = probe->trigger; *tc; tc++) { for (tc = ch->trigger; *tc; tc++) {
devc->trigger_mask[stage] |= probe_bit; devc->trigger_mask[stage] |= channel_bit;
if (*tc == '1') if (*tc == '1')
devc->trigger_value[stage] |= probe_bit; devc->trigger_value[stage] |= channel_bit;
stage++; stage++;
if (stage > NUM_TRIGGER_STAGES) if (stage > NUM_TRIGGER_STAGES)
return SR_ERR; return SR_ERR;

View File

@ -103,7 +103,7 @@ SR_PRIV int fx2lafw_command_start_acquisition(libusb_device_handle *devhdl,
uint64_t samplerate, gboolean samplewide); uint64_t samplerate, gboolean samplewide);
SR_PRIV gboolean fx2lafw_check_conf_profile(libusb_device *dev); SR_PRIV gboolean fx2lafw_check_conf_profile(libusb_device *dev);
SR_PRIV int fx2lafw_dev_open(struct sr_dev_inst *sdi, struct sr_dev_driver *di); SR_PRIV int fx2lafw_dev_open(struct sr_dev_inst *sdi, struct sr_dev_driver *di);
SR_PRIV int fx2lafw_configure_probes(const struct sr_dev_inst *sdi); SR_PRIV int fx2lafw_configure_channels(const struct sr_dev_inst *sdi);
SR_PRIV struct dev_context *fx2lafw_dev_new(void); SR_PRIV struct dev_context *fx2lafw_dev_new(void);
SR_PRIV void fx2lafw_abort_acquisition(struct dev_context *devc); SR_PRIV void fx2lafw_abort_acquisition(struct dev_context *devc);
SR_PRIV void fx2lafw_receive_transfer(struct libusb_transfer *transfer); SR_PRIV void fx2lafw_receive_transfer(struct libusb_transfer *transfer);

View File

@ -162,7 +162,7 @@ static GSList *scan_1x_2x_rs232(GSList *options)
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_config *src; struct sr_config *src;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
GSList *l, *devices; GSList *l, *devices;
const char *conn, *serialcomm; const char *conn, *serialcomm;
@ -240,9 +240,9 @@ static GSList *scan_1x_2x_rs232(GSList *options)
sdi->conn = serial; sdi->conn = serial;
sdi->priv = devc; sdi->priv = devc;
sdi->driver = &gmc_mh_1x_2x_rs232_driver_info; sdi->driver = &gmc_mh_1x_2x_rs232_driver_info;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);
} }
@ -259,7 +259,7 @@ static GSList *scan_2x_bd232(GSList *options)
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_config *src; struct sr_config *src;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
GSList *l, *devices; GSList *l, *devices;
const char *conn, *serialcomm; const char *conn, *serialcomm;
@ -343,9 +343,9 @@ static GSList *scan_2x_bd232(GSList *options)
sdi->conn = serial; sdi->conn = serial;
sdi->priv = devc; sdi->priv = devc;
sdi->driver = &gmc_mh_2x_bd232_driver_info; sdi->driver = &gmc_mh_2x_bd232_driver_info;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
goto exit_err; goto exit_err;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);

View File

@ -648,7 +648,7 @@ static void send_value(struct sr_dev_inst *sdi)
devc = sdi->priv; devc = sdi->priv;
memset(&analog, 0, sizeof(analog)); memset(&analog, 0, sizeof(analog));
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = 1; analog.num_samples = 1;
analog.mq = devc->mq; analog.mq = devc->mq;
analog.unit = devc->unit; analog.unit = devc->unit;

View File

@ -565,53 +565,53 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
SR_PRIV int hmo_request_data(const struct sr_dev_inst *sdi) SR_PRIV int hmo_request_data(const struct sr_dev_inst *sdi)
{ {
char command[MAX_COMMAND_SIZE]; char command[MAX_COMMAND_SIZE];
struct sr_channel *probe; struct sr_channel *ch;
struct dev_context *devc; struct dev_context *devc;
struct scope_config *model; struct scope_config *model;
devc = sdi->priv; devc = sdi->priv;
model = devc->model_config; model = devc->model_config;
probe = devc->current_probe->data; ch = devc->current_channel->data;
switch (probe->type) { switch (ch->type) {
case SR_PROBE_ANALOG: case SR_PROBE_ANALOG:
g_snprintf(command, sizeof(command), g_snprintf(command, sizeof(command),
(*model->scpi_dialect)[SCPI_CMD_GET_ANALOG_DATA], (*model->scpi_dialect)[SCPI_CMD_GET_ANALOG_DATA],
probe->index + 1); ch->index + 1);
break; break;
case SR_PROBE_LOGIC: case SR_PROBE_LOGIC:
g_snprintf(command, sizeof(command), g_snprintf(command, sizeof(command),
(*model->scpi_dialect)[SCPI_CMD_GET_DIG_DATA], (*model->scpi_dialect)[SCPI_CMD_GET_DIG_DATA],
probe->index < 8 ? 1 : 2); ch->index < 8 ? 1 : 2);
break; break;
default: default:
sr_err("Invalid probe type."); sr_err("Invalid channel type.");
break; break;
} }
return sr_scpi_send(sdi->conn, command); return sr_scpi_send(sdi->conn, command);
} }
static int hmo_check_probes(GSList *probes) static int hmo_check_channels(GSList *channels)
{ {
GSList *l; GSList *l;
struct sr_channel *probe; struct sr_channel *ch;
gboolean enabled_pod1, enabled_pod2, enabled_chan3, enabled_chan4; gboolean enabled_pod1, enabled_pod2, enabled_chan3, enabled_chan4;
enabled_pod1 = enabled_pod2 = enabled_chan3 = enabled_chan4 = FALSE; enabled_pod1 = enabled_pod2 = enabled_chan3 = enabled_chan4 = FALSE;
for (l = probes; l; l = l->next) { for (l = channels; l; l = l->next) {
probe = l->data; ch = l->data;
switch (probe->type) { switch (ch->type) {
case SR_PROBE_ANALOG: case SR_PROBE_ANALOG:
if (probe->index == 2) if (ch->index == 2)
enabled_chan3 = TRUE; enabled_chan3 = TRUE;
else if (probe->index == 3) else if (ch->index == 3)
enabled_chan4 = TRUE; enabled_chan4 = TRUE;
break; break;
case SR_PROBE_LOGIC: case SR_PROBE_LOGIC:
if (probe->index < 8) if (ch->index < 8)
enabled_pod1 = TRUE; enabled_pod1 = TRUE;
else else
enabled_pod2 = TRUE; enabled_pod2 = TRUE;
@ -628,7 +628,7 @@ static int hmo_check_probes(GSList *probes)
return SR_OK; return SR_OK;
} }
static int hmo_setup_probes(const struct sr_dev_inst *sdi) static int hmo_setup_channels(const struct sr_dev_inst *sdi)
{ {
GSList *l; GSList *l;
unsigned int i; unsigned int i;
@ -636,7 +636,7 @@ static int hmo_setup_probes(const struct sr_dev_inst *sdi)
char command[MAX_COMMAND_SIZE]; char command[MAX_COMMAND_SIZE];
struct scope_state *state; struct scope_state *state;
struct scope_config *model; struct scope_config *model;
struct sr_channel *probe; struct sr_channel *ch;
struct dev_context *devc; struct dev_context *devc;
struct sr_scpi_dev_inst *scpi; struct sr_scpi_dev_inst *scpi;
@ -648,39 +648,39 @@ static int hmo_setup_probes(const struct sr_dev_inst *sdi)
pod_enabled = g_try_malloc0(sizeof(gboolean) * model->digital_pods); pod_enabled = g_try_malloc0(sizeof(gboolean) * model->digital_pods);
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
switch (probe->type) { switch (ch->type) {
case SR_PROBE_ANALOG: case SR_PROBE_ANALOG:
if (probe->enabled == state->analog_channels[probe->index].state) if (ch->enabled == state->analog_channels[ch->index].state)
break; break;
g_snprintf(command, sizeof(command), g_snprintf(command, sizeof(command),
(*model->scpi_dialect)[SCPI_CMD_SET_ANALOG_CHAN_STATE], (*model->scpi_dialect)[SCPI_CMD_SET_ANALOG_CHAN_STATE],
probe->index + 1, probe->enabled); ch->index + 1, ch->enabled);
if (sr_scpi_send(scpi, command) != SR_OK) if (sr_scpi_send(scpi, command) != SR_OK)
return SR_ERR; return SR_ERR;
state->analog_channels[probe->index].state = probe->enabled; state->analog_channels[ch->index].state = ch->enabled;
setup_changed = TRUE; setup_changed = TRUE;
break; break;
case SR_PROBE_LOGIC: case SR_PROBE_LOGIC:
/* /*
* A digital POD needs to be enabled for every group of * A digital POD needs to be enabled for every group of
* 8 probes. * 8 channels.
*/ */
if (probe->enabled) if (ch->enabled)
pod_enabled[probe->index < 8 ? 0 : 1] = TRUE; pod_enabled[ch->index < 8 ? 0 : 1] = TRUE;
if (probe->enabled == state->digital_channels[probe->index]) if (ch->enabled == state->digital_channels[ch->index])
break; break;
g_snprintf(command, sizeof(command), g_snprintf(command, sizeof(command),
(*model->scpi_dialect)[SCPI_CMD_SET_DIG_CHAN_STATE], (*model->scpi_dialect)[SCPI_CMD_SET_DIG_CHAN_STATE],
probe->index, probe->enabled); ch->index, ch->enabled);
if (sr_scpi_send(scpi, command) != SR_OK) if (sr_scpi_send(scpi, command) != SR_OK)
return SR_ERR; return SR_ERR;
state->digital_channels[probe->index] = probe->enabled; state->digital_channels[ch->index] = ch->enabled;
setup_changed = TRUE; setup_changed = TRUE;
break; break;
default: default:
@ -712,7 +712,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{ {
GSList *l; GSList *l;
gboolean digital_added; gboolean digital_added;
struct sr_channel *probe; struct sr_channel *ch;
struct dev_context *devc; struct dev_context *devc;
struct sr_scpi_dev_inst *scpi; struct sr_scpi_dev_inst *scpi;
@ -723,29 +723,29 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
devc = sdi->priv; devc = sdi->priv;
digital_added = FALSE; digital_added = FALSE;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (!probe->enabled) if (!ch->enabled)
continue; continue;
/* Only add a single digital probe. */ /* Only add a single digital channel. */
if (probe->type != SR_PROBE_LOGIC || !digital_added) { if (ch->type != SR_PROBE_LOGIC || !digital_added) {
devc->enabled_probes = g_slist_append( devc->enabled_channels = g_slist_append(
devc->enabled_probes, probe); devc->enabled_channels, ch);
if (probe->type == SR_PROBE_LOGIC) if (ch->type == SR_PROBE_LOGIC)
digital_added = TRUE; digital_added = TRUE;
} }
} }
if (!devc->enabled_probes) if (!devc->enabled_channels)
return SR_ERR; return SR_ERR;
if (hmo_check_probes(devc->enabled_probes) != SR_OK) { if (hmo_check_channels(devc->enabled_channels) != SR_OK) {
sr_err("Invalid probe configuration specified!"); sr_err("Invalid channel configuration specified!");
return SR_ERR_NA; return SR_ERR_NA;
} }
if (hmo_setup_probes(sdi) != SR_OK) { if (hmo_setup_channels(sdi) != SR_OK) {
sr_err("Failed to setup probe configuration!"); sr_err("Failed to setup channel configuration!");
return SR_ERR; return SR_ERR;
} }
@ -754,7 +754,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
/* Send header packet to the session bus. */ /* Send header packet to the session bus. */
std_session_send_df_header(cb_data, LOG_PREFIX); std_session_send_df_header(cb_data, LOG_PREFIX);
devc->current_probe = devc->enabled_probes; devc->current_channel = devc->enabled_channels;
return hmo_request_data(sdi); return hmo_request_data(sdi);
} }
@ -777,8 +777,8 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
devc = sdi->priv; devc = sdi->priv;
devc->num_frames = 0; devc->num_frames = 0;
g_slist_free(devc->enabled_probes); g_slist_free(devc->enabled_channels);
devc->enabled_probes = NULL; devc->enabled_channels = NULL;
scpi = sdi->conn; scpi = sdi->conn;
sr_scpi_source_remove(scpi); sr_scpi_source_remove(scpi);

View File

@ -168,14 +168,14 @@ static const uint64_t hmo_vdivs[][2] = {
{ 10, 1 }, { 10, 1 },
}; };
static const char *scope_analog_probe_names[] = { static const char *scope_analog_channel_names[] = {
"CH1", "CH1",
"CH2", "CH2",
"CH3", "CH3",
"CH4", "CH4",
}; };
static const char *scope_digital_probe_names[] = { static const char *scope_digital_channel_names[] = {
"D0", "D0",
"D1", "D1",
"D2", "D2",
@ -201,8 +201,8 @@ static struct scope_config scope_models[] = {
.digital_channels = 8, .digital_channels = 8,
.digital_pods = 1, .digital_pods = 1,
.analog_names = &scope_analog_probe_names, .analog_names = &scope_analog_channel_names,
.digital_names = &scope_digital_probe_names, .digital_names = &scope_digital_channel_names,
.hw_caps = &hmo_hwcaps, .hw_caps = &hmo_hwcaps,
.num_hwcaps = ARRAY_SIZE(hmo_hwcaps), .num_hwcaps = ARRAY_SIZE(hmo_hwcaps),
@ -231,8 +231,8 @@ static struct scope_config scope_models[] = {
.digital_channels = 8, .digital_channels = 8,
.digital_pods = 1, .digital_pods = 1,
.analog_names = &scope_analog_probe_names, .analog_names = &scope_analog_channel_names,
.digital_names = &scope_digital_probe_names, .digital_names = &scope_digital_channel_names,
.hw_caps = &hmo_hwcaps, .hw_caps = &hmo_hwcaps,
.num_hwcaps = ARRAY_SIZE(hmo_hwcaps), .num_hwcaps = ARRAY_SIZE(hmo_hwcaps),
@ -581,7 +581,7 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
char tmp[25]; char tmp[25];
int model_index; int model_index;
unsigned int i, j; unsigned int i, j;
struct sr_channel *probe; struct sr_channel *ch;
struct dev_context *devc; struct dev_context *devc;
devc = sdi->priv; devc = sdi->priv;
@ -614,14 +614,14 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
/* Add analog channels. */ /* Add analog channels. */
for (i = 0; i < scope_models[model_index].analog_channels; i++) { for (i = 0; i < scope_models[model_index].analog_channels; i++) {
if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, if (!(ch = sr_probe_new(i, SR_PROBE_ANALOG, TRUE,
(*scope_models[model_index].analog_names)[i]))) (*scope_models[model_index].analog_names)[i])))
return SR_ERR_MALLOC; return SR_ERR_MALLOC;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
devc->analog_groups[i].name = devc->analog_groups[i].name =
(char *)(*scope_models[model_index].analog_names)[i]; (char *)(*scope_models[model_index].analog_names)[i];
devc->analog_groups[i].channels = g_slist_append(NULL, probe); devc->analog_groups[i].channels = g_slist_append(NULL, ch);
sdi->channel_groups = g_slist_append(sdi->channel_groups, sdi->channel_groups = g_slist_append(sdi->channel_groups,
&devc->analog_groups[i]); &devc->analog_groups[i]);
@ -637,13 +637,13 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
/* Add digital channels. */ /* Add digital channels. */
for (i = 0; i < scope_models[model_index].digital_channels; i++) { for (i = 0; i < scope_models[model_index].digital_channels; i++) {
if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, if (!(ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE,
(*scope_models[model_index].digital_names)[i]))) (*scope_models[model_index].digital_names)[i])))
return SR_ERR_MALLOC; return SR_ERR_MALLOC;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
devc->digital_groups[i < 8 ? 0 : 1].channels = g_slist_append( devc->digital_groups[i < 8 ? 0 : 1].channels = g_slist_append(
devc->digital_groups[i < 8 ? 0 : 1].channels, probe); devc->digital_groups[i < 8 ? 0 : 1].channels, ch);
} }
devc->model_config = &scope_models[model_index]; devc->model_config = &scope_models[model_index];
@ -657,7 +657,7 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data) SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
{ {
struct sr_channel *probe; struct sr_channel *ch;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct dev_context *devc; struct dev_context *devc;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
@ -674,9 +674,9 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
return TRUE; return TRUE;
if (revents == G_IO_IN) { if (revents == G_IO_IN) {
probe = devc->current_probe->data; ch = devc->current_channel->data;
switch (probe->type) { switch (ch->type) {
case SR_PROBE_ANALOG: case SR_PROBE_ANALOG:
if (sr_scpi_get_floatv(sdi->conn, NULL, &data) != SR_OK) { if (sr_scpi_get_floatv(sdi->conn, NULL, &data) != SR_OK) {
if (data) if (data)
@ -688,7 +688,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
packet.type = SR_DF_FRAME_BEGIN; packet.type = SR_DF_FRAME_BEGIN;
sr_session_send(sdi, &packet); sr_session_send(sdi, &packet);
analog.probes = g_slist_append(NULL, probe); analog.channels = g_slist_append(NULL, ch);
analog.num_samples = data->len; analog.num_samples = data->len;
analog.data = (float *) data->data; analog.data = (float *) data->data;
analog.mq = SR_MQ_VOLTAGE; analog.mq = SR_MQ_VOLTAGE;
@ -697,7 +697,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
sr_session_send(cb_data, &packet); sr_session_send(cb_data, &packet);
g_slist_free(analog.probes); g_slist_free(analog.channels);
g_array_free(data, TRUE); g_array_free(data, TRUE);
break; break;
case SR_PROBE_LOGIC: case SR_PROBE_LOGIC:
@ -719,20 +719,20 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
g_array_free(data, TRUE); g_array_free(data, TRUE);
break; break;
default: default:
sr_err("Invalid probe type."); sr_err("Invalid channel type.");
break; break;
} }
packet.type = SR_DF_FRAME_END; packet.type = SR_DF_FRAME_END;
sr_session_send(sdi, &packet); sr_session_send(sdi, &packet);
if (devc->current_probe->next) { if (devc->current_channel->next) {
devc->current_probe = devc->current_probe->next; devc->current_channel = devc->current_channel->next;
hmo_request_data(sdi); hmo_request_data(sdi);
} else if (++devc->num_frames == devc->frame_limit) { } else if (++devc->num_frames == devc->frame_limit) {
sdi->driver->dev_acquisition_stop(sdi, cb_data); sdi->driver->dev_acquisition_stop(sdi, cb_data);
} else { } else {
devc->current_probe = devc->enabled_probes; devc->current_channel = devc->enabled_channels;
hmo_request_data(sdi); hmo_request_data(sdi);
} }
} }

View File

@ -96,8 +96,8 @@ struct dev_context {
struct sr_channel_group *analog_groups; struct sr_channel_group *analog_groups;
struct sr_channel_group *digital_groups; struct sr_channel_group *digital_groups;
GSList *enabled_probes; GSList *enabled_channels;
GSList *current_probe; GSList *current_channel;
uint64_t num_frames; uint64_t num_frames;
uint64_t frame_limit; uint64_t frame_limit;

View File

@ -60,7 +60,7 @@ static const int32_t devopts[] = {
SR_CONF_NUM_VDIV, SR_CONF_NUM_VDIV,
}; };
static const char *probe_names[] = { static const char *channel_names[] = {
"CH1", "CH2", "CH1", "CH2",
NULL, NULL,
}; };
@ -160,7 +160,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
static struct sr_dev_inst *dso_dev_new(int index, const struct dso_profile *prof) static struct sr_dev_inst *dso_dev_new(int index, const struct dso_profile *prof)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
int i; int i;
@ -172,14 +172,14 @@ static struct sr_dev_inst *dso_dev_new(int index, const struct dso_profile *prof
sdi->driver = di; sdi->driver = di;
/* /*
* Add only the real probes -- EXT isn't a source of data, only * Add only the real channels -- EXT isn't a source of data, only
* a trigger source internal to the device. * a trigger source internal to the device.
*/ */
for (i = 0; probe_names[i]; i++) { for (i = 0; channel_names[i]; i++) {
if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, if (!(ch = sr_probe_new(i, SR_PROBE_ANALOG, TRUE,
probe_names[i]))) channel_names[i])))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) { if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
@ -210,25 +210,25 @@ static struct sr_dev_inst *dso_dev_new(int index, const struct dso_profile *prof
return sdi; return sdi;
} }
static int configure_probes(const struct sr_dev_inst *sdi) static int configure_channels(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
const GSList *l; const GSList *l;
int p; int p;
devc = sdi->priv; devc = sdi->priv;
g_slist_free(devc->enabled_probes); g_slist_free(devc->enabled_channels);
devc->ch1_enabled = devc->ch2_enabled = FALSE; devc->ch1_enabled = devc->ch2_enabled = FALSE;
for (l = sdi->probes, p = 0; l; l = l->next, p++) { for (l = sdi->channels, p = 0; l; l = l->next, p++) {
probe = l->data; ch = l->data;
if (p == 0) if (p == 0)
devc->ch1_enabled = probe->enabled; devc->ch1_enabled = ch->enabled;
else else
devc->ch2_enabled = probe->enabled; devc->ch2_enabled = ch->enabled;
if (probe->enabled) if (ch->enabled)
devc->enabled_probes = g_slist_append(devc->enabled_probes, probe); devc->enabled_channels = g_slist_append(devc->enabled_channels, ch);
} }
return SR_OK; return SR_OK;
@ -240,7 +240,7 @@ static void clear_dev_context(void *priv)
devc = priv; devc = priv;
g_free(devc->triggersource); g_free(devc->triggersource);
g_slist_free(devc->enabled_probes); g_slist_free(devc->enabled_channels);
} }
@ -657,19 +657,19 @@ static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf,
struct sr_datafeed_analog analog; struct sr_datafeed_analog analog;
struct dev_context *devc; struct dev_context *devc;
float ch1, ch2, range; float ch1, ch2, range;
int num_probes, data_offset, i; int num_channels, data_offset, i;
devc = sdi->priv; devc = sdi->priv;
num_probes = (devc->ch1_enabled && devc->ch2_enabled) ? 2 : 1; num_channels = (devc->ch1_enabled && devc->ch2_enabled) ? 2 : 1;
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
/* TODO: support for 5xxx series 9-bit samples */ /* TODO: support for 5xxx series 9-bit samples */
analog.probes = devc->enabled_probes; analog.channels = devc->enabled_channels;
analog.num_samples = num_samples; analog.num_samples = num_samples;
analog.mq = SR_MQ_VOLTAGE; analog.mq = SR_MQ_VOLTAGE;
analog.unit = SR_UNIT_VOLT; analog.unit = SR_UNIT_VOLT;
/* TODO: Check malloc return value. */ /* TODO: Check malloc return value. */
analog.data = g_try_malloc(analog.num_samples * sizeof(float) * num_probes); analog.data = g_try_malloc(analog.num_samples * sizeof(float) * num_channels);
data_offset = 0; data_offset = 0;
for (i = 0; i < analog.num_samples; i++) { for (i = 0; i < analog.num_samples; i++) {
/* /*
@ -806,7 +806,7 @@ static int handle_event(int fd, int revents, void *cb_data)
struct timeval tv; struct timeval tv;
struct dev_context *devc; struct dev_context *devc;
struct drv_context *drvc = di->priv; struct drv_context *drvc = di->priv;
int num_probes; int num_channels;
uint32_t trigger_offset; uint32_t trigger_offset;
uint8_t capturestate; uint8_t capturestate;
@ -876,9 +876,9 @@ static int handle_event(int fd, int revents, void *cb_data)
/* Remember where in the captured frame the trigger is. */ /* Remember where in the captured frame the trigger is. */
devc->trigger_offset = trigger_offset; devc->trigger_offset = trigger_offset;
num_probes = (devc->ch1_enabled && devc->ch2_enabled) ? 2 : 1; num_channels = (devc->ch1_enabled && devc->ch2_enabled) ? 2 : 1;
/* TODO: Check malloc return value. */ /* TODO: Check malloc return value. */
devc->framebuf = g_try_malloc(devc->framesize * num_probes * 2); devc->framebuf = g_try_malloc(devc->framesize * num_channels * 2);
devc->samp_buffered = devc->samp_received = 0; devc->samp_buffered = devc->samp_received = 0;
/* Tell the scope to send us the first frame. */ /* Tell the scope to send us the first frame. */
@ -921,8 +921,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
devc = sdi->priv; devc = sdi->priv;
devc->cb_data = cb_data; devc->cb_data = cb_data;
if (configure_probes(sdi) != SR_OK) { if (configure_channels(sdi) != SR_OK) {
sr_err("Failed to configure probes."); sr_err("Failed to configure channels.");
return SR_ERR; return SR_ERR;
} }

View File

@ -165,7 +165,7 @@ struct dev_context {
void *cb_data; void *cb_data;
uint64_t limit_frames; uint64_t limit_frames;
uint64_t num_frames; uint64_t num_frames;
GSList *enabled_probes; GSList *enabled_channels;
/* We can't keep track of an FX2-based device after upgrading /* We can't keep track of an FX2-based device after upgrading
* the firmware (it re-enumerates into a different device address * the firmware (it re-enumerates into a different device address
* after the upgrade) this is like a global lock. No device will open * after the upgrade) this is like a global lock. No device will open

View File

@ -41,7 +41,7 @@ SR_PRIV const uint64_t sl2_samplerates[NUM_SAMPLERATES] = {
SR_MHZ(20), SR_MHZ(20),
}; };
static const char *probe_names[NUM_PROBES + 1] = { static const char *channel_names[NUM_PROBES + 1] = {
"0", "1", "2", "3", "0", "1", "2", "3",
NULL, NULL,
}; };
@ -59,7 +59,7 @@ static GSList *scan(GSList *options)
GSList *usb_devices, *devices, *l; GSList *usb_devices, *devices, *l;
struct drv_context *drvc; struct drv_context *drvc;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
struct dev_context *devc; struct dev_context *devc;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
struct device_info dev_info; struct device_info dev_info;
@ -136,11 +136,11 @@ static GSList *scan(GSList *options)
sdi->inst_type = SR_INST_USB; sdi->inst_type = SR_INST_USB;
sdi->conn = usb; sdi->conn = usb;
for (i = 0; probe_names[i]; i++) { for (i = 0; channel_names[i]; i++) {
probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE,
probe_names[i]); channel_names[i]);
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
devc->probes[i] = probe; devc->channels[i] = ch;
} }
devc->state = STATE_IDLE; devc->state = STATE_IDLE;
@ -443,21 +443,21 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
if (trigger_bytes % PACKET_NUM_SAMPLE_BYTES != 0) if (trigger_bytes % PACKET_NUM_SAMPLE_BYTES != 0)
devc->num_sample_packets++; devc->num_sample_packets++;
devc->num_enabled_probes = 0; devc->num_enabled_channels = 0;
/* /*
* Count the number of enabled probes and number them for a sequential * Count the number of enabled channels and number them for a sequential
* access. * access.
*/ */
for (i = 0, j = 0; i < NUM_PROBES; i++) { for (i = 0, j = 0; i < NUM_PROBES; i++) {
if (devc->probes[i]->enabled) { if (devc->channels[i]->enabled) {
devc->num_enabled_probes++; devc->num_enabled_channels++;
devc->probe_map[j] = i; devc->channel_map[j] = i;
j++; j++;
} }
} }
sr_dbg("Number of enabled probes: %i.", devc->num_enabled_probes); sr_dbg("Number of enabled channels: %i.", devc->num_enabled_channels);
/* Set up the transfer buffer for the acquisition. */ /* Set up the transfer buffer for the acquisition. */
devc->xfer_data_out[0] = CMD_SAMPLE; devc->xfer_data_out[0] = CMD_SAMPLE;

View File

@ -65,7 +65,7 @@ static void buffer_sample_data(const struct sr_dev_inst *sdi)
devc = sdi->priv; devc = sdi->priv;
if (devc->probes[devc->channel]->enabled) { if (devc->channels[devc->channel]->enabled) {
offset = devc->sample_packet * PACKET_NUM_SAMPLE_BYTES; offset = devc->sample_packet * PACKET_NUM_SAMPLE_BYTES;
/* /*
@ -101,8 +101,8 @@ static void process_sample_data(const struct sr_dev_inst *sdi)
* enabled one for an uniform access to them. Note that the currently * enabled one for an uniform access to them. Note that the currently
* received samples always belong to the last enabled channel. * received samples always belong to the last enabled channel.
*/ */
for (i = 0; i < devc->num_enabled_probes - 1; i++) for (i = 0; i < devc->num_enabled_channels - 1; i++)
ptr[i] = devc->sample_buffer[devc->probe_map[i]] + offset; ptr[i] = devc->sample_buffer[devc->channel_map[i]] + offset;
/* /*
* Skip the first 4 bytes of the buffer because they contain channel * Skip the first 4 bytes of the buffer because they contain channel
@ -156,9 +156,9 @@ static void process_sample_data(const struct sr_dev_inst *sdi)
* Extract the current sample for each enabled channel * Extract the current sample for each enabled channel
* and store them in the buffer. * and store them in the buffer.
*/ */
for (j = 0; j < devc->num_enabled_probes; j++) { for (j = 0; j < devc->num_enabled_channels; j++) {
tmp = (ptr[j][i] & (1 << k)) >> k; tmp = (ptr[j][i] & (1 << k)) >> k;
buffer[n] |= tmp << devc->probe_map[j]; buffer[n] |= tmp << devc->channel_map[j];
} }
n++; n++;
@ -313,7 +313,7 @@ SR_PRIV void sl2_receive_transfer_in( struct libusb_transfer *transfer)
devc->wait_data_ready_time = g_get_monotonic_time(); devc->wait_data_ready_time = g_get_monotonic_time();
} }
} else if (devc->state == STATE_RECEIVE_DATA) { } else if (devc->state == STATE_RECEIVE_DATA) {
last_channel = devc->probe_map[devc->num_enabled_probes - 1]; last_channel = devc->channel_map[devc->num_enabled_channels - 1];
if (devc->channel < last_channel) { if (devc->channel < last_channel) {
buffer_sample_data(sdi); buffer_sample_data(sdi);
@ -322,7 +322,7 @@ SR_PRIV void sl2_receive_transfer_in( struct libusb_transfer *transfer)
} else { } else {
/* /*
* Stop acquisition because all samples of enabled * Stop acquisition because all samples of enabled
* probes are processed. * channels are processed.
*/ */
devc->next_state = STATE_RESET_AND_IDLE; devc->next_state = STATE_RESET_AND_IDLE;
} }
@ -482,9 +482,9 @@ SR_PRIV int sl2_set_limit_samples(const struct sr_dev_inst *sdi,
SR_PRIV void sl2_configure_trigger(const struct sr_dev_inst *sdi) SR_PRIV void sl2_configure_trigger(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
uint8_t trigger_type; uint8_t trigger_type;
int probe_index, num_triggers_anyedge; int channel_index, num_triggers_anyedge;
char *trigger; char *trigger;
GSList *l; GSList *l;
@ -496,11 +496,11 @@ SR_PRIV void sl2_configure_trigger(const struct sr_dev_inst *sdi)
num_triggers_anyedge = 0; num_triggers_anyedge = 0;
for (l = sdi->probes, probe_index = 0; l; l = l->next, probe_index++) { for (l = sdi->channels, channel_index = 0; l; l = l->next, channel_index++) {
probe = l->data; ch = l->data;
trigger = probe->trigger; trigger = ch->trigger;
if (!trigger || !probe->enabled) if (!trigger || !ch->enabled)
continue; continue;
switch (*trigger) { switch (*trigger) {
@ -518,7 +518,7 @@ SR_PRIV void sl2_configure_trigger(const struct sr_dev_inst *sdi)
continue; continue;
} }
devc->trigger_channel = probe_index + 1; devc->trigger_channel = channel_index + 1;
devc->trigger_type = trigger_type; devc->trigger_type = trigger_type;
} }

View File

@ -151,8 +151,8 @@ struct dev_context {
void *cb_data; void *cb_data;
/* Array to provide an index based access to all probes. */ /* Array to provide an index based access to all channels. */
const struct sr_channel *probes[NUM_PROBES]; const struct sr_channel *channels[NUM_PROBES];
struct libusb_transfer *xfer_in, *xfer_out; struct libusb_transfer *xfer_in, *xfer_out;
@ -208,11 +208,11 @@ struct dev_context {
/* Channel number that is currently processed. */ /* Channel number that is currently processed. */
uint8_t channel; uint8_t channel;
/* Number of enabled probes. */ /* Number of enabled channels. */
unsigned int num_enabled_probes; unsigned int num_enabled_channels;
/* Array to provide a sequential access to all enabled probe indices. */ /* Array to provide a sequential access to all enabled channel indices. */
uint8_t probe_map[NUM_PROBES]; uint8_t channel_map[NUM_PROBES];
/* Indicates whether a transfer failed. */ /* Indicates whether a transfer failed. */
gboolean transfer_error; gboolean transfer_error;

View File

@ -36,8 +36,8 @@ static const int32_t hwcaps[] = {
SR_CONF_CONTINUOUS, // TODO? SR_CONF_CONTINUOUS, // TODO?
}; };
/* Probes are numbered 1-9. */ /* Channels are numbered 1-9. */
static const char *probe_names[] = { static const char *channel_names[] = {
"1", "2", "3", "4", "5", "6", "7", "8", "9", "1", "2", "3", "4", "5", "6", "7", "8", "9",
NULL, NULL,
}; };
@ -74,7 +74,7 @@ static int init(struct sr_context *sr_ctx)
static GSList *scan(GSList *options) static GSList *scan(GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
GSList *devices; GSList *devices;
@ -132,11 +132,11 @@ static GSList *scan(GSList *options)
sdi->driver = di; sdi->driver = di;
sdi->priv = devc; sdi->priv = devc;
for (i = 0; probe_names[i]; i++) { for (i = 0; channel_names[i]; i++) {
if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, if (!(ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE,
probe_names[i]))) channel_names[i])))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);
@ -377,7 +377,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
if (!devc->ftdic) if (!devc->ftdic)
return SR_ERR_BUG; return SR_ERR_BUG;
/* TODO: Configure probes later (thresholds etc.). */ /* TODO: Configure channels later (thresholds etc.). */
devc->cb_data = cb_data; devc->cb_data = cb_data;

View File

@ -116,7 +116,7 @@ static void send_samples(struct dev_context *devc, uint64_t samples_to_send)
packet.type = SR_DF_LOGIC; packet.type = SR_DF_LOGIC;
packet.payload = &logic; packet.payload = &logic;
logic.length = samples_to_send * 2; logic.length = samples_to_send * 2;
logic.unitsize = 2; /* We need 2 bytes for 9 probes. */ logic.unitsize = 2; /* We need 2 bytes for 9 channels. */
logic.data = devc->sample_buf; logic.data = devc->sample_buf;
sr_session_send(devc->cb_data, &packet); sr_session_send(devc->cb_data, &packet);
@ -267,17 +267,17 @@ SR_PRIV int scanaplus_start_acquisition(struct dev_context *devc)
{ {
uint8_t buf[4]; uint8_t buf[4];
/* Threshold and differential probe settings not yet implemented. */ /* Threshold and differential channel settings not yet implemented. */
buf[0] = 0x89; buf[0] = 0x89;
buf[1] = 0x7f; /* Logic level threshold for probes 1-4. */ buf[1] = 0x7f; /* Logic level threshold for channels 1-4. */
buf[2] = 0x8a; buf[2] = 0x8a;
buf[3] = 0x7f; /* Logic level threshold for probes 5-9. */ buf[3] = 0x7f; /* Logic level threshold for channels 5-9. */
if (scanaplus_write(devc, (uint8_t *)&buf, 4) < 0) if (scanaplus_write(devc, (uint8_t *)&buf, 4) < 0)
return SR_ERR; return SR_ERR;
buf[0] = 0x88; buf[0] = 0x88;
buf[1] = 0x40; /* Special config of probes 5/6 and 7/8. */ buf[1] = 0x40; /* Special config of channels 5/6 and 7/8. */
/* 0x40: normal, 0x50: ch56 diff, 0x48: ch78 diff, 0x58: ch5678 diff */ /* 0x40: normal, 0x50: ch56 diff, 0x48: ch78 diff, 0x58: ch5678 diff */
if (scanaplus_write(devc, (uint8_t *)&buf, 2) < 0) if (scanaplus_write(devc, (uint8_t *)&buf, 2) < 0)
return SR_ERR; return SR_ERR;
@ -327,7 +327,7 @@ SR_PRIV int scanaplus_receive_data(int fd, int revents, void *cb_data)
/* /*
* After a ScanaPLUS acquisition starts, a bunch of samples will be * After a ScanaPLUS acquisition starts, a bunch of samples will be
* returned as all-zero, no matter which signals are actually present * returned as all-zero, no matter which signals are actually present
* on the probes. This is probably due to the FPGA reconfiguring some * on the channels. This is probably due to the FPGA reconfiguring some
* of its internal state/config during this time. * of its internal state/config during this time.
* *
* As far as we know there is apparently no way for the PC-side to * As far as we know there is apparently no way for the PC-side to

View File

@ -112,7 +112,7 @@ static GSList *scan(GSList *options)
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
GSList *usb_devices, *devices, *l; GSList *usb_devices, *devices, *l;
char *model; char *model;
@ -135,9 +135,9 @@ static GSList *scan(GSList *options)
sdi->driver = di; sdi->driver = di;
sdi->inst_type = SR_INST_USB; sdi->inst_type = SR_INST_USB;
sdi->conn = l->data; sdi->conn = l->data;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "SPL"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "SPL")))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (!(devc = g_try_malloc(sizeof(struct dev_context)))) { if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
sr_dbg("Device context malloc failed."); sr_dbg("Device context malloc failed.");

View File

@ -114,7 +114,7 @@ static void send_data(const struct sr_dev_inst *sdi, void *buf, unsigned int buf
analog.mq = SR_MQ_SOUND_PRESSURE_LEVEL; analog.mq = SR_MQ_SOUND_PRESSURE_LEVEL;
analog.mqflags = devc->mqflags; analog.mqflags = devc->mqflags;
analog.unit = SR_UNIT_DECIBEL_SPL; analog.unit = SR_UNIT_DECIBEL_SPL;
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = buf_len; analog.num_samples = buf_len;
analog.data = buf; analog.data = buf;
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;

View File

@ -293,7 +293,7 @@ static struct sr_dev_inst *lascar_identify(unsigned char *config)
struct dev_context *devc; struct dev_context *devc;
const struct elusb_profile *profile; const struct elusb_profile *profile;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
int modelid, i; int modelid, i;
char firmware[5]; char firmware[5];
@ -329,21 +329,21 @@ static struct sr_dev_inst *lascar_identify(unsigned char *config)
sdi->driver = di; sdi->driver = di;
if (profile->logformat == LOG_TEMP_RH) { if (profile->logformat == LOG_TEMP_RH) {
/* Model this as two probes: temperature and humidity. */ /* Model this as two channels: temperature and humidity. */
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "Temp"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "Temp")))
return NULL; return NULL;
sdi->probes = g_slist_append(NULL, probe); sdi->channels = g_slist_append(NULL, ch);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "Hum"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "Hum")))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} else if (profile->logformat == LOG_CO) { } else if (profile->logformat == LOG_CO) {
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "CO"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "CO")))
return NULL; return NULL;
sdi->probes = g_slist_append(NULL, probe); sdi->channels = g_slist_append(NULL, ch);
} else { } else {
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
return NULL; return NULL;
sdi->probes = g_slist_append(NULL, probe); sdi->channels = g_slist_append(NULL, ch);
} }
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
@ -398,7 +398,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
struct dev_context *devc; struct dev_context *devc;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog; struct sr_datafeed_analog analog;
struct sr_channel *probe; struct sr_channel *ch;
float *temp, *rh; float *temp, *rh;
uint16_t s; uint16_t s;
int samples, samples_left, i, j; int samples, samples_left, i, j;
@ -435,9 +435,9 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
} }
analog.num_samples = j; analog.num_samples = j;
probe = sdi->probes->data; ch = sdi->channels->data;
if (probe->enabled) { if (ch->enabled) {
analog.probes = g_slist_append(NULL, probe); analog.channels = g_slist_append(NULL, ch);
analog.mq = SR_MQ_TEMPERATURE; analog.mq = SR_MQ_TEMPERATURE;
if (devc->temp_unit == 1) if (devc->temp_unit == 1)
analog.unit = SR_UNIT_FAHRENHEIT; analog.unit = SR_UNIT_FAHRENHEIT;
@ -447,9 +447,9 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
sr_session_send(devc->cb_data, &packet); sr_session_send(devc->cb_data, &packet);
} }
probe = sdi->probes->next->data; ch = sdi->channels->next->data;
if (probe->enabled) { if (ch->enabled) {
analog.probes = g_slist_append(NULL, probe); analog.channels = g_slist_append(NULL, ch);
analog.mq = SR_MQ_RELATIVE_HUMIDITY; analog.mq = SR_MQ_RELATIVE_HUMIDITY;
analog.unit = SR_UNIT_PERCENTAGE; analog.unit = SR_UNIT_PERCENTAGE;
analog.data = rh; analog.data = rh;
@ -462,7 +462,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
case LOG_CO: case LOG_CO:
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = samples; analog.num_samples = samples;
analog.mq = SR_MQ_CARBON_MONOXIDE; analog.mq = SR_MQ_CARBON_MONOXIDE;
analog.unit = SR_UNIT_CONCENTRATION; analog.unit = SR_UNIT_CONCENTRATION;

View File

@ -33,11 +33,11 @@ static const int32_t hwcaps[] = {
}; };
/* /*
* Probes are numbered 0 to 7. * Channels are numbered 0 to 7.
* *
* See also: http://www.linkinstruments.com/images/mso19_1113.gif * See also: http://www.linkinstruments.com/images/mso19_1113.gif
*/ */
SR_PRIV const char *mso19_probe_names[NUM_PROBES + 1] = { SR_PRIV const char *mso19_channel_names[NUM_PROBES + 1] = {
/* Note: DSO needs to be first. */ /* Note: DSO needs to be first. */
"DSO", "0", "1", "2", "3", "4", "5", "6", "7", NULL, "DSO", "0", "1", "2", "3", "4", "5", "6", "7", NULL,
}; };
@ -217,12 +217,12 @@ static GSList *scan(GSList *options)
sdi->priv = devc; sdi->priv = devc;
for (i = 0; i < NUM_PROBES; i++) { for (i = 0; i < NUM_PROBES; i++) {
struct sr_channel *probe; struct sr_channel *ch;
ptype = (i == 0) ? SR_PROBE_ANALOG : SR_PROBE_LOGIC; ptype = (i == 0) ? SR_PROBE_ANALOG : SR_PROBE_LOGIC;
if (!(probe = sr_probe_new(i, ptype, TRUE, if (!(ch = sr_probe_new(i, ptype, TRUE,
mso19_probe_names[i]))) mso19_channel_names[i])))
return 0; return 0;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
//Add the driver //Add the driver
@ -409,8 +409,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
devc = sdi->priv; devc = sdi->priv;
if (mso_configure_probes(sdi) != SR_OK) { if (mso_configure_channels(sdi) != SR_OK) {
sr_err("Failed to configure probes."); sr_err("Failed to configure channels.");
return SR_ERR; return SR_ERR;
} }
@ -457,7 +457,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
/* Send header packet to the session bus. */ /* Send header packet to the session bus. */
std_session_send_df_header(cb_data, LOG_PREFIX); std_session_send_df_header(cb_data, LOG_PREFIX);
/* Our first probe is analog, the other 8 are of type 'logic'. */ /* Our first channel is analog, the other 8 are of type 'logic'. */
/* TODO. */ /* TODO. */
serial_source_add(devc->serial, G_IO_IN, -1, mso_receive_data, cb_data); serial_source_add(devc->serial, G_IO_IN, -1, mso_receive_data, cb_data);

View File

@ -435,10 +435,10 @@ SR_PRIV int mso_receive_data(int fd, int revents, void *cb_data)
return TRUE; return TRUE;
} }
SR_PRIV int mso_configure_probes(const struct sr_dev_inst *sdi) SR_PRIV int mso_configure_channels(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
char *tc; char *tc;
@ -452,21 +452,21 @@ SR_PRIV int mso_configure_probes(const struct sr_dev_inst *sdi)
devc->trigger_chan = 3; //LA combination trigger devc->trigger_chan = 3; //LA combination trigger
devc->use_trigger = FALSE; devc->use_trigger = FALSE;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = (struct sr_channel *)l->data; ch = (struct sr_channel *)l->data;
if (probe->enabled == FALSE) if (ch->enabled == FALSE)
continue; continue;
int probe_bit = 1 << (probe->index); int channel_bit = 1 << (ch->index);
if (!(probe->trigger)) if (!(ch->trigger))
continue; continue;
devc->use_trigger = TRUE; devc->use_trigger = TRUE;
//Configure trigger mask and value. //Configure trigger mask and value.
for (tc = probe->trigger; *tc; tc++) { for (tc = ch->trigger; *tc; tc++) {
devc->la_trigger_mask &= ~probe_bit; devc->la_trigger_mask &= ~channel_bit;
if (*tc == '1') if (*tc == '1')
devc->la_trigger |= probe_bit; devc->la_trigger |= channel_bit;
} }
} }

View File

@ -139,7 +139,7 @@ SR_PRIV inline uint16_t mso_calc_raw_from_mv(struct dev_context *devc);
SR_PRIV int mso_reset_fsm(struct sr_dev_inst *sdi); SR_PRIV int mso_reset_fsm(struct sr_dev_inst *sdi);
SR_PRIV int mso_toggle_led(struct sr_dev_inst *sdi, int state); SR_PRIV int mso_toggle_led(struct sr_dev_inst *sdi, int state);
SR_PRIV int mso_configure_probes(const struct sr_dev_inst *sdi); SR_PRIV int mso_configure_channels(const struct sr_dev_inst *sdi);
SR_PRIV void stop_acquisition(const struct sr_dev_inst *sdi); SR_PRIV void stop_acquisition(const struct sr_dev_inst *sdi);
/* bank agnostic registers */ /* bank agnostic registers */

View File

@ -66,7 +66,7 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
GSList *devices; GSList *devices;
@ -101,14 +101,14 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
sdi->priv = devc; sdi->priv = devc;
sdi->driver = mic_devs[idx].di; sdi->driver = mic_devs[idx].di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "Temperature"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "Temperature")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (mic_devs[idx].has_humidity) { if (mic_devs[idx].has_humidity) {
if (!(probe = sr_probe_new(1, SR_PROBE_ANALOG, TRUE, "Humidity"))) if (!(ch = sr_probe_new(1, SR_PROBE_ANALOG, TRUE, "Humidity")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);

View File

@ -111,15 +111,15 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
/* Clear 'analog', otherwise it'll contain random garbage. */ /* Clear 'analog', otherwise it'll contain random garbage. */
memset(&analog, 0, sizeof(struct sr_datafeed_analog)); memset(&analog, 0, sizeof(struct sr_datafeed_analog));
/* Common values for both probes. */ /* Common values for both channels. */
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
analog.num_samples = 1; analog.num_samples = 1;
/* Temperature. */ /* Temperature. */
l = g_slist_copy(sdi->probes); l = g_slist_copy(sdi->channels);
l = g_slist_remove_link(l, g_slist_nth(l, 1)); l = g_slist_remove_link(l, g_slist_nth(l, 1));
analog.probes = l; analog.channels = l;
analog.mq = SR_MQ_TEMPERATURE; analog.mq = SR_MQ_TEMPERATURE;
analog.unit = SR_UNIT_CELSIUS; /* TODO: Use C/F correctly. */ analog.unit = SR_UNIT_CELSIUS; /* TODO: Use C/F correctly. */
analog.data = &temperature; analog.data = &temperature;
@ -128,9 +128,9 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
/* Humidity. */ /* Humidity. */
if (mic_devs[idx].has_humidity) { if (mic_devs[idx].has_humidity) {
l = g_slist_copy(sdi->probes); l = g_slist_copy(sdi->channels);
l = g_slist_remove_link(l, g_slist_nth(l, 0)); l = g_slist_remove_link(l, g_slist_nth(l, 0));
analog.probes = l; analog.channels = l;
analog.mq = SR_MQ_RELATIVE_HUMIDITY; analog.mq = SR_MQ_RELATIVE_HUMIDITY;
analog.unit = SR_UNIT_PERCENTAGE; analog.unit = SR_UNIT_PERCENTAGE;
analog.data = &humidity; analog.data = &humidity;

View File

@ -49,7 +49,7 @@ static GSList *scan(GSList *options)
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_config *src; struct sr_config *src;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
GSList *l, *devices; GSList *l, *devices;
int len, cnt; int len, cnt;
@ -128,10 +128,10 @@ static GSList *scan(GSList *options)
sdi->conn = serial; sdi->conn = serial;
sdi->priv = devc; sdi->priv = devc;
sdi->driver = di; sdi->driver = di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE,
"P1"))) "P1")))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);
break; break;

View File

@ -349,7 +349,7 @@ static void nma_process_line(const struct sr_dev_inst *sdi)
(double)scale, (double)value); (double)scale, (double)value);
/* Finish and send packet. */ /* Finish and send packet. */
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = 1; analog.num_samples = 1;
analog.data = &value; analog.data = &value;

View File

@ -61,8 +61,8 @@ static const char *patterns[] = {
STR_PATTERN_INTERNAL, STR_PATTERN_INTERNAL,
}; };
/* Probes are numbered 0-31 (on the PCB silkscreen). */ /* Channels are numbered 0-31 (on the PCB silkscreen). */
SR_PRIV const char *ols_probe_names[NUM_PROBES + 1] = { SR_PRIV const char *ols_channel_names[NUM_PROBES + 1] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
"13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23",
"24", "25", "26", "27", "28", "29", "30", "31", "24", "25", "26", "27", "28", "29", "30", "31",
@ -90,7 +90,7 @@ static GSList *scan(GSList *options)
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
GPollFD probefd; GPollFD probefd;
GSList *l, *devices; GSList *l, *devices;
@ -177,10 +177,10 @@ static GSList *scan(GSList *options)
"Sump", "Logic Analyzer", "v1.0"); "Sump", "Logic Analyzer", "v1.0");
sdi->driver = di; sdi->driver = di;
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, if (!(ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE,
ols_probe_names[i]))) ols_channel_names[i])))
return 0; return 0;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
devc = ols_dev_new(); devc = ols_dev_new();
sdi->priv = devc; sdi->priv = devc;
@ -190,7 +190,7 @@ static GSList *scan(GSList *options)
sr_dbg("Failed to set default samplerate (%"PRIu64").", sr_dbg("Failed to set default samplerate (%"PRIu64").",
DEFAULT_SAMPLERATE); DEFAULT_SAMPLERATE);
/* Clear trigger masks, values and stages. */ /* Clear trigger masks, values and stages. */
ols_configure_probes(sdi); ols_configure_channels(sdi);
sdi->inst_type = SR_INST_SERIAL; sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial; sdi->conn = serial;
@ -390,13 +390,13 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
/* Device didn't specify sample memory size in metadata. */ /* Device didn't specify sample memory size in metadata. */
return SR_ERR_NA; return SR_ERR_NA;
/* /*
* Channel groups are turned off if no probes in that group are * Channel groups are turned off if no channels in that group are
* enabled, making more room for samples for the enabled group. * enabled, making more room for samples for the enabled group.
*/ */
ols_configure_probes(sdi); ols_configure_channels(sdi);
num_channels = 0; num_channels = 0;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (devc->probe_mask & (0xff << (i * 8))) if (devc->channel_mask & (0xff << (i * 8)))
num_channels++; num_channels++;
} }
grange[0] = g_variant_new_uint64(MIN_NUM_SAMPLES); grange[0] = g_variant_new_uint64(MIN_NUM_SAMPLES);
@ -463,20 +463,20 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
devc = sdi->priv; devc = sdi->priv;
serial = sdi->conn; serial = sdi->conn;
if (ols_configure_probes(sdi) != SR_OK) { if (ols_configure_channels(sdi) != SR_OK) {
sr_err("Failed to configure probes."); sr_err("Failed to configure channels.");
return SR_ERR; return SR_ERR;
} }
/* /*
* Enable/disable channel groups in the flag register according to the * Enable/disable channel groups in the flag register according to the
* probe mask. Calculate this here, because num_channels is needed * channel mask. Calculate this here, because num_channels is needed
* to limit readcount. * to limit readcount.
*/ */
changrp_mask = 0; changrp_mask = 0;
num_channels = 0; num_channels = 0;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (devc->probe_mask & (0xff << (i * 8))) { if (devc->channel_mask & (0xff << (i * 8))) {
changrp_mask |= (1 << i); changrp_mask |= (1 << i);
num_channels++; num_channels++;
} }
@ -495,7 +495,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
/* Basic triggers. */ /* Basic triggers. */
if (devc->trigger_mask[0] != 0x00000000) { if (devc->trigger_mask[0] != 0x00000000) {
/* At least one probe has a trigger on it. */ /* At least one channel has a trigger on it. */
delaycount = readcount * (1 - devc->capture_ratio / 100.0); delaycount = readcount * (1 - devc->capture_ratio / 100.0);
devc->trigger_at = (readcount - delaycount) * 4 - devc->num_stages; devc->trigger_at = (readcount - delaycount) * 4 - devc->num_stages;
for (i = 0; i <= devc->num_stages; i++) { for (i = 0; i <= devc->num_stages; i++) {

View File

@ -54,49 +54,49 @@ SR_PRIV int send_longcommand(struct sr_serial_dev_inst *serial,
return SR_OK; return SR_OK;
} }
SR_PRIV int ols_configure_probes(const struct sr_dev_inst *sdi) SR_PRIV int ols_configure_channels(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; struct dev_context *devc;
const struct sr_channel *probe; const struct sr_channel *ch;
const GSList *l; const GSList *l;
int probe_bit, stage, i; int channel_bit, stage, i;
char *tc; char *tc;
devc = sdi->priv; devc = sdi->priv;
devc->probe_mask = 0; devc->channel_mask = 0;
for (i = 0; i < NUM_TRIGGER_STAGES; i++) { for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
devc->trigger_mask[i] = 0; devc->trigger_mask[i] = 0;
devc->trigger_value[i] = 0; devc->trigger_value[i] = 0;
} }
devc->num_stages = 0; devc->num_stages = 0;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = (const struct sr_channel *)l->data; ch = (const struct sr_channel *)l->data;
if (!probe->enabled) if (!ch->enabled)
continue; continue;
if (probe->index >= devc->max_probes) { if (ch->index >= devc->max_channels) {
sr_err("Channels over the limit of %d\n", devc->max_probes); sr_err("Channels over the limit of %d\n", devc->max_channels);
return SR_ERR; return SR_ERR;
} }
/* /*
* Set up the probe mask for later configuration into the * Set up the channel mask for later configuration into the
* flag register. * flag register.
*/ */
probe_bit = 1 << (probe->index); channel_bit = 1 << (ch->index);
devc->probe_mask |= probe_bit; devc->channel_mask |= channel_bit;
if (!probe->trigger) if (!ch->trigger)
continue; continue;
/* Configure trigger mask and value. */ /* Configure trigger mask and value. */
stage = 0; stage = 0;
for (tc = probe->trigger; tc && *tc; tc++) { for (tc = ch->trigger; tc && *tc; tc++) {
devc->trigger_mask[stage] |= probe_bit; devc->trigger_mask[stage] |= channel_bit;
if (*tc == '1') if (*tc == '1')
devc->trigger_value[stage] |= probe_bit; devc->trigger_value[stage] |= channel_bit;
stage++; stage++;
/* Only supporting parallel mode, with up to 4 stages. */ /* Only supporting parallel mode, with up to 4 stages. */
if (stage > 4) if (stage > 4)
@ -124,7 +124,7 @@ SR_PRIV struct dev_context *ols_dev_new(void)
/* Acquisition settings */ /* Acquisition settings */
devc->limit_samples = devc->capture_ratio = 0; devc->limit_samples = devc->capture_ratio = 0;
devc->trigger_at = -1; devc->trigger_at = -1;
devc->probe_mask = 0xffffffff; devc->channel_mask = 0xffffffff;
devc->flag_reg = 0; devc->flag_reg = 0;
return devc; return devc;
@ -134,7 +134,7 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
uint32_t tmp_int, ui; uint32_t tmp_int, ui;
uint8_t key, type, token; uint8_t key, type, token;
GString *tmp_str, *devname, *version; GString *tmp_str, *devname, *version;
@ -201,12 +201,12 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
key, tmp_int); key, tmp_int);
switch (token) { switch (token) {
case 0x00: case 0x00:
/* Number of usable probes */ /* Number of usable channels */
for (ui = 0; ui < tmp_int; ui++) { for (ui = 0; ui < tmp_int; ui++) {
if (!(probe = sr_probe_new(ui, SR_PROBE_LOGIC, TRUE, if (!(ch = sr_probe_new(ui, SR_PROBE_LOGIC, TRUE,
ols_probe_names[ui]))) ols_channel_names[ui])))
return 0; return 0;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
break; break;
case 0x01: case 0x01:
@ -239,12 +239,12 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
key, tmp_c); key, tmp_c);
switch (token) { switch (token) {
case 0x00: case 0x00:
/* Number of usable probes */ /* Number of usable channels */
for (ui = 0; ui < tmp_c; ui++) { for (ui = 0; ui < tmp_c; ui++) {
if (!(probe = sr_probe_new(ui, SR_PROBE_LOGIC, TRUE, if (!(ch = sr_probe_new(ui, SR_PROBE_LOGIC, TRUE,
ols_probe_names[ui]))) ols_channel_names[ui])))
return 0; return 0;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
break; break;
case 0x01: case 0x01:
@ -284,13 +284,13 @@ SR_PRIV int ols_set_samplerate(const struct sr_dev_inst *sdi,
sr_info("Enabling demux mode."); sr_info("Enabling demux mode.");
devc->flag_reg |= FLAG_DEMUX; devc->flag_reg |= FLAG_DEMUX;
devc->flag_reg &= ~FLAG_FILTER; devc->flag_reg &= ~FLAG_FILTER;
devc->max_probes = NUM_PROBES / 2; devc->max_channels = NUM_PROBES / 2;
devc->cur_samplerate_divider = (CLOCK_RATE * 2 / samplerate) - 1; devc->cur_samplerate_divider = (CLOCK_RATE * 2 / samplerate) - 1;
} else { } else {
sr_info("Disabling demux mode."); sr_info("Disabling demux mode.");
devc->flag_reg &= ~FLAG_DEMUX; devc->flag_reg &= ~FLAG_DEMUX;
devc->flag_reg |= FLAG_FILTER; devc->flag_reg |= FLAG_FILTER;
devc->max_probes = NUM_PROBES; devc->max_channels = NUM_PROBES;
devc->cur_samplerate_divider = (CLOCK_RATE / samplerate) - 1; devc->cur_samplerate_divider = (CLOCK_RATE / samplerate) - 1;
} }
@ -415,7 +415,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
* submitting it over the session bus -- * submitting it over the session bus --
* whatever is listening on the bus will be * whatever is listening on the bus will be
* expecting a full 32-bit sample, based on * expecting a full 32-bit sample, based on
* the number of probes. * the number of channels.
*/ */
j = 0; j = 0;
memset(devc->tmp_sample, 0, 4); memset(devc->tmp_sample, 0, 4);

View File

@ -70,7 +70,7 @@
/* Private, per-device-instance driver context. */ /* Private, per-device-instance driver context. */
struct dev_context { struct dev_context {
/* Fixed device settings */ /* Fixed device settings */
int max_probes; int max_channels;
uint32_t max_samples; uint32_t max_samples;
uint32_t max_samplerate; uint32_t max_samplerate;
uint32_t protocol_version; uint32_t protocol_version;
@ -81,7 +81,7 @@ struct dev_context {
uint64_t limit_samples; uint64_t limit_samples;
int capture_ratio; int capture_ratio;
int trigger_at; int trigger_at;
uint32_t probe_mask; uint32_t channel_mask;
uint32_t trigger_mask[4]; uint32_t trigger_mask[4];
uint32_t trigger_value[4]; uint32_t trigger_value[4];
int num_stages; int num_stages;
@ -103,13 +103,13 @@ struct dev_context {
}; };
SR_PRIV extern const char *ols_probe_names[NUM_PROBES + 1]; SR_PRIV extern const char *ols_channel_names[NUM_PROBES + 1];
SR_PRIV int send_shortcommand(struct sr_serial_dev_inst *serial, SR_PRIV int send_shortcommand(struct sr_serial_dev_inst *serial,
uint8_t command); uint8_t command);
SR_PRIV int send_longcommand(struct sr_serial_dev_inst *serial, SR_PRIV int send_longcommand(struct sr_serial_dev_inst *serial,
uint8_t command, uint8_t *data); uint8_t command, uint8_t *data);
SR_PRIV int ols_configure_probes(const struct sr_dev_inst *sdi); SR_PRIV int ols_configure_channels(const struct sr_dev_inst *sdi);
SR_PRIV struct dev_context *ols_dev_new(void); SR_PRIV struct dev_context *ols_dev_new(void);
SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial); SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial);
SR_PRIV int ols_set_samplerate(const struct sr_dev_inst *sdi, SR_PRIV int ols_set_samplerate(const struct sr_dev_inst *sdi,

View File

@ -260,7 +260,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
struct dev_context *devc; struct dev_context *devc;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_scpi_hw_info *hw_info; struct sr_scpi_hw_info *hw_info;
struct sr_channel *probe; struct sr_channel *ch;
long n[3]; long n[3];
unsigned int i; unsigned int i;
const struct rigol_ds_model *model = NULL; const struct rigol_ds_model *model = NULL;
@ -335,10 +335,10 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
for (i = 0; i < model->analog_channels; i++) { for (i = 0; i < model->analog_channels; i++) {
if (!(channel_name = g_strdup_printf("CH%d", i + 1))) if (!(channel_name = g_strdup_printf("CH%d", i + 1)))
return NULL; return NULL;
probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, channel_name); ch = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, channel_name);
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
devc->analog_groups[i].name = channel_name; devc->analog_groups[i].name = channel_name;
devc->analog_groups[i].channels = g_slist_append(NULL, probe); devc->analog_groups[i].channels = g_slist_append(NULL, ch);
sdi->channel_groups = g_slist_append(sdi->channel_groups, sdi->channel_groups = g_slist_append(sdi->channel_groups,
&devc->analog_groups[i]); &devc->analog_groups[i]);
} }
@ -347,13 +347,13 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
if (!(channel_name = g_strdup_printf("D%d", i))) if (!(channel_name = g_strdup_printf("D%d", i)))
return NULL; return NULL;
probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, channel_name); ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, channel_name);
g_free(channel_name); g_free(channel_name);
if (!probe) if (!ch)
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
devc->digital_group.channels = g_slist_append( devc->digital_group.channels = g_slist_append(
devc->digital_group.channels, probe); devc->digital_group.channels, ch);
} }
devc->digital_group.name = "LA"; devc->digital_group.name = "LA";
sdi->channel_groups = g_slist_append(sdi->channel_groups, sdi->channel_groups = g_slist_append(sdi->channel_groups,
@ -439,24 +439,24 @@ static int cleanup(void)
static int analog_frame_size(const struct sr_dev_inst *sdi) static int analog_frame_size(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc = sdi->priv; struct dev_context *devc = sdi->priv;
struct sr_channel *probe; struct sr_channel *ch;
int analog_probes = 0; int analog_channels = 0;
GSList *l; GSList *l;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (probe->type == SR_PROBE_ANALOG && probe->enabled) if (ch->type == SR_PROBE_ANALOG && ch->enabled)
analog_probes++; analog_channels++;
} }
if (analog_probes == 0) if (analog_channels == 0)
return 0; return 0;
switch (devc->data_source) { switch (devc->data_source) {
case DATA_SOURCE_LIVE: case DATA_SOURCE_LIVE:
return devc->model->series->live_samples; return devc->model->series->live_samples;
case DATA_SOURCE_MEMORY: case DATA_SOURCE_MEMORY:
return devc->model->series->buffer_samples / analog_probes; return devc->model->series->buffer_samples / analog_channels;
default: default:
return 0; return 0;
} }
@ -480,7 +480,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
const char *tmp_str; const char *tmp_str;
uint64_t samplerate; uint64_t samplerate;
int analog_channel = -1; int analog_channel = -1;
@ -498,13 +498,13 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
} }
if (cg) { if (cg) {
probe = g_slist_nth_data(cg->channels, 0); ch = g_slist_nth_data(cg->channels, 0);
if (!probe) if (!ch)
return SR_ERR; return SR_ERR;
if (probe->type == SR_PROBE_ANALOG) { if (ch->type == SR_PROBE_ANALOG) {
if (probe->name[2] < '1' || probe->name[2] > '4') if (ch->name[2] < '1' || ch->name[2] > '4')
return SR_ERR; return SR_ERR;
analog_channel = probe->name[2] - '1'; analog_channel = ch->name[2] - '1';
} }
} }
@ -865,7 +865,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{ {
struct sr_scpi_dev_inst *scpi; struct sr_scpi_dev_inst *scpi;
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
GSList *l; GSList *l;
@ -877,24 +877,24 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
devc->num_frames = 0; devc->num_frames = 0;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
sr_dbg("handling probe %s", probe->name); sr_dbg("handling channel %s", ch->name);
if (probe->type == SR_PROBE_ANALOG) { if (ch->type == SR_PROBE_ANALOG) {
if (probe->enabled) if (ch->enabled)
devc->enabled_analog_probes = g_slist_append( devc->enabled_analog_channels = g_slist_append(
devc->enabled_analog_probes, probe); devc->enabled_analog_channels, ch);
if (probe->enabled != devc->analog_channels[probe->index]) { if (ch->enabled != devc->analog_channels[ch->index]) {
/* Enabled channel is currently disabled, or vice versa. */ /* Enabled channel is currently disabled, or vice versa. */
if (rigol_ds_config_set(sdi, ":CHAN%d:DISP %s", probe->index + 1, if (rigol_ds_config_set(sdi, ":CHAN%d:DISP %s", ch->index + 1,
probe->enabled ? "ON" : "OFF") != SR_OK) ch->enabled ? "ON" : "OFF") != SR_OK)
return SR_ERR; return SR_ERR;
devc->analog_channels[probe->index] = probe->enabled; devc->analog_channels[ch->index] = ch->enabled;
} }
} else if (probe->type == SR_PROBE_LOGIC) { } else if (ch->type == SR_PROBE_LOGIC) {
if (probe->enabled) { if (ch->enabled) {
devc->enabled_digital_probes = g_slist_append( devc->enabled_digital_channels = g_slist_append(
devc->enabled_digital_probes, probe); devc->enabled_digital_channels, ch);
/* Turn on LA module if currently off. */ /* Turn on LA module if currently off. */
if (!devc->la_enabled) { if (!devc->la_enabled) {
if (rigol_ds_config_set(sdi, ":LA:DISP ON") != SR_OK) if (rigol_ds_config_set(sdi, ":LA:DISP ON") != SR_OK)
@ -902,21 +902,21 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
devc->la_enabled = TRUE; devc->la_enabled = TRUE;
} }
} }
if (probe->enabled != devc->digital_channels[probe->index]) { if (ch->enabled != devc->digital_channels[ch->index]) {
/* Enabled channel is currently disabled, or vice versa. */ /* Enabled channel is currently disabled, or vice versa. */
if (rigol_ds_config_set(sdi, ":DIG%d:TURN %s", probe->index, if (rigol_ds_config_set(sdi, ":DIG%d:TURN %s", ch->index,
probe->enabled ? "ON" : "OFF") != SR_OK) ch->enabled ? "ON" : "OFF") != SR_OK)
return SR_ERR; return SR_ERR;
devc->digital_channels[probe->index] = probe->enabled; devc->digital_channels[ch->index] = ch->enabled;
} }
} }
} }
if (!devc->enabled_analog_probes && !devc->enabled_digital_probes) if (!devc->enabled_analog_channels && !devc->enabled_digital_channels)
return SR_ERR; return SR_ERR;
/* Turn off LA module if on and no digital probes selected. */ /* Turn off LA module if on and no digital channels selected. */
if (devc->la_enabled && !devc->enabled_digital_probes) if (devc->la_enabled && !devc->enabled_digital_channels)
if (rigol_ds_config_set(sdi, ":LA:DISP OFF") != SR_OK) if (rigol_ds_config_set(sdi, ":LA:DISP OFF") != SR_OK)
return SR_ERR; return SR_ERR;
@ -959,10 +959,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
/* Send header packet to the session bus. */ /* Send header packet to the session bus. */
std_session_send_df_header(cb_data, LOG_PREFIX); std_session_send_df_header(cb_data, LOG_PREFIX);
if (devc->enabled_analog_probes) if (devc->enabled_analog_channels)
devc->channel_entry = devc->enabled_analog_probes; devc->channel_entry = devc->enabled_analog_channels;
else else
devc->channel_entry = devc->enabled_digital_probes; devc->channel_entry = devc->enabled_digital_channels;
if (rigol_ds_capture_start(sdi) != SR_OK) if (rigol_ds_capture_start(sdi) != SR_OK)
return SR_ERR; return SR_ERR;
@ -993,10 +993,10 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
packet.type = SR_DF_END; packet.type = SR_DF_END;
sr_session_send(sdi, &packet); sr_session_send(sdi, &packet);
g_slist_free(devc->enabled_analog_probes); g_slist_free(devc->enabled_analog_channels);
g_slist_free(devc->enabled_digital_probes); g_slist_free(devc->enabled_digital_channels);
devc->enabled_analog_probes = NULL; devc->enabled_analog_channels = NULL;
devc->enabled_digital_probes = NULL; devc->enabled_digital_channels = NULL;
scpi = sdi->conn; scpi = sdi->conn;
sr_scpi_source_remove(scpi); sr_scpi_source_remove(scpi);

View File

@ -207,19 +207,19 @@ static int rigol_ds_stop_wait(const struct sr_dev_inst *sdi)
static int rigol_ds_check_stop(const struct sr_dev_inst *sdi) static int rigol_ds_check_stop(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
int tmp; int tmp;
if (!(devc = sdi->priv)) if (!(devc = sdi->priv))
return SR_ERR; return SR_ERR;
probe = devc->channel_entry->data; ch = devc->channel_entry->data;
if (devc->model->series->protocol <= PROTOCOL_V2) if (devc->model->series->protocol <= PROTOCOL_V2)
return SR_OK; return SR_OK;
if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d", if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
probe->index + 1) != SR_OK) ch->index + 1) != SR_OK)
return SR_ERR; return SR_ERR;
/* Check that the number of samples will be accepted */ /* Check that the number of samples will be accepted */
if (rigol_ds_config_set(sdi, ":WAV:POIN %d", devc->analog_frame_size) != SR_OK) if (rigol_ds_config_set(sdi, ":WAV:POIN %d", devc->analog_frame_size) != SR_OK)
@ -376,28 +376,28 @@ SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi)
SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi) SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
if (!(devc = sdi->priv)) if (!(devc = sdi->priv))
return SR_ERR; return SR_ERR;
probe = devc->channel_entry->data; ch = devc->channel_entry->data;
sr_dbg("Starting reading data from channel %d", probe->index + 1); sr_dbg("Starting reading data from channel %d", ch->index + 1);
if (devc->model->series->protocol <= PROTOCOL_V2) { if (devc->model->series->protocol <= PROTOCOL_V2) {
if (probe->type == SR_PROBE_LOGIC) { if (ch->type == SR_PROBE_LOGIC) {
if (sr_scpi_send(sdi->conn, ":WAV:DATA? DIG") != SR_OK) if (sr_scpi_send(sdi->conn, ":WAV:DATA? DIG") != SR_OK)
return SR_ERR; return SR_ERR;
} else { } else {
if (sr_scpi_send(sdi->conn, ":WAV:DATA? CHAN%d", if (sr_scpi_send(sdi->conn, ":WAV:DATA? CHAN%d",
probe->index + 1) != SR_OK) ch->index + 1) != SR_OK)
return SR_ERR; return SR_ERR;
} }
rigol_ds_set_wait_event(devc, WAIT_NONE); rigol_ds_set_wait_event(devc, WAIT_NONE);
} else { } else {
if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d", if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
probe->index + 1) != SR_OK) ch->index + 1) != SR_OK)
return SR_ERR; return SR_ERR;
if (devc->data_source != DATA_SOURCE_LIVE) { if (devc->data_source != DATA_SOURCE_LIVE) {
if (rigol_ds_config_set(sdi, ":WAV:RES") != SR_OK) if (rigol_ds_config_set(sdi, ":WAV:RES") != SR_OK)
@ -483,7 +483,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
struct sr_datafeed_logic logic; struct sr_datafeed_logic logic;
double vdiv, offset; double vdiv, offset;
int len, i, vref; int len, i, vref;
struct sr_channel *probe; struct sr_channel *ch;
gsize expected_data_bytes; gsize expected_data_bytes;
(void)fd; (void)fd;
@ -522,9 +522,9 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
sr_err("BUG: Unknown event target encountered"); sr_err("BUG: Unknown event target encountered");
} }
probe = devc->channel_entry->data; ch = devc->channel_entry->data;
expected_data_bytes = probe->type == SR_PROBE_ANALOG ? expected_data_bytes = ch->type == SR_PROBE_ANALOG ?
devc->analog_frame_size : devc->digital_frame_size; devc->analog_frame_size : devc->digital_frame_size;
if (devc->num_block_bytes == 0) { if (devc->num_block_bytes == 0) {
@ -586,17 +586,17 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
devc->num_block_read += len; devc->num_block_read += len;
if (probe->type == SR_PROBE_ANALOG) { if (ch->type == SR_PROBE_ANALOG) {
vref = devc->vert_reference[probe->index]; vref = devc->vert_reference[ch->index];
vdiv = devc->vdiv[probe->index] / 25.6; vdiv = devc->vdiv[ch->index] / 25.6;
offset = devc->vert_offset[probe->index]; offset = devc->vert_offset[ch->index];
if (devc->model->series->protocol >= PROTOCOL_V3) if (devc->model->series->protocol >= PROTOCOL_V3)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
devc->data[i] = ((int)devc->buffer[i] - vref) * vdiv - offset; devc->data[i] = ((int)devc->buffer[i] - vref) * vdiv - offset;
else else
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
devc->data[i] = (128 - devc->buffer[i]) * vdiv - offset; devc->data[i] = (128 - devc->buffer[i]) * vdiv - offset;
analog.probes = g_slist_append(NULL, probe); analog.channels = g_slist_append(NULL, ch);
analog.num_samples = len; analog.num_samples = len;
analog.data = devc->data; analog.data = devc->data;
analog.mq = SR_MQ_VOLTAGE; analog.mq = SR_MQ_VOLTAGE;
@ -605,7 +605,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
sr_session_send(cb_data, &packet); sr_session_send(cb_data, &packet);
g_slist_free(analog.probes); g_slist_free(analog.channels);
} else { } else {
logic.length = len; logic.length = len;
logic.unitsize = 2; logic.unitsize = 2;
@ -658,7 +658,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
rigol_ds_config_set(sdi, ":WAV:END"); rigol_ds_config_set(sdi, ":WAV:END");
} }
if (probe->type == SR_PROBE_ANALOG if (ch->type == SR_PROBE_ANALOG
&& devc->channel_entry->next != NULL) { && devc->channel_entry->next != NULL) {
/* We got the frame for this analog channel, but /* We got the frame for this analog channel, but
* there's another analog channel. */ * there's another analog channel. */
@ -666,10 +666,10 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
rigol_ds_channel_start(sdi); rigol_ds_channel_start(sdi);
} else { } else {
/* Done with all analog channels in this frame. */ /* Done with all analog channels in this frame. */
if (devc->enabled_digital_probes if (devc->enabled_digital_channels
&& devc->channel_entry != devc->enabled_digital_probes) { && devc->channel_entry != devc->enabled_digital_channels) {
/* Now we need to get the digital data. */ /* Now we need to get the digital data. */
devc->channel_entry = devc->enabled_digital_probes; devc->channel_entry = devc->enabled_digital_channels;
rigol_ds_channel_start(sdi); rigol_ds_channel_start(sdi);
} else { } else {
/* Done with this frame. */ /* Done with this frame. */
@ -681,10 +681,10 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
sdi->driver->dev_acquisition_stop(sdi, cb_data); sdi->driver->dev_acquisition_stop(sdi, cb_data);
} else { } else {
/* Get the next frame, starting with the first analog channel. */ /* Get the next frame, starting with the first analog channel. */
if (devc->enabled_analog_probes) if (devc->enabled_analog_channels)
devc->channel_entry = devc->enabled_analog_probes; devc->channel_entry = devc->enabled_analog_channels;
else else
devc->channel_entry = devc->enabled_digital_probes; devc->channel_entry = devc->enabled_digital_channels;
rigol_ds_capture_start(sdi); rigol_ds_capture_start(sdi);

View File

@ -102,8 +102,8 @@ struct dev_context {
struct sr_channel_group digital_group; struct sr_channel_group digital_group;
/* Acquisition settings */ /* Acquisition settings */
GSList *enabled_analog_probes; GSList *enabled_analog_channels;
GSList *enabled_digital_probes; GSList *enabled_digital_channels;
uint64_t limit_frames; uint64_t limit_frames;
void *cb_data; void *cb_data;
enum data_source data_source; enum data_source data_source;

View File

@ -55,7 +55,7 @@ static const int32_t hwcaps[] = {
SR_CONF_CONTINUOUS, SR_CONF_CONTINUOUS,
}; };
static const char *probe_names[] = { static const char *channel_names[] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", "10", "11", "12", "13", "14", "15", "9", "10", "11", "12", "13", "14", "15",
NULL, NULL,
@ -136,7 +136,7 @@ static GSList *scan(GSList *options)
struct dev_context *devc; struct dev_context *devc;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_config *src; struct sr_config *src;
GSList *l, *devices, *conn_devices; GSList *l, *devices, *conn_devices;
struct libusb_device_descriptor des; struct libusb_device_descriptor des;
@ -194,11 +194,11 @@ static GSList *scan(GSList *options)
return NULL; return NULL;
sdi->driver = di; sdi->driver = di;
for (j = 0; probe_names[j]; j++) { for (j = 0; channel_names[j]; j++) {
if (!(probe = sr_probe_new(j, SR_PROBE_LOGIC, TRUE, if (!(ch = sr_probe_new(j, SR_PROBE_LOGIC, TRUE,
probe_names[j]))) channel_names[j])))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
@ -621,25 +621,25 @@ static unsigned int get_timeout(struct dev_context *devc)
return timeout + timeout / 4; /* Leave a headroom of 25% percent. */ return timeout + timeout / 4; /* Leave a headroom of 25% percent. */
} }
static int configure_probes(const struct sr_dev_inst *sdi) static int configure_channels(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
uint16_t probe_bit; uint16_t channel_bit;
devc = sdi->priv; devc = sdi->priv;
devc->cur_channels = 0; devc->cur_channels = 0;
devc->num_channels = 0; devc->num_channels = 0;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = (struct sr_channel *)l->data; ch = (struct sr_channel *)l->data;
if (probe->enabled == FALSE) if (ch->enabled == FALSE)
continue; continue;
probe_bit = 1 << (probe->index); channel_bit = 1 << (ch->index);
devc->cur_channels |= probe_bit; devc->cur_channels |= channel_bit;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
/* /*
@ -647,10 +647,10 @@ static int configure_probes(const struct sr_dev_inst *sdi)
* To speed things up during conversion, do the switcharoo * To speed things up during conversion, do the switcharoo
* here instead. * here instead.
*/ */
probe_bit = 1 << (probe->index ^ 8); channel_bit = 1 << (ch->index ^ 8);
#endif #endif
devc->channel_masks[devc->num_channels++] = probe_bit; devc->channel_masks[devc->num_channels++] = channel_bit;
} }
return SR_OK; return SR_OK;
@ -700,8 +700,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
usb = sdi->conn; usb = sdi->conn;
/* Configures devc->cur_channels. */ /* Configures devc->cur_channels. */
if (configure_probes(sdi) != SR_OK) { if (configure_channels(sdi) != SR_OK) {
sr_err("Failed to configure probes."); sr_err("Failed to configure channels.");
return SR_ERR; return SR_ERR;
} }

View File

@ -337,7 +337,7 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm)
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
GSList *devices; GSList *devices;
int dropped, ret; int dropped, ret;
@ -405,9 +405,9 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm)
sdi->priv = devc; sdi->priv = devc;
sdi->driver = dmms[dmm].di; sdi->driver = dmms[dmm].di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);

View File

@ -48,7 +48,7 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi,
memset(&analog, 0, sizeof(struct sr_datafeed_analog)); memset(&analog, 0, sizeof(struct sr_datafeed_analog));
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = 1; analog.num_samples = 1;
analog.mq = -1; analog.mq = -1;

View File

@ -72,21 +72,21 @@ static int init(struct sr_context *sr_ctx)
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *gen_probe_list(int num_probes) static GSList *gen_channel_list(int num_channels)
{ {
GSList *list; GSList *list;
struct sr_channel *probe; struct sr_channel *ch;
int i; int i;
char name[8]; char name[8];
list = NULL; list = NULL;
for (i = num_probes; i > 0; --i) { for (i = num_channels; i > 0; --i) {
/* The LWLA series simply number probes from CH1 to CHxx. */ /* The LWLA series simply number channels from CH1 to CHxx. */
g_snprintf(name, sizeof(name), "CH%d", i); g_snprintf(name, sizeof(name), "CH%d", i);
probe = sr_probe_new(i - 1, SR_PROBE_LOGIC, TRUE, name); ch = sr_probe_new(i - 1, SR_PROBE_LOGIC, TRUE, name);
list = g_slist_prepend(list, probe); list = g_slist_prepend(list, ch);
} }
return list; return list;
@ -113,12 +113,12 @@ static struct sr_dev_inst *dev_inst_new(int device_index)
return NULL; return NULL;
} }
/* Enable all channels to match the default probe configuration. */ /* Enable all channels to match the default channel configuration. */
devc->channel_mask = ALL_CHANNELS_MASK; devc->channel_mask = ALL_CHANNELS_MASK;
devc->samplerate = DEFAULT_SAMPLERATE; devc->samplerate = DEFAULT_SAMPLERATE;
sdi->priv = devc; sdi->priv = devc;
sdi->probes = gen_probe_list(NUM_PROBES); sdi->channels = gen_channel_list(NUM_PROBES);
return sdi; return sdi;
} }
@ -402,9 +402,9 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
} }
static int config_probe_set(const struct sr_dev_inst *sdi, static int config_probe_set(const struct sr_dev_inst *sdi,
struct sr_channel *probe, unsigned int changes) struct sr_channel *ch, unsigned int changes)
{ {
uint64_t probe_bit; uint64_t channel_bit;
uint64_t trigger_mask; uint64_t trigger_mask;
uint64_t trigger_values; uint64_t trigger_values;
uint64_t trigger_edge_mask; uint64_t trigger_edge_mask;
@ -414,46 +414,46 @@ static int config_probe_set(const struct sr_dev_inst *sdi,
if (!devc) if (!devc)
return SR_ERR_DEV_CLOSED; return SR_ERR_DEV_CLOSED;
if (probe->index < 0 || probe->index >= NUM_PROBES) { if (ch->index < 0 || ch->index >= NUM_PROBES) {
sr_err("Probe index %d out of range.", probe->index); sr_err("Channel index %d out of range.", ch->index);
return SR_ERR_BUG; return SR_ERR_BUG;
} }
probe_bit = (uint64_t)1 << probe->index; channel_bit = (uint64_t)1 << ch->index;
if ((changes & SR_PROBE_SET_ENABLED) != 0) { if ((changes & SR_PROBE_SET_ENABLED) != 0) {
/* Enable or disable input channel for this probe. */ /* Enable or disable input channel for this channel. */
if (probe->enabled) if (ch->enabled)
devc->channel_mask |= probe_bit; devc->channel_mask |= channel_bit;
else else
devc->channel_mask &= ~probe_bit; devc->channel_mask &= ~channel_bit;
} }
if ((changes & SR_PROBE_SET_TRIGGER) != 0) { if ((changes & SR_PROBE_SET_TRIGGER) != 0) {
trigger_mask = devc->trigger_mask & ~probe_bit; trigger_mask = devc->trigger_mask & ~channel_bit;
trigger_values = devc->trigger_values & ~probe_bit; trigger_values = devc->trigger_values & ~channel_bit;
trigger_edge_mask = devc->trigger_edge_mask & ~probe_bit; trigger_edge_mask = devc->trigger_edge_mask & ~channel_bit;
if (probe->trigger && probe->trigger[0] != '\0') { if (ch->trigger && ch->trigger[0] != '\0') {
if (probe->trigger[1] != '\0') { if (ch->trigger[1] != '\0') {
sr_warn("Trigger configuration \"%s\" with " sr_warn("Trigger configuration \"%s\" with "
"multiple stages is not supported.", "multiple stages is not supported.",
probe->trigger); ch->trigger);
return SR_ERR_ARG; return SR_ERR_ARG;
} }
/* Enable trigger for this probe. */ /* Enable trigger for this channel. */
trigger_mask |= probe_bit; trigger_mask |= channel_bit;
/* Configure edge mask and trigger value. */ /* Configure edge mask and trigger value. */
switch (probe->trigger[0]) { switch (ch->trigger[0]) {
case '1': trigger_values |= probe_bit; case '1': trigger_values |= channel_bit;
case '0': break; case '0': break;
case 'r': trigger_values |= probe_bit; case 'r': trigger_values |= channel_bit;
case 'f': trigger_edge_mask |= probe_bit; case 'f': trigger_edge_mask |= channel_bit;
break; break;
default: default:
sr_warn("Trigger type '%c' is not supported.", sr_warn("Trigger type '%c' is not supported.",
probe->trigger[0]); ch->trigger[0]);
return SR_ERR_ARG; return SR_ERR_ARG;
} }
} }

View File

@ -49,7 +49,7 @@ static GSList *scan(GSList *options)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
GSList *devices = NULL, *l; GSList *devices = NULL, *l;
const char *conn = NULL, *serialcomm = NULL; const char *conn = NULL, *serialcomm = NULL;
uint8_t buf[292]; uint8_t buf[292];
@ -107,56 +107,56 @@ static GSList *scan(GSList *options)
sdi->priv = devc; sdi->priv = devc;
sdi->driver = di; sdi->driver = di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (devc->optarif == OPTARIF_BASE) { if (devc->optarif == OPTARIF_BASE) {
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "BASE"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "BASE")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} else if (devc->optarif == OPTARIF_HC) { } else if (devc->optarif == OPTARIF_HC) {
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HP"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HP")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HC"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HC")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} else if (devc->optarif == OPTARIF_EJP) { } else if (devc->optarif == OPTARIF_EJP) {
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HN"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HN")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HPM"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HPM")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} else if (devc->optarif == OPTARIF_BBR) { } else if (devc->optarif == OPTARIF_BBR) {
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HPJB"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HPJB")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HPJW"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HPJW")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HPJR"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HPJR")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HCJB"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HCJB")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HCJW"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HCJW")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HCJR"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HCJR")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "IINST"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "IINST")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "PAPP"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "PAPP")))
goto scan_cleanup; goto scan_cleanup;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);

View File

@ -39,37 +39,37 @@ static gboolean teleinfo_control_check(char *label, char *data, char control)
return ((sum & 0x3F) + ' ') == control; return ((sum & 0x3F) + ' ') == control;
} }
static gint teleinfo_probe_compare(gconstpointer a, gconstpointer b) static gint teleinfo_channel_compare(gconstpointer a, gconstpointer b)
{ {
const struct sr_channel *probe = a; const struct sr_channel *ch = a;
const char *name = b; const char *name = b;
return strcmp(probe->name, name); return strcmp(ch->name, name);
} }
static struct sr_channel *teleinfo_find_probe(struct sr_dev_inst *sdi, static struct sr_channel *teleinfo_find_channel(struct sr_dev_inst *sdi,
const char *name) const char *name)
{ {
GSList *elem = g_slist_find_custom(sdi->probes, name, GSList *elem = g_slist_find_custom(sdi->channels, name,
teleinfo_probe_compare); teleinfo_channel_compare);
return elem ? elem->data : NULL; return elem ? elem->data : NULL;
} }
static void teleinfo_send_value(struct sr_dev_inst *sdi, const char *probe_name, static void teleinfo_send_value(struct sr_dev_inst *sdi, const char *channel_name,
float value, int mq, int unit) float value, int mq, int unit)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog; struct sr_datafeed_analog analog;
struct sr_channel *probe; struct sr_channel *ch;
devc = sdi->priv; devc = sdi->priv;
probe = teleinfo_find_probe(sdi, probe_name); ch = teleinfo_find_channel(sdi, channel_name);
if (!probe || !probe->enabled) if (!ch || !ch->enabled)
return; return;
memset(&analog, 0, sizeof(struct sr_datafeed_analog)); memset(&analog, 0, sizeof(struct sr_datafeed_analog));
analog.probes = g_slist_append(analog.probes, probe); analog.channels = g_slist_append(analog.channels, ch);
analog.num_samples = 1; analog.num_samples = 1;
analog.mq = mq; analog.mq = mq;
analog.unit = unit; analog.unit = unit;
@ -78,7 +78,7 @@ static void teleinfo_send_value(struct sr_dev_inst *sdi, const char *probe_name,
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
sr_session_send(devc->session_cb_data, &packet); sr_session_send(devc->session_cb_data, &packet);
g_slist_free(analog.probes); g_slist_free(analog.channels);
} }
static void teleinfo_handle_mesurement(struct sr_dev_inst *sdi, static void teleinfo_handle_mesurement(struct sr_dev_inst *sdi,

View File

@ -51,7 +51,7 @@ static GSList *scan(GSList *options)
struct dev_context *devc; struct dev_context *devc;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_config *src; struct sr_config *src;
struct sr_channel *probe; struct sr_channel *ch;
GSList *devices, *l; GSList *devices, *l;
const char *conn, *serialcomm; const char *conn, *serialcomm;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
@ -106,12 +106,12 @@ static GSList *scan(GSList *options)
sdi->priv = devc; sdi->priv = devc;
sdi->driver = di; sdi->driver = di;
probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"); ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1");
if (!probe) { if (!ch) {
sr_err("Failed to create probe."); sr_err("Failed to create channel.");
return NULL; return NULL;
} }
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);

View File

@ -98,7 +98,7 @@ static void decode_packet(struct sr_dev_inst *sdi)
parse_packet(devc->buf, &floatval, &analog); parse_packet(devc->buf, &floatval, &analog);
/* Send a sample packet with one analog value. */ /* Send a sample packet with one analog value. */
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = 1; analog.num_samples = 1;
analog.data = &floatval; analog.data = &floatval;
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;

View File

@ -181,7 +181,7 @@ static GSList *scan(GSList *options, int dmm)
struct drv_context *drvc; struct drv_context *drvc;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
struct sr_config *src; struct sr_config *src;
struct sr_channel *probe; struct sr_channel *ch;
const char *conn; const char *conn;
drvc = udmms[dmm].di->priv; drvc = udmms[dmm].di->priv;
@ -221,9 +221,9 @@ static GSList *scan(GSList *options, int dmm)
} }
sdi->priv = devc; sdi->priv = devc;
sdi->driver = udmms[dmm].di; sdi->driver = udmms[dmm].di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
sdi->inst_type = SR_INST_USB; sdi->inst_type = SR_INST_USB;
sdi->conn = usb; sdi->conn = usb;

View File

@ -77,7 +77,7 @@ static void decode_packet(struct sr_dev_inst *sdi, int dmm, const uint8_t *buf,
udmms[dmm].dmm_details(&analog, info); udmms[dmm].dmm_details(&analog, info);
/* Send a sample packet with one analog value. */ /* Send a sample packet with one analog value. */
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = 1; analog.num_samples = 1;
analog.data = &floatval; analog.data = &floatval;
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;

View File

@ -28,7 +28,7 @@ static const int32_t hwcaps[] = {
SR_CONF_DATA_SOURCE, SR_CONF_DATA_SOURCE,
}; };
static char *probes[] = { static char *channels[] = {
"T1", "T1",
"T2", "T2",
"T1-T2", "T1-T2",
@ -53,7 +53,7 @@ static GSList *scan(GSList *options)
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
struct sr_config *src; struct sr_config *src;
GSList *usb_devices, *devices, *l; GSList *usb_devices, *devices, *l;
int i; int i;
@ -86,12 +86,12 @@ static GSList *scan(GSList *options)
sdi->inst_type = SR_INST_USB; sdi->inst_type = SR_INST_USB;
sdi->conn = l->data; sdi->conn = l->data;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, if (!(ch = sr_probe_new(i, SR_PROBE_ANALOG, TRUE,
probes[i]))) { channels[i]))) {
sr_dbg("Probe malloc failed."); sr_dbg("Channel malloc failed.");
return NULL; return NULL;
} }
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
if (!(devc = g_try_malloc(sizeof(struct dev_context)))) { if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {

View File

@ -82,7 +82,7 @@ static void process_packet(struct sr_dev_inst *sdi)
is_valid = TRUE; is_valid = TRUE;
if (devc->packet[1] == 0x3b && devc->packet[2] == 0x3b if (devc->packet[1] == 0x3b && devc->packet[2] == 0x3b
&& devc->packet[3] == 0x3b && devc->packet[4] == 0x3b) && devc->packet[3] == 0x3b && devc->packet[4] == 0x3b)
/* No measurement: missing probe, empty storage location, ... */ /* No measurement: missing channel, empty storage location, ... */
is_valid = FALSE; is_valid = FALSE;
temp = parse_temperature(devc->packet + 1); temp = parse_temperature(devc->packet + 1);
@ -109,21 +109,21 @@ static void process_packet(struct sr_dev_inst *sdi)
} }
switch (devc->packet[13] - 0x30) { switch (devc->packet[13] - 0x30) {
case 0: case 0:
/* Probe T1. */ /* Channel T1. */
analog.probes = g_slist_append(NULL, g_slist_nth_data(sdi->probes, 0)); analog.channels = g_slist_append(NULL, g_slist_nth_data(sdi->channels, 0));
break; break;
case 1: case 1:
/* Probe T2. */ /* Channel T2. */
analog.probes = g_slist_append(NULL, g_slist_nth_data(sdi->probes, 1)); analog.channels = g_slist_append(NULL, g_slist_nth_data(sdi->channels, 1));
break; break;
case 2: case 2:
case 3: case 3:
/* Probe T1-T2. */ /* Channel T1-T2. */
analog.probes = g_slist_append(NULL, g_slist_nth_data(sdi->probes, 2)); analog.channels = g_slist_append(NULL, g_slist_nth_data(sdi->channels, 2));
analog.mqflags |= SR_MQFLAG_RELATIVE; analog.mqflags |= SR_MQFLAG_RELATIVE;
break; break;
default: default:
sr_err("Unknown probe 0x%.2x.", devc->packet[13]); sr_err("Unknown channel 0x%.2x.", devc->packet[13]);
is_valid = FALSE; is_valid = FALSE;
} }
if (is_valid) { if (is_valid) {
@ -132,7 +132,7 @@ static void process_packet(struct sr_dev_inst *sdi)
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
sr_session_send(devc->cb_data, &packet); sr_session_send(devc->cb_data, &packet);
g_slist_free(analog.probes); g_slist_free(analog.channels);
} }
} }

View File

@ -56,7 +56,7 @@ static GSList *scan(GSList *options)
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
struct libusb_device_descriptor des; struct libusb_device_descriptor des;
libusb_device **devlist; libusb_device **devlist;
GSList *devices; GSList *devices;
@ -88,9 +88,9 @@ static GSList *scan(GSList *options)
return NULL; return NULL;
sdi->priv = devc; sdi->priv = devc;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
return NULL; return NULL;
sdi->probes = g_slist_append(NULL, probe); sdi->channels = g_slist_append(NULL, ch);
if (!(sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]), if (!(sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
libusb_get_device_address(devlist[i]), NULL))) libusb_get_device_address(devlist[i]), NULL)))

View File

@ -252,7 +252,7 @@ static void decode_buf(struct sr_dev_inst *sdi, unsigned char *data)
if (is_relative) if (is_relative)
analog.mqflags |= SR_MQFLAG_RELATIVE; analog.mqflags |= SR_MQFLAG_RELATIVE;
analog.probes = sdi->probes; analog.channels = sdi->channels;
analog.num_samples = 1; analog.num_samples = 1;
analog.data = &fvalue; analog.data = &fvalue;
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;

View File

@ -62,10 +62,10 @@ static const int32_t hwcaps[] = {
}; };
/* /*
* ZEROPLUS LAP-C (16032) numbers the 16 probes A0-A7 and B0-B7. * ZEROPLUS LAP-C (16032) numbers the 16 channels A0-A7 and B0-B7.
* We currently ignore other untested/unsupported devices here. * We currently ignore other untested/unsupported devices here.
*/ */
static const char *probe_names[] = { static const char *channel_names[] = {
"A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
"B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7",
"C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7",
@ -124,37 +124,37 @@ const uint64_t samplerates_200[] = {
static int dev_close(struct sr_dev_inst *sdi); static int dev_close(struct sr_dev_inst *sdi);
#if 0 #if 0
static int configure_probes(const struct sr_dev_inst *sdi) static int configure_channels(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; struct dev_context *devc;
const struct sr_channel *probe; const struct sr_channel *ch;
const GSList *l; const GSList *l;
int probe_bit, stage, i; int channel_bit, stage, i;
char *tc; char *tc;
/* Note: sdi and sdi->priv are non-NULL, the caller checked this. */ /* Note: sdi and sdi->priv are non-NULL, the caller checked this. */
devc = sdi->priv; devc = sdi->priv;
devc->probe_mask = 0; devc->channel_mask = 0;
for (i = 0; i < NUM_TRIGGER_STAGES; i++) { for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
devc->trigger_mask[i] = 0; devc->trigger_mask[i] = 0;
devc->trigger_value[i] = 0; devc->trigger_value[i] = 0;
} }
stage = -1; stage = -1;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = (struct sr_channel *)l->data; ch = (struct sr_channel *)l->data;
if (probe->enabled == FALSE) if (ch->enabled == FALSE)
continue; continue;
probe_bit = 1 << (probe->index); channel_bit = 1 << (ch->index);
devc->probe_mask |= probe_bit; devc->channel_mask |= channel_bit;
if (probe->trigger) { if (ch->trigger) {
stage = 0; stage = 0;
for (tc = probe->trigger; *tc; tc++) { for (tc = ch->trigger; *tc; tc++) {
devc->trigger_mask[stage] |= probe_bit; devc->trigger_mask[stage] |= channel_bit;
if (*tc == '1') if (*tc == '1')
devc->trigger_value[stage] |= probe_bit; devc->trigger_value[stage] |= channel_bit;
stage++; stage++;
if (stage > NUM_TRIGGER_STAGES) if (stage > NUM_TRIGGER_STAGES)
return SR_ERR; return SR_ERR;
@ -166,23 +166,23 @@ static int configure_probes(const struct sr_dev_inst *sdi)
} }
#endif #endif
static int configure_probes(const struct sr_dev_inst *sdi) static int configure_channels(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; struct dev_context *devc;
const GSList *l; const GSList *l;
const struct sr_channel *probe; const struct sr_channel *ch;
char *tc; char *tc;
int type; int type;
/* Note: sdi and sdi->priv are non-NULL, the caller checked this. */ /* Note: sdi and sdi->priv are non-NULL, the caller checked this. */
devc = sdi->priv; devc = sdi->priv;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = (struct sr_channel *)l->data; ch = (struct sr_channel *)l->data;
if (probe->enabled == FALSE) if (ch->enabled == FALSE)
continue; continue;
if ((tc = probe->trigger)) { if ((tc = ch->trigger)) {
switch (*tc) { switch (*tc) {
case '1': case '1':
type = TRIGGER_HIGH; type = TRIGGER_HIGH;
@ -204,7 +204,7 @@ static int configure_probes(const struct sr_dev_inst *sdi)
default: default:
return SR_ERR; return SR_ERR;
} }
analyzer_add_trigger(probe->index, type); analyzer_add_trigger(ch->index, type);
devc->trigger = 1; devc->trigger = 1;
} }
} }
@ -247,7 +247,7 @@ static int init(struct sr_context *sr_ctx)
static GSList *scan(GSList *options) static GSList *scan(GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
const struct zp_model *prof; const struct zp_model *prof;
@ -314,12 +314,12 @@ static GSList *scan(GSList *options)
devc->memory_size = MEMORY_SIZE_8K; devc->memory_size = MEMORY_SIZE_8K;
// memset(devc->trigger_buffer, 0, NUM_TRIGGER_STAGES); // memset(devc->trigger_buffer, 0, NUM_TRIGGER_STAGES);
/* Fill in probelist according to this device's profile. */ /* Fill in channellist according to this device's profile. */
for (j = 0; j < devc->num_channels; j++) { for (j = 0; j < devc->num_channels; j++) {
if (!(probe = sr_probe_new(j, SR_PROBE_LOGIC, TRUE, if (!(ch = sr_probe_new(j, SR_PROBE_LOGIC, TRUE,
probe_names[j]))) channel_names[j])))
return NULL; return NULL;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);
@ -634,8 +634,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_ERR_ARG; return SR_ERR_ARG;
} }
if (configure_probes(sdi) != SR_OK) { if (configure_channels(sdi) != SR_OK) {
sr_err("Failed to configure probes."); sr_err("Failed to configure channels.");
return SR_ERR; return SR_ERR;
} }

View File

@ -38,7 +38,7 @@ struct dev_context {
int num_channels; int num_channels;
int memory_size; int memory_size;
unsigned int max_sample_depth; unsigned int max_sample_depth;
//uint8_t probe_mask; //uint8_t channel_mask;
//uint8_t trigger_mask[NUM_TRIGGER_STAGES]; //uint8_t trigger_mask[NUM_TRIGGER_STAGES];
//uint8_t trigger_value[NUM_TRIGGER_STAGES]; //uint8_t trigger_value[NUM_TRIGGER_STAGES];
// uint8_t trigger_buffer[NUM_TRIGGER_STAGES]; // uint8_t trigger_buffer[NUM_TRIGGER_STAGES];

View File

@ -45,8 +45,8 @@ static int format_match(const char *filename)
static int init(struct sr_input *in, const char *filename) static int init(struct sr_input *in, const char *filename)
{ {
struct sr_channel *probe; struct sr_channel *ch;
int num_probes, i; int num_channels, i;
char name[SR_MAX_PROBENAME_LEN + 1]; char name[SR_MAX_PROBENAME_LEN + 1];
char *param; char *param;
struct context *ctx; struct context *ctx;
@ -58,14 +58,14 @@ static int init(struct sr_input *in, const char *filename)
return SR_ERR_MALLOC; return SR_ERR_MALLOC;
} }
num_probes = DEFAULT_NUM_PROBES; num_channels = DEFAULT_NUM_PROBES;
ctx->samplerate = 0; ctx->samplerate = 0;
if (in->param) { if (in->param) {
param = g_hash_table_lookup(in->param, "numprobes"); param = g_hash_table_lookup(in->param, "numchannels");
if (param) { if (param) {
num_probes = strtoul(param, NULL, 10); num_channels = strtoul(param, NULL, 10);
if (num_probes < 1) if (num_channels < 1)
return SR_ERR; return SR_ERR;
} }
@ -80,12 +80,12 @@ static int init(struct sr_input *in, const char *filename)
in->sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, NULL, NULL, NULL); in->sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, NULL, NULL, NULL);
in->internal = ctx; in->internal = ctx;
for (i = 0; i < num_probes; i++) { for (i = 0; i < num_channels; i++) {
snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i); snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i);
/* TODO: Check return value. */ /* TODO: Check return value. */
if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, name))) if (!(ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, name)))
return SR_ERR; return SR_ERR;
in->sdi->probes = g_slist_append(in->sdi->probes, probe); in->sdi->channels = g_slist_append(in->sdi->channels, ch);
} }
return SR_OK; return SR_OK;
@ -98,7 +98,7 @@ static int loadfile(struct sr_input *in, const char *filename)
struct sr_datafeed_logic logic; struct sr_datafeed_logic logic;
struct sr_config *src; struct sr_config *src;
unsigned char buffer[CHUNKSIZE]; unsigned char buffer[CHUNKSIZE];
int fd, size, num_probes; int fd, size, num_channels;
struct context *ctx; struct context *ctx;
ctx = in->internal; ctx = in->internal;
@ -106,7 +106,7 @@ static int loadfile(struct sr_input *in, const char *filename)
if ((fd = open(filename, O_RDONLY)) == -1) if ((fd = open(filename, O_RDONLY)) == -1)
return SR_ERR; return SR_ERR;
num_probes = g_slist_length(in->sdi->probes); num_channels = g_slist_length(in->sdi->channels);
/* Send header packet to the session bus. */ /* Send header packet to the session bus. */
std_session_send_df_header(in->sdi, LOG_PREFIX); std_session_send_df_header(in->sdi, LOG_PREFIX);
@ -124,7 +124,7 @@ static int loadfile(struct sr_input *in, const char *filename)
/* Chop up the input file into chunks & send it to the session bus. */ /* Chop up the input file into chunks & send it to the session bus. */
packet.type = SR_DF_LOGIC; packet.type = SR_DF_LOGIC;
packet.payload = &logic; packet.payload = &logic;
logic.unitsize = (num_probes + 7) / 8; logic.unitsize = (num_channels + 7) / 8;
logic.data = buffer; logic.data = buffer;
while ((size = read(fd, buffer, CHUNKSIZE)) > 0) { while ((size = read(fd, buffer, CHUNKSIZE)) > 0) {
logic.length = size; logic.length = size;

View File

@ -96,20 +96,20 @@ static int format_match(const char *filename)
static int init(struct sr_input *in, const char *filename) static int init(struct sr_input *in, const char *filename)
{ {
struct sr_channel *probe; struct sr_channel *ch;
int num_probes, i; int num_channels, i;
char name[SR_MAX_PROBENAME_LEN + 1]; char name[SR_MAX_PROBENAME_LEN + 1];
char *param; char *param;
(void)filename; (void)filename;
num_probes = DEFAULT_NUM_PROBES; num_channels = DEFAULT_NUM_PROBES;
if (in->param) { if (in->param) {
param = g_hash_table_lookup(in->param, "numprobes"); param = g_hash_table_lookup(in->param, "numchannels");
if (param) { if (param) {
num_probes = strtoul(param, NULL, 10); num_channels = strtoul(param, NULL, 10);
if (num_probes < 1) { if (num_channels < 1) {
sr_err("%s: strtoul failed", __func__); sr_err("%s: strtoul failed", __func__);
return SR_ERR; return SR_ERR;
} }
@ -119,12 +119,12 @@ static int init(struct sr_input *in, const char *filename)
/* Create a virtual device. */ /* Create a virtual device. */
in->sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, NULL, NULL, NULL); in->sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, NULL, NULL, NULL);
for (i = 0; i < num_probes; i++) { for (i = 0; i < num_channels; i++) {
snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i); snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i);
/* TODO: Check return value. */ /* TODO: Check return value. */
if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, name))) if (!(ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, name)))
return SR_ERR; return SR_ERR;
in->sdi->probes = g_slist_append(in->sdi->probes, probe); in->sdi->channels = g_slist_append(in->sdi->channels, ch);
} }
return SR_OK; return SR_OK;
@ -137,7 +137,7 @@ static int loadfile(struct sr_input *in, const char *filename)
struct sr_datafeed_logic logic; struct sr_datafeed_logic logic;
struct sr_config *src; struct sr_config *src;
uint8_t buf[PACKET_SIZE], divcount; uint8_t buf[PACKET_SIZE], divcount;
int i, fd, size, num_probes; int i, fd, size, num_channels;
uint64_t samplerate; uint64_t samplerate;
/* TODO: Use glib functions! GIOChannel, g_fopen, etc. */ /* TODO: Use glib functions! GIOChannel, g_fopen, etc. */
@ -146,7 +146,7 @@ static int loadfile(struct sr_input *in, const char *filename)
return SR_ERR; return SR_ERR;
} }
num_probes = g_slist_length(in->sdi->probes); num_channels = g_slist_length(in->sdi->channels);
/* Seek to the end of the file, and read the divcount byte. */ /* Seek to the end of the file, and read the divcount byte. */
divcount = 0x00; /* TODO: Don't hardcode! */ divcount = 0x00; /* TODO: Don't hardcode! */
@ -176,7 +176,7 @@ static int loadfile(struct sr_input *in, const char *filename)
sr_dbg("%s: sending SR_DF_LOGIC data packets", __func__); sr_dbg("%s: sending SR_DF_LOGIC data packets", __func__);
packet.type = SR_DF_LOGIC; packet.type = SR_DF_LOGIC;
packet.payload = &logic; packet.payload = &logic;
logic.unitsize = (num_probes + 7) / 8; logic.unitsize = (num_channels + 7) / 8;
logic.data = buf; logic.data = buf;
/* Send 8MB of total data to the session bus in small chunks. */ /* Send 8MB of total data to the session bus in small chunks. */

View File

@ -32,10 +32,10 @@
* single column mode and enables single column mode. Multi * single column mode and enables single column mode. Multi
* column mode is used if this parameter is omitted. * column mode is used if this parameter is omitted.
* *
* numprobes: Specifies the number of probes to use. In multi column mode * numchannels: Specifies the number of channels to use. In multi column mode
* the number of probes are the number of columns and in single * the number of channels are the number of columns and in single
* column mode the number of bits (LSB first) beginning at * column mode the number of bits (LSB first) beginning at
* 'first-probe'. * 'first-channel'.
* *
* delimiter: Specifies the delimiter for columns. Must be at least one * delimiter: Specifies the delimiter for columns. Must be at least one
* character. Comma is used as default delimiter. * character. Comma is used as default delimiter.
@ -52,13 +52,13 @@
* samplerate: Samplerate which the sample data was captured with. Default * samplerate: Samplerate which the sample data was captured with. Default
* value is 0. * value is 0.
* *
* first-probe: Column number of the first probe in multi column mode and * first-channel: Column number of the first channel in multi column mode and
* position of the bit for the first probe in single column mode. * position of the bit for the first channel in single column mode.
* Default value is 0. * Default value is 0.
* *
* header: Determines if the first line should be treated as header * header: Determines if the first line should be treated as header
* and used for probe names in multi column mode. Empty header * and used for channel names in multi column mode. Empty header
* names will be replaced by the probe number. If enabled in * names will be replaced by the channel number. If enabled in
* single column mode the first line will be skipped. Usage of * single column mode the first line will be skipped. Usage of
* header is disabled by default. * header is disabled by default.
* *
@ -77,8 +77,8 @@ struct context {
/* Current selected samplerate. */ /* Current selected samplerate. */
uint64_t samplerate; uint64_t samplerate;
/* Number of probes. */ /* Number of channels. */
gsize num_probes; gsize num_channels;
/* Column delimiter character(s). */ /* Column delimiter character(s). */
GString *delimiter; GString *delimiter;
@ -94,23 +94,23 @@ struct context {
/* /*
* Number of the first column to parse. Equivalent to the number of the * Number of the first column to parse. Equivalent to the number of the
* first probe in multi column mode and the single column number in * first channel in multi column mode and the single column number in
* single column mode. * single column mode.
*/ */
gsize first_column; gsize first_column;
/* /*
* Column number of the first probe in multi column mode and position of * Column number of the first channel in multi column mode and position of
* the bit for the first probe in single column mode. * the bit for the first channel in single column mode.
*/ */
gsize first_probe; gsize first_channel;
/* Line number to start processing. */ /* Line number to start processing. */
gsize start_line; gsize start_line;
/* /*
* Determines if the first line should be treated as header and used for * Determines if the first line should be treated as header and used for
* probe names in multi column mode. * channel names in multi column mode.
*/ */
gboolean header; gboolean header;
@ -203,11 +203,11 @@ static int parse_binstr(const char *str, struct context *ctx)
} }
/* Clear buffer in order to set bits only. */ /* Clear buffer in order to set bits only. */
memset(ctx->sample_buffer, 0, (ctx->num_probes + 7) >> 3); memset(ctx->sample_buffer, 0, (ctx->num_channels + 7) >> 3);
i = ctx->first_probe; i = ctx->first_channel;
for (j = 0; i < length && j < ctx->num_probes; i++, j++) { for (j = 0; i < length && j < ctx->num_channels; i++, j++) {
if (str[length - i - 1] == '1') { if (str[length - i - 1] == '1') {
ctx->sample_buffer[j / 8] |= (1 << (j % 8)); ctx->sample_buffer[j / 8] |= (1 << (j % 8));
} else if (str[length - i - 1] != '0') { } else if (str[length - i - 1] != '0') {
@ -235,12 +235,12 @@ static int parse_hexstr(const char *str, struct context *ctx)
} }
/* Clear buffer in order to set bits only. */ /* Clear buffer in order to set bits only. */
memset(ctx->sample_buffer, 0, (ctx->num_probes + 7) >> 3); memset(ctx->sample_buffer, 0, (ctx->num_channels + 7) >> 3);
/* Calculate the position of the first hexadecimal digit. */ /* Calculate the position of the first hexadecimal digit. */
i = ctx->first_probe / 4; i = ctx->first_channel / 4;
for (j = 0; i < length && j < ctx->num_probes; i++) { for (j = 0; i < length && j < ctx->num_channels; i++) {
c = str[length - i - 1]; c = str[length - i - 1];
if (!g_ascii_isxdigit(c)) { if (!g_ascii_isxdigit(c)) {
@ -251,9 +251,9 @@ static int parse_hexstr(const char *str, struct context *ctx)
value = g_ascii_xdigit_value(c); value = g_ascii_xdigit_value(c);
k = (ctx->first_probe + j) % 4; k = (ctx->first_channel + j) % 4;
for (; j < ctx->num_probes && k < 4; k++) { for (; j < ctx->num_channels && k < 4; k++) {
if (value & (1 << k)) if (value & (1 << k))
ctx->sample_buffer[j / 8] |= (1 << (j % 8)); ctx->sample_buffer[j / 8] |= (1 << (j % 8));
@ -279,12 +279,12 @@ static int parse_octstr(const char *str, struct context *ctx)
} }
/* Clear buffer in order to set bits only. */ /* Clear buffer in order to set bits only. */
memset(ctx->sample_buffer, 0, (ctx->num_probes + 7) >> 3); memset(ctx->sample_buffer, 0, (ctx->num_channels + 7) >> 3);
/* Calculate the position of the first octal digit. */ /* Calculate the position of the first octal digit. */
i = ctx->first_probe / 3; i = ctx->first_channel / 3;
for (j = 0; i < length && j < ctx->num_probes; i++) { for (j = 0; i < length && j < ctx->num_channels; i++) {
c = str[length - i - 1]; c = str[length - i - 1];
if (c < '0' || c > '7') { if (c < '0' || c > '7') {
@ -295,9 +295,9 @@ static int parse_octstr(const char *str, struct context *ctx)
value = g_ascii_xdigit_value(c); value = g_ascii_xdigit_value(c);
k = (ctx->first_probe + j) % 3; k = (ctx->first_channel + j) % 3;
for (; j < ctx->num_probes && k < 3; k++) { for (; j < ctx->num_channels && k < 3; k++) {
if (value & (1 << k)) if (value & (1 << k))
ctx->sample_buffer[j / 8] |= (1 << (j % 8)); ctx->sample_buffer[j / 8] |= (1 << (j % 8));
@ -361,18 +361,18 @@ static int parse_multi_columns(char **columns, struct context *ctx)
gsize i; gsize i;
/* Clear buffer in order to set bits only. */ /* Clear buffer in order to set bits only. */
memset(ctx->sample_buffer, 0, (ctx->num_probes + 7) >> 3); memset(ctx->sample_buffer, 0, (ctx->num_channels + 7) >> 3);
for (i = 0; i < ctx->num_probes; i++) { for (i = 0; i < ctx->num_channels; i++) {
if (columns[i][0] == '1') { if (columns[i][0] == '1') {
ctx->sample_buffer[i / 8] |= (1 << (i % 8)); ctx->sample_buffer[i / 8] |= (1 << (i % 8));
} else if (!strlen(columns[i])) { } else if (!strlen(columns[i])) {
sr_err("Column %zu in line %zu is empty.", sr_err("Column %zu in line %zu is empty.",
ctx->first_probe + i, ctx->line_number); ctx->first_channel + i, ctx->line_number);
return SR_ERR; return SR_ERR;
} else if (columns[i][0] != '0') { } else if (columns[i][0] != '0') {
sr_err("Invalid value '%s' in column %zu in line %zu.", sr_err("Invalid value '%s' in column %zu in line %zu.",
columns[i], ctx->first_probe + i, columns[i], ctx->first_channel + i,
ctx->line_number); ctx->line_number);
return SR_ERR; return SR_ERR;
} }
@ -431,8 +431,8 @@ static int init(struct sr_input *in, const char *filename)
const char *param; const char *param;
GIOStatus status; GIOStatus status;
gsize i, term_pos; gsize i, term_pos;
char probe_name[SR_MAX_PROBENAME_LEN + 1]; char channel_name[SR_MAX_PROBENAME_LEN + 1];
struct sr_channel *probe; struct sr_channel *ch;
char **columns; char **columns;
gsize num_columns; gsize num_columns;
char *ptr; char *ptr;
@ -450,11 +450,11 @@ static int init(struct sr_input *in, const char *filename)
ctx->samplerate = 0; ctx->samplerate = 0;
/* /*
* Enable auto-detection of the number of probes in multi column mode * Enable auto-detection of the number of channels in multi column mode
* and enforce the specification of the number of probes in single * and enforce the specification of the number of channels in single
* column mode. * column mode.
*/ */
ctx->num_probes = 0; ctx->num_channels = 0;
/* Set default delimiter. */ /* Set default delimiter. */
if (!(ctx->delimiter = g_string_new(","))) { if (!(ctx->delimiter = g_string_new(","))) {
@ -483,7 +483,7 @@ static int init(struct sr_input *in, const char *filename)
* In multi column mode start parsing sample data at the first column * In multi column mode start parsing sample data at the first column
* and in single column mode at the first bit. * and in single column mode at the first bit.
*/ */
ctx->first_probe = 0; ctx->first_channel = 0;
/* Start at the beginning of the file. */ /* Start at the beginning of the file. */
ctx->start_line = 1; ctx->start_line = 1;
@ -511,8 +511,8 @@ static int init(struct sr_input *in, const char *filename)
} }
} }
if ((param = g_hash_table_lookup(in->param, "numprobes"))) if ((param = g_hash_table_lookup(in->param, "numchannels")))
ctx->num_probes = g_ascii_strtoull(param, NULL, 10); ctx->num_channels = g_ascii_strtoull(param, NULL, 10);
if ((param = g_hash_table_lookup(in->param, "delimiter"))) { if ((param = g_hash_table_lookup(in->param, "delimiter"))) {
if (!strlen(param)) { if (!strlen(param)) {
@ -542,8 +542,8 @@ static int init(struct sr_input *in, const char *filename)
} }
} }
if ((param = g_hash_table_lookup(in->param, "first-probe"))) if ((param = g_hash_table_lookup(in->param, "first-channel")))
ctx->first_probe = g_ascii_strtoull(param, NULL, 10); ctx->first_channel = g_ascii_strtoull(param, NULL, 10);
if ((param = g_hash_table_lookup(in->param, "startline"))) { if ((param = g_hash_table_lookup(in->param, "startline"))) {
ctx->start_line = g_ascii_strtoull(param, NULL, 10); ctx->start_line = g_ascii_strtoull(param, NULL, 10);
@ -574,12 +574,12 @@ static int init(struct sr_input *in, const char *filename)
} }
if (ctx->multi_column_mode) if (ctx->multi_column_mode)
ctx->first_column = ctx->first_probe; ctx->first_column = ctx->first_channel;
else else
ctx->first_column = ctx->single_column; ctx->first_column = ctx->single_column;
if (!ctx->multi_column_mode && !ctx->num_probes) { if (!ctx->multi_column_mode && !ctx->num_channels) {
sr_err("Number of probes needs to be specified in single column mode."); sr_err("Number of channels needs to be specified in single column mode.");
free_context(ctx); free_context(ctx);
return SR_ERR; return SR_ERR;
} }
@ -653,21 +653,21 @@ static int init(struct sr_input *in, const char *filename)
if (ctx->multi_column_mode) { if (ctx->multi_column_mode) {
/* /*
* Detect the number of probes in multi column mode * Detect the number of channels in multi column mode
* automatically if not specified. * automatically if not specified.
*/ */
if (!ctx->num_probes) { if (!ctx->num_channels) {
ctx->num_probes = num_columns; ctx->num_channels = num_columns;
sr_info("Number of auto-detected probes: %zu.", sr_info("Number of auto-detected channels: %zu.",
ctx->num_probes); ctx->num_channels);
} }
/* /*
* Ensure that the number of probes does not exceed the number * Ensure that the number of channels does not exceed the number
* of columns in multi column mode. * of columns in multi column mode.
*/ */
if (num_columns < ctx->num_probes) { if (num_columns < ctx->num_channels) {
sr_err("Not enough columns for desired number of probes in line %zu.", sr_err("Not enough columns for desired number of channels in line %zu.",
ctx->line_number); ctx->line_number);
g_strfreev(columns); g_strfreev(columns);
free_context(ctx); free_context(ctx);
@ -675,32 +675,32 @@ static int init(struct sr_input *in, const char *filename)
} }
} }
for (i = 0; i < ctx->num_probes; i++) { for (i = 0; i < ctx->num_channels; i++) {
if (ctx->header && ctx->multi_column_mode && strlen(columns[i])) if (ctx->header && ctx->multi_column_mode && strlen(columns[i]))
snprintf(probe_name, sizeof(probe_name), "%s", snprintf(channel_name, sizeof(channel_name), "%s",
columns[i]); columns[i]);
else else
snprintf(probe_name, sizeof(probe_name), "%zu", i); snprintf(channel_name, sizeof(channel_name), "%zu", i);
probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, probe_name); ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, channel_name);
if (!probe) { if (!ch) {
sr_err("Probe creation failed."); sr_err("Channel creation failed.");
free_context(ctx); free_context(ctx);
g_strfreev(columns); g_strfreev(columns);
return SR_ERR; return SR_ERR;
} }
in->sdi->probes = g_slist_append(in->sdi->probes, probe); in->sdi->channels = g_slist_append(in->sdi->channels, ch);
} }
g_strfreev(columns); g_strfreev(columns);
/* /*
* Calculate the minimum buffer size to store the sample data of the * Calculate the minimum buffer size to store the sample data of the
* probes. * channels.
*/ */
ctx->sample_buffer_size = (ctx->num_probes + 7) >> 3; ctx->sample_buffer_size = (ctx->num_channels + 7) >> 3;
if (!(ctx->sample_buffer = g_try_malloc(ctx->sample_buffer_size))) { if (!(ctx->sample_buffer = g_try_malloc(ctx->sample_buffer_size))) {
sr_err("Sample buffer malloc failed."); sr_err("Sample buffer malloc failed.");
@ -746,7 +746,7 @@ static int loadfile(struct sr_input *in, const char *filename)
/* Limit the number of columns to parse. */ /* Limit the number of columns to parse. */
if (ctx->multi_column_mode) if (ctx->multi_column_mode)
max_columns = ctx->num_probes; max_columns = ctx->num_channels;
else else
max_columns = 1; max_columns = 1;
@ -810,11 +810,11 @@ static int loadfile(struct sr_input *in, const char *filename)
} }
/* /*
* Ensure that the number of probes does not exceed the number * Ensure that the number of channels does not exceed the number
* of columns in multi column mode. * of columns in multi column mode.
*/ */
if (ctx->multi_column_mode && num_columns < ctx->num_probes) { if (ctx->multi_column_mode && num_columns < ctx->num_channels) {
sr_err("Not enough columns for desired number of probes in line %zu.", sr_err("Not enough columns for desired number of channels in line %zu.",
ctx->line_number); ctx->line_number);
g_strfreev(columns); g_strfreev(columns);
free_context(ctx); free_context(ctx);

View File

@ -19,7 +19,7 @@
/* The VCD input module has the following options: /* The VCD input module has the following options:
* *
* numprobes: Maximum number of probes to use. The probes are * numchannels: Maximum number of channels to use. The channels are
* detected in the same order as they are listed * detected in the same order as they are listed
* in the $var sections of the VCD file. * in the $var sections of the VCD file.
* *
@ -53,7 +53,7 @@
* - analog, integer and real number variables * - analog, integer and real number variables
* - $dumpvars initial value declaration * - $dumpvars initial value declaration
* - $scope namespaces * - $scope namespaces
* - more than 64 probes * - more than 64 channels
*/ */
#include <stdlib.h> #include <stdlib.h>
@ -70,15 +70,15 @@
struct context { struct context {
uint64_t samplerate; uint64_t samplerate;
int maxprobes; int maxchannels;
int probecount; int channelcount;
int downsample; int downsample;
unsigned compress; unsigned compress;
int64_t skip; int64_t skip;
GSList *probes; GSList *channels;
}; };
struct probe { struct vcd_channel {
gchar *name; gchar *name;
gchar *identifier; gchar *identifier;
}; };
@ -164,17 +164,17 @@ static gboolean parse_section(FILE *file, gchar **name, gchar **contents)
return status; return status;
} }
static void free_probe(void *data) static void free_channel(void *data)
{ {
struct probe *probe = data; struct vcd_channel *vcd_ch = data;
g_free(probe->name); g_free(vcd_ch->name);
g_free(probe->identifier); g_free(vcd_ch->identifier);
g_free(probe); g_free(vcd_ch);
} }
static void release_context(struct context *ctx) static void release_context(struct context *ctx)
{ {
g_slist_free_full(ctx->probes, free_probe); g_slist_free_full(ctx->channels, free_channel);
g_free(ctx); g_free(ctx);
} }
@ -201,7 +201,7 @@ static gboolean parse_header(FILE *file, struct context *ctx)
uint64_t p, q; uint64_t p, q;
gchar *name = NULL, *contents = NULL; gchar *name = NULL, *contents = NULL;
gboolean status = FALSE; gboolean status = FALSE;
struct probe *probe; struct vcd_channel *vcd_ch;
while (parse_section(file, &name, &contents)) { while (parse_section(file, &name, &contents)) {
sr_dbg("Section '%s', contents '%s'.", name, contents); sr_dbg("Section '%s', contents '%s'.", name, contents);
@ -237,15 +237,15 @@ static gboolean parse_header(FILE *file, struct context *ctx)
sr_info("Unsupported signal type: '%s'", parts[0]); sr_info("Unsupported signal type: '%s'", parts[0]);
else if (strtol(parts[1], NULL, 10) != 1) else if (strtol(parts[1], NULL, 10) != 1)
sr_info("Unsupported signal size: '%s'", parts[1]); sr_info("Unsupported signal size: '%s'", parts[1]);
else if (ctx->probecount >= ctx->maxprobes) else if (ctx->channelcount >= ctx->maxchannels)
sr_warn("Skipping '%s' because only %d probes requested.", parts[3], ctx->maxprobes); sr_warn("Skipping '%s' because only %d channels requested.", parts[3], ctx->maxchannels);
else { else {
sr_info("Probe %d is '%s' identified by '%s'.", ctx->probecount, parts[3], parts[2]); sr_info("Channel %d is '%s' identified by '%s'.", ctx->channelcount, parts[3], parts[2]);
probe = g_malloc(sizeof(struct probe)); vcd_ch = g_malloc(sizeof(struct vcd_channel));
probe->identifier = g_strdup(parts[2]); vcd_ch->identifier = g_strdup(parts[2]);
probe->name = g_strdup(parts[3]); vcd_ch->name = g_strdup(parts[3]);
ctx->probes = g_slist_append(ctx->probes, probe); ctx->channels = g_slist_append(ctx->channels, vcd_ch);
ctx->probecount++; ctx->channelcount++;
} }
g_strfreev(parts); g_strfreev(parts);
@ -287,8 +287,8 @@ static int format_match(const char *filename)
static int init(struct sr_input *in, const char *filename) static int init(struct sr_input *in, const char *filename)
{ {
struct sr_channel *probe; struct sr_channel *ch;
int num_probes, i; int num_channels, i;
char name[SR_MAX_PROBENAME_LEN + 1]; char name[SR_MAX_PROBENAME_LEN + 1];
char *param; char *param;
struct context *ctx; struct context *ctx;
@ -300,20 +300,20 @@ static int init(struct sr_input *in, const char *filename)
return SR_ERR_MALLOC; return SR_ERR_MALLOC;
} }
num_probes = DEFAULT_NUM_PROBES; num_channels = DEFAULT_NUM_PROBES;
ctx->samplerate = 0; ctx->samplerate = 0;
ctx->downsample = 1; ctx->downsample = 1;
ctx->skip = -1; ctx->skip = -1;
if (in->param) { if (in->param) {
param = g_hash_table_lookup(in->param, "numprobes"); param = g_hash_table_lookup(in->param, "numchannels");
if (param) { if (param) {
num_probes = strtoul(param, NULL, 10); num_channels = strtoul(param, NULL, 10);
if (num_probes < 1) { if (num_channels < 1) {
release_context(ctx); release_context(ctx);
return SR_ERR; return SR_ERR;
} else if (num_probes > 64) { } else if (num_channels > 64) {
sr_err("No more than 64 probes supported."); sr_err("No more than 64 channels supported.");
return SR_ERR; return SR_ERR;
} }
} }
@ -334,22 +334,22 @@ static int init(struct sr_input *in, const char *filename)
ctx->skip = strtoul(param, NULL, 10) / ctx->downsample; ctx->skip = strtoul(param, NULL, 10) / ctx->downsample;
} }
/* Maximum number of probes to parse from the VCD */ /* Maximum number of channels to parse from the VCD */
ctx->maxprobes = num_probes; ctx->maxchannels = num_channels;
/* Create a virtual device. */ /* Create a virtual device. */
in->sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, NULL, NULL, NULL); in->sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, NULL, NULL, NULL);
in->internal = ctx; in->internal = ctx;
for (i = 0; i < num_probes; i++) { for (i = 0; i < num_channels; i++) {
snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i); snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i);
if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, name))) { if (!(ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, name))) {
release_context(ctx); release_context(ctx);
return SR_ERR; return SR_ERR;
} }
in->sdi->probes = g_slist_append(in->sdi->probes, probe); in->sdi->channels = g_slist_append(in->sdi->channels, ch);
} }
return SR_OK; return SR_OK;
@ -452,7 +452,7 @@ static void parse_contents(FILE *file, const struct sr_dev_inst *sdi, struct con
/* A new 1-bit sample value */ /* A new 1-bit sample value */
int i, bit; int i, bit;
GSList *l; GSList *l;
struct probe *probe; struct vcd_channel *vcd_ch;
bit = (token->str[0] == '1'); bit = (token->str[0] == '1');
@ -465,11 +465,11 @@ static void parse_contents(FILE *file, const struct sr_dev_inst *sdi, struct con
read_until(file, token, 'W'); read_until(file, token, 'W');
} }
for (i = 0, l = ctx->probes; i < ctx->probecount && l; i++, l = l->next) { for (i = 0, l = ctx->channels; i < ctx->channelcount && l; i++, l = l->next) {
probe = l->data; vcd_ch = l->data;
if (g_strcmp0(token->str, probe->identifier) == 0) { if (g_strcmp0(token->str, vcd_ch->identifier) == 0) {
/* Found our probe */ /* Found our channel */
if (bit) if (bit)
prev_values |= (uint64_t)1 << i; prev_values |= (uint64_t)1 << i;
else else
@ -479,8 +479,8 @@ static void parse_contents(FILE *file, const struct sr_dev_inst *sdi, struct con
} }
} }
if (i == ctx->probecount) if (i == ctx->channelcount)
sr_dbg("Did not find probe for identifier '%s'.", token->str); sr_dbg("Did not find channel for identifier '%s'.", token->str);
} else { } else {
sr_warn("Skipping unknown token '%s'.", token->str); sr_warn("Skipping unknown token '%s'.", token->str);
} }

View File

@ -85,9 +85,9 @@ static int format_match(const char *filename)
static int init(struct sr_input *in, const char *filename) static int init(struct sr_input *in, const char *filename)
{ {
struct sr_channel *probe; struct sr_channel *ch;
struct context *ctx; struct context *ctx;
char buf[40], probename[8]; char buf[40], channelname[8];
int i; int i;
if (get_wav_header(filename, buf) != SR_OK) if (get_wav_header(filename, buf) != SR_OK)
@ -113,10 +113,10 @@ static int init(struct sr_input *in, const char *filename)
} }
for (i = 0; i < ctx->num_channels; i++) { for (i = 0; i < ctx->num_channels; i++) {
snprintf(probename, 8, "CH%d", i + 1); snprintf(channelname, 8, "CH%d", i + 1);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, probename))) if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, channelname)))
return SR_ERR; return SR_ERR;
in->sdi->probes = g_slist_append(in->sdi->probes, probe); in->sdi->channels = g_slist_append(in->sdi->channels, ch);
} }
return SR_OK; return SR_OK;
@ -178,7 +178,7 @@ static int loadfile(struct sr_input *in, const char *filename)
} }
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
analog.probes = in->sdi->probes; analog.channels = in->sdi->channels;
analog.num_samples = chunk_samples; analog.num_samples = chunk_samples;
analog.mq = 0; analog.mq = 0;
analog.unit = 0; analog.unit = 0;

View File

@ -340,8 +340,8 @@ struct sr_datafeed_logic {
/** Analog datafeed payload for type SR_DF_ANALOG. */ /** Analog datafeed payload for type SR_DF_ANALOG. */
struct sr_datafeed_analog { struct sr_datafeed_analog {
/** The probes for which data is included in this packet. */ /** The channels for which data is included in this packet. */
GSList *probes; GSList *channels;
/** Number of samples in data */ /** Number of samples in data */
int num_samples; int num_samples;
/** Measured quantity (voltage, current, temperature, and so on). /** Measured quantity (voltage, current, temperature, and so on).
@ -352,7 +352,7 @@ struct sr_datafeed_analog {
/** Bitmap with extra information about the MQ. Use SR_MQFLAG_AC, ... */ /** Bitmap with extra information about the MQ. Use SR_MQFLAG_AC, ... */
uint64_t mqflags; uint64_t mqflags;
/** The analog value(s). The data is interleaved according to /** The analog value(s). The data is interleaved according to
* the probes list. */ * the channels list. */
float *data; float *data;
}; };
@ -438,7 +438,7 @@ struct sr_output {
/** /**
* The device for which this output module is creating output. This * The device for which this output module is creating output. This
* can be used by the module to find out probe names and numbers. * can be used by the module to find out channel names and numbers.
*/ */
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
@ -919,8 +919,8 @@ struct sr_dev_inst {
char *model; char *model;
/** Device version. */ /** Device version. */
char *version; char *version;
/** List of probes. */ /** List of channels. */
GSList *probes; GSList *channels;
/** List of sr_channel_group structs */ /** List of sr_channel_group structs */
GSList *channel_groups; GSList *channel_groups;
/** Device instance connection data (used?) */ /** Device instance connection data (used?) */
@ -995,7 +995,7 @@ struct sr_dev_driver {
/** Probe status change. /** Probe status change.
* @see sr_dev_probe_enable(), sr_dev_trigger_set(). */ * @see sr_dev_probe_enable(), sr_dev_trigger_set(). */
int (*config_probe_set) (const struct sr_dev_inst *sdi, int (*config_probe_set) (const struct sr_dev_inst *sdi,
struct sr_channel *probe, unsigned int changes); struct sr_channel *ch, unsigned int changes);
/** Apply configuration settings to the device hardware. /** Apply configuration settings to the device hardware.
* @see sr_config_commit().*/ * @see sr_config_commit().*/
int (*config_commit) (const struct sr_dev_inst *sdi); int (*config_commit) (const struct sr_dev_inst *sdi);

View File

@ -27,14 +27,14 @@
#define LOG_PREFIX "output/analog" #define LOG_PREFIX "output/analog"
struct context { struct context {
int num_enabled_probes; int num_enabled_channels;
GPtrArray *probelist; GPtrArray *channellist;
}; };
static int init(struct sr_output *o) static int init(struct sr_output *o)
{ {
struct context *ctx; struct context *ctx;
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
sr_spew("Initializing output module."); sr_spew("Initializing output module.");
@ -48,14 +48,14 @@ static int init(struct sr_output *o)
} }
o->internal = ctx; o->internal = ctx;
/* Get the number of probes and their names. */ /* Get the number of channels and their names. */
ctx->probelist = g_ptr_array_new(); ctx->channellist = g_ptr_array_new();
for (l = o->sdi->probes; l; l = l->next) { for (l = o->sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (!probe || !probe->enabled) if (!ch || !ch->enabled)
continue; continue;
g_ptr_array_add(ctx->probelist, probe->name); g_ptr_array_add(ctx->channellist, ch->name);
ctx->num_enabled_probes++; ctx->num_enabled_channels++;
} }
return SR_OK; return SR_OK;
@ -210,7 +210,7 @@ static int receive(struct sr_output *o, const struct sr_dev_inst *sdi,
const struct sr_datafeed_packet *packet, GString **out) const struct sr_datafeed_packet *packet, GString **out)
{ {
const struct sr_datafeed_analog *analog; const struct sr_datafeed_analog *analog;
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
const float *fdata; const float *fdata;
int i, p; int i, p;
@ -233,9 +233,9 @@ static int receive(struct sr_output *o, const struct sr_dev_inst *sdi,
fdata = (const float *)analog->data; fdata = (const float *)analog->data;
*out = g_string_sized_new(512); *out = g_string_sized_new(512);
for (i = 0; i < analog->num_samples; i++) { for (i = 0; i < analog->num_samples; i++) {
for (l = analog->probes, p = 0; l; l = l->next, p++) { for (l = analog->channels, p = 0; l; l = l->next, p++) {
probe = l->data; ch = l->data;
g_string_append_printf(*out, "%s: ", probe->name); g_string_append_printf(*out, "%s: ", ch->name);
fancyprint(analog->unit, analog->mqflags, fancyprint(analog->unit, analog->mqflags,
fdata[i + p], *out); fdata[i + p], *out);
} }
@ -254,7 +254,7 @@ static int cleanup(struct sr_output *o)
return SR_ERR_ARG; return SR_ERR_ARG;
ctx = o->internal; ctx = o->internal;
g_ptr_array_free(ctx->probelist, 1); g_ptr_array_free(ctx->channellist, 1);
g_free(ctx); g_free(ctx);
o->internal = NULL; o->internal = NULL;

View File

@ -27,7 +27,7 @@
#define LOG_PREFIX "output/chronovu-la8" #define LOG_PREFIX "output/chronovu-la8"
struct context { struct context {
unsigned int num_enabled_probes; unsigned int num_enabled_channels;
unsigned int unitsize; unsigned int unitsize;
uint64_t trigger_point; uint64_t trigger_point;
uint64_t samplerate; uint64_t samplerate;
@ -84,7 +84,7 @@ static uint8_t samplerate_to_divcount(uint64_t samplerate)
static int init(struct sr_output *o) static int init(struct sr_output *o)
{ {
struct context *ctx; struct context *ctx;
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
GVariant *gvar; GVariant *gvar;
@ -106,15 +106,15 @@ static int init(struct sr_output *o)
o->internal = ctx; o->internal = ctx;
/* Get the unitsize. */ /* Get the unitsize. */
for (l = o->sdi->probes; l; l = l->next) { for (l = o->sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (probe->type != SR_PROBE_LOGIC) if (ch->type != SR_PROBE_LOGIC)
continue; continue;
if (!probe->enabled) if (!ch->enabled)
continue; continue;
ctx->num_enabled_probes++; ctx->num_enabled_channels++;
} }
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8; ctx->unitsize = (ctx->num_enabled_channels + 7) / 8;
if (sr_config_get(o->sdi->driver, o->sdi, NULL, SR_CONF_SAMPLERATE, if (sr_config_get(o->sdi->driver, o->sdi, NULL, SR_CONF_SAMPLERATE,
&gvar) == SR_OK) { &gvar) == SR_OK) {

View File

@ -28,7 +28,7 @@
#define LOG_PREFIX "output/csv" #define LOG_PREFIX "output/csv"
struct context { struct context {
unsigned int num_enabled_probes; unsigned int num_enabled_channels;
unsigned int unitsize; unsigned int unitsize;
uint64_t samplerate; uint64_t samplerate;
GString *header; GString *header;
@ -43,17 +43,17 @@ struct context {
* - Option to (not) print samplenumber / time as extra column. * - Option to (not) print samplenumber / time as extra column.
* - Option to "compress" output (only print changed samples, VCD-like). * - Option to "compress" output (only print changed samples, VCD-like).
* - Option to print comma-separated bits, or whole bytes/words (for 8/16 * - Option to print comma-separated bits, or whole bytes/words (for 8/16
* probe LAs) as ASCII/hex etc. etc. * channel LAs) as ASCII/hex etc. etc.
* - Trigger support. * - Trigger support.
*/ */
static int init(struct sr_output *o) static int init(struct sr_output *o)
{ {
struct context *ctx; struct context *ctx;
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
GVariant *gvar; GVariant *gvar;
int num_probes; int num_channels;
time_t t; time_t t;
if (!o) if (!o)
@ -65,19 +65,19 @@ static int init(struct sr_output *o)
ctx = g_try_malloc0(sizeof(struct context)); ctx = g_try_malloc0(sizeof(struct context));
o->internal = ctx; o->internal = ctx;
/* Get the number of probes, and the unitsize. */ /* Get the number of channels, and the unitsize. */
for (l = o->sdi->probes; l; l = l->next) { for (l = o->sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (probe->type != SR_PROBE_LOGIC) if (ch->type != SR_PROBE_LOGIC)
continue; continue;
if (!probe->enabled) if (!ch->enabled)
continue; continue;
ctx->num_enabled_probes++; ctx->num_enabled_channels++;
} }
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8; ctx->unitsize = (ctx->num_enabled_channels + 7) / 8;
num_probes = g_slist_length(o->sdi->probes); num_channels = g_slist_length(o->sdi->channels);
if (sr_config_get(o->sdi->driver, o->sdi, NULL, SR_CONF_SAMPLERATE, if (sr_config_get(o->sdi->driver, o->sdi, NULL, SR_CONF_SAMPLERATE,
&gvar) == SR_OK) { &gvar) == SR_OK) {
@ -99,16 +99,16 @@ static int init(struct sr_output *o)
/* Columns / channels */ /* Columns / channels */
g_string_append_printf(ctx->header, "; Channels (%d/%d):", g_string_append_printf(ctx->header, "; Channels (%d/%d):",
ctx->num_enabled_probes, num_probes); ctx->num_enabled_channels, num_channels);
for (l = o->sdi->probes; l; l = l->next) { for (l = o->sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (probe->type != SR_PROBE_LOGIC) if (ch->type != SR_PROBE_LOGIC)
continue; continue;
if (!probe->enabled) if (!ch->enabled)
continue; continue;
g_string_append_printf(ctx->header, " %s,", probe->name); g_string_append_printf(ctx->header, " %s,", ch->name);
} }
if (o->sdi->probes) if (o->sdi->channels)
/* Drop last separator. */ /* Drop last separator. */
g_string_truncate(ctx->header, ctx->header->len - 1); g_string_truncate(ctx->header, ctx->header->len - 1);
g_string_append_printf(ctx->header, "\n"); g_string_append_printf(ctx->header, "\n");
@ -147,7 +147,7 @@ static int receive(struct sr_output *o, const struct sr_dev_inst *sdi,
} }
for (i = 0; i <= logic->length - ctx->unitsize; i += ctx->unitsize) { for (i = 0; i <= logic->length - ctx->unitsize; i += ctx->unitsize) {
for (j = 0; j < ctx->num_enabled_probes; j++) { for (j = 0; j < ctx->num_enabled_channels; j++) {
p = logic->data + i + j / 8; p = logic->data + i + j / 8;
c = *p & (1 << (j % 8)); c = *p & (1 << (j % 8));
g_string_append_c(*out, c ? '1' : '0'); g_string_append_c(*out, c ? '1' : '0');

View File

@ -28,7 +28,7 @@
#define LOG_PREFIX "output/gnuplot" #define LOG_PREFIX "output/gnuplot"
struct context { struct context {
unsigned int num_enabled_probes; unsigned int num_enabled_channels;
unsigned int unitsize; unsigned int unitsize;
char *header; char *header;
uint8_t *old_sample; uint8_t *old_sample;
@ -40,23 +40,23 @@ static const char *gnuplot_header = "\
# Generated by: %s on %s%s\ # Generated by: %s on %s%s\
# Period: %s\n\ # Period: %s\n\
#\n\ #\n\
# Column\tProbe\n\ # Column\tChannel\n\
# -------------------------------------\ # -------------------------------------\
----------------------------------------\n\ ----------------------------------------\n\
# 0\t\tSample counter (for internal gnuplot purposes)\n%s\n"; # 0\t\tSample counter (for internal gnuplot purposes)\n%s\n";
static const char *gnuplot_header_comment = "\ static const char *gnuplot_header_comment = "\
# Comment: Acquisition with %d/%d probes at %s\n"; # Comment: Acquisition with %d/%d channels at %s\n";
static int init(struct sr_output *o) static int init(struct sr_output *o)
{ {
struct context *ctx; struct context *ctx;
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
GVariant *gvar; GVariant *gvar;
uint64_t samplerate; uint64_t samplerate;
unsigned int i; unsigned int i;
int num_probes; int num_channels;
char *c, *frequency_s; char *c, *frequency_s;
char wbuf[1000], comment[128]; char wbuf[1000], comment[128];
time_t t; time_t t;
@ -77,23 +77,23 @@ static int init(struct sr_output *o)
} }
o->internal = ctx; o->internal = ctx;
ctx->num_enabled_probes = 0; ctx->num_enabled_channels = 0;
for (l = o->sdi->probes; l; l = l->next) { for (l = o->sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (probe->type != SR_PROBE_LOGIC) if (ch->type != SR_PROBE_LOGIC)
continue; continue;
if (!probe->enabled) if (!ch->enabled)
continue; continue;
ctx->num_enabled_probes++; ctx->num_enabled_channels++;
} }
if (ctx->num_enabled_probes <= 0) { if (ctx->num_enabled_channels <= 0) {
sr_err("%s: no logic probe enabled", __func__); sr_err("%s: no logic channel enabled", __func__);
return SR_ERR; return SR_ERR;
} }
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8; ctx->unitsize = (ctx->num_enabled_channels + 7) / 8;
num_probes = g_slist_length(o->sdi->probes); num_channels = g_slist_length(o->sdi->channels);
comment[0] = '\0'; comment[0] = '\0';
samplerate = 0; samplerate = 0;
if (sr_config_get(o->sdi->driver, o->sdi, NULL, SR_CONF_SAMPLERATE, if (sr_config_get(o->sdi->driver, o->sdi, NULL, SR_CONF_SAMPLERATE,
@ -106,20 +106,20 @@ static int init(struct sr_output *o)
return SR_ERR; return SR_ERR;
} }
snprintf(comment, 127, gnuplot_header_comment, snprintf(comment, 127, gnuplot_header_comment,
ctx->num_enabled_probes, num_probes, frequency_s); ctx->num_enabled_channels, num_channels, frequency_s);
g_free(frequency_s); g_free(frequency_s);
} }
/* Columns / channels */ /* Columns / channels */
wbuf[0] = '\0'; wbuf[0] = '\0';
for (i = 0, l = o->sdi->probes; l; l = l->next, i++) { for (i = 0, l = o->sdi->channels; l; l = l->next, i++) {
probe = l->data; ch = l->data;
if (probe->type != SR_PROBE_LOGIC) if (ch->type != SR_PROBE_LOGIC)
continue; continue;
if (!probe->enabled) if (!ch->enabled)
continue; continue;
c = (char *)&wbuf + strlen((const char *)&wbuf); c = (char *)&wbuf + strlen((const char *)&wbuf);
sprintf(c, "# %d\t\t%s\n", i + 1, probe->name); sprintf(c, "# %d\t\t%s\n", i + 1, ch->name);
} }
if (!(frequency_s = sr_period_string(samplerate))) { if (!(frequency_s = sr_period_string(samplerate))) {
@ -215,7 +215,7 @@ static int data(struct sr_output *o, const uint8_t *data_in,
} }
ctx = o->internal; ctx = o->internal;
max_linelen = 16 + ctx->num_enabled_probes * 2; max_linelen = 16 + ctx->num_enabled_channels * 2;
outsize = length_in / ctx->unitsize * max_linelen; outsize = length_in / ctx->unitsize * max_linelen;
if (ctx->header) if (ctx->header)
outsize += strlen(ctx->header); outsize += strlen(ctx->header);
@ -253,7 +253,7 @@ static int data(struct sr_output *o, const uint8_t *data_in,
sprintf((char *)c, "%" PRIu64 "\t", samplecount++); sprintf((char *)c, "%" PRIu64 "\t", samplecount++);
/* The next columns are the values of all channels. */ /* The next columns are the values of all channels. */
for (p = 0; p < ctx->num_enabled_probes; p++) { for (p = 0; p < ctx->num_enabled_channels; p++) {
curbit = (sample[p / 8] & ((uint8_t) (1 << (p % 8)))) >> (p % 8); curbit = (sample[p / 8] & ((uint8_t) (1 << (p % 8)))) >> (p % 8);
c = outbuf + strlen((const char *)outbuf); c = outbuf + strlen((const char *)outbuf);
sprintf((char *)c, "%d ", curbit); sprintf((char *)c, "%d ", curbit);

View File

@ -56,11 +56,11 @@ static int init(struct sr_output *o)
static GString *gen_header(const struct sr_dev_inst *sdi, struct context *ctx) static GString *gen_header(const struct sr_dev_inst *sdi, struct context *ctx)
{ {
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
GString *s; GString *s;
GVariant *gvar; GVariant *gvar;
int num_enabled_probes; int num_enabled_channels;
if (!ctx->samplerate && sr_config_get(sdi->driver, sdi, NULL, if (!ctx->samplerate && sr_config_get(sdi->driver, sdi, NULL,
SR_CONF_SAMPLERATE, &gvar) == SR_OK) { SR_CONF_SAMPLERATE, &gvar) == SR_OK) {
@ -68,19 +68,19 @@ static GString *gen_header(const struct sr_dev_inst *sdi, struct context *ctx)
g_variant_unref(gvar); g_variant_unref(gvar);
} }
num_enabled_probes = 0; num_enabled_channels = 0;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (probe->type != SR_PROBE_LOGIC) if (ch->type != SR_PROBE_LOGIC)
continue; continue;
if (!probe->enabled) if (!ch->enabled)
continue; continue;
num_enabled_probes++; num_enabled_channels++;
} }
s = g_string_sized_new(512); s = g_string_sized_new(512);
g_string_append_printf(s, ";Rate: %"PRIu64"\n", ctx->samplerate); g_string_append_printf(s, ";Rate: %"PRIu64"\n", ctx->samplerate);
g_string_append_printf(s, ";Channels: %d\n", num_enabled_probes); g_string_append_printf(s, ";Channels: %d\n", num_enabled_channels);
g_string_append_printf(s, ";EnabledChannels: -1\n"); g_string_append_printf(s, ";EnabledChannels: -1\n");
g_string_append_printf(s, ";Compressed: true\n"); g_string_append_printf(s, ";Compressed: true\n");
g_string_append_printf(s, ";CursorEnabled: false\n"); g_string_append_printf(s, ";CursorEnabled: false\n");

View File

@ -50,7 +50,7 @@ SR_PRIV int data_ascii(struct sr_output *o, const uint8_t *data_in,
* extra output, e.g. trigger. * extra output, e.g. trigger.
*/ */
outsize = 512 + (1 + (length_in / ctx->unitsize) / ctx->samples_per_line) outsize = 512 + (1 + (length_in / ctx->unitsize) / ctx->samples_per_line)
* (ctx->num_enabled_probes * max_linelen); * (ctx->num_enabled_channels * max_linelen);
if (!(outbuf = g_try_malloc0(outsize + 1))) { if (!(outbuf = g_try_malloc0(outsize + 1))) {
sr_err("%s: outbuf malloc failed", __func__); sr_err("%s: outbuf malloc failed", __func__);
@ -70,9 +70,9 @@ SR_PRIV int data_ascii(struct sr_output *o, const uint8_t *data_in,
offset += ctx->unitsize) { offset += ctx->unitsize) {
sample = data_in + offset; sample = data_in + offset;
char tmpval[ctx->num_enabled_probes]; char tmpval[ctx->num_enabled_channels];
for (p = 0; p < ctx->num_enabled_probes; p++) { for (p = 0; p < ctx->num_enabled_channels; p++) {
uint8_t curbit = (sample[p / 8] & ((uint8_t) 1 << (p % 8))); uint8_t curbit = (sample[p / 8] & ((uint8_t) 1 << (p % 8)));
uint8_t prevbit = (ctx->prevsample[p / 8] & uint8_t prevbit = (ctx->prevsample[p / 8] &
((uint8_t) 1 << (p % 8))); ((uint8_t) 1 << (p % 8)));
@ -99,7 +99,7 @@ SR_PRIV int data_ascii(struct sr_output *o, const uint8_t *data_in,
ctx->mark_trigger = -1; ctx->mark_trigger = -1;
} }
for (p = 0; p < ctx->num_enabled_probes; p++) { for (p = 0; p < ctx->num_enabled_channels; p++) {
ctx->linebuf[p * ctx->linebuf_len + ctx->linebuf[p * ctx->linebuf_len +
ctx->line_offset] = tmpval[p]; ctx->line_offset] = tmpval[p];
} }

View File

@ -50,7 +50,7 @@ SR_PRIV int data_bits(struct sr_output *o, const uint8_t *data_in,
* extra output, e.g. trigger. * extra output, e.g. trigger.
*/ */
outsize = 512 + (1 + (length_in / ctx->unitsize) / ctx->samples_per_line) outsize = 512 + (1 + (length_in / ctx->unitsize) / ctx->samples_per_line)
* (ctx->num_enabled_probes * max_linelen); * (ctx->num_enabled_channels * max_linelen);
if (!(outbuf = g_try_malloc0(outsize + 1))) { if (!(outbuf = g_try_malloc0(outsize + 1))) {
sr_err("%s: outbuf malloc failed", __func__); sr_err("%s: outbuf malloc failed", __func__);
@ -69,7 +69,7 @@ SR_PRIV int data_bits(struct sr_output *o, const uint8_t *data_in,
for (offset = 0; offset <= length_in - ctx->unitsize; for (offset = 0; offset <= length_in - ctx->unitsize;
offset += ctx->unitsize) { offset += ctx->unitsize) {
sample = data_in + offset; sample = data_in + offset;
for (p = 0; p < ctx->num_enabled_probes; p++) { for (p = 0; p < ctx->num_enabled_channels; p++) {
c = (sample[p / 8] & ((uint8_t) 1 << (p % 8))) ? '1' : '0'; c = (sample[p / 8] & ((uint8_t) 1 << (p % 8))) ? '1' : '0';
ctx->linebuf[p * ctx->linebuf_len + ctx->linebuf[p * ctx->linebuf_len +
ctx->line_offset] = c; ctx->line_offset] = c;
@ -79,7 +79,7 @@ SR_PRIV int data_bits(struct sr_output *o, const uint8_t *data_in,
/* Add a space every 8th bit. */ /* Add a space every 8th bit. */
if ((ctx->spl_cnt & 7) == 0) { if ((ctx->spl_cnt & 7) == 0) {
for (p = 0; p < ctx->num_enabled_probes; p++) for (p = 0; p < ctx->num_enabled_channels; p++)
ctx->linebuf[p * ctx->linebuf_len + ctx->linebuf[p * ctx->linebuf_len +
ctx->line_offset] = ' '; ctx->line_offset] = ' ';
ctx->line_offset++; ctx->line_offset++;

View File

@ -45,7 +45,7 @@ SR_PRIV int data_hex(struct sr_output *o, const uint8_t *data_in,
ctx = o->internal; ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
+ ctx->samples_per_line / 2; + ctx->samples_per_line / 2;
outsize = length_in / ctx->unitsize * ctx->num_enabled_probes outsize = length_in / ctx->unitsize * ctx->num_enabled_channels
/ ctx->samples_per_line * max_linelen + 512; / ctx->samples_per_line * max_linelen + 512;
if (!(outbuf = g_try_malloc0(outsize + 1))) { if (!(outbuf = g_try_malloc0(outsize + 1))) {
@ -65,7 +65,7 @@ SR_PRIV int data_hex(struct sr_output *o, const uint8_t *data_in,
for (offset = 0; offset <= length_in - ctx->unitsize; for (offset = 0; offset <= length_in - ctx->unitsize;
offset += ctx->unitsize) { offset += ctx->unitsize) {
sample = data_in + offset; sample = data_in + offset;
for (p = 0; p < ctx->num_enabled_probes; p++) { for (p = 0; p < ctx->num_enabled_channels; p++) {
ctx->linevalues[p] <<= 1; ctx->linevalues[p] <<= 1;
if (sample[p / 8] & ((uint8_t) 1 << (p % 8))) if (sample[p / 8] & ((uint8_t) 1 << (p % 8)))
ctx->linevalues[p] |= 1; ctx->linevalues[p] |= 1;
@ -76,7 +76,7 @@ SR_PRIV int data_hex(struct sr_output *o, const uint8_t *data_in,
/* Add a space after every complete hex byte. */ /* Add a space after every complete hex byte. */
if ((ctx->spl_cnt & 7) == 0) { if ((ctx->spl_cnt & 7) == 0) {
for (p = 0; p < ctx->num_enabled_probes; p++) for (p = 0; p < ctx->num_enabled_channels; p++)
ctx->linebuf[p * ctx->linebuf_len + ctx->linebuf[p * ctx->linebuf_len +
ctx->line_offset + 2] = ' '; ctx->line_offset + 2] = ' ';
ctx->line_offset += 3; ctx->line_offset += 3;

View File

@ -31,29 +31,29 @@
SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf) SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf)
{ {
static int max_probename_len = 0; static int max_channelname_len = 0;
int len, i; int len, i;
GSList *l; GSList *l;
char *probe_name; char *channel_name;
if (ctx->linebuf[0] == 0) if (ctx->linebuf[0] == 0)
return; return;
if (max_probename_len == 0) { if (max_channelname_len == 0) {
/* First time through... */ /* First time through... */
for (l = ctx->probenames; l; l = l->next) { for (l = ctx->channelnames; l; l = l->next) {
probe_name = l->data; channel_name = l->data;
len = strlen(probe_name); len = strlen(channel_name);
if (len > max_probename_len) if (len > max_channelname_len)
max_probename_len = len; max_channelname_len = len;
} }
} }
for (i = 0, l = ctx->probenames; l; l = l->next, i++) { for (i = 0, l = ctx->channelnames; l; l = l->next, i++) {
probe_name = l->data; channel_name = l->data;
sprintf((char *)outbuf + strlen((const char *)outbuf), sprintf((char *)outbuf + strlen((const char *)outbuf),
"%*s:%s\n", max_probename_len, "%*s:%s\n", max_channelname_len,
probe_name, ctx->linebuf + i * ctx->linebuf_len); channel_name, ctx->linebuf + i * ctx->linebuf_len);
} }
/* Mark trigger with a ^ character. */ /* Mark trigger with a ^ character. */
@ -74,11 +74,11 @@ SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf)
SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode) SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
{ {
struct context *ctx; struct context *ctx;
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
GVariant *gvar; GVariant *gvar;
uint64_t samplerate; uint64_t samplerate;
int num_probes, ret; int num_channels, ret;
char *samplerate_s; char *samplerate_s;
if (!(ctx = g_try_malloc0(sizeof(struct context)))) { if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
@ -87,20 +87,20 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
} }
o->internal = ctx; o->internal = ctx;
ctx->num_enabled_probes = 0; ctx->num_enabled_channels = 0;
ctx->probenames = NULL; ctx->channelnames = NULL;
for (l = o->sdi->probes; l; l = l->next) { for (l = o->sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (probe->type != SR_PROBE_LOGIC) if (ch->type != SR_PROBE_LOGIC)
continue; continue;
if (!probe->enabled) if (!ch->enabled)
continue; continue;
ctx->probenames = g_slist_append(ctx->probenames, probe->name); ctx->channelnames = g_slist_append(ctx->channelnames, ch->name);
ctx->num_enabled_probes++; ctx->num_enabled_channels++;
} }
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8; ctx->unitsize = (ctx->num_enabled_channels + 7) / 8;
ctx->line_offset = 0; ctx->line_offset = 0;
ctx->spl_cnt = 0; ctx->spl_cnt = 0;
ctx->mark_trigger = -1; ctx->mark_trigger = -1;
@ -123,7 +123,7 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
} }
snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING); snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
num_probes = g_slist_length(o->sdi->probes); num_channels = g_slist_length(o->sdi->channels);
if (sr_config_get(o->sdi->driver, o->sdi, NULL, SR_CONF_SAMPLERATE, if (sr_config_get(o->sdi->driver, o->sdi, NULL, SR_CONF_SAMPLERATE,
&gvar) == SR_OK) { &gvar) == SR_OK) {
samplerate = g_variant_get_uint64(gvar); samplerate = g_variant_get_uint64(gvar);
@ -134,25 +134,25 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
} }
snprintf(ctx->header + strlen(ctx->header), snprintf(ctx->header + strlen(ctx->header),
511 - strlen(ctx->header), 511 - strlen(ctx->header),
"Acquisition with %d/%d probes at %s\n", "Acquisition with %d/%d channels at %s\n",
ctx->num_enabled_probes, num_probes, samplerate_s); ctx->num_enabled_channels, num_channels, samplerate_s);
g_free(samplerate_s); g_free(samplerate_s);
} }
ctx->linebuf_len = ctx->samples_per_line * 2 + 4; ctx->linebuf_len = ctx->samples_per_line * 2 + 4;
if (!(ctx->linebuf = g_try_malloc0(num_probes * ctx->linebuf_len))) { if (!(ctx->linebuf = g_try_malloc0(num_channels * ctx->linebuf_len))) {
sr_err("%s: ctx->linebuf malloc failed", __func__); sr_err("%s: ctx->linebuf malloc failed", __func__);
ret = SR_ERR_MALLOC; ret = SR_ERR_MALLOC;
goto err; goto err;
} }
if (!(ctx->linevalues = g_try_malloc0(num_probes))) { if (!(ctx->linevalues = g_try_malloc0(num_channels))) {
sr_err("%s: ctx->linevalues malloc failed", __func__); sr_err("%s: ctx->linevalues malloc failed", __func__);
ret = SR_ERR_MALLOC; ret = SR_ERR_MALLOC;
} }
if (mode == MODE_ASCII && if (mode == MODE_ASCII &&
!(ctx->prevsample = g_try_malloc0(num_probes / 8))) { !(ctx->prevsample = g_try_malloc0(num_channels / 8))) {
sr_err("%s: ctx->prevsample malloc failed", __func__); sr_err("%s: ctx->prevsample malloc failed", __func__);
ret = SR_ERR_MALLOC; ret = SR_ERR_MALLOC;
} }
@ -182,7 +182,7 @@ SR_PRIV int text_cleanup(struct sr_output *o)
if (ctx->prevsample) if (ctx->prevsample)
g_free(ctx->prevsample); g_free(ctx->prevsample);
g_slist_free(ctx->probenames); g_slist_free(ctx->channelnames);
g_free(ctx); g_free(ctx);
@ -206,7 +206,7 @@ SR_PRIV int event(struct sr_output *o, int event_type, uint8_t **data_out,
*length_out = 0; *length_out = 0;
break; break;
case SR_DF_END: case SR_DF_END:
outsize = ctx->num_enabled_probes outsize = ctx->num_enabled_channels
* (ctx->samples_per_line + 20) + 512; * (ctx->samples_per_line + 20) + 512;
if (!(outbuf = g_try_malloc0(outsize))) { if (!(outbuf = g_try_malloc0(outsize))) {
sr_err("%s: outbuf malloc failed", __func__); sr_err("%s: outbuf malloc failed", __func__);

View File

@ -31,12 +31,12 @@ enum outputmode {
}; };
struct context { struct context {
unsigned int num_enabled_probes; unsigned int num_enabled_channels;
int samples_per_line; int samples_per_line;
unsigned int unitsize; unsigned int unitsize;
int line_offset; int line_offset;
int linebuf_len; int linebuf_len;
GSList *probenames; GSList *channelnames;
uint8_t *linebuf; uint8_t *linebuf;
int spl_cnt; int spl_cnt;
uint8_t *linevalues; uint8_t *linevalues;

View File

@ -29,8 +29,8 @@
#define LOG_PREFIX "output/vcd" #define LOG_PREFIX "output/vcd"
struct context { struct context {
int num_enabled_probes; int num_enabled_channels;
GArray *probeindices; GArray *channelindices;
GString *header; GString *header;
uint8_t *prevsample; uint8_t *prevsample;
int period; int period;
@ -40,15 +40,15 @@ struct context {
}; };
static const char *const vcd_header_comment = static const char *const vcd_header_comment =
"$comment\n Acquisition with %d/%d probes at %s\n$end\n"; "$comment\n Acquisition with %d/%d channels at %s\n$end\n";
static int init(struct sr_output *o) static int init(struct sr_output *o)
{ {
struct context *ctx; struct context *ctx;
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
GVariant *gvar; GVariant *gvar;
int num_probes, i; int num_channels, i;
char *samplerate_s, *frequency_s, *timestamp; char *samplerate_s, *frequency_s, *timestamp;
time_t t; time_t t;
@ -58,27 +58,27 @@ static int init(struct sr_output *o)
} }
o->internal = ctx; o->internal = ctx;
ctx->num_enabled_probes = 0; ctx->num_enabled_channels = 0;
ctx->probeindices = g_array_new(FALSE, FALSE, sizeof(int)); ctx->channelindices = g_array_new(FALSE, FALSE, sizeof(int));
for (l = o->sdi->probes; l; l = l->next) { for (l = o->sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (probe->type != SR_PROBE_LOGIC) if (ch->type != SR_PROBE_LOGIC)
continue; continue;
if (!probe->enabled) if (!ch->enabled)
continue; continue;
ctx->probeindices = g_array_append_val( ctx->channelindices = g_array_append_val(
ctx->probeindices, probe->index); ctx->channelindices, ch->index);
ctx->num_enabled_probes++; ctx->num_enabled_channels++;
} }
if (ctx->num_enabled_probes > 94) { if (ctx->num_enabled_channels > 94) {
sr_err("VCD only supports 94 probes."); sr_err("VCD only supports 94 channels.");
return SR_ERR; return SR_ERR;
} }
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8; ctx->unitsize = (ctx->num_enabled_channels + 7) / 8;
ctx->header = g_string_sized_new(512); ctx->header = g_string_sized_new(512);
num_probes = g_slist_length(o->sdi->probes); num_channels = g_slist_length(o->sdi->channels);
/* timestamp */ /* timestamp */
t = time(NULL); t = time(NULL);
@ -101,7 +101,7 @@ static int init(struct sr_output *o)
return SR_ERR; return SR_ERR;
} }
g_string_append_printf(ctx->header, vcd_header_comment, g_string_append_printf(ctx->header, vcd_header_comment,
ctx->num_enabled_probes, num_probes, samplerate_s); ctx->num_enabled_channels, num_channels, samplerate_s);
g_free(samplerate_s); g_free(samplerate_s);
} }
@ -125,14 +125,14 @@ static int init(struct sr_output *o)
g_string_append_printf(ctx->header, "$scope module %s $end\n", PACKAGE); g_string_append_printf(ctx->header, "$scope module %s $end\n", PACKAGE);
/* Wires / channels */ /* Wires / channels */
for (i = 0, l = o->sdi->probes; l; l = l->next, i++) { for (i = 0, l = o->sdi->channels; l; l = l->next, i++) {
probe = l->data; ch = l->data;
if (probe->type != SR_PROBE_LOGIC) if (ch->type != SR_PROBE_LOGIC)
continue; continue;
if (!probe->enabled) if (!ch->enabled)
continue; continue;
g_string_append_printf(ctx->header, "$var wire 1 %c %s $end\n", g_string_append_printf(ctx->header, "$var wire 1 %c %s $end\n",
(char)('!' + i), probe->name); (char)('!' + i), ch->name);
} }
g_string_append(ctx->header, "$upscope $end\n" g_string_append(ctx->header, "$upscope $end\n"
@ -188,8 +188,8 @@ static int receive(struct sr_output *o, const struct sr_dev_inst *sdi,
sample = logic->data + i; sample = logic->data + i;
timestamp_written = FALSE; timestamp_written = FALSE;
for (p = 0; p < ctx->num_enabled_probes; p++) { for (p = 0; p < ctx->num_enabled_channels; p++) {
index = g_array_index(ctx->probeindices, int, p); index = g_array_index(ctx->channelindices, int, p);
curbit = ((unsigned)sample[index / 8] curbit = ((unsigned)sample[index / 8]
>> (index % 8)) & 1; >> (index % 8)) & 1;

View File

@ -113,11 +113,11 @@ SR_API int sr_session_load(const char *filename)
struct zip_file *zf; struct zip_file *zf;
struct zip_stat zs; struct zip_stat zs;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_channel *probe; struct sr_channel *ch;
int ret, probenum, devcnt, i, j; int ret, channelnum, devcnt, i, j;
uint64_t tmp_u64, total_probes, enabled_probes, p; uint64_t tmp_u64, total_channels, enabled_channels, p;
char **sections, **keys, *metafile, *val; char **sections, **keys, *metafile, *val;
char probename[SR_MAX_PROBENAME_LEN + 1]; char channelname[SR_MAX_PROBENAME_LEN + 1];
if ((ret = sr_sessionfile_check(filename)) != SR_OK) if ((ret = sr_sessionfile_check(filename)) != SR_OK)
return ret; return ret;
@ -155,7 +155,7 @@ SR_API int sr_session_load(const char *filename)
if (!strncmp(sections[i], "device ", 7)) { if (!strncmp(sections[i], "device ", 7)) {
/* device section */ /* device section */
sdi = NULL; sdi = NULL;
enabled_probes = total_probes = 0; enabled_channels = total_channels = 0;
keys = g_key_file_get_keys(kf, sections[i], NULL, NULL); keys = g_key_file_get_keys(kf, sections[i], NULL, NULL);
for (j = 0; keys[j]; j++) { for (j = 0; keys[j]; j++) {
val = g_key_file_get_string(kf, sections[i], keys[j], NULL); val = g_key_file_get_string(kf, sections[i], keys[j], NULL);
@ -181,32 +181,32 @@ SR_API int sr_session_load(const char *filename)
sdi->driver->config_set(SR_CONF_CAPTURE_UNITSIZE, sdi->driver->config_set(SR_CONF_CAPTURE_UNITSIZE,
g_variant_new_uint64(tmp_u64), sdi, NULL); g_variant_new_uint64(tmp_u64), sdi, NULL);
} else if (!strcmp(keys[j], "total probes")) { } else if (!strcmp(keys[j], "total probes")) {
total_probes = strtoull(val, NULL, 10); total_channels = strtoull(val, NULL, 10);
sdi->driver->config_set(SR_CONF_NUM_LOGIC_PROBES, sdi->driver->config_set(SR_CONF_NUM_LOGIC_PROBES,
g_variant_new_uint64(total_probes), sdi, NULL); g_variant_new_uint64(total_channels), sdi, NULL);
for (p = 0; p < total_probes; p++) { for (p = 0; p < total_channels; p++) {
snprintf(probename, SR_MAX_PROBENAME_LEN, "%" PRIu64, p); snprintf(channelname, SR_MAX_PROBENAME_LEN, "%" PRIu64, p);
if (!(probe = sr_probe_new(p, SR_PROBE_LOGIC, TRUE, if (!(ch = sr_probe_new(p, SR_PROBE_LOGIC, TRUE,
probename))) channelname)))
return SR_ERR; return SR_ERR;
sdi->probes = g_slist_append(sdi->probes, probe); sdi->channels = g_slist_append(sdi->channels, ch);
} }
} else if (!strncmp(keys[j], "probe", 5)) { } else if (!strncmp(keys[j], "probe", 5)) {
if (!sdi) if (!sdi)
continue; continue;
enabled_probes++; enabled_channels++;
tmp_u64 = strtoul(keys[j]+5, NULL, 10); tmp_u64 = strtoul(keys[j]+5, NULL, 10);
/* sr_session_save() */ /* sr_session_save() */
sr_dev_probe_name_set(sdi, tmp_u64 - 1, val); sr_dev_probe_name_set(sdi, tmp_u64 - 1, val);
} else if (!strncmp(keys[j], "trigger", 7)) { } else if (!strncmp(keys[j], "trigger", 7)) {
probenum = strtoul(keys[j]+7, NULL, 10); channelnum = strtoul(keys[j]+7, NULL, 10);
sr_dev_trigger_set(sdi, probenum, val); sr_dev_trigger_set(sdi, channelnum, val);
} }
} }
g_strfreev(keys); g_strfreev(keys);
/* Disable probes not specifically listed. */ /* Disable channels not specifically listed. */
if (total_probes) if (total_channels)
for (p = enabled_probes; p < total_probes; p++) for (p = enabled_channels; p < total_channels; p++)
sr_dev_probe_enable(sdi, p, FALSE); sr_dev_probe_enable(sdi, p, FALSE);
} }
devcnt++; devcnt++;
@ -234,12 +234,12 @@ SR_API int sr_session_load(const char *filename)
SR_API int sr_session_save(const char *filename, const struct sr_dev_inst *sdi, SR_API int sr_session_save(const char *filename, const struct sr_dev_inst *sdi,
unsigned char *buf, int unitsize, int units) unsigned char *buf, int unitsize, int units)
{ {
struct sr_channel *probe; struct sr_channel *ch;
GSList *l; GSList *l;
GVariant *gvar; GVariant *gvar;
uint64_t samplerate; uint64_t samplerate;
int cnt, ret; int cnt, ret;
char **probe_names; char **channel_names;
samplerate = 0; samplerate = 0;
if (sr_dev_has_option(sdi, SR_CONF_SAMPLERATE)) { if (sr_dev_has_option(sdi, SR_CONF_SAMPLERATE)) {
@ -250,21 +250,21 @@ SR_API int sr_session_save(const char *filename, const struct sr_dev_inst *sdi,
} }
} }
probe_names = g_malloc0(sizeof(char *) * (g_slist_length(sdi->probes) + 1)); channel_names = g_malloc0(sizeof(char *) * (g_slist_length(sdi->channels) + 1));
cnt = 0; cnt = 0;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = l->data; ch = l->data;
if (probe->type != SR_PROBE_LOGIC) if (ch->type != SR_PROBE_LOGIC)
continue; continue;
if (probe->enabled != TRUE) if (ch->enabled != TRUE)
continue; continue;
if (!probe->name) if (!ch->name)
continue; continue;
/* Just borrowing the ptr. */ /* Just borrowing the ptr. */
probe_names[cnt++] = probe->name; channel_names[cnt++] = ch->name;
} }
if ((ret = sr_session_save_init(filename, samplerate, probe_names)) != SR_OK) if ((ret = sr_session_save_init(filename, samplerate, channel_names)) != SR_OK)
return ret; return ret;
ret = sr_session_append(filename, buf, unitsize, units); ret = sr_session_append(filename, buf, unitsize, units);
@ -278,15 +278,15 @@ SR_API int sr_session_save(const char *filename, const struct sr_dev_inst *sdi,
* @param filename The name of the filename to save the current session as. * @param filename The name of the filename to save the current session as.
* Must not be NULL. * Must not be NULL.
* @param samplerate The samplerate to store for this session. * @param samplerate The samplerate to store for this session.
* @param probes A NULL-terminated array of strings containing the names * @param channels A NULL-terminated array of strings containing the names
* of all the probes active in this session. * of all the channels active in this session.
* *
* @retval SR_OK Success * @retval SR_OK Success
* @retval SR_ERR_ARG Invalid arguments * @retval SR_ERR_ARG Invalid arguments
* @retval SR_ERR Other errors * @retval SR_ERR Other errors
*/ */
SR_API int sr_session_save_init(const char *filename, uint64_t samplerate, SR_API int sr_session_save_init(const char *filename, uint64_t samplerate,
char **probes) char **channels)
{ {
FILE *meta; FILE *meta;
struct zip *zipfile; struct zip *zipfile;
@ -329,15 +329,15 @@ SR_API int sr_session_save_init(const char *filename, uint64_t samplerate,
/* metadata */ /* metadata */
fprintf(meta, "capturefile = logic-1\n"); fprintf(meta, "capturefile = logic-1\n");
cnt = 0; cnt = 0;
for (i = 0; probes[i]; i++) for (i = 0; channels[i]; i++)
cnt++; cnt++;
fprintf(meta, "total probes = %d\n", cnt); fprintf(meta, "total probes = %d\n", cnt);
s = sr_samplerate_string(samplerate); s = sr_samplerate_string(samplerate);
fprintf(meta, "samplerate = %s\n", s); fprintf(meta, "samplerate = %s\n", s);
g_free(s); g_free(s);
for (i = 0; probes[i]; i++) for (i = 0; channels[i]; i++)
fprintf(meta, "probe%d = %s\n", i + 1, probes[i]); fprintf(meta, "probe%d = %s\n", i + 1, channels[i]);
fclose(meta); fclose(meta);

View File

@ -360,9 +360,9 @@ SR_API char *sr_voltage_string(uint64_t v_p, uint64_t v_q)
* intended. Must not be NULL. Also, sdi->driver and * intended. Must not be NULL. Also, sdi->driver and
* sdi->driver->info_get must not be NULL. * sdi->driver->info_get must not be NULL.
* @param triggerstring The string containing the trigger specification for * @param triggerstring The string containing the trigger specification for
* one or more probes of this device. Entries for multiple probes are * one or more channels of this device. Entries for multiple channels are
* comma-separated. Triggers are specified in the form key=value, * comma-separated. Triggers are specified in the form key=value,
* where the key is a probe number (or probe name) and the value is * where the key is a channel number (or channel name) and the value is
* the requested trigger type. Valid trigger types currently * the requested trigger type. Valid trigger types currently
* include 'r' (rising edge), 'f' (falling edge), 'c' (any pin value * include 'r' (rising edge), 'f' (falling edge), 'c' (any pin value
* change), '0' (low value), or '1' (high value). * change), '0' (low value), or '1' (high value).
@ -370,27 +370,27 @@ SR_API char *sr_voltage_string(uint64_t v_p, uint64_t v_q)
* *
* @return Pointer to a list of trigger types (strings), or NULL upon errors. * @return Pointer to a list of trigger types (strings), or NULL upon errors.
* The pointer list (if non-NULL) has as many entries as the * The pointer list (if non-NULL) has as many entries as the
* respective device has probes (all physically available probes, * respective device has channels (all physically available channels,
* not just enabled ones). Entries of the list which don't have * not just enabled ones). Entries of the list which don't have
* a trigger value set in 'triggerstring' are NULL, the other entries * a trigger value set in 'triggerstring' are NULL, the other entries
* contain the respective trigger type which is requested for the * contain the respective trigger type which is requested for the
* respective probe (e.g. "r", "c", and so on). * respective channel (e.g. "r", "c", and so on).
*/ */
SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi, SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
const char *triggerstring) const char *triggerstring)
{ {
GSList *l; GSList *l;
GVariant *gvar; GVariant *gvar;
struct sr_channel *probe; struct sr_channel *ch;
int max_probes, probenum, i; int max_channels, channelnum, i;
char **tokens, **triggerlist, *trigger, *tc; char **tokens, **triggerlist, *trigger, *tc;
const char *trigger_types; const char *trigger_types;
gboolean error; gboolean error;
max_probes = g_slist_length(sdi->probes); max_channels = g_slist_length(sdi->channels);
error = FALSE; error = FALSE;
if (!(triggerlist = g_try_malloc0(max_probes * sizeof(char *)))) { if (!(triggerlist = g_try_malloc0(max_channels * sizeof(char *)))) {
sr_err("%s: triggerlist malloc failed", __func__); sr_err("%s: triggerlist malloc failed", __func__);
return NULL; return NULL;
} }
@ -402,21 +402,21 @@ SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
} }
trigger_types = g_variant_get_string(gvar, NULL); trigger_types = g_variant_get_string(gvar, NULL);
tokens = g_strsplit(triggerstring, ",", max_probes); tokens = g_strsplit(triggerstring, ",", max_channels);
for (i = 0; tokens[i]; i++) { for (i = 0; tokens[i]; i++) {
probenum = -1; channelnum = -1;
for (l = sdi->probes; l; l = l->next) { for (l = sdi->channels; l; l = l->next) {
probe = (struct sr_channel *)l->data; ch = (struct sr_channel *)l->data;
if (probe->enabled if (ch->enabled
&& !strncmp(probe->name, tokens[i], && !strncmp(ch->name, tokens[i],
strlen(probe->name))) { strlen(ch->name))) {
probenum = probe->index; channelnum = ch->index;
break; break;
} }
} }
if (probenum < 0 || probenum >= max_probes) { if (channelnum < 0 || channelnum >= max_channels) {
sr_err("Invalid probe."); sr_err("Invalid channel.");
error = TRUE; error = TRUE;
break; break;
} }
@ -431,14 +431,14 @@ SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
} }
} }
if (!error) if (!error)
triggerlist[probenum] = g_strdup(trigger); triggerlist[channelnum] = g_strdup(trigger);
} }
} }
g_strfreev(tokens); g_strfreev(tokens);
g_variant_unref(gvar); g_variant_unref(gvar);
if (error) { if (error) {
for (i = 0; i < max_probes; i++) for (i = 0; i < max_channels; i++)
g_free(triggerlist[i]); g_free(triggerlist[i]);
g_free(triggerlist); g_free(triggerlist);
triggerlist = NULL; triggerlist = NULL;

View File

@ -213,7 +213,7 @@ 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_probes(const struct sr_dev_inst *sdi)
{ {
struct sr_channel *probe; struct sr_channel *ch;
GArray *probes; GArray *probes;
GSList *l; GSList *l;