#include <glib.h>
#include <sigrok.h>
-int sigrok_init(void)
+int sr_init(void)
{
return load_hwplugins();
}
/* TODO: Should return int to be able to report back error codes. */
-void sigrok_cleanup(void)
+void sr_cleanup(void)
{
device_close_all();
}
#include <glib.h>
#include <sigrok.h>
-extern struct sigrok_global *global;
+extern struct sr_global *global;
GSList *devices = NULL;
static int hw_init(char *deviceinfo)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct alsa *alsa;
/* Avoid compiler warnings. */
return 0;
memset(alsa, 0, sizeof(struct alsa));
- sdi = sigrok_device_instance_new(0, ST_ACTIVE, "alsa", NULL, NULL);
+ sdi = sr_device_instance_new(0, ST_ACTIVE, "alsa", NULL, NULL);
if (!sdi)
goto free_alsa;
static int hw_opendev(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct alsa *alsa;
int err;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
alsa = sdi->priv;
static void hw_closedev(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct alsa *alsa;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return;
alsa = sdi->priv;
if (!alsa)
static void hw_cleanup(void)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- if (!(sdi = get_sigrok_device_instance(device_instances, 0)))
+ if (!(sdi = get_sr_device_instance(device_instances, 0)))
return;
free(sdi->priv);
- sigrok_device_instance_free(sdi);
+ sr_device_instance_free(sdi);
}
static void *hw_get_device_info(int device_index, int device_info_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct alsa *alsa;
void *info = NULL;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return NULL;
alsa = sdi->priv;
static int hw_set_configuration(int device_index, int capability, void *value)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct alsa *alsa;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
alsa = sdi->priv;
static int receive_data(int fd, int revents, void *user_data)
{
- struct sigrok_device_instance *sdi = user_data;
+ struct sr_device_instance *sdi = user_data;
struct alsa *alsa = sdi->priv;
struct datafeed_packet packet;
struct analog_sample *sample;
static int hw_start_acquisition(int device_index, gpointer session_device_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct alsa *alsa;
struct datafeed_packet packet;
struct datafeed_header header;
int count;
int err;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
alsa = sdi->priv;
static int hw_init(char *deviceinfo)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct sigma *sigma = g_malloc(sizeof(struct sigma));
deviceinfo = deviceinfo;
sigma->use_triggers = 0;
/* Register SIGMA device. */
- sdi = sigrok_device_instance_new(0, ST_INITIALIZING,
+ sdi = sr_device_instance_new(0, ST_INITIALIZING,
USB_VENDOR_NAME, USB_MODEL_NAME, USB_MODEL_VERSION);
if (!sdi)
goto free;
static int hw_opendev(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct sigma *sigma;
int ret;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
sigma = sdi->priv;
return SR_OK;
}
-static int set_samplerate(struct sigrok_device_instance *sdi,
+static int set_samplerate(struct sr_device_instance *sdi,
uint64_t samplerate)
{
int i, ret;
* The Sigma supports complex triggers using boolean expressions, but this
* has not been implemented yet.
*/
-static int configure_probes(struct sigrok_device_instance *sdi, GSList *probes)
+static int configure_probes(struct sr_device_instance *sdi, GSList *probes)
{
struct sigma *sigma = sdi->priv;
struct probe *probe;
static void hw_closedev(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct sigma *sigma;
- if ((sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if ((sdi = get_sr_device_instance(device_instances, device_index)))
{
sigma = sdi->priv;
if (sdi->status == ST_ACTIVE)
static void hw_cleanup(void)
{
GSList *l;
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
/* Properly close all devices. */
for (l = device_instances; l; l = l->next) {
sdi = l->data;
if (sdi->priv != NULL)
free(sdi->priv);
- sigrok_device_instance_free(sdi);
+ sr_device_instance_free(sdi);
}
g_slist_free(device_instances);
device_instances = NULL;
static void *hw_get_device_info(int device_index, int device_info_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct sigma *sigma;
void *info = NULL;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index))) {
+ if (!(sdi = get_sr_device_instance(device_instances, device_index))) {
fprintf(stderr, "It's NULL.\n");
return NULL;
}
static int hw_get_status(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- sdi = get_sigrok_device_instance(device_instances, device_index);
+ sdi = get_sr_device_instance(device_instances, device_index);
if (sdi)
return sdi->status;
else
static int hw_set_configuration(int device_index, int capability, void *value)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct sigma *sigma;
int ret;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
sigma = sdi->priv;
uint16_t *lastsample, int triggerpos,
uint16_t limit_chunk, void *user_data)
{
- struct sigrok_device_instance *sdi = user_data;
+ struct sr_device_instance *sdi = user_data;
struct sigma *sigma = sdi->priv;
uint16_t tsdiff, ts;
uint16_t samples[65536 * sigma->samples_per_event];
static int receive_data(int fd, int revents, void *user_data)
{
- struct sigrok_device_instance *sdi = user_data;
+ struct sr_device_instance *sdi = user_data;
struct sigma *sigma = sdi->priv;
struct datafeed_packet packet;
const int chunks_per_read = 32;
static int hw_start_acquisition(int device_index, gpointer session_device_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct sigma *sigma;
struct datafeed_packet packet;
struct datafeed_header header;
session_device_id = session_device_id;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
sigma = sdi->priv;
static void hw_stop_acquisition(int device_index, gpointer session_device_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct sigma *sigma;
uint8_t modestatus;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return;
sigma = sdi->priv;
#include <libusb.h>
#include <sigrok.h>
-int opendev2(int device_index, struct sigrok_device_instance **sdi,
+int opendev2(int device_index, struct sr_device_instance **sdi,
libusb_device *dev, struct libusb_device_descriptor *des,
int *skip, uint16_t vid, uint16_t pid, int interface)
{
return 0;
}
-int opendev3(struct sigrok_device_instance **sdi, libusb_device *dev,
+int opendev3(struct sr_device_instance **sdi, libusb_device *dev,
struct libusb_device_descriptor *des,
uint16_t vid, uint16_t pid, int interface)
{
0xbe, 0xbe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
-/* List of struct sigrok_device_instance, maintained by opendev()/closedev(). */
+/* List of struct sr_device_instance, maintained by opendev()/closedev(). */
static GSList *device_instances = NULL;
static uint64_t cur_samplerate = KHZ(200);
static uint64_t limit_samples = 0;
static int hw_init(char *deviceinfo)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
/* Avoid compiler warnings. */
deviceinfo = deviceinfo;
- sdi = sigrok_device_instance_new(0, ST_ACTIVE, DEMONAME, NULL, NULL);
+ sdi = sr_device_instance_new(0, ST_ACTIVE, DEMONAME, NULL, NULL);
if (!sdi)
return 0;
static void *hw_get_device_info(int device_index, int device_info_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
void *info = NULL;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return NULL;
switch (device_info_id) {
static GSList *device_instances = NULL;
-static int mso_send_control_message(struct sigrok_device_instance *sdi,
+static int mso_send_control_message(struct sr_device_instance *sdi,
uint16_t payload[], int n)
{
int fd = sdi->serial->fd;
return ret;
}
-static int mso_reset_adc(struct sigrok_device_instance *sdi)
+static int mso_reset_adc(struct sr_device_instance *sdi)
{
struct mso *mso = sdi->priv;
uint16_t ops[2];
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
-static int mso_reset_fsm(struct sigrok_device_instance *sdi)
+static int mso_reset_fsm(struct sr_device_instance *sdi)
{
struct mso *mso = sdi->priv;
uint16_t ops[1];
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
-static int mso_toggle_led(struct sigrok_device_instance *sdi, int state)
+static int mso_toggle_led(struct sr_device_instance *sdi, int state)
{
struct mso *mso = sdi->priv;
uint16_t ops[1];
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
-static int mso_check_trigger(struct sigrok_device_instance *sdi,
+static int mso_check_trigger(struct sr_device_instance *sdi,
uint8_t *info)
{
uint16_t ops[] = { mso_trans(REG_TRIGGER, 0) };
return ret;
}
-static int mso_read_buffer(struct sigrok_device_instance *sdi)
+static int mso_read_buffer(struct sr_device_instance *sdi)
{
uint16_t ops[] = { mso_trans(REG_BUFFER, 0) };
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
-static int mso_arm(struct sigrok_device_instance *sdi)
+static int mso_arm(struct sr_device_instance *sdi)
{
struct mso *mso = sdi->priv;
uint16_t ops[] = {
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
-static int mso_force_capture(struct sigrok_device_instance *sdi)
+static int mso_force_capture(struct sr_device_instance *sdi)
{
struct mso *mso = sdi->priv;
uint16_t ops[] = {
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
-static int mso_dac_out(struct sigrok_device_instance *sdi, uint16_t val)
+static int mso_dac_out(struct sr_device_instance *sdi, uint16_t val)
{
struct mso *mso = sdi->priv;
uint16_t ops[] = {
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
-static int mso_clkrate_out(struct sigrok_device_instance *sdi, uint16_t val)
+static int mso_clkrate_out(struct sr_device_instance *sdi, uint16_t val)
{
uint16_t ops[] = {
mso_trans(REG_CLKRATE1, (val >> 8) & 0xff),
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
-static int mso_configure_rate(struct sigrok_device_instance *sdi,
+static int mso_configure_rate(struct sr_device_instance *sdi,
uint32_t rate)
{
struct mso *mso = sdi->priv;
mso->vbit));
}
-static int mso_configure_trigger(struct sigrok_device_instance *sdi)
+static int mso_configure_trigger(struct sr_device_instance *sdi)
{
struct mso *mso = sdi->priv;
uint16_t ops[16];
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
-static int mso_configure_threshold_level(struct sigrok_device_instance *sdi)
+static int mso_configure_threshold_level(struct sr_device_instance *sdi)
{
struct mso *mso = sdi->priv;
static int hw_init(char *deviceinfo)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
int devcnt = 0;
struct udev *udev;
struct udev_enumerate *enumerate;
/* hardware initial state */
mso->ctlbase = 0;
- sdi = sigrok_device_instance_new(devcnt, ST_INITIALIZING,
+ sdi = sr_device_instance_new(devcnt, ST_INITIALIZING,
manufacturer, product, hwrev);
if (!sdi) {
g_warning("Unable to create device instance for %s",
continue;
err_device_instance_free:
- sigrok_device_instance_free(sdi);
+ sr_device_instance_free(sdi);
err_free_mso:
free(mso);
}
static void hw_cleanup(void)
{
GSList *l;
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
/* Properly close all devices. */
for (l = device_instances; l; l = l->next) {
serial_close(sdi->serial->fd);
if (sdi->priv != NULL)
free(sdi->priv);
- sigrok_device_instance_free(sdi);
+ sr_device_instance_free(sdi);
}
g_slist_free(device_instances);
device_instances = NULL;
static int hw_opendev(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct mso *mso;
int ret = SR_ERR;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return ret;
mso = sdi->priv;
static void hw_closedev(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return;
if (sdi->serial->fd != -1) {
static void *hw_get_device_info(int device_index, int device_info_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct mso *mso;
void *info = NULL;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return NULL;
mso = sdi->priv;
static int hw_get_status(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return ST_NOT_FOUND;
return sdi->status;
static int hw_set_configuration(int device_index, int capability, void *value)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
switch (capability) {
/* FIXME: Pass errors? */
static int receive_data(int fd, int revents, void *user_data)
{
- struct sigrok_device_instance *sdi = user_data;
+ struct sr_device_instance *sdi = user_data;
struct mso *mso = sdi->priv;
struct datafeed_packet packet;
uint8_t in[1024], logic_out[1024];
static int hw_start_acquisition(int device_index, gpointer session_device_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct mso *mso;
struct datafeed_packet packet;
struct datafeed_header header;
int ret = SR_ERR;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return ret;
mso = sdi->priv;
static int hw_init(char *deviceinfo)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
GSList *ports, *l;
GPollFD *fds;
int devcnt, final_devcnt, num_ports, fd, ret, i;
if (!strncmp(buf, "1SLO", 4)
|| !strncmp(buf, "1ALS", 4)) {
if (!strncmp(buf, "1SLO", 4))
- sdi = sigrok_device_instance_new
+ sdi = sr_device_instance_new
(final_devcnt, ST_INACTIVE,
"Openbench",
"Logic Sniffer", "v1.0");
else
- sdi = sigrok_device_instance_new
+ sdi = sr_device_instance_new
(final_devcnt, ST_INACTIVE,
"Openbench", "Logic Sniffer",
"v1.0");
static int hw_opendev(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
sdi->serial->fd = serial_open(sdi->serial->port, O_RDWR);
static void hw_closedev(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return;
if (sdi->serial->fd != -1) {
static void hw_cleanup(void)
{
GSList *l;
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
/* Properly close all devices. */
for (l = device_instances; l; l = l->next) {
sdi = l->data;
if (sdi->serial->fd != -1)
serial_close(sdi->serial->fd);
- sigrok_device_instance_free(sdi);
+ sr_device_instance_free(sdi);
}
g_slist_free(device_instances);
device_instances = NULL;
static void *hw_get_device_info(int device_index, int device_info_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
void *info;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return NULL;
info = NULL;
static int hw_get_status(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return ST_NOT_FOUND;
return sdi->status;
return capabilities;
}
-static int set_configuration_samplerate(struct sigrok_device_instance *sdi,
+static int set_configuration_samplerate(struct sr_device_instance *sdi,
uint64_t samplerate)
{
uint32_t divider;
static int hw_set_configuration(int device_index, int capability, void *value)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
int ret;
uint64_t *tmp_u64;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
if (sdi->status != ST_ACTIVE)
int i;
struct datafeed_packet *packet;
struct datafeed_header *header;
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
uint32_t trigger_config[4];
uint32_t data;
uint16_t readcount, delaycount;
uint8_t changrp_mask;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
if (sdi->status != ST_ACTIVE)
0,
};
-/* List of struct sigrok_device_instance, maintained by opendev()/closedev(). */
+/* List of struct sr_device_instance, maintained by opendev()/closedev(). */
static GSList *device_instances = NULL;
/*
return ret;
}
-struct sigrok_device_instance *sl_open_device(int device_index)
+struct sr_device_instance *sl_open_device(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
libusb_device **devlist;
struct libusb_device_descriptor des;
int err, skip, i;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return NULL;
libusb_get_device_list(usb_context, &devlist);
return 0;
}
-static void close_device(struct sigrok_device_instance *sdi)
+static void close_device(struct sr_device_instance *sdi)
{
if (sdi->usb->devhdl == NULL)
return;
static int hw_init(char *deviceinfo)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct libusb_device_descriptor des;
libusb_device **devlist;
int err, devcnt, i;
if (des.idVendor != USB_VENDOR || des.idProduct != USB_PRODUCT)
continue; /* Not a Saleae Logic... */
- sdi = sigrok_device_instance_new(devcnt, ST_INITIALIZING,
+ sdi = sr_device_instance_new(devcnt, ST_INITIALIZING,
USB_VENDOR_NAME, USB_MODEL_NAME, USB_MODEL_VERSION);
if (!sdi)
return 0;
static int hw_opendev(int device_index)
{
GTimeVal cur_time;
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
int timediff, err;
unsigned int cur, upd;
static void hw_closedev(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- if ((sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if ((sdi = get_sr_device_instance(device_instances, device_index)))
close_device(sdi);
}
/* Properly close all devices... */
for (l = device_instances; l; l = l->next)
- close_device((struct sigrok_device_instance *)l->data);
+ close_device((struct sr_device_instance *)l->data);
/* ...and free all their memory. */
for (l = device_instances; l; l = l->next)
static void *hw_get_device_info(int device_index, int device_info_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
void *info = NULL;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return NULL;
switch (device_info_id) {
static int hw_get_status(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- sdi = get_sigrok_device_instance(device_instances, device_index);
+ sdi = get_sr_device_instance(device_instances, device_index);
if (sdi)
return sdi->status;
else
return capabilities;
}
-static int set_configuration_samplerate(struct sigrok_device_instance *sdi,
+static int set_configuration_samplerate(struct sr_device_instance *sdi,
uint64_t samplerate)
{
uint8_t divider;
static int hw_set_configuration(int device_index, int capability, void *value)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
int ret;
uint64_t *tmp_u64;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
if (capability == HWCAP_SAMPLERATE) {
static int hw_start_acquisition(int device_index, gpointer session_device_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct datafeed_packet *packet;
struct datafeed_header *header;
struct libusb_transfer *transfer;
int size, i;
unsigned char *buf;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
packet = g_malloc(sizeof(struct datafeed_packet));
0,
};
-/* List of struct sigrok_device_instance, maintained by opendev()/closedev(). */
+/* List of struct sr_device_instance, maintained by opendev()/closedev(). */
static GSList *device_instances = NULL;
static libusb_context *usb_context = NULL;
return 0;
}
-static int opendev4(struct sigrok_device_instance **sdi, libusb_device *dev,
+static int opendev4(struct sr_device_instance **sdi, libusb_device *dev,
struct libusb_device_descriptor *des)
{
unsigned int i;
return 0;
}
-struct sigrok_device_instance *zp_open_device(int device_index)
+struct sr_device_instance *zp_open_device(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
libusb_device **devlist;
struct libusb_device_descriptor des;
int err, i;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return NULL;
libusb_get_device_list(usb_context, &devlist);
return sdi;
}
-static void close_device(struct sigrok_device_instance *sdi)
+static void close_device(struct sr_device_instance *sdi)
{
if (!sdi->usb->devhdl)
return;
static int hw_init(char *deviceinfo)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct libusb_device_descriptor des;
libusb_device **devlist;
int err, devcnt, i;
* TODO: Any way to detect specific model/version in
* the zeroplus range?
*/
- sdi = sigrok_device_instance_new(devcnt,
+ sdi = sr_device_instance_new(devcnt,
ST_INACTIVE, USB_VENDOR_NAME,
USB_MODEL_NAME, USB_MODEL_VERSION);
if (!sdi)
static int hw_opendev(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
int err;
if (!(sdi = zp_open_device(device_index))) {
static void hw_closedev(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- if ((sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if ((sdi = get_sr_device_instance(device_instances, device_index)))
close_device(sdi);
}
/* Properly close all devices... */
for (l = device_instances; l; l = l->next)
- close_device((struct sigrok_device_instance *)l->data);
+ close_device((struct sr_device_instance *)l->data);
/* ...and free all their memory. */
for (l = device_instances; l; l = l->next)
static void *hw_get_device_info(int device_index, int device_info_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
void *info = NULL;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return NULL;
switch (device_info_id) {
static int hw_get_status(int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- sdi = get_sigrok_device_instance(device_instances, device_index);
+ sdi = get_sr_device_instance(device_instances, device_index);
if (sdi)
return sdi->status;
else
static int hw_set_configuration(int device_index, int capability, void *value)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
uint64_t *tmp_u64;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
switch (capability) {
static int hw_start_acquisition(int device_index, gpointer session_device_id)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
struct datafeed_packet packet;
struct datafeed_header header;
int res;
unsigned int packet_num;
unsigned char *buf;
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return SR_ERR;
/* push configured settings to device */
static void hw_stop_acquisition(int device_index, gpointer session_device_id)
{
struct datafeed_packet packet;
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
packet.type = DF_END;
session_bus(session_device_id, &packet);
- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
+ if (!(sdi = get_sr_device_instance(device_instances, device_index)))
return; /* TODO: Cry? */
analyzer_reset(sdi->usb->devhdl);
return plugins;
}
-struct sigrok_device_instance *sigrok_device_instance_new(int index, int status,
+struct sr_device_instance *sr_device_instance_new(int index, int status,
const char *vendor, const char *model, const char *version)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
- if (!(sdi = malloc(sizeof(struct sigrok_device_instance))))
+ if (!(sdi = malloc(sizeof(struct sr_device_instance))))
return NULL;
sdi->index = index;
return sdi;
}
-struct sigrok_device_instance *get_sigrok_device_instance(
+struct sr_device_instance *get_sr_device_instance(
GSList *device_instances, int device_index)
{
- struct sigrok_device_instance *sdi;
+ struct sr_device_instance *sdi;
GSList *l;
for (l = device_instances; l; l = l->next) {
- sdi = (struct sigrok_device_instance *)(l->data);
+ sdi = (struct sr_device_instance *)(l->data);
if (sdi->index == device_index)
return sdi;
}
return NULL;
}
-void sigrok_device_instance_free(struct sigrok_device_instance *sdi)
+void sr_device_instance_free(struct sr_device_instance *sdi)
{
switch (sdi->instance_type) {
case USB_INSTANCE:
* @return A malloc()ed string representation of the samplerate value,
* or NULL upon errors. The caller is responsible to free() the memory.
*/
-char *sigrok_samplerate_string(uint64_t samplerate)
+char *sr_samplerate_string(uint64_t samplerate)
{
char *o;
int r;
* @return A malloc()ed string representation of the frequency value,
* or NULL upon errors. The caller is responsible to free() the memory.
*/
-char *sigrok_period_string(uint64_t frequency)
+char *sr_period_string(uint64_t frequency)
{
char *o;
int r;
if (o->device->plugin) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info(
o->device->plugin_index, DI_CUR_SAMPLERATE));
- if (!(samplerate_s = sigrok_samplerate_string(samplerate))) {
+ if (!(samplerate_s = sr_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
return SR_ERR;
if (o->device->plugin) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info(
o->device->plugin_index, DI_CUR_SAMPLERATE));
- if (!(frequency_s = sigrok_samplerate_string(samplerate))) {
+ if (!(frequency_s = sr_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
return SR_ERR;
sprintf(c, "# %d\t\t%s\n", i + 1, ctx->probelist[i]);
}
- if (!(frequency_s = sigrok_period_string(samplerate))) {
+ if (!(frequency_s = sr_period_string(samplerate))) {
free(ctx->header);
free(ctx);
return SR_ERR;
if (o->device->plugin) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info(
o->device->plugin_index, DI_CUR_SAMPLERATE));
- if (!(frequency_s = sigrok_samplerate_string(samplerate))) {
+ if (!(frequency_s = sr_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
return SR_ERR;
sprintf(c, "# %d\t\t%s\n", i + 1, ctx->probelist[i]);
}
- if (!(frequency_s = sigrok_period_string(samplerate))) {
+ if (!(frequency_s = sr_period_string(samplerate))) {
free(ctx->header);
free(ctx);
return SR_ERR;
if (o->device->plugin) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info(
o->device->plugin_index, DI_CUR_SAMPLERATE));
- if (!(frequency_s = sigrok_samplerate_string(samplerate))) {
+ if (!(frequency_s = sr_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
return SR_ERR;
sprintf(c, "# %d\t\t%s\n", i + 1, ctx->probelist[i]);
}
- if (!(frequency_s = sigrok_period_string(samplerate))) {
+ if (!(frequency_s = sr_period_string(samplerate))) {
free(ctx->header);
free(ctx);
return SR_ERR;
if (o->device->plugin) {
ctx->samplerate = *((uint64_t *) o->device->plugin->get_device_info(
o->device->plugin_index, DI_CUR_SAMPLERATE));
- if (!((samplerate_s = sigrok_samplerate_string(ctx->samplerate)))) {
+ if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) {
g_string_free(ctx->header, TRUE);
free(ctx);
return SR_ERR;
ctx->period = MHZ(1);
else
ctx->period = KHZ(1);
- if (!(frequency_s = sigrok_period_string(ctx->period))) {
+ if (!(frequency_s = sr_period_string(ctx->period))) {
g_string_free(ctx->header, TRUE);
free(ctx);
return SR_ERR;
if (o->device->plugin) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info(
o->device->plugin_index, DI_CUR_SAMPLERATE));
- if (!(samplerate_s = sigrok_samplerate_string(samplerate))) {
+ if (!(samplerate_s = sr_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
return SR_ERR;
/*--- hardware/common/misc.c ------------------------------------------------*/
-int opendev2(int device_index, struct sigrok_device_instance **sdi,
+int opendev2(int device_index, struct sr_device_instance **sdi,
libusb_device *dev, struct libusb_device_descriptor *des,
int *skip, uint16_t vid, uint16_t pid, int interface);
-int opendev3(struct sigrok_device_instance **sdi, libusb_device *dev,
+int opendev3(struct sr_device_instance **sdi, libusb_device *dev,
struct libusb_device_descriptor *des,
uint16_t vid, uint16_t pid, int interface);
/*--- backend.c -------------------------------------------------------------*/
-int sigrok_init(void);
-void sigrok_cleanup(void);
+int sr_init(void);
+void sr_cleanup(void);
/*--- datastore.c -----------------------------------------------------------*/
GSList *list_hwplugins(void);
/* Generic device instances */
-struct sigrok_device_instance *sigrok_device_instance_new(int index,
+struct sr_device_instance *sr_device_instance_new(int index,
int status, const char *vendor, const char *model, const char *version);
-struct sigrok_device_instance *get_sigrok_device_instance(
+struct sr_device_instance *get_sr_device_instance(
GSList *device_instances, int device_index);
-void sigrok_device_instance_free(struct sigrok_device_instance *sdi);
+void sr_device_instance_free(struct sr_device_instance *sdi);
/* USB-specific instances */
struct usb_device_instance *usb_device_instance_new(uint8_t bus,
/*--- output/common.c -------------------------------------------------------*/
-char *sigrok_samplerate_string(uint64_t samplerate);
-char *sigrok_period_string(uint64_t frequency);
+char *sr_samplerate_string(uint64_t samplerate);
+char *sr_period_string(uint64_t frequency);
#endif
char *shortname;
};
-struct sigrok_device_instance {
+struct sr_device_instance {
int index;
int status;
int instance_type;
};
};
-/* sigrok_device_instance types */
+/* sr_device_instance types */
enum {
USB_INSTANCE,
SERIAL_INSTANCE,
/* Device info IDs */
enum {
- /* struct sigrok_device_instance for this specific device */
+ /* struct sr_device_instance for this specific device */
DI_INSTANCE,
/* The number of probes connected to this device */
DI_NUM_PROBES,