This fixes parts of bug #259.
__all__ = ['Error', 'Context', 'Driver', 'Device', 'Session', 'Packet', 'Log',
'LogLevel', 'PacketType', 'Quantity', 'Unit', 'QuantityFlag', 'ConfigKey',
- 'ProbeType', 'Probe', 'ChannelGroup', 'InputFormat', 'OutputFormat',
+ 'ChannelType', 'Channel', 'ChannelGroup', 'InputFormat', 'OutputFormat',
'InputFile', 'Output']
class Error(Exception):
device = super(Device, cls).__new__(cls)
device.struct = struct
device.context = context
- device._probes = None
+ device._channels = None
device._channel_groups = None
context._devices[address] = device
return context._devices[address]
return self.struct.version
@property
- def probes(self):
- if self._probes is None:
- self._probes = {}
- probe_list = self.struct.probes
- while (probe_list):
- probe_ptr = void_ptr_to_sr_channel_ptr(probe_list.data)
- self._probes[probe_ptr.name] = Probe(self, probe_ptr)
- probe_list = probe_list.next
- return self._probes
+ def channels(self):
+ if self._channels is None:
+ self._channels = {}
+ channel_list = self.struct.channels
+ while (channel_list):
+ channel_ptr = void_ptr_to_sr_channel_ptr(channel_list.data)
+ self._channels[channel_ptr.name] = Channel(self, channel_ptr)
+ channel_list = channel_list.next
+ return self._channels
@property
def channel_groups(self):
return
check(sr_config_set(self.struct, None, key.id, python_to_gvariant(value)))
-class Probe(object):
+class Channel(object):
def __init__(self, device, struct):
self.device = device
@property
def type(self):
- return ProbeType(self.struct.type)
+ return ChannelType(self.struct.type)
@property
def enabled(self):
channel_list = self.struct.channels
while (channel_list):
channel_ptr = void_ptr_to_sr_channel_ptr(channel_list.data)
- self._channels.append(Probe(self, probe_ptr))
+ self._channels.append(Channel(self, channel_ptr))
channel_list = channel_list.next
return self._channels
class DataType(EnumValue):
pass
-class ProbeType(EnumValue):
+class ChannelType(EnumValue):
pass
for symbol_name in dir(lowlevel):
('SR_MQFLAG_', QuantityFlag),
('SR_CONF_', ConfigKey),
('SR_T_', DataType),
- ('SR_PROBE_', ProbeType)]:
+ ('SR_CHANNEL_', ChannelType)]:
if symbol_name.startswith(prefix):
name = symbol_name[len(prefix):]
value = getattr(lowlevel, symbol_name)
if (!state != !was_enabled && sdi->driver
&& sdi->driver->config_probe_set) {
ret = sdi->driver->config_probe_set(
- sdi, ch, SR_PROBE_SET_ENABLED);
+ sdi, ch, SR_CHANNEL_SET_ENABLED);
/* Roll back change if it wasn't applicable. */
if (ret == SR_ERR_ARG)
ch->enabled = was_enabled;
if (sdi->driver && sdi->driver->config_probe_set) {
ret = sdi->driver->config_probe_set(
- sdi, ch, SR_PROBE_SET_TRIGGER);
+ sdi, ch, SR_CHANNEL_SET_TRIGGER);
/* Roll back change if it wasn't applicable. */
if (ret == SR_ERR_ARG) {
g_free(ch->trigger);
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
for (i = 0; i < devc->num_channels; i++) {
snprintf(p_name, sizeof(p_name), "Ch_%d", i);
- if (!(ch = sr_channel_new(i, SR_PROBE_ANALOG, TRUE, p_name)))
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, p_name)))
goto scan_error_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
}
sdi->priv = devc;
sdi->driver = di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "T1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T1")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "T2")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T2")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog;
struct sr_channel *ch;
- float values[APPA_55II_NUM_PROBES], *val_ptr;
+ float values[APPA_55II_NUM_CHANNELS], *val_ptr;
int i;
devc = sdi->priv;
analog.mqflags = appa_55ii_flags(buf);
analog.data = values;
- for (i = 0; i < APPA_55II_NUM_PROBES; i++) {
+ for (i = 0; i < APPA_55II_NUM_CHANNELS; i++) {
ch = g_slist_nth_data(sdi->channels, i);
if (!ch->enabled)
continue;
struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog;
struct sr_channel *ch;
- float values[APPA_55II_NUM_PROBES], *val_ptr;
+ float values[APPA_55II_NUM_CHANNELS], *val_ptr;
const uint8_t *buf;
int16_t temp;
int offset, i;
analog.unit = SR_UNIT_CELSIUS;
analog.data = values;
- for (i = 0; i < APPA_55II_NUM_PROBES; i++) {
+ for (i = 0; i < APPA_55II_NUM_CHANNELS; i++) {
temp = RL16(buf + 12 + 2 * i);
ch = g_slist_nth_data(sdi->channels, i);
if (!ch->enabled)
#define LOG_PREFIX "appa-55ii"
-#define APPA_55II_NUM_PROBES 2
+#define APPA_55II_NUM_CHANNELS 2
#define APPA_55II_BUF_SIZE (4 + 32 + 1)
#define DEFAULT_DATA_SOURCE DATA_SOURCE_LIVE
#define USB_MODEL_NAME "SIGMA"
#define USB_MODEL_VERSION ""
#define TRIGGER_TYPE "rf10"
-#define NUM_PROBES 16
+#define NUM_CHANNELS 16
SR_PRIV struct sr_dev_driver asix_sigma_driver_info;
static struct sr_dev_driver *di = &asix_sigma_driver_info;
* http://tools.asix.net/img/sigma_sigmacab_pins_720.jpg
* (the cable has two additional GND pins, and a TI and TO pin)
*/
-static const char *channel_names[NUM_PROBES + 1] = {
+static const char *channel_names[NUM_CHANNELS + 1] = {
"1", "2", "3", "4", "5", "6", "7", "8",
"9", "10", "11", "12", "13", "14", "15", "16",
NULL,
sdi->driver = di;
for (i = 0; channel_names[i]; i++) {
- if (!(ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE,
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
channel_names[i])))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
sdi->conn = serial;
for (i = 0; i < MAX_CHANNELS; i++) {
snprintf(channel, 10, "CH%d", i + 1);
- ch = sr_channel_new(i, SR_PROBE_ANALOG, TRUE, channel);
+ ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channel);
sdi->channels = g_slist_append(sdi->channels, ch);
cg = g_malloc(sizeof(struct sr_channel_group));
cg->name = g_strdup(channel);
sdi->priv = devc;
sdi->driver = di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P2")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P2")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
sdi->priv = devc;
sdi->driver = di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
sdi->inst_type = SR_INST_SERIAL;
sdi->priv = devc;
sdi->driver = di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "SPL")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
sdi->driver = center_devs[idx].di;
for (i = 0; i < center_devs[idx].num_channels; i++) {
- if (!(ch = sr_channel_new(i, SR_PROBE_ANALOG,
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG,
TRUE, channel_names[i])))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
sdi->priv = devc;
for (i = 0; chronovu_la8_channel_names[i]; i++) {
- if (!(ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE,
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
chronovu_la8_channel_names[i])))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
#include "protocol.h"
/* Probes are numbered 0-7. */
-SR_PRIV const char *chronovu_la8_channel_names[NUM_PROBES + 1] = {
+SR_PRIV const char *chronovu_la8_channel_names[NUM_CHANNELS + 1] = {
"0", "1", "2", "3", "4", "5", "6", "7",
NULL,
};
#define USB_MODEL_NAME "LA8"
#define USB_MODEL_VERSION ""
-#define NUM_PROBES 8
+#define NUM_CHANNELS 8
#define TRIGGER_TYPE "01"
#define SDRAM_SIZE (8 * 1024 * 1024)
#define MIN_NUM_SAMPLES 1
sdi->inst_type = SR_INST_SERIAL;
sdi->priv = devc;
sdi->driver = di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
sdi->conn = serial;
sdi->priv = NULL;
sdi->driver = di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "CH1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CH1")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
#define LOG_PREFIX "demo"
-#define DEFAULT_NUM_LOGIC_PROBES 8
-#define DEFAULT_NUM_ANALOG_PROBES 4
+#define DEFAULT_NUM_LOGIC_CHANNELS 8
+#define DEFAULT_NUM_ANALOG_CHANNELS 4
/* The size in bytes of chunks to send through the session bus. */
#define LOGIC_BUFSIZE 4096
};
static const int32_t scanopts[] = {
- SR_CONF_NUM_LOGIC_PROBES,
- SR_CONF_NUM_ANALOG_PROBES,
+ SR_CONF_NUM_LOGIC_CHANNELS,
+ SR_CONF_NUM_ANALOG_CHANNELS,
};
static const int devopts[] = {
drvc = di->priv;
- num_logic_channels = DEFAULT_NUM_LOGIC_PROBES;
- num_analog_channels = DEFAULT_NUM_ANALOG_PROBES;
+ num_logic_channels = DEFAULT_NUM_LOGIC_CHANNELS;
+ num_analog_channels = DEFAULT_NUM_ANALOG_CHANNELS;
for (l = options; l; l = l->next) {
src = l->data;
switch (src->key) {
- case SR_CONF_NUM_LOGIC_PROBES:
+ case SR_CONF_NUM_LOGIC_CHANNELS:
num_logic_channels = g_variant_get_int32(src->data);
break;
- case SR_CONF_NUM_ANALOG_PROBES:
+ case SR_CONF_NUM_ANALOG_CHANNELS:
num_analog_channels = g_variant_get_int32(src->data);
break;
}
cg->priv = NULL;
for (i = 0; i < num_logic_channels; i++) {
sprintf(channel_name, "D%d", i);
- if (!(ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE, channel_name)))
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name)))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
cg->channels = g_slist_append(cg->channels, ch);
for (i = 0; i < num_analog_channels; i++) {
sprintf(channel_name, "A%d", i);
if (!(ch = sr_channel_new(i + num_logic_channels,
- SR_PROBE_ANALOG, TRUE, channel_name)))
+ SR_CHANNEL_ANALOG, TRUE, channel_name)))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
if (!cg)
return SR_ERR_CHANNEL_GROUP;
ch = cg->channels->data;
- if (ch->type == SR_PROBE_LOGIC) {
+ if (ch->type == SR_CHANNEL_LOGIC) {
pattern = devc->logic_pattern;
*data = g_variant_new_string(logic_pattern_str[pattern]);
- } else if (ch->type == SR_PROBE_ANALOG) {
+ } else if (ch->type == SR_CHANNEL_ANALOG) {
ag = cg->priv;
pattern = ag->pattern;
*data = g_variant_new_string(analog_pattern_str[pattern]);
} else
return SR_ERR_BUG;
break;
- case SR_CONF_NUM_LOGIC_PROBES:
+ case SR_CONF_NUM_LOGIC_CHANNELS:
*data = g_variant_new_int32(devc->num_logic_channels);
break;
- case SR_CONF_NUM_ANALOG_PROBES:
+ case SR_CONF_NUM_ANALOG_CHANNELS:
*data = g_variant_new_int32(devc->num_analog_channels);
break;
default:
stropt = g_variant_get_string(data, NULL);
ch = cg->channels->data;
pattern = -1;
- if (ch->type == SR_PROBE_LOGIC) {
+ if (ch->type == SR_CHANNEL_LOGIC) {
for (i = 0; i < ARRAY_SIZE(logic_pattern_str); i++) {
if (!strcmp(stropt, logic_pattern_str[i])) {
pattern = i;
memset(devc->logic_data, 0xff, LOGIC_BUFSIZE);
sr_dbg("Setting logic pattern to %s",
logic_pattern_str[pattern]);
- } else if (ch->type == SR_PROBE_ANALOG) {
+ } else if (ch->type == SR_CHANNEL_ANALOG) {
for (i = 0; i < ARRAY_SIZE(analog_pattern_str); i++) {
if (!strcmp(stropt, analog_pattern_str[i])) {
pattern = i;
devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(int32_t));
break;
case SR_CONF_PATTERN_MODE:
- if (ch->type == SR_PROBE_LOGIC)
+ if (ch->type == SR_CHANNEL_LOGIC)
*data = g_variant_new_strv(logic_pattern_str,
ARRAY_SIZE(logic_pattern_str));
- else if (ch->type == SR_PROBE_ANALOG)
+ else if (ch->type == SR_CHANNEL_ANALOG)
*data = g_variant_new_strv(analog_pattern_str,
ARRAY_SIZE(analog_pattern_str));
else
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
/* Fill in channellist according to this device's profile. */
num_logic_channels = prof->dev_caps & DEV_CAPS_16BIT ? 16 : 8;
for (j = 0; j < num_logic_channels; j++) {
- if (!(ch = sr_channel_new(j, SR_PROBE_LOGIC, TRUE,
+ if (!(ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j])))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = &gmc_mh_1x_2x_rs232_driver_info;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = &gmc_mh_2x_bd232_driver_info;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
goto exit_err;
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
ch = devc->current_channel->data;
switch (ch->type) {
- case SR_PROBE_ANALOG:
+ case SR_CHANNEL_ANALOG:
g_snprintf(command, sizeof(command),
(*model->scpi_dialect)[SCPI_CMD_GET_ANALOG_DATA],
ch->index + 1);
break;
- case SR_PROBE_LOGIC:
+ case SR_CHANNEL_LOGIC:
g_snprintf(command, sizeof(command),
(*model->scpi_dialect)[SCPI_CMD_GET_DIG_DATA],
ch->index < 8 ? 1 : 2);
for (l = channels; l; l = l->next) {
ch = l->data;
switch (ch->type) {
- case SR_PROBE_ANALOG:
+ case SR_CHANNEL_ANALOG:
if (ch->index == 2)
enabled_chan3 = TRUE;
else if (ch->index == 3)
enabled_chan4 = TRUE;
break;
- case SR_PROBE_LOGIC:
+ case SR_CHANNEL_LOGIC:
if (ch->index < 8)
enabled_pod1 = TRUE;
else
for (l = sdi->channels; l; l = l->next) {
ch = l->data;
switch (ch->type) {
- case SR_PROBE_ANALOG:
+ case SR_CHANNEL_ANALOG:
if (ch->enabled == state->analog_channels[ch->index].state)
break;
g_snprintf(command, sizeof(command),
state->analog_channels[ch->index].state = ch->enabled;
setup_changed = TRUE;
break;
- case SR_PROBE_LOGIC:
+ case SR_CHANNEL_LOGIC:
/*
* A digital POD needs to be enabled for every group of
* 8 channels.
if (!ch->enabled)
continue;
/* Only add a single digital channel. */
- if (ch->type != SR_PROBE_LOGIC || !digital_added) {
+ if (ch->type != SR_CHANNEL_LOGIC || !digital_added) {
devc->enabled_channels = g_slist_append(
devc->enabled_channels, ch);
- if (ch->type == SR_PROBE_LOGIC)
+ if (ch->type == SR_CHANNEL_LOGIC)
digital_added = TRUE;
}
}
/* Add analog channels. */
for (i = 0; i < scope_models[model_index].analog_channels; i++) {
- if (!(ch = sr_channel_new(i, SR_PROBE_ANALOG, TRUE,
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
(*scope_models[model_index].analog_names)[i])))
return SR_ERR_MALLOC;
sdi->channels = g_slist_append(sdi->channels, ch);
/* Add digital channels. */
for (i = 0; i < scope_models[model_index].digital_channels; i++) {
- if (!(ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE,
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
(*scope_models[model_index].digital_names)[i])))
return SR_ERR_MALLOC;
sdi->channels = g_slist_append(sdi->channels, ch);
ch = devc->current_channel->data;
switch (ch->type) {
- case SR_PROBE_ANALOG:
+ case SR_CHANNEL_ANALOG:
if (sr_scpi_get_floatv(sdi->conn, NULL, &data) != SR_OK) {
if (data)
g_array_free(data, TRUE);
g_slist_free(analog.channels);
g_array_free(data, TRUE);
break;
- case SR_PROBE_LOGIC:
+ case SR_CHANNEL_LOGIC:
if (sr_scpi_get_uint8v(sdi->conn, NULL, &data) != SR_OK) {
if (data)
g_free(data);
* a trigger source internal to the device.
*/
for (i = 0; channel_names[i]; i++) {
- if (!(ch = sr_channel_new(i, SR_PROBE_ANALOG, TRUE,
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
channel_names[i])))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
SR_MHZ(20),
};
-static const char *channel_names[NUM_PROBES + 1] = {
+static const char *channel_names[NUM_CHANNELS + 1] = {
"0", "1", "2", "3",
NULL,
};
sdi->conn = usb;
for (i = 0; channel_names[i]; i++) {
- ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE,
+ ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
channel_names[i]);
sdi->channels = g_slist_append(sdi->channels, ch);
devc->channels[i] = ch;
* Count the number of enabled channels and number them for a sequential
* access.
*/
- for (i = 0, j = 0; i < NUM_PROBES; i++) {
+ for (i = 0, j = 0; i < NUM_CHANNELS; i++) {
if (devc->channels[i]->enabled) {
devc->num_enabled_channels++;
devc->channel_map[j] = i;
struct dev_context *devc;
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
- uint8_t i, j, tmp, buffer[PACKET_NUM_SAMPLES], *ptr[NUM_PROBES];
+ uint8_t i, j, tmp, buffer[PACKET_NUM_SAMPLES], *ptr[NUM_CHANNELS];
uint16_t offset, n = 0;
int8_t k;
* Set trigger to any edge on all channels if the trigger for each
* channel is set to any edge.
*/
- if (num_triggers_anyedge == NUM_PROBES) {
+ if (num_triggers_anyedge == NUM_CHANNELS) {
devc->trigger_channel = TRIGGER_CHANNEL_ALL;
devc->trigger_type = TRIGGER_TYPE_ANYEDGE;
}
#define USB_HID_REPORT_TYPE_FEATURE 0x300
#define NUM_SAMPLERATES 11
-#define NUM_PROBES 4
+#define NUM_CHANNELS 4
#define TRIGGER_TYPES "rfc"
void *cb_data;
/* Array to provide an index based access to all channels. */
- const struct sr_channel *channels[NUM_PROBES];
+ const struct sr_channel *channels[NUM_CHANNELS];
struct libusb_transfer *xfer_in, *xfer_out;
* channel except the last one. The samples of the last channel will be
* processed directly after they will be received.
*/
- uint8_t sample_buffer[NUM_PROBES - 1][MAX_DEV_SAMPLE_BYTES];
+ uint8_t sample_buffer[NUM_CHANNELS - 1][MAX_DEV_SAMPLE_BYTES];
/* Expected number of sample packets for each channel. */
uint16_t num_sample_packets;
unsigned int num_enabled_channels;
/* Array to provide a sequential access to all enabled channel indices. */
- uint8_t channel_map[NUM_PROBES];
+ uint8_t channel_map[NUM_CHANNELS];
/* Indicates whether a transfer failed. */
gboolean transfer_error;
sdi->priv = devc;
for (i = 0; channel_names[i]; i++) {
- if (!(ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE,
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
channel_names[i])))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
sdi->driver = di;
sdi->inst_type = SR_INST_USB;
sdi->conn = l->data;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "SPL")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
if (profile->logformat == LOG_TEMP_RH) {
/* Model this as two channels: temperature and humidity. */
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "Temp")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Temp")))
return NULL;
sdi->channels = g_slist_append(NULL, ch);
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "Hum")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Hum")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
} else if (profile->logformat == LOG_CO) {
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "CO")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CO")))
return NULL;
sdi->channels = g_slist_append(NULL, ch);
} else {
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
sdi->channels = g_slist_append(NULL, ch);
}
*
* See also: http://www.linkinstruments.com/images/mso19_1113.gif
*/
-SR_PRIV const char *mso19_channel_names[NUM_PROBES + 1] = {
+SR_PRIV const char *mso19_channel_names[NUM_CHANNELS + 1] = {
/* Note: DSO needs to be first. */
"DSO", "0", "1", "2", "3", "4", "5", "6", "7", NULL,
};
sdi->driver = di;
sdi->priv = devc;
- for (i = 0; i < NUM_PROBES; i++) {
+ for (i = 0; i < NUM_CHANNELS; i++) {
struct sr_channel *ch;
- ptype = (i == 0) ? SR_PROBE_ANALOG : SR_PROBE_LOGIC;
+ ptype = (i == 0) ? SR_CHANNEL_ANALOG : SR_CHANNEL_LOGIC;
if (!(ch = sr_channel_new(i, ptype, TRUE,
mso19_channel_names[i])))
return 0;
#define USB_VENDOR "3195"
#define USB_PRODUCT "f190"
-#define NUM_PROBES (1 + 8)
+#define NUM_CHANNELS (1 + 8)
#define NUM_TRIGGER_STAGES 4
#define TRIGGER_TYPE "01" //the first r/f is used for the whole group
#define SERIALCOMM "460800/8n1/flow=2"
sdi->priv = devc;
sdi->driver = mic_devs[idx].di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "Temperature")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Temperature")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
if (mic_devs[idx].has_humidity) {
- if (!(ch = sr_channel_new(1, SR_PROBE_ANALOG, TRUE, "Humidity")))
+ if (!(ch = sr_channel_new(1, SR_CHANNEL_ANALOG, TRUE, "Humidity")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
}
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE,
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE,
"P1")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
};
/* Channels are numbered 0-31 (on the PCB silkscreen). */
-SR_PRIV const char *ols_channel_names[NUM_PROBES + 1] = {
+SR_PRIV const char *ols_channel_names[NUM_CHANNELS + 1] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
"13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23",
"24", "25", "26", "27", "28", "29", "30", "31",
"Sump", "Logic Analyzer", "v1.0");
sdi->driver = di;
for (i = 0; i < 32; i++) {
- if (!(ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE,
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
ols_channel_names[i])))
return 0;
sdi->channels = g_slist_append(sdi->channels, ch);
case SR_CONF_SWAP:
if (g_variant_get_boolean(data)) {
sr_info("Enabling channel swapping.");
- devc->flag_reg |= FLAG_SWAP_PROBES;
+ devc->flag_reg |= FLAG_SWAP_CHANNELS;
} else {
sr_info("Disabling channel swapping.");
- devc->flag_reg &= ~FLAG_SWAP_PROBES;
+ devc->flag_reg &= ~FLAG_SWAP_CHANNELS;
}
ret = SR_OK;
break;
case 0x00:
/* Number of usable channels */
for (ui = 0; ui < tmp_int; ui++) {
- if (!(ch = sr_channel_new(ui, SR_PROBE_LOGIC, TRUE,
+ if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
ols_channel_names[ui])))
return 0;
sdi->channels = g_slist_append(sdi->channels, ch);
case 0x00:
/* Number of usable channels */
for (ui = 0; ui < tmp_c; ui++) {
- if (!(ch = sr_channel_new(ui, SR_PROBE_LOGIC, TRUE,
+ if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
ols_channel_names[ui])))
return 0;
sdi->channels = g_slist_append(sdi->channels, ch);
sr_info("Enabling demux mode.");
devc->flag_reg |= FLAG_DEMUX;
devc->flag_reg &= ~FLAG_FILTER;
- devc->max_channels = NUM_PROBES / 2;
+ devc->max_channels = NUM_CHANNELS / 2;
devc->cur_samplerate_divider = (CLOCK_RATE * 2 / samplerate) - 1;
} else {
sr_info("Disabling demux mode.");
devc->flag_reg &= ~FLAG_DEMUX;
devc->flag_reg |= FLAG_FILTER;
- devc->max_channels = NUM_PROBES;
+ devc->max_channels = NUM_CHANNELS;
devc->cur_samplerate_divider = (CLOCK_RATE / samplerate) - 1;
}
}
num_channels = 0;
- for (i = NUM_PROBES; i > 0x02; i /= 2) {
+ for (i = NUM_CHANNELS; i > 0x02; i /= 2) {
if ((devc->flag_reg & i) == 0) {
num_channels++;
}
#define LOG_PREFIX "ols"
-#define NUM_PROBES 32
+#define NUM_CHANNELS 32
#define NUM_TRIGGER_STAGES 4
#define TRIGGER_TYPE "01"
#define SERIAL_SPEED B115200
/* 12-13 unused, 14-15 RLE mode (we hardcode mode 0). */
#define FLAG_INTERNAL_TEST_MODE (1 << 11)
#define FLAG_EXTERNAL_TEST_MODE (1 << 10)
-#define FLAG_SWAP_PROBES (1 << 9)
+#define FLAG_SWAP_CHANNELS (1 << 9)
#define FLAG_RLE (1 << 8)
#define FLAG_SLOPE_FALLING (1 << 7)
#define FLAG_CLOCK_EXTERNAL (1 << 6)
};
-SR_PRIV extern const char *ols_channel_names[NUM_PROBES + 1];
+SR_PRIV extern const char *ols_channel_names[NUM_CHANNELS + 1];
SR_PRIV int send_shortcommand(struct sr_serial_dev_inst *serial,
uint8_t command);
for (i = 0; i < model->analog_channels; i++) {
if (!(channel_name = g_strdup_printf("CH%d", i + 1)))
return NULL;
- ch = sr_channel_new(i, SR_PROBE_ANALOG, TRUE, channel_name);
+ ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channel_name);
sdi->channels = g_slist_append(sdi->channels, ch);
devc->analog_groups[i].name = channel_name;
devc->analog_groups[i].channels = g_slist_append(NULL, ch);
for (i = 0; i < 16; i++) {
if (!(channel_name = g_strdup_printf("D%d", i)))
return NULL;
- ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE, channel_name);
+ ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name);
g_free(channel_name);
if (!ch)
return NULL;
for (l = sdi->channels; l; l = l->next) {
ch = l->data;
- if (ch->type == SR_PROBE_ANALOG && ch->enabled)
+ if (ch->type == SR_CHANNEL_ANALOG && ch->enabled)
analog_channels++;
}
ch = g_slist_nth_data(cg->channels, 0);
if (!ch)
return SR_ERR;
- if (ch->type == SR_PROBE_ANALOG) {
+ if (ch->type == SR_CHANNEL_ANALOG) {
if (ch->name[2] < '1' || ch->name[2] > '4')
return SR_ERR;
analog_channel = ch->name[2] - '1';
for (l = sdi->channels; l; l = l->next) {
ch = l->data;
sr_dbg("handling channel %s", ch->name);
- if (ch->type == SR_PROBE_ANALOG) {
+ if (ch->type == SR_CHANNEL_ANALOG) {
if (ch->enabled)
devc->enabled_analog_channels = g_slist_append(
devc->enabled_analog_channels, ch);
return SR_ERR;
devc->analog_channels[ch->index] = ch->enabled;
}
- } else if (ch->type == SR_PROBE_LOGIC) {
+ } else if (ch->type == SR_CHANNEL_LOGIC) {
if (ch->enabled) {
devc->enabled_digital_channels = g_slist_append(
devc->enabled_digital_channels, ch);
sr_dbg("Starting reading data from channel %d", ch->index + 1);
if (devc->model->series->protocol <= PROTOCOL_V2) {
- if (ch->type == SR_PROBE_LOGIC) {
+ if (ch->type == SR_CHANNEL_LOGIC) {
if (sr_scpi_send(sdi->conn, ":WAV:DATA? DIG") != SR_OK)
return SR_ERR;
} else {
ch = devc->channel_entry->data;
- expected_data_bytes = ch->type == SR_PROBE_ANALOG ?
+ expected_data_bytes = ch->type == SR_CHANNEL_ANALOG ?
devc->analog_frame_size : devc->digital_frame_size;
if (devc->num_block_bytes == 0) {
devc->num_block_read += len;
- if (ch->type == SR_PROBE_ANALOG) {
+ if (ch->type == SR_CHANNEL_ANALOG) {
vref = devc->vert_reference[ch->index];
vdiv = devc->vdiv[ch->index] / 25.6;
offset = devc->vert_offset[ch->index];
rigol_ds_config_set(sdi, ":WAV:END");
}
- if (ch->type == SR_PROBE_ANALOG
+ if (ch->type == SR_CHANNEL_ANALOG
&& devc->channel_entry->next != NULL) {
/* We got the frame for this analog channel, but
* there's another analog channel. */
/* Size of acquisition buffers */
#define ACQ_BUFFER_SIZE 32768
-#define MAX_ANALOG_PROBES 4
-#define MAX_DIGITAL_PROBES 16
+#define MAX_ANALOG_CHANNELS 4
+#define MAX_DIGITAL_CHANNELS 16
enum protocol_version {
PROTOCOL_V1, /* VS5000 */
uint64_t num_vdivs;
/* Channel groups */
- struct sr_channel_group analog_groups[MAX_ANALOG_PROBES];
+ struct sr_channel_group analog_groups[MAX_ANALOG_CHANNELS];
struct sr_channel_group digital_group;
/* Acquisition settings */
uint64_t digital_frame_size;
/* Device settings */
- gboolean analog_channels[MAX_ANALOG_PROBES];
- gboolean digital_channels[MAX_DIGITAL_PROBES];
+ gboolean analog_channels[MAX_ANALOG_CHANNELS];
+ gboolean digital_channels[MAX_DIGITAL_CHANNELS];
gboolean la_enabled;
float timebase;
- float vdiv[MAX_ANALOG_PROBES];
- int vert_reference[MAX_ANALOG_PROBES];
- float vert_offset[MAX_ANALOG_PROBES];
+ float vdiv[MAX_ANALOG_CHANNELS];
+ int vert_reference[MAX_ANALOG_CHANNELS];
+ float vert_offset[MAX_ANALOG_CHANNELS];
char *trigger_source;
float horiz_triggerpos;
char *trigger_slope;
- char *coupling[MAX_ANALOG_PROBES];
+ char *coupling[MAX_ANALOG_CHANNELS];
/* Operational state */
sdi->driver = di;
for (j = 0; channel_names[j]; j++) {
- if (!(ch = sr_channel_new(j, SR_PROBE_LOGIC, TRUE,
+ if (!(ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j])))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
sdi->priv = devc;
sdi->driver = dmms[dmm].di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
/* The LWLA series simply number channels from CH1 to CHxx. */
g_snprintf(name, sizeof(name), "CH%d", i);
- ch = sr_channel_new(i - 1, SR_PROBE_LOGIC, TRUE, name);
+ ch = sr_channel_new(i - 1, SR_CHANNEL_LOGIC, TRUE, name);
list = g_slist_prepend(list, ch);
}
devc->samplerate = DEFAULT_SAMPLERATE;
sdi->priv = devc;
- sdi->channels = gen_channel_list(NUM_PROBES);
+ sdi->channels = gen_channel_list(NUM_CHANNELS);
return sdi;
}
if (!devc)
return SR_ERR_DEV_CLOSED;
- if (ch->index < 0 || ch->index >= NUM_PROBES) {
+ if (ch->index < 0 || ch->index >= NUM_CHANNELS) {
sr_err("Channel index %d out of range.", ch->index);
return SR_ERR_BUG;
}
channel_bit = (uint64_t)1 << ch->index;
- if ((changes & SR_PROBE_SET_ENABLED) != 0) {
+ if ((changes & SR_CHANNEL_SET_ENABLED) != 0) {
/* Enable or disable input channel for this channel. */
if (ch->enabled)
devc->channel_mask |= channel_bit;
devc->channel_mask &= ~channel_bit;
}
- if ((changes & SR_PROBE_SET_TRIGGER) != 0) {
+ if ((changes & SR_CHANNEL_SET_TRIGGER) != 0) {
trigger_mask = devc->trigger_mask & ~channel_bit;
trigger_values = devc->trigger_values & ~channel_bit;
trigger_edge_mask = devc->trigger_edge_mask & ~channel_bit;
if (acq->rle == RLE_STATE_DATA) {
acq->sample = word & ALL_CHANNELS_MASK;
- acq->run_len = ((word >> NUM_PROBES) & 1) + 1;
+ acq->run_len = ((word >> NUM_CHANNELS) & 1) + 1;
if (word & RLE_FLAG_LEN_FOLLOWS)
acq->rle = RLE_STATE_LEN;
} else {
#define USB_INTERFACE 0
#define USB_TIMEOUT 3000 /* ms */
-#define NUM_PROBES 34
+#define NUM_CHANNELS 34
#define TRIGGER_TYPES "01fr"
/* Bit mask covering all 34 channels.
*/
-#define ALL_CHANNELS_MASK (((uint64_t)1 << NUM_PROBES) - 1)
+#define ALL_CHANNELS_MASK (((uint64_t)1 << NUM_CHANNELS) - 1)
/** Unit and packet size for the sigrok logic datafeed.
*/
-#define UNIT_SIZE ((NUM_PROBES + 7) / 8)
+#define UNIT_SIZE ((NUM_CHANNELS + 7) / 8)
#define PACKET_LENGTH 10000 /* units */
/** Size of the acquisition buffer in device memory units.
sdi->priv = devc;
sdi->driver = di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
if (devc->optarif == OPTARIF_BASE) {
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "BASE")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "BASE")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
} else if (devc->optarif == OPTARIF_HC) {
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "HP")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HP")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "HC")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HC")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
} else if (devc->optarif == OPTARIF_EJP) {
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "HN")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HN")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "HPM")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPM")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
} else if (devc->optarif == OPTARIF_BBR) {
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "HPJB")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJB")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "HPJW")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJW")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "HPJR")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJR")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "HCJB")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJB")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "HCJW")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJW")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "HCJR")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJR")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
}
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "IINST")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "IINST")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "PAPP")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "PAPP")))
goto scan_cleanup;
sdi->channels = g_slist_append(sdi->channels, ch);
sdi->priv = devc;
sdi->driver = di;
- ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P1");
+ ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
if (!ch) {
sr_err("Failed to create channel.");
return NULL;
}
sdi->priv = devc;
sdi->driver = udmms[dmm].di;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
sdi->inst_type = SR_INST_USB;
sdi->conn = l->data;
for (i = 0; i < 3; i++) {
- if (!(ch = sr_channel_new(i, SR_PROBE_ANALOG, TRUE,
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
channels[i]))) {
sr_dbg("Channel malloc failed.");
return NULL;
return NULL;
sdi->priv = devc;
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
sdi->channels = g_slist_append(NULL, ch);
/* Fill in channellist according to this device's profile. */
for (j = 0; j < devc->num_channels; j++) {
- if (!(ch = sr_channel_new(j, SR_PROBE_LOGIC, TRUE,
+ if (!(ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j])))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
"Power off", NULL},
{SR_CONF_DATA_SOURCE, SR_T_CHAR, "data_source",
"Data source", NULL},
- {SR_CONF_NUM_LOGIC_PROBES, SR_T_INT32, "logic_probes",
+ {SR_CONF_NUM_LOGIC_CHANNELS, SR_T_INT32, "logic_probes",
"Number of logic probes", NULL},
- {SR_CONF_NUM_ANALOG_PROBES, SR_T_INT32, "analog_probes",
+ {SR_CONF_NUM_ANALOG_CHANNELS, SR_T_INT32, "analog_probes",
"Number of analog probes", NULL},
{SR_CONF_OUTPUT_VOLTAGE, SR_T_FLOAT, "output_voltage",
"Current output voltage", NULL},
#define LOG_PREFIX "input/binary"
#define CHUNKSIZE (512 * 1024)
-#define DEFAULT_NUM_PROBES 8
+#define DEFAULT_NUM_CHANNELS 8
struct context {
uint64_t samplerate;
{
struct sr_channel *ch;
int num_channels, i;
- char name[SR_MAX_PROBENAME_LEN + 1];
+ char name[SR_MAX_CHANNELNAME_LEN + 1];
char *param;
struct context *ctx;
return SR_ERR_MALLOC;
}
- num_channels = DEFAULT_NUM_PROBES;
+ num_channels = DEFAULT_NUM_CHANNELS;
ctx->samplerate = 0;
if (in->param) {
in->internal = ctx;
for (i = 0; i < num_channels; i++) {
- snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i);
+ snprintf(name, SR_MAX_CHANNELNAME_LEN, "%d", i);
/* TODO: Check return value. */
- if (!(ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE, name)))
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, name)))
return SR_ERR;
in->sdi->channels = g_slist_append(in->sdi->channels, ch);
}
#define NUM_PACKETS 2048
#define PACKET_SIZE 4096
-#define DEFAULT_NUM_PROBES 8
+#define DEFAULT_NUM_CHANNELS 8
/**
* Convert the LA8 'divcount' value to the respective samplerate (in Hz).
{
struct sr_channel *ch;
int num_channels, i;
- char name[SR_MAX_PROBENAME_LEN + 1];
+ char name[SR_MAX_CHANNELNAME_LEN + 1];
char *param;
(void)filename;
- num_channels = DEFAULT_NUM_PROBES;
+ num_channels = DEFAULT_NUM_CHANNELS;
if (in->param) {
param = g_hash_table_lookup(in->param, "numchannels");
in->sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, NULL, NULL, NULL);
for (i = 0; i < num_channels; i++) {
- snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i);
+ snprintf(name, SR_MAX_CHANNELNAME_LEN, "%d", i);
/* TODO: Check return value. */
- if (!(ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE, name)))
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, name)))
return SR_ERR;
in->sdi->channels = g_slist_append(in->sdi->channels, ch);
}
const char *param;
GIOStatus status;
gsize i, term_pos;
- char channel_name[SR_MAX_PROBENAME_LEN + 1];
+ char channel_name[SR_MAX_CHANNELNAME_LEN + 1];
struct sr_channel *ch;
char **columns;
gsize num_columns;
else
snprintf(channel_name, sizeof(channel_name), "%zu", i);
- ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE, channel_name);
+ ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name);
if (!ch) {
sr_err("Channel creation failed.");
#define LOG_PREFIX "input/vcd"
-#define DEFAULT_NUM_PROBES 8
+#define DEFAULT_NUM_CHANNELS 8
#define CHUNKSIZE 1024
struct context {
{
struct sr_channel *ch;
int num_channels, i;
- char name[SR_MAX_PROBENAME_LEN + 1];
+ char name[SR_MAX_CHANNELNAME_LEN + 1];
char *param;
struct context *ctx;
return SR_ERR_MALLOC;
}
- num_channels = DEFAULT_NUM_PROBES;
+ num_channels = DEFAULT_NUM_CHANNELS;
ctx->samplerate = 0;
ctx->downsample = 1;
ctx->skip = -1;
in->internal = ctx;
for (i = 0; i < num_channels; i++) {
- snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i);
+ snprintf(name, SR_MAX_CHANNELNAME_LEN, "%d", i);
- if (!(ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE, name))) {
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, name))) {
release_context(ctx);
return SR_ERR;
}
for (i = 0; i < ctx->num_channels; i++) {
snprintf(channelname, 8, "CH%d", i + 1);
- if (!(ch = sr_channel_new(0, SR_PROBE_ANALOG, TRUE, channelname)))
+ if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, channelname)))
return SR_ERR;
in->sdi->channels = g_slist_append(in->sdi->channels, ch);
}
/** Values for the changes argument of sr_dev_driver.config_probe_set. */
enum {
/** The enabled state of the probe has been changed. */
- SR_PROBE_SET_ENABLED = 1 << 0,
+ SR_CHANNEL_SET_ENABLED = 1 << 0,
/** The trigger setup of the probe has been changed. */
- SR_PROBE_SET_TRIGGER = 1 << 1,
+ SR_CHANNEL_SET_TRIGGER = 1 << 1,
};
SR_PRIV struct sr_channel *sr_channel_new(int index, int type,
*/
};
-#define SR_MAX_PROBENAME_LEN 32
+#define SR_MAX_CHANNELNAME_LEN 32
/* Handy little macros */
#define SR_HZ(n) (n)
/** Constants for probe type. */
enum {
/** Probe type is logic probe. */
- SR_PROBE_LOGIC = 10000,
+ SR_CHANNEL_LOGIC = 10000,
/** Probe type is analog probe. */
- SR_PROBE_ANALOG,
+ SR_CHANNEL_ANALOG,
};
/** Information on single channel. */
struct sr_channel {
/** Number of channels, starting at 0. */
int index;
- /** Channel type (SR_PROBE_LOGIC, ...) */
+ /** Channel type (SR_CHANNEL_LOGIC, ...) */
int type;
/** Is this channel enabled? */
gboolean enabled;
SR_CONF_CENTER_FREQUENCY,
/** The device supports setting the number of logic probes. */
- SR_CONF_NUM_LOGIC_PROBES,
+ SR_CONF_NUM_LOGIC_CHANNELS,
/** The device supports setting the number of analog probes. */
- SR_CONF_NUM_ANALOG_PROBES,
+ SR_CONF_NUM_ANALOG_CHANNELS,
/** Output voltage. */
SR_CONF_OUTPUT_VOLTAGE,
/* Get the unitsize. */
for (l = o->sdi->channels; l; l = l->next) {
ch = l->data;
- if (ch->type != SR_PROBE_LOGIC)
+ if (ch->type != SR_CHANNEL_LOGIC)
continue;
if (!ch->enabled)
continue;
/* Get the number of channels, and the unitsize. */
for (l = o->sdi->channels; l; l = l->next) {
ch = l->data;
- if (ch->type != SR_PROBE_LOGIC)
+ if (ch->type != SR_CHANNEL_LOGIC)
continue;
if (!ch->enabled)
continue;
ctx->num_enabled_channels, num_channels);
for (l = o->sdi->channels; l; l = l->next) {
ch = l->data;
- if (ch->type != SR_PROBE_LOGIC)
+ if (ch->type != SR_CHANNEL_LOGIC)
continue;
if (!ch->enabled)
continue;
ctx->num_enabled_channels = 0;
for (l = o->sdi->channels; l; l = l->next) {
ch = l->data;
- if (ch->type != SR_PROBE_LOGIC)
+ if (ch->type != SR_CHANNEL_LOGIC)
continue;
if (!ch->enabled)
continue;
wbuf[0] = '\0';
for (i = 0, l = o->sdi->channels; l; l = l->next, i++) {
ch = l->data;
- if (ch->type != SR_PROBE_LOGIC)
+ if (ch->type != SR_CHANNEL_LOGIC)
continue;
if (!ch->enabled)
continue;
num_enabled_channels = 0;
for (l = sdi->channels; l; l = l->next) {
ch = l->data;
- if (ch->type != SR_PROBE_LOGIC)
+ if (ch->type != SR_CHANNEL_LOGIC)
continue;
if (!ch->enabled)
continue;
uint8_t *outbuf;
ctx = o->internal;
- max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
+ max_linelen = SR_MAX_CHANNELNAME_LEN + 3 + ctx->samples_per_line
+ ctx->samples_per_line / 8;
/*
* Calculate space needed for probes. Set aside 512 bytes for
uint8_t *outbuf, c;
ctx = o->internal;
- max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
+ max_linelen = SR_MAX_CHANNELNAME_LEN + 3 + ctx->samples_per_line
+ ctx->samples_per_line / 8;
/*
* Calculate space needed for probes. Set aside 512 bytes for
uint8_t *outbuf;
ctx = o->internal;
- max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
+ max_linelen = SR_MAX_CHANNELNAME_LEN + 3 + ctx->samples_per_line
+ ctx->samples_per_line / 2;
outsize = length_in / ctx->unitsize * ctx->num_enabled_channels
/ ctx->samples_per_line * max_linelen + 512;
for (l = o->sdi->channels; l; l = l->next) {
ch = l->data;
- if (ch->type != SR_PROBE_LOGIC)
+ if (ch->type != SR_CHANNEL_LOGIC)
continue;
if (!ch->enabled)
continue;
for (l = o->sdi->channels; l; l = l->next) {
ch = l->data;
- if (ch->type != SR_PROBE_LOGIC)
+ if (ch->type != SR_CHANNEL_LOGIC)
continue;
if (!ch->enabled)
continue;
/* Wires / channels */
for (i = 0, l = o->sdi->channels; l; l = l->next, i++) {
ch = l->data;
- if (ch->type != SR_PROBE_LOGIC)
+ if (ch->type != SR_CHANNEL_LOGIC)
continue;
if (!ch->enabled)
continue;
case SR_CONF_CAPTURE_UNITSIZE:
vdev->unitsize = g_variant_get_uint64(data);
break;
- case SR_CONF_NUM_LOGIC_PROBES:
+ case SR_CONF_NUM_LOGIC_CHANNELS:
vdev->num_probes = g_variant_get_uint64(data);
break;
default:
int ret, channelnum, devcnt, i, j;
uint64_t tmp_u64, total_channels, enabled_channels, p;
char **sections, **keys, *metafile, *val;
- char channelname[SR_MAX_PROBENAME_LEN + 1];
+ char channelname[SR_MAX_CHANNELNAME_LEN + 1];
if ((ret = sr_sessionfile_check(filename)) != SR_OK)
return ret;
g_variant_new_uint64(tmp_u64), sdi, NULL);
} else if (!strcmp(keys[j], "total probes")) {
total_channels = strtoull(val, NULL, 10);
- sdi->driver->config_set(SR_CONF_NUM_LOGIC_PROBES,
+ sdi->driver->config_set(SR_CONF_NUM_LOGIC_CHANNELS,
g_variant_new_uint64(total_channels), sdi, NULL);
for (p = 0; p < total_channels; p++) {
- snprintf(channelname, SR_MAX_PROBENAME_LEN, "%" PRIu64, p);
- if (!(ch = sr_channel_new(p, SR_PROBE_LOGIC, TRUE,
+ snprintf(channelname, SR_MAX_CHANNELNAME_LEN, "%" PRIu64, p);
+ if (!(ch = sr_channel_new(p, SR_CHANNEL_LOGIC, TRUE,
channelname)))
return SR_ERR;
sdi->channels = g_slist_append(sdi->channels, ch);
cnt = 0;
for (l = sdi->channels; l; l = l->next) {
ch = l->data;
- if (ch->type != SR_PROBE_LOGIC)
+ if (ch->type != SR_CHANNEL_LOGIC)
continue;
if (ch->enabled != TRUE)
continue;
probes = g_array_new(FALSE, FALSE, sizeof(int));
for (l = sdi->probes; l; l = l->next) {
probe = l->data;
- if (probe->type != SR_PROBE_LOGIC)
+ if (probe->type != SR_CHANNEL_LOGIC)
continue;
if (probe->enabled != TRUE)
continue;