g_message("initializing %s plugin", plugin->name);
num_devices = plugin->init(NULL);
for (i = 0; i < num_devices; i++) {
- num_probes = (int)plugin->get_device_info(i, DI_NUM_PROBES);
+ num_probes = (int)plugin->get_device_info(i, SR_DI_NUM_PROBES);
device_new(plugin, i, num_probes);
}
#define AUDIO_DEV "plughw:0,0"
static int capabilities[] = {
- HWCAP_SAMPLERATE,
- HWCAP_LIMIT_SAMPLES,
- HWCAP_CONTINUOUS,
+ SR_HWCAP_SAMPLERATE,
+ SR_HWCAP_LIMIT_SAMPLES,
+ SR_HWCAP_CONTINUOUS,
};
static GSList *device_instances = NULL;
return 0;
memset(alsa, 0, sizeof(struct alsa));
- sdi = sr_device_instance_new(0, ST_ACTIVE, "alsa", NULL, NULL);
+ sdi = sr_device_instance_new(0, SR_ST_ACTIVE, "alsa", NULL, NULL);
if (!sdi)
goto free_alsa;
alsa = sdi->priv;
switch (device_info_id) {
- case DI_INSTANCE:
+ case SR_DI_INSTANCE:
info = sdi;
break;
- case DI_NUM_PROBES:
+ case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(NUM_PROBES);
break;
- case DI_CUR_SAMPLERATE:
+ case SR_DI_CUR_SAMPLERATE:
info = &alsa->cur_rate;
break;
- // case DI_PROBE_TYPE:
- // info = GINT_TO_POINTER(PROBE_TYPE_ANALOG);
+ // case SR_DI_PROBE_TYPE:
+ // info = GINT_TO_POINTER(SR_PROBE_TYPE_ANALOG);
// break;
}
/* Avoid compiler warnings. */
device_index = device_index;
- return ST_ACTIVE;
+ return SR_ST_ACTIVE;
}
static int *hw_get_capabilities(void)
alsa = sdi->priv;
switch (capability) {
- case HWCAP_PROBECONFIG:
+ case SR_HWCAP_PROBECONFIG:
return SR_OK;
- case HWCAP_SAMPLERATE:
+ case SR_HWCAP_SAMPLERATE:
alsa->cur_rate = *(uint64_t *) value;
return SR_OK;
- case HWCAP_LIMIT_SAMPLES:
+ case SR_HWCAP_LIMIT_SAMPLES:
alsa->limit_samples = *(uint64_t *) value;
return SR_OK;
default:
}
}
- packet.type = DF_ANALOG;
+ packet.type = SR_DF_ANALOG;
packet.length = count * sample_size;
packet.unitsize = sample_size;
packet.payload = outb;
} while (alsa->limit_samples > 0);
- packet.type = DF_END;
+ packet.type = SR_DF_END;
session_bus(user_data, &packet);
return TRUE;
alsa->session_id = session_device_id;
source_add(ufds[0].fd, ufds[0].events, 10, receive_data, sdi);
- packet.type = DF_HEADER;
+ packet.type = SR_DF_HEADER;
packet.length = sizeof(struct sr_datafeed_header);
packet.payload = (unsigned char *) &header;
header.feed_version = 1;
header.samplerate = alsa->cur_rate;
header.num_analog_probes = NUM_PROBES;
header.num_logic_probes = 0;
- header.protocol_id = PROTO_RAW;
+ header.protocol_id = SR_PROTO_RAW;
session_bus(session_device_id, &packet);
free(ufds);
};
static int capabilities[] = {
- HWCAP_LOGIC_ANALYZER,
- HWCAP_SAMPLERATE,
- HWCAP_CAPTURE_RATIO,
- HWCAP_PROBECONFIG,
+ SR_HWCAP_LOGIC_ANALYZER,
+ SR_HWCAP_SAMPLERATE,
+ SR_HWCAP_CAPTURE_RATIO,
+ SR_HWCAP_PROBECONFIG,
- HWCAP_LIMIT_MSEC,
+ SR_HWCAP_LIMIT_MSEC,
0,
};
sigma->use_triggers = 0;
/* Register SIGMA device. */
- sdi = sr_device_instance_new(0, ST_INITIALIZING,
+ sdi = sr_device_instance_new(0, SR_ST_INITIALIZING,
USB_VENDOR_NAME, USB_MODEL_NAME, USB_MODEL_VERSION);
if (!sdi)
goto free;
return 0;
}
- sdi->status = ST_ACTIVE;
+ sdi->status = SR_ST_ACTIVE;
return SR_OK;
}
if ((sdi = sr_get_device_instance(device_instances, device_index)))
{
sigma = sdi->priv;
- if (sdi->status == ST_ACTIVE)
+ if (sdi->status == SR_ST_ACTIVE)
ftdi_usb_close(&sigma->ftdic);
- sdi->status = ST_INACTIVE;
+ sdi->status = SR_ST_INACTIVE;
}
}
sigma = sdi->priv;
switch (device_info_id) {
- case DI_INSTANCE:
+ case SR_DI_INSTANCE:
info = sdi;
break;
- case DI_NUM_PROBES:
+ case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(16);
break;
- case DI_SAMPLERATES:
+ case SR_DI_SAMPLERATES:
info = &samplerates;
break;
- case DI_TRIGGER_TYPES:
+ case SR_DI_TRIGGER_TYPES:
info = (char *)TRIGGER_TYPES;
break;
- case DI_CUR_SAMPLERATE:
+ case SR_DI_CUR_SAMPLERATE:
info = &sigma->cur_samplerate;
break;
}
if (sdi)
return sdi->status;
else
- return ST_NOT_FOUND;
+ return SR_ST_NOT_FOUND;
}
static int *hw_get_capabilities(void)
sigma = sdi->priv;
- if (capability == HWCAP_SAMPLERATE) {
+ if (capability == SR_HWCAP_SAMPLERATE) {
ret = set_samplerate(sdi, *(uint64_t*) value);
- } else if (capability == HWCAP_PROBECONFIG) {
+ } else if (capability == SR_HWCAP_PROBECONFIG) {
ret = configure_probes(sdi, value);
- } else if (capability == HWCAP_LIMIT_MSEC) {
+ } else if (capability == SR_HWCAP_LIMIT_MSEC) {
sigma->limit_msec = *(uint64_t*) value;
if (sigma->limit_msec > 0)
ret = SR_OK;
else
ret = SR_ERR;
- } else if (capability == HWCAP_CAPTURE_RATIO) {
+ } else if (capability == SR_HWCAP_CAPTURE_RATIO) {
sigma->capture_ratio = *(uint64_t*) value;
if (sigma->capture_ratio < 0 || sigma->capture_ratio > 100)
ret = SR_ERR;
while (sent < n) {
tosend = MIN(2048, n - sent);
- packet.type = DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples + sent;
&sigma->trigger);
if (tosend > 0) {
- packet.type = DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples;
/* Only send trigger if explicitly enabled. */
if (sigma->use_triggers) {
- packet.type = DF_TRIGGER;
+ packet.type = SR_DF_TRIGGER;
packet.length = 0;
packet.payload = 0;
session_bus(sigma->session_id, &packet);
tosend = n - sent;
if (tosend > 0) {
- packet.type = DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples + sent;
} else if (sigma->state.state == SIGMA_DOWNLOAD) {
if (sigma->state.chunks_downloaded >= numchunks) {
/* End of samples. */
- packet.type = DF_END;
+ packet.type = SR_DF_END;
packet.length = 0;
session_bus(sigma->session_id, &packet);
sigma->session_id = session_device_id;
/* Send header packet to the session bus. */
- packet.type = DF_HEADER;
+ packet.type = SR_DF_HEADER;
packet.length = sizeof(struct sr_datafeed_header);
packet.payload = &header;
header.feed_version = 1;
gettimeofday(&header.starttime, NULL);
header.samplerate = sigma->cur_samplerate;
- header.protocol_id = PROTO_RAW;
+ header.protocol_id = SR_PROTO_RAW;
header.num_logic_probes = sigma->num_probes;
header.num_analog_probes = 0;
session_bus(session_device_id, &packet);
*/
if (!(err = libusb_open(dev, &((*sdi)->usb->devhdl)))) {
(*sdi)->usb->address = libusb_get_device_address(dev);
- (*sdi)->status = ST_ACTIVE;
+ (*sdi)->status = SR_ST_ACTIVE;
g_message("opened device %d on %d.%d interface %d",
(*sdi)->index, (*sdi)->usb->bus,
(*sdi)->usb->address, interface);
&& libusb_get_device_address(dev) == (*sdi)->usb->address) {
/* Found it. */
if (!(err = libusb_open(dev, &((*sdi)->usb->devhdl)))) {
- (*sdi)->status = ST_ACTIVE;
+ (*sdi)->status = SR_ST_ACTIVE;
g_message("opened device %d on %d.%d interface %d",
(*sdi)->index, (*sdi)->usb->bus,
(*sdi)->usb->address, interface);
};
static int capabilities[] = {
- HWCAP_LOGIC_ANALYZER,
- HWCAP_PATTERN_MODE,
- HWCAP_LIMIT_SAMPLES,
- HWCAP_LIMIT_MSEC,
- HWCAP_CONTINUOUS
+ SR_HWCAP_LOGIC_ANALYZER,
+ SR_HWCAP_PATTERN_MODE,
+ SR_HWCAP_LIMIT_SAMPLES,
+ SR_HWCAP_LIMIT_MSEC,
+ SR_HWCAP_CONTINUOUS,
};
static const char *patternmodes[] = {
/* Avoid compiler warnings. */
deviceinfo = deviceinfo;
- sdi = sr_device_instance_new(0, ST_ACTIVE, DEMONAME, NULL, NULL);
+ sdi = sr_device_instance_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
if (!sdi)
return 0;
return NULL;
switch (device_info_id) {
- case DI_INSTANCE:
+ case SR_DI_INSTANCE:
info = sdi;
break;
- case DI_NUM_PROBES:
+ case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(NUM_PROBES);
break;
- case DI_CUR_SAMPLERATE:
+ case SR_DI_CUR_SAMPLERATE:
info = &cur_samplerate;
break;
- case DI_PATTERNMODES:
+ case SR_DI_PATTERNMODES:
info = &patternmodes;
break;
}
/* Avoid compiler warnings. */
device_index = device_index;
- return ST_ACTIVE;
+ return SR_ST_ACTIVE;
}
static int *hw_get_capabilities(void)
/* Avoid compiler warnings. */
device_index = device_index;
- if (capability == HWCAP_PROBECONFIG) {
+ if (capability == SR_HWCAP_PROBECONFIG) {
/* Nothing to do. */
ret = SR_OK;
- } else if (capability == HWCAP_LIMIT_SAMPLES) {
+ } else if (capability == SR_HWCAP_LIMIT_SAMPLES) {
tmp_u64 = value;
limit_samples = *tmp_u64;
ret = SR_OK;
- } else if (capability == HWCAP_LIMIT_MSEC) {
+ } else if (capability == SR_HWCAP_LIMIT_MSEC) {
tmp_u64 = value;
limit_msec = *tmp_u64;
ret = SR_OK;
- } else if (capability == HWCAP_PATTERN_MODE) {
+ } else if (capability == SR_HWCAP_PATTERN_MODE) {
stropt = value;
if (!strcmp(stropt, "random")) {
default_genmode = GENMODE_RANDOM;
(gchar *)&c, BUFSIZE, &z, NULL);
if (z > 0) {
- packet.type = DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.length = z;
packet.unitsize = 1;
packet.payload = c;
g_io_channel_close(channels[0]);
/* Send last packet. */
- packet.type = DF_END;
+ packet.type = SR_DF_END;
session_bus(user_data, &packet);
return FALSE;
if (!packet || !header)
return SR_ERR_MALLOC;
- packet->type = DF_HEADER;
+ packet->type = SR_DF_HEADER;
packet->length = sizeof(struct sr_datafeed_header);
packet->payload = (unsigned char *)header;
header->feed_version = 1;
gettimeofday(&header->starttime, NULL);
header->samplerate = cur_samplerate;
- header->protocol_id = PROTO_RAW;
+ header->protocol_id = SR_PROTO_RAW;
header->num_logic_probes = NUM_PROBES;
header->num_analog_probes = 0;
session_bus(session_device_id, packet);
#define USB_PRODUCT "f190"
static int capabilities[] = {
- HWCAP_LOGIC_ANALYZER,
-// HWCAP_OSCILLOSCOPE,
-// HWCAP_PAT_GENERATOR,
+ SR_HWCAP_LOGIC_ANALYZER,
+// SR_HWCAP_OSCILLOSCOPE,
+// SR_HWCAP_PAT_GENERATOR,
- HWCAP_SAMPLERATE,
-// HWCAP_CAPTURE_RATIO,
- HWCAP_LIMIT_SAMPLES,
+ SR_HWCAP_SAMPLERATE,
+// SR_HWCAP_CAPTURE_RATIO,
+ SR_HWCAP_LIMIT_SAMPLES,
0,
};
/* hardware initial state */
mso->ctlbase = 0;
- sdi = sr_device_instance_new(devcnt, ST_INITIALIZING,
+ sdi = sr_device_instance_new(devcnt, SR_ST_INITIALIZING,
manufacturer, product, hwrev);
if (!sdi) {
g_warning("Unable to create device instance for %s",
if (ret != SR_OK)
return ret;
- sdi->status = ST_ACTIVE;
+ sdi->status = SR_ST_ACTIVE;
/* FIXME: discard serial buffer */
if (sdi->serial->fd != -1) {
serial_close(sdi->serial->fd);
sdi->serial->fd = -1;
- sdi->status = ST_INACTIVE;
+ sdi->status = SR_ST_INACTIVE;
}
}
mso = sdi->priv;
switch (device_info_id) {
- case DI_INSTANCE:
+ case SR_DI_INSTANCE:
info = sdi;
break;
- case DI_NUM_PROBES: /* FIXME: How to report analog probe? */
+ case SR_DI_NUM_PROBES: /* FIXME: How to report analog probe? */
info = GINT_TO_POINTER(8);
break;
- case DI_SAMPLERATES:
+ case SR_DI_SAMPLERATES:
info = &samplerates;
break;
- case DI_TRIGGER_TYPES:
+ case SR_DI_TRIGGER_TYPES:
info = "01"; /* FIXME */
break;
- case DI_CUR_SAMPLERATE:
+ case SR_DI_CUR_SAMPLERATE:
info = &mso->cur_rate;
break;
}
struct sr_device_instance *sdi;
if (!(sdi = sr_get_device_instance(device_instances, device_index)))
- return ST_NOT_FOUND;
+ return SR_ST_NOT_FOUND;
return sdi->status;
}
return SR_ERR;
switch (capability) {
- case HWCAP_SAMPLERATE:
+ case SR_HWCAP_SAMPLERATE:
return mso_configure_rate(sdi, *(uint64_t *) value);
- case HWCAP_PROBECONFIG:
- case HWCAP_LIMIT_SAMPLES:
+ case SR_HWCAP_PROBECONFIG:
+ case SR_HWCAP_LIMIT_SAMPLES:
default:
return SR_OK; /* FIXME */
}
((mso->buffer[i * 3 + 2] & 0x3f) << 2);
}
- packet.type = DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.length = 1024;
packet.unitsize = 1;
packet.payload = logic_out;
session_bus(mso->session_id, &packet);
- packet.type = DF_ANALOG;
+ packet.type = SR_DF_ANALOG;
packet.length = 1024;
packet.unitsize = sizeof(double);
packet.payload = analog_out;
session_bus(mso->session_id, &packet);
- packet.type = DF_END;
+ packet.type = SR_DF_END;
session_bus(mso->session_id, &packet);
return TRUE;
mso->session_id = session_device_id;
source_add(sdi->serial->fd, G_IO_IN, -1, receive_data, sdi);
- packet.type = DF_HEADER;
+ packet.type = SR_DF_HEADER;
packet.length = sizeof(struct sr_datafeed_header);
packet.payload = (unsigned char *) &header;
header.feed_version = 1;
header.samplerate = mso->cur_rate;
header.num_analog_probes = 1;
header.num_logic_probes = 8;
- header.protocol_id = PROTO_RAW;
+ header.protocol_id = SR_PROTO_RAW;
session_bus(session_device_id, &packet);
return ret;
device_index = device_index;
- packet.type = DF_END;
+ packet.type = SR_DF_END;
session_bus(session_device_id, &packet);
}
#define FLAG_RLE 0x0100
static int capabilities[] = {
- HWCAP_LOGIC_ANALYZER,
- HWCAP_SAMPLERATE,
- HWCAP_CAPTURE_RATIO,
- HWCAP_LIMIT_SAMPLES,
+ SR_HWCAP_LOGIC_ANALYZER,
+ SR_HWCAP_SAMPLERATE,
+ SR_HWCAP_CAPTURE_RATIO,
+ SR_HWCAP_LIMIT_SAMPLES,
0,
};
|| !strncmp(buf, "1ALS", 4)) {
if (!strncmp(buf, "1SLO", 4))
sdi = sr_device_instance_new
- (final_devcnt, ST_INACTIVE,
+ (final_devcnt, SR_ST_INACTIVE,
"Openbench",
"Logic Sniffer", "v1.0");
else
sdi = sr_device_instance_new
- (final_devcnt, ST_INACTIVE,
+ (final_devcnt, SR_ST_INACTIVE,
"Openbench", "Logic Sniffer",
"v1.0");
sdi->serial = sr_serial_device_instance_new
if (sdi->serial->fd == -1)
return SR_ERR;
- sdi->status = ST_ACTIVE;
+ sdi->status = SR_ST_ACTIVE;
return SR_OK;
}
if (sdi->serial->fd != -1) {
serial_close(sdi->serial->fd);
sdi->serial->fd = -1;
- sdi->status = ST_INACTIVE;
+ sdi->status = SR_ST_INACTIVE;
}
}
info = NULL;
switch (device_info_id) {
- case DI_INSTANCE:
+ case SR_DI_INSTANCE:
info = sdi;
break;
- case DI_NUM_PROBES:
+ case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(NUM_PROBES);
break;
- case DI_SAMPLERATES:
+ case SR_DI_SAMPLERATES:
info = &samplerates;
break;
- case DI_TRIGGER_TYPES:
+ case SR_DI_TRIGGER_TYPES:
info = (char *)TRIGGER_TYPES;
break;
- case DI_CUR_SAMPLERATE:
+ case SR_DI_CUR_SAMPLERATE:
info = &cur_samplerate;
break;
}
struct sr_device_instance *sdi;
if (!(sdi = sr_get_device_instance(device_instances, device_index)))
- return ST_NOT_FOUND;
+ return SR_ST_NOT_FOUND;
return sdi->status;
}
if (!(sdi = sr_get_device_instance(device_instances, device_index)))
return SR_ERR;
- if (sdi->status != ST_ACTIVE)
+ if (sdi->status != SR_ST_ACTIVE)
return SR_ERR;
switch (capability) {
- case HWCAP_SAMPLERATE:
+ case SR_HWCAP_SAMPLERATE:
tmp_u64 = value;
ret = set_configuration_samplerate(sdi, *tmp_u64);
break;
- case HWCAP_PROBECONFIG:
+ case SR_HWCAP_PROBECONFIG:
ret = configure_probes((GSList *) value);
break;
- case HWCAP_LIMIT_SAMPLES:
+ case SR_HWCAP_LIMIT_SAMPLES:
tmp_u64 = value;
if (*tmp_u64 < MIN_NUM_SAMPLES)
return SR_ERR;
g_message("ols: sample limit %" PRIu64, limit_samples);
ret = SR_OK;
break;
- case HWCAP_CAPTURE_RATIO:
+ case SR_HWCAP_CAPTURE_RATIO:
tmp_u64 = value;
capture_ratio = *tmp_u64;
if (capture_ratio < 0 || capture_ratio > 100) {
*/
if (trigger_at > 0) {
/* there are pre-trigger samples, send those first */
- packet.type = DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.length = trigger_at * 4;
packet.unitsize = 4;
packet.payload = raw_sample_buf;
session_bus(user_data, &packet);
}
- packet.type = DF_TRIGGER;
+ packet.type = SR_DF_TRIGGER;
packet.length = 0;
session_bus(user_data, &packet);
- packet.type = DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.length = (limit_samples * 4) - (trigger_at * 4);
packet.unitsize = 4;
packet.payload = raw_sample_buf + trigger_at * 4;
session_bus(user_data, &packet);
} else {
- packet.type = DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.length = limit_samples * 4;
packet.unitsize = 4;
packet.payload = raw_sample_buf;
serial_flush(fd);
serial_close(fd);
- packet.type = DF_END;
+ packet.type = SR_DF_END;
packet.length = 0;
session_bus(user_data, &packet);
}
if (!(sdi = sr_get_device_instance(device_instances, device_index)))
return SR_ERR;
- if (sdi->status != ST_ACTIVE)
+ if (sdi->status != SR_ST_ACTIVE)
return SR_ERR;
readcount = limit_samples / 4;
header = g_malloc(sizeof(struct sr_datafeed_header));
if (!packet || !header)
return SR_ERR;
- packet->type = DF_HEADER;
+ packet->type = SR_DF_HEADER;
packet->length = sizeof(struct sr_datafeed_header);
packet->payload = (unsigned char *)header;
header->feed_version = 1;
gettimeofday(&header->starttime, NULL);
header->samplerate = cur_samplerate;
- header->protocol_id = PROTO_RAW;
+ header->protocol_id = SR_PROTO_RAW;
header->num_logic_probes = NUM_PROBES;
header->num_analog_probes = 0;
session_bus(session_device_id, packet);
/* Avoid compiler warnings. */
device_index = device_index;
- packet.type = DF_END;
+ packet.type = SR_DF_END;
packet.length = 0;
session_bus(session_device_id, &packet);
}
/* There is only one model Saleae Logic, and this is what it supports: */
static int capabilities[] = {
- HWCAP_LOGIC_ANALYZER,
- HWCAP_SAMPLERATE,
+ SR_HWCAP_LOGIC_ANALYZER,
+ SR_HWCAP_SAMPLERATE,
/* These are really implemented in the driver, not the hardware. */
- HWCAP_LIMIT_SAMPLES,
- HWCAP_CONTINUOUS,
+ SR_HWCAP_LIMIT_SAMPLES,
+ SR_HWCAP_CONTINUOUS,
0,
};
return NULL;
libusb_get_device_list(usb_context, &devlist);
- if (sdi->status == ST_INITIALIZING) {
+ if (sdi->status == SR_ST_INITIALIZING) {
/*
* This device was renumerating last time we touched it.
* opendev() guarantees we've waited long enough for it to
&skip, USB_VENDOR, USB_PRODUCT,
USB_INTERFACE);
}
- } else if (sdi->status == ST_INACTIVE) {
+ } else if (sdi->status == SR_ST_INACTIVE) {
/*
* This device is fully enumerated, so we need to find this
* device by vendor, product, bus and address.
USB_PRODUCT, USB_INTERFACE);
}
} else {
- /* Status must be ST_ACTIVE, i.e. already in use... */
+ /* Status must be SR_ST_ACTIVE, i.e. already in use... */
sdi = NULL;
}
libusb_free_device_list(devlist, 1);
- if (sdi && sdi->status != ST_ACTIVE)
+ if (sdi && sdi->status != SR_ST_ACTIVE)
sdi = NULL;
return sdi;
libusb_release_interface(sdi->usb->devhdl, USB_INTERFACE);
libusb_close(sdi->usb->devhdl);
sdi->usb->devhdl = NULL;
- sdi->status = ST_INACTIVE;
+ sdi->status = SR_ST_INACTIVE;
}
static int configure_probes(GSList *probes)
if (des.idVendor != USB_VENDOR || des.idProduct != USB_PRODUCT)
continue; /* Not a Saleae Logic... */
- sdi = sr_device_instance_new(devcnt, ST_INITIALIZING,
+ sdi = sr_device_instance_new(devcnt, SR_ST_INITIALIZING,
USB_VENDOR_NAME, USB_MODEL_NAME, USB_MODEL_VERSION);
if (!sdi)
return 0;
if (cur_samplerate == 0) {
/* Samplerate hasn't been set; default to the slowest one. */
- if (hw_set_configuration(device_index, HWCAP_SAMPLERATE,
+ if (hw_set_configuration(device_index, SR_HWCAP_SAMPLERATE,
&supported_samplerates[0]) == SR_ERR)
return SR_ERR;
}
return NULL;
switch (device_info_id) {
- case DI_INSTANCE:
+ case SR_DI_INSTANCE:
info = sdi;
break;
- case DI_NUM_PROBES:
+ case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(NUM_PROBES);
break;
- case DI_SAMPLERATES:
+ case SR_DI_SAMPLERATES:
info = &samplerates;
break;
- case DI_TRIGGER_TYPES:
+ case SR_DI_TRIGGER_TYPES:
info = TRIGGER_TYPES;
break;
- case DI_CUR_SAMPLERATE:
+ case SR_DI_CUR_SAMPLERATE:
info = &cur_samplerate;
break;
}
if (sdi)
return sdi->status;
else
- return ST_NOT_FOUND;
+ return SR_ST_NOT_FOUND;
}
static int *hw_get_capabilities(void)
if (!(sdi = sr_get_device_instance(device_instances, device_index)))
return SR_ERR;
- if (capability == HWCAP_SAMPLERATE) {
+ if (capability == SR_HWCAP_SAMPLERATE) {
tmp_u64 = value;
ret = set_configuration_samplerate(sdi, *tmp_u64);
- } else if (capability == HWCAP_PROBECONFIG) {
+ } else if (capability == SR_HWCAP_PROBECONFIG) {
ret = configure_probes((GSList *) value);
- } else if (capability == HWCAP_LIMIT_SAMPLES) {
+ } else if (capability == SR_HWCAP_LIMIT_SAMPLES) {
tmp_u64 = value;
limit_samples = *tmp_u64;
ret = SR_OK;
* TODO: Send pre-trigger buffer to session bus.
* Tell the frontend we hit the trigger here.
*/
- packet.type = DF_TRIGGER;
+ packet.type = SR_DF_TRIGGER;
packet.length = 0;
session_bus(user_data, &packet);
* Send the samples that triggered it, since we're
* skipping past them.
*/
- packet.type = DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.length = trigger_stage;
packet.unitsize = 1;
packet.payload = trigger_buffer;
if (trigger_stage == TRIGGER_FIRED) {
/* Send the incoming transfer to the session bus. */
- packet.type = DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.length = cur_buflen - trigger_offset;
packet.unitsize = 1;
packet.payload = cur_buf + trigger_offset;
NULL);
free(lupfd);
- packet->type = DF_HEADER;
+ packet->type = SR_DF_HEADER;
packet->length = sizeof(struct sr_datafeed_header);
packet->payload = (unsigned char *)header;
header->feed_version = 1;
gettimeofday(&header->starttime, NULL);
header->samplerate = cur_samplerate;
- header->protocol_id = PROTO_RAW;
+ header->protocol_id = SR_PROTO_RAW;
header->num_logic_probes = NUM_PROBES;
header->num_analog_probes = 0;
session_bus(session_device_id, packet);
/* Avoid compiler warnings. */
device_index = device_index;
- packet.type = DF_END;
+ packet.type = SR_DF_END;
session_bus(session_device_id, &packet);
receive_transfer(NULL);
};
static int capabilities[] = {
- HWCAP_LOGIC_ANALYZER,
- HWCAP_SAMPLERATE,
- HWCAP_PROBECONFIG,
- HWCAP_CAPTURE_RATIO,
+ SR_HWCAP_LOGIC_ANALYZER,
+ SR_HWCAP_SAMPLERATE,
+ SR_HWCAP_PROBECONFIG,
+ SR_HWCAP_CAPTURE_RATIO,
/* These are really implemented in the driver, not the hardware. */
- HWCAP_LIMIT_SAMPLES,
+ SR_HWCAP_LIMIT_SAMPLES,
0,
};
/* Found it. */
if (!(err = libusb_open(dev, &((*sdi)->usb->devhdl)))) {
- (*sdi)->status = ST_ACTIVE;
+ (*sdi)->status = SR_ST_ACTIVE;
g_message("opened device %d on %d.%d interface %d",
(*sdi)->index, (*sdi)->usb->bus,
(*sdi)->usb->address, USB_INTERFACE);
return NULL;
libusb_get_device_list(usb_context, &devlist);
- if (sdi->status == ST_INACTIVE) {
+ if (sdi->status == SR_ST_INACTIVE) {
/* Find the device by vendor, product, bus and address. */
libusb_get_device_list(usb_context, &devlist);
for (i = 0; devlist[i]; i++) {
err = opendev4(&sdi, devlist[i], &des);
}
} else {
- /* Status must be ST_ACTIVE, i.e. already in use... */
+ /* Status must be SR_ST_ACTIVE, i.e. already in use... */
sdi = NULL;
}
libusb_free_device_list(devlist, 1);
- if (sdi && sdi->status != ST_ACTIVE)
+ if (sdi && sdi->status != SR_ST_ACTIVE)
sdi = NULL;
return sdi;
libusb_release_interface(sdi->usb->devhdl, USB_INTERFACE);
libusb_close(sdi->usb->devhdl);
sdi->usb->devhdl = NULL;
- sdi->status = ST_INACTIVE;
+ sdi->status = SR_ST_INACTIVE;
}
static int configure_probes(GSList *probes)
* the zeroplus range?
*/
sdi = sr_device_instance_new(devcnt,
- ST_INACTIVE, USB_VENDOR_NAME,
+ SR_ST_INACTIVE, USB_VENDOR_NAME,
USB_MODEL_NAME, USB_MODEL_VERSION);
if (!sdi)
return 0;
if (cur_samplerate == 0) {
/* Samplerate hasn't been set. Default to the slowest one. */
- if (hw_set_configuration(device_index, HWCAP_SAMPLERATE,
+ if (hw_set_configuration(device_index, SR_HWCAP_SAMPLERATE,
&samplerates.low) == SR_ERR)
return SR_ERR;
}
return NULL;
switch (device_info_id) {
- case DI_INSTANCE:
+ case SR_DI_INSTANCE:
info = sdi;
break;
- case DI_NUM_PROBES:
+ case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(num_channels);
break;
- case DI_SAMPLERATES:
+ case SR_DI_SAMPLERATES:
info = &samplerates;
break;
- case DI_TRIGGER_TYPES:
+ case SR_DI_TRIGGER_TYPES:
info = TRIGGER_TYPES;
break;
- case DI_CUR_SAMPLERATE:
+ case SR_DI_CUR_SAMPLERATE:
info = &cur_samplerate;
break;
}
if (sdi)
return sdi->status;
else
- return ST_NOT_FOUND;
+ return SR_ST_NOT_FOUND;
}
static int *hw_get_capabilities(void)
return SR_ERR;
switch (capability) {
- case HWCAP_SAMPLERATE:
+ case SR_HWCAP_SAMPLERATE:
tmp_u64 = value;
return set_configuration_samplerate(*tmp_u64);
- case HWCAP_PROBECONFIG:
+ case SR_HWCAP_PROBECONFIG:
return configure_probes((GSList *) value);
- case HWCAP_LIMIT_SAMPLES:
+ case SR_HWCAP_LIMIT_SAMPLES:
tmp_u64 = value;
limit_samples = *tmp_u64;
return SR_OK;
g_message("Trigger address = 0x%x",
analyzer_get_trigger_address(sdi->usb->devhdl));
- packet.type = DF_HEADER;
+ packet.type = SR_DF_HEADER;
packet.length = sizeof(struct sr_datafeed_header);
packet.payload = (unsigned char *)&header;
header.feed_version = 1;
gettimeofday(&header.starttime, NULL);
header.samplerate = cur_samplerate;
- header.protocol_id = PROTO_RAW;
+ header.protocol_id = SR_PROTO_RAW;
header.num_logic_probes = num_channels;
header.num_analog_probes = 0;
session_bus(session_device_id, &packet);
PACKET_SIZE, res);
#endif
- packet.type = DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.length = PACKET_SIZE;
packet.unitsize = 4;
packet.payload = buf;
analyzer_read_stop(sdi->usb->devhdl);
g_free(buf);
- packet.type = DF_END;
+ packet.type = SR_DF_END;
session_bus(session_device_id, &packet);
return SR_OK;
struct sr_datafeed_packet packet;
struct sr_device_instance *sdi;
- packet.type = DF_END;
+ packet.type = SR_DF_END;
session_bus(session_device_id, &packet);
if (!(sdi = sr_get_device_instance(device_instances, device_index)))
* options.
*/
struct hwcap_option hwcap_options[] = {
- {HWCAP_SAMPLERATE, T_UINT64, "Sample rate", "samplerate"},
- {HWCAP_CAPTURE_RATIO, T_UINT64, "Pre-trigger capture ratio", "captureratio"},
- {HWCAP_PATTERN_MODE, T_CHAR, "Pattern generator mode", "patternmode"},
+ {SR_HWCAP_SAMPLERATE, SR_T_UINT64, "Sample rate", "samplerate"},
+ {SR_HWCAP_CAPTURE_RATIO, SR_T_UINT64, "Pre-trigger capture ratio", "captureratio"},
+ {SR_HWCAP_PATTERN_MODE, SR_T_CHAR, "Pattern generator mode", "patternmode"},
{0, 0, NULL, NULL},
};
void sr_device_instance_free(struct sr_device_instance *sdi)
{
switch (sdi->instance_type) {
- case USB_INSTANCE:
+ case SR_USB_INSTANCE:
sr_usb_device_instance_free(sdi->usb);
break;
- case SERIAL_INSTANCE:
+ case SR_SERIAL_INSTANCE:
sr_serial_device_instance_free(sdi->serial);
break;
default:
header.feed_version = 1;
header.num_logic_probes = num_probes;
header.num_analog_probes = 0;
- header.protocol_id = PROTO_RAW;
+ header.protocol_id = SR_PROTO_RAW;
header.samplerate = 0;
gettimeofday(&header.starttime, NULL);
- packet.type = DF_HEADER;
+ packet.type = SR_DF_HEADER;
packet.length = sizeof(struct sr_datafeed_header);
packet.payload = &header;
session_bus(in->vdevice, &packet);
/* chop up the input file into chunks and feed it into the session bus */
- packet.type = DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.unitsize = (num_probes + 7) / 8;
packet.payload = buffer;
while ((size = read(fd, buffer, CHUNKSIZE)) > 0) {
close(fd);
/* end of stream */
- packet.type = DF_END;
+ packet.type = SR_DF_END;
packet.length = 0;
session_bus(in->vdevice, &packet);
num_probes = g_slist_length(o->device->probes);
if (o->device->plugin) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, DI_CUR_SAMPLERATE));
+ o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(samplerate_s = sr_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
ctx = o->internal;
switch (event_type) {
- case DF_TRIGGER:
+ case SR_DF_TRIGGER:
ctx->mark_trigger = ctx->spl_cnt;
*data_out = NULL;
*length_out = 0;
break;
- case DF_END:
+ case SR_DF_END:
outsize = ctx->num_enabled_probes
* (ctx->samples_per_line + 20) + 512;
if (!(outbuf = calloc(1, outsize)))
struct sr_output_format output_analog_bits = {
"analog_bits",
"Bits (takes argument, default 64)",
- DF_ANALOG,
+ SR_DF_ANALOG,
init_bits,
data_bits,
event,
struct sr_output_format output_analog_hex = {
"analog_hex",
"Hexadecimal (takes argument, default 192)",
- DF_ANALOG,
+ SR_DF_ANALOG,
init_hex,
data_hex,
event,
struct sr_output_format output_analog_ascii = {
"analog_ascii",
"ASCII (takes argument, default 74)",
- DF_ANALOG,
+ SR_DF_ANALOG,
init_ascii,
data_ascii,
event,
struct sr_output_format output_binary = {
"binary",
"Raw binary",
- DF_LOGIC,
+ SR_DF_LOGIC,
NULL,
data,
NULL,
comment[0] = '\0';
if (o->device->plugin) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, DI_CUR_SAMPLERATE));
+ o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(frequency_s = sr_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
ctx = o->internal;
switch (event_type) {
- case DF_TRIGGER:
+ case SR_DF_TRIGGER:
/* TODO: can a trigger mark be in a gnuplot data file? */
break;
- case DF_END:
+ case SR_DF_END:
free(o->internal);
o->internal = NULL;
break;
comment[0] = '\0';
if (o->device->plugin) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, DI_CUR_SAMPLERATE));
+ o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(frequency_s = sr_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
struct sr_output_format output_gnuplot = {
"gnuplot",
"Gnuplot",
- DF_LOGIC,
+ SR_DF_LOGIC,
init,
data,
event,
struct sr_output_format output_analog_gnuplot = {
"analog_gnuplot",
"Gnuplot analog",
- DF_ANALOG,
+ SR_DF_ANALOG,
analog_init,
analog_data,
event,
if (o->device->plugin) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, DI_CUR_SAMPLERATE));
+ o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(frequency_s = sr_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
ctx = o->internal;
switch (event_type) {
- case DF_TRIGGER:
+ case SR_DF_TRIGGER:
/* TODO */
break;
- case DF_END:
+ case SR_DF_END:
free(o->internal);
o->internal = NULL;
break;
struct sr_output_format output_ols = {
"ols",
"OpenBench Logic Sniffer",
- DF_LOGIC,
+ SR_DF_LOGIC,
init,
data,
event,
struct sr_output_format output_foo = {
"foo",
"The foo format",
- DF_LOGIC,
+ SR_DF_LOGIC,
init,
data,
event,
if (o->device->plugin) {
ctx->samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, DI_CUR_SAMPLERATE));
+ o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) {
g_string_free(ctx->header, TRUE);
free(ctx);
ctx = o->internal;
switch (event_type) {
- case DF_END:
+ case SR_DF_END:
outbuf = strdup("$dumpoff\n$end\n");
*data_out = outbuf;
*length_out = strlen(outbuf);
struct sr_output_format output_vcd = {
"vcd",
"Value Change Dump (VCD)",
- DF_LOGIC,
+ SR_DF_LOGIC,
init,
data,
event,
struct sr_output_format output_text_ascii = {
"ascii",
"ASCII (takes argument, default 74)",
- DF_LOGIC,
+ SR_DF_LOGIC,
init_ascii,
data_ascii,
event,
struct sr_output_format output_text_bits = {
"bits",
"Bits (takes argument, default 64)",
- DF_LOGIC,
+ SR_DF_LOGIC,
init_bits,
data_bits,
event,
struct sr_output_format output_text_hex = {
"hex",
"Hexadecimal (takes argument, default 192)",
- DF_LOGIC,
+ SR_DF_LOGIC,
init_hex,
data_hex,
event,
num_probes = g_slist_length(o->device->probes);
if (o->device->plugin) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, DI_CUR_SAMPLERATE));
+ o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(samplerate_s = sr_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
ctx = o->internal;
switch (event_type) {
- case DF_TRIGGER:
+ case SR_DF_TRIGGER:
ctx->mark_trigger = ctx->spl_cnt;
*data_out = NULL;
*length_out = 0;
break;
- case DF_END:
+ case SR_DF_END:
outsize = ctx->num_enabled_probes
* (ctx->samples_per_line + 20) + 512;
if (!(outbuf = calloc(1, outsize)))
/* Data types used by hardware plugins for set_configuration() */
enum {
- T_UINT64,
- T_CHAR,
- T_NULL,
+ SR_T_UINT64,
+ SR_T_CHAR,
+ SR_T_NULL,
};
enum {
- PROTO_RAW,
+ SR_PROTO_RAW,
};
/* (Unused) protocol decoder stack entry */
/* sr_datafeed_packet.type values */
enum {
- DF_HEADER,
- DF_END,
- DF_TRIGGER,
- DF_LOGIC,
- DF_ANALOG,
- DF_PD,
+ SR_DF_HEADER,
+ SR_DF_END,
+ SR_DF_TRIGGER,
+ SR_DF_LOGIC,
+ SR_DF_ANALOG,
+ SR_DF_PD,
};
struct sr_datafeed_packet {
};
enum {
- PROBE_TYPE_LOGIC,
- PROBE_TYPE_ANALOG,
+ SR_PROBE_TYPE_LOGIC,
+ SR_PROBE_TYPE_ANALOG,
};
struct probe {
/* Hardware plugin capabilities */
enum {
- HWCAP_DUMMY, /* Used to terminate lists */
+ SR_HWCAP_DUMMY, /* Used to terminate lists */
/* device classes */
- HWCAP_LOGIC_ANALYZER,
+ SR_HWCAP_LOGIC_ANALYZER,
/* device options */
- HWCAP_SAMPLERATE, /* Change samplerate */
- HWCAP_PROBECONFIG, /* Configure probe mask */
- HWCAP_CAPTURE_RATIO, /* Set pre/post-trigger capture ratio */
- HWCAP_PATTERN_MODE, /* Pattern generator mode */
+ SR_HWCAP_SAMPLERATE, /* Change samplerate */
+ SR_HWCAP_PROBECONFIG, /* Configure probe mask */
+ SR_HWCAP_CAPTURE_RATIO, /* Set pre/post-trigger capture ratio */
+ SR_HWCAP_PATTERN_MODE, /* Pattern generator mode */
/* acquisition modes */
- HWCAP_LIMIT_MSEC, /* Set a time limit for sample acquisition */
- HWCAP_LIMIT_SAMPLES, /* Set a limit on number of samples */
- HWCAP_CONTINUOUS,
+ SR_HWCAP_LIMIT_MSEC, /* Set a time limit for sample acquisition */
+ SR_HWCAP_LIMIT_SAMPLES, /* Set a limit on number of samples */
+ SR_HWCAP_CONTINUOUS,
};
struct hwcap_option {
/* sr_device_instance types */
enum {
- USB_INSTANCE,
- SERIAL_INSTANCE,
+ SR_USB_INSTANCE,
+ SR_SERIAL_INSTANCE,
};
struct sr_usb_device_instance {
/* Device instance status */
enum {
- ST_NOT_FOUND,
+ SR_ST_NOT_FOUND,
/* Found, but still booting */
- ST_INITIALIZING,
+ SR_ST_INITIALIZING,
/* Live, but not in use */
- ST_INACTIVE,
+ SR_ST_INACTIVE,
/* Actively in use in a session */
- ST_ACTIVE,
+ SR_ST_ACTIVE,
};
/*
/* Device info IDs */
enum {
/* struct sr_device_instance for this specific device */
- DI_INSTANCE,
+ SR_DI_INSTANCE,
/* The number of probes connected to this device */
- DI_NUM_PROBES,
+ SR_DI_NUM_PROBES,
/* Samplerates supported by this device, (struct samplerates) */
- DI_SAMPLERATES,
+ SR_DI_SAMPLERATES,
/* Types of trigger supported, out of "01crf" (char *) */
- DI_TRIGGER_TYPES,
+ SR_DI_TRIGGER_TYPES,
/* The currently set samplerate in Hz (uint64_t) */
- DI_CUR_SAMPLERATE,
+ SR_DI_CUR_SAMPLERATE,
/* Supported pattern generator modes */
- DI_PATTERNMODES,
+ SR_DI_PATTERNMODES,
};
/*