Also, a few s/instance/inst/ occurences.
#include "sigrok.h"
#include "sigrok-internal.h"
-static GSList *devices = NULL;
+static GSList *devs = NULL;
/**
* Scan the system for attached logic analyzers / devices.
SR_API int sr_dev_scan(void)
{
GSList *plugins, *l;
- struct sr_device_plugin *plugin;
+ struct sr_dev_plugin *plugin;
if (!(plugins = sr_hw_list())) {
sr_err("dev: %s: no supported devices/hwplugins", __func__);
*/
SR_API GSList *sr_dev_list(void)
{
- if (!devices)
+ if (!devs)
sr_dev_scan();
- return devices;
+ return devs;
}
/**
*
* @return Pointer to the newly allocated device, or NULL upon errors.
*/
-SR_API struct sr_device *sr_dev_new(const struct sr_device_plugin *plugin,
- int plugin_index)
+SR_API struct sr_dev *sr_dev_new(const struct sr_dev_plugin *plugin,
+ int plugin_index)
{
- struct sr_device *device;
+ struct sr_dev *dev;
/* TODO: Check if plugin_index valid? */
- if (!(device = g_try_malloc0(sizeof(struct sr_device)))) {
- sr_err("dev: %s: device malloc failed", __func__);
+ if (!(dev = g_try_malloc0(sizeof(struct sr_dev)))) {
+ sr_err("dev: %s: dev malloc failed", __func__);
return NULL;
}
- device->plugin = (struct sr_device_plugin *)plugin;
- device->plugin_index = plugin_index;
- devices = g_slist_append(devices, device);
+ dev->plugin = (struct sr_dev_plugin *)plugin;
+ dev->plugin_index = plugin_index;
+ devs = g_slist_append(devs, dev);
- return device;
+ return dev;
}
/**
* TODO: Error if the max. probe number for the specific LA is reached, e.g.
* if the caller tries to add more probes than the device actually has.
*
- * @param device The device to which to add a probe with the specified name.
- * Must not be NULL.
+ * @param dev The device to which to add a probe with the specified name.
+ * Must not be NULL.
* @param name The name of the probe to add to this device. Must not be NULL.
* TODO: Maximum length, allowed characters, etc.
*
* @return SR_OK upon success, SR_ERR_MALLOC upon memory allocation errors,
* or SR_ERR_ARG upon invalid arguments.
- * If something other than SR_OK is returned, 'device' is unchanged.
+ * If something other than SR_OK is returned, 'dev' is unchanged.
*/
-SR_API int sr_dev_probe_add(struct sr_device *device, const char *name)
+SR_API int sr_dev_probe_add(struct sr_dev *dev, const char *name)
{
struct sr_probe *p;
int probenum;
- if (!device) {
- sr_err("dev: %s: device was NULL", __func__);
+ if (!dev) {
+ sr_err("dev: %s: dev was NULL", __func__);
return SR_ERR_ARG;
}
/* TODO: Further checks to ensure name is valid. */
- probenum = g_slist_length(device->probes) + 1;
+ probenum = g_slist_length(dev->probes) + 1;
if (!(p = g_try_malloc0(sizeof(struct sr_probe)))) {
sr_err("dev: %s: p malloc failed", __func__);
p->enabled = TRUE;
p->name = g_strdup(name);
p->trigger = NULL;
- device->probes = g_slist_append(device->probes, p);
+ dev->probes = g_slist_append(dev->probes, p);
return SR_OK;
}
*
* TODO
*
- * @param device TODO. Must not be NULL.
+ * @param dev TODO. Must not be NULL.
* @param probenum The number of the probe whose 'struct sr_probe' we want.
* Note that the probe numbers start at 1 (not 0!).
*
* @return A pointer to the requested probe's 'struct sr_probe', or NULL
* if the probe could not be found.
*/
-SR_API struct sr_probe *sr_dev_probe_find(const struct sr_device *device,
- int probenum)
+SR_API struct sr_probe *sr_dev_probe_find(const struct sr_dev *dev,
+ int probenum)
{
GSList *l;
struct sr_probe *p, *found_probe;
- if (!device) {
- sr_err("dev: %s: device was NULL", __func__);
+ if (!dev) {
+ sr_err("dev: %s: dev was NULL", __func__);
return NULL; /* TODO: SR_ERR_ARG */
}
/* TODO: Sanity check on probenum. */
found_probe = NULL;
- for (l = device->probes; l; l = l->next) {
+ for (l = dev->probes; l; l = l->next) {
p = l->data;
/* TODO: Check for p != NULL. */
if (p->index == probenum) {
* If the probe already has a different name assigned to it, it will be
* removed, and the new name will be saved instead.
*
- * TODO: Rename to sr_device_set_probe_name().
+ * TODO: Rename to sr_dev_probe_name_set().
*
- * @param device TODO
+ * @param dev TODO
* @param probenum The number of the probe whose name to set.
* Note that the probe numbers start at 1 (not 0!).
* @param name The new name that the specified probe should get.
*
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or SR_ERR
* upon other errors.
- * If something other than SR_OK is returned, 'device' is unchanged.
+ * If something other than SR_OK is returned, 'dev' is unchanged.
*/
-SR_API int sr_dev_probe_name(struct sr_device *device, int probenum,
- const char *name)
+SR_API int sr_dev_probe_name(struct sr_dev *dev, int probenum,
+ const char *name)
{
struct sr_probe *p;
- if (!device) {
- sr_err("dev: %s: device was NULL", __func__);
+ if (!dev) {
+ sr_err("dev: %s: dev was NULL", __func__);
return SR_ERR_ARG;
}
- p = sr_dev_probe_find(device, probenum);
+ p = sr_dev_probe_find(dev, probenum);
if (!p) {
sr_err("dev: %s: probe %d not found", __func__, probenum);
return SR_ERR; /* TODO: More specific error? */
*
* TODO: Better description.
*
- * @param device TODO
+ * @param dev TODO
*
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
- * If something other than SR_OK is returned, 'device' is unchanged.
+ * If something other than SR_OK is returned, 'dev' is unchanged.
*/
-SR_API int sr_dev_trigger_clear(struct sr_device *device)
+SR_API int sr_dev_trigger_clear(struct sr_dev *dev)
{
struct sr_probe *p;
unsigned int pnum; /* TODO: uint16_t? */
- if (!device) {
- sr_err("dev: %s: device was NULL", __func__);
+ if (!dev) {
+ sr_err("dev: %s: dev was NULL", __func__);
return SR_ERR_ARG;
}
- if (!device->probes) {
- sr_err("dev: %s: device->probes was NULL", __func__);
+ if (!dev->probes) {
+ sr_err("dev: %s: dev->probes was NULL", __func__);
return SR_ERR_ARG;
}
- for (pnum = 1; pnum <= g_slist_length(device->probes); pnum++) {
- p = sr_dev_probe_find(device, pnum);
+ for (pnum = 1; pnum <= g_slist_length(dev->probes); pnum++) {
+ p = sr_dev_probe_find(dev, pnum);
/* TODO: Silently ignore probes which cannot be found? */
if (p) {
g_free(p->trigger);
* TODO: Better description.
* TODO: Describe valid format of the 'trigger' string.
*
- * @param device TODO. Must not be NULL.
+ * @param dev TODO. Must not be NULL.
* @param probenum The number of the probe. TODO.
* Note that the probe numbers start at 1 (not 0!).
* @param trigger TODO.
*
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or SR_ERR
* upon other errors.
- * If something other than SR_OK is returned, 'device' is unchanged.
+ * If something other than SR_OK is returned, 'dev' is unchanged.
*/
-SR_API int sr_dev_trigger_set(struct sr_device *device, int probenum,
- const char *trigger)
+SR_API int sr_dev_trigger_set(struct sr_dev *dev, int probenum,
+ const char *trigger)
{
struct sr_probe *p;
- if (!device) {
- sr_err("dev: %s: device was NULL", __func__);
+ if (!dev) {
+ sr_err("dev: %s: dev was NULL", __func__);
return SR_ERR_ARG;
}
/* TODO: Sanity check on 'trigger'. */
- p = sr_dev_probe_find(device, probenum);
+ p = sr_dev_probe_find(dev, probenum);
if (!p) {
sr_err("dev: %s: probe %d not found", __func__, probenum);
return SR_ERR; /* TODO: More specific error? */
*
* TODO: Should return int?
*
- * @param device Pointer to the device to be checked. Must not be NULL.
- * The device's 'plugin' field must not be NULL either.
+ * @param dev Pointer to the device to be checked. Must not be NULL.
+ * The device's 'plugin' field must not be NULL either.
* @param hwcap The capability that should be checked (whether it's supported
* by the specified device).
*
* FALSE is also returned upon invalid input parameters or other
* error conditions.
*/
-SR_API gboolean sr_dev_has_hwcap(const struct sr_device *device, int hwcap)
+SR_API gboolean sr_dev_has_hwcap(const struct sr_dev *dev, int hwcap)
{
int *capabilities, i;
- if (!device) {
- sr_err("dev: %s: device was NULL", __func__);
+ if (!dev) {
+ sr_err("dev: %s: dev was NULL", __func__);
return FALSE; /* TODO: SR_ERR_ARG. */
}
- if (!device->plugin) {
- sr_err("dev: %s: device->plugin was NULL", __func__);
+ if (!dev->plugin) {
+ sr_err("dev: %s: dev->plugin was NULL", __func__);
return FALSE; /* TODO: SR_ERR_ARG. */
}
/* TODO: Sanity check on 'hwcap'. */
- if (!(capabilities = device->plugin->get_capabilities())) {
- sr_err("dev: %s: device has no capabilities", __func__);
+ if (!(capabilities = dev->plugin->get_capabilities())) {
+ sr_err("dev: %s: dev has no capabilities", __func__);
return FALSE; /* TODO: SR_ERR*. */
}
/**
* Returns information about the given device.
*
- * @param device Pointer to the device to be checked. Must not be NULL.
- * The device's 'plugin' field must not be NULL either.
+ * @param dev Pointer to the device to be checked. Must not be NULL.
+ * The device's 'plugin' field must not be NULL either.
* @param id The type of information.
* @param data The return value. Must not be NULL.
*
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or SR_ERR
* upon other errors.
*/
-SR_API int sr_dev_info_get(const struct sr_device *device, int id,
- const void **data)
+SR_API int sr_dev_info_get(const struct sr_dev *dev, int id, const void **data)
{
- if ((device == NULL) || (device->plugin == NULL))
+ if ((dev == NULL) || (dev->plugin == NULL))
return SR_ERR_ARG;
if (data == NULL)
return SR_ERR_ARG;
- *data = device->plugin->get_device_info(device->plugin_index, id);
+ *data = dev->plugin->get_dev_info(dev->plugin_index, id);
if (*data == NULL)
return SR_ERR;
gpointer session_id;
};
-static int hw_init(const char *deviceinfo)
+static int hw_init(const char *devinfo)
{
struct sr_dev_inst *sdi;
struct alsa *alsa;
/* Avoid compiler warnings. */
- deviceinfo = deviceinfo;
+ devinfo = devinfo;
if (!(alsa = g_try_malloc0(sizeof(struct alsa)))) {
sr_err("alsa: %s: alsa malloc failed", __func__);
return 0;
}
-static int hw_opendev(int device_index)
+static int hw_opendev(int dev_index)
{
struct sr_dev_inst *sdi;
struct alsa *alsa;
int err;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
alsa = sdi->priv;
return SR_OK;
}
-static int hw_closedev(int device_index)
+static int hw_closedev(int dev_index)
{
struct sr_dev_inst *sdi;
struct alsa *alsa;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("alsa: %s: sdi was NULL", __func__);
return SR_ERR; /* TODO: SR_ERR_ARG? */
}
return SR_OK;
}
-static void *hw_get_device_info(int device_index, int device_info_id)
+static void *hw_get_dev_info(int dev_index, int dev_info_id)
{
struct sr_dev_inst *sdi;
struct alsa *alsa;
void *info = NULL;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return NULL;
alsa = sdi->priv;
- switch (device_info_id) {
+ switch (dev_info_id) {
case SR_DI_INSTANCE:
info = sdi;
break;
return info;
}
-static int hw_get_status(int device_index)
+static int hw_get_status(int dev_index)
{
/* Avoid compiler warnings. */
- device_index = device_index;
+ dev_index = dev_index;
return SR_ST_ACTIVE;
}
return capabilities;
}
-static int hw_set_configuration(int device_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int capability, void *value)
{
struct sr_dev_inst *sdi;
struct alsa *alsa;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
alsa = sdi->priv;
return TRUE;
}
-static int hw_start_acquisition(int device_index, gpointer session_device_id)
+static int hw_start_acquisition(int dev_index, gpointer session_dev_id)
{
struct sr_dev_inst *sdi;
struct alsa *alsa;
int count;
int err;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
alsa = sdi->priv;
return SR_ERR;
}
- alsa->session_id = session_device_id;
+ alsa->session_id = session_dev_id;
sr_source_add(ufds[0].fd, ufds[0].events, 10, receive_data, sdi);
packet.type = SR_DF_HEADER;
header.num_analog_probes = NUM_PROBES;
header.num_logic_probes = 0;
header.protocol_id = SR_PROTO_RAW;
- sr_session_bus(session_device_id, &packet);
+ sr_session_bus(session_dev_id, &packet);
g_free(ufds);
return SR_OK;
}
-static int hw_stop_acquisition(int device_index, gpointer session_device_id)
+static int hw_stop_acquisition(int dev_index, gpointer session_dev_id)
{
/* Avoid compiler warnings. */
- device_index = device_index;
- session_device_id = session_device_id;
+ dev_index = dev_index;
+ session_dev_id = session_dev_id;
return SR_OK;
}
-SR_PRIV struct sr_device_plugin alsa_plugin_info = {
+SR_PRIV struct sr_dev_plugin alsa_plugin_info = {
.name = "alsa",
.longname = "ALSA driver",
.api_version = 1,
.cleanup = hw_cleanup,
.opendev = hw_opendev,
.closedev = hw_closedev,
- .get_device_info = hw_get_device_info,
+ .get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
.get_capabilities = hw_get_capabilities,
.set_configuration = hw_set_configuration,
"asix-sigma-phasor.fw", /* Frequency counter */
};
-static int hw_stop_acquisition(int device_index, gpointer session_data);
+static int hw_stop_acquisition(int dev_index, gpointer session_data);
static int sigma_read(void *buf, size_t size, struct sigma *sigma)
{
return SR_OK;
}
-static int hw_init(const char *deviceinfo)
+static int hw_init(const char *devinfo)
{
struct sr_dev_inst *sdi;
struct sigma *sigma;
/* Avoid compiler warnings. */
- (void)deviceinfo;
+ (void)devinfo;
if (!(sigma = g_try_malloc(sizeof(struct sigma)))) {
sr_err("sigma: %s: sigma malloc failed", __func__);
return SR_OK;
}
-static int hw_opendev(int device_index)
+static int hw_opendev(int dev_index)
{
struct sr_dev_inst *sdi;
struct sigma *sigma;
int ret;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
sigma = sdi->priv;
return SR_OK;
}
-static int hw_closedev(int device_index)
+static int hw_closedev(int dev_index)
{
struct sr_dev_inst *sdi;
struct sigma *sigma;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("sigma: %s: sdi was NULL", __func__);
return SR_ERR; /* TODO: SR_ERR_ARG? */
}
return ret;
}
-static void *hw_get_device_info(int device_index, int device_info_id)
+static void *hw_get_dev_info(int dev_index, int dev_info_id)
{
struct sr_dev_inst *sdi;
struct sigma *sigma;
void *info = NULL;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("sigma: %s: sdi was NULL", __func__);
return NULL;
}
sigma = sdi->priv;
- switch (device_info_id) {
+ switch (dev_info_id) {
case SR_DI_INSTANCE:
info = sdi;
break;
return info;
}
-static int hw_get_status(int device_index)
+static int hw_get_status(int dev_index)
{
struct sr_dev_inst *sdi;
- sdi = sr_dev_inst_get(dev_insts, device_index);
+ sdi = sr_dev_inst_get(dev_insts, dev_index);
if (sdi)
return sdi->status;
else
return capabilities;
}
-static int hw_set_configuration(int device_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int capability, void *value)
{
struct sr_dev_inst *sdi;
struct sigma *sigma;
int ret;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
sigma = sdi->priv;
return SR_OK;
}
-static int hw_start_acquisition(int device_index, gpointer session_data)
+static int hw_start_acquisition(int dev_index, gpointer session_data)
{
struct sr_dev_inst *sdi;
struct sigma *sigma;
/* Avoid compiler warnings. */
(void)session_data;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
sigma = sdi->priv;
return SR_OK;
}
-static int hw_stop_acquisition(int device_index, gpointer session_data)
+static int hw_stop_acquisition(int dev_index, gpointer session_data)
{
struct sr_dev_inst *sdi;
struct sigma *sigma;
/* Avoid compiler warnings. */
(void)session_data;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("sigma: %s: sdi was NULL", __func__);
return SR_ERR_BUG;
}
return SR_OK;
}
-SR_PRIV struct sr_device_plugin asix_sigma_plugin_info = {
+SR_PRIV struct sr_dev_plugin asix_sigma_plugin_info = {
.name = "asix-sigma",
.longname = "ASIX SIGMA",
.api_version = 1,
.cleanup = hw_cleanup,
.opendev = hw_opendev,
.closedev = hw_closedev,
- .get_device_info = hw_get_device_info,
+ .get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
.get_capabilities = hw_get_capabilities,
.set_configuration = hw_set_configuration,
uint8_t divcount;
};
-/* This will be initialized via hw_get_device_info()/SR_DI_SAMPLERATES. */
+/* This will be initialized via hw_get_dev_info()/SR_DI_SAMPLERATES. */
static uint64_t supported_samplerates[255 + 1] = { 0 };
/*
/* Function prototypes. */
static int la8_close_usb_reset_sequencer(struct la8 *la8);
-static int hw_stop_acquisition(int device_index, gpointer session_data);
+static int hw_stop_acquisition(int dev_index, gpointer session_data);
static int la8_reset(struct la8 *la8);
static void fill_supported_samplerates_if_needed(void)
return SR_OK;
}
-static int hw_init(const char *deviceinfo)
+static int hw_init(const char *devinfo)
{
int ret;
struct sr_dev_inst *sdi;
struct la8 *la8;
/* Avoid compiler errors. */
- (void)deviceinfo;
+ (void)devinfo;
/* Allocate memory for our private driver context. */
if (!(la8 = g_try_malloc(sizeof(struct la8)))) {
return 0;
}
-static int hw_opendev(int device_index)
+static int hw_opendev(int dev_index)
{
int ret;
struct sr_dev_inst *sdi;
struct la8 *la8;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("la8: %s: sdi was NULL", __func__);
return SR_ERR; /* TODO: SR_ERR_ARG? */
}
return SR_OK;
}
-static int hw_closedev(int device_index)
+static int hw_closedev(int dev_index)
{
struct sr_dev_inst *sdi;
struct la8 *la8;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("la8: %s: sdi was NULL", __func__);
return SR_ERR; /* TODO: SR_ERR_ARG? */
}
return ret;
}
-static void *hw_get_device_info(int device_index, int device_info_id)
+static void *hw_get_dev_info(int dev_index, int dev_info_id)
{
struct sr_dev_inst *sdi;
struct la8 *la8;
sr_spew("la8: entering %s", __func__);
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("la8: %s: sdi was NULL", __func__);
return NULL;
}
return NULL;
}
- switch (device_info_id) {
+ switch (dev_info_id) {
case SR_DI_INSTANCE:
info = sdi;
break;
return info;
}
-static int hw_get_status(int device_index)
+static int hw_get_status(int dev_index)
{
struct sr_dev_inst *sdi;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("la8: %s: sdi was NULL, device not found", __func__);
return SR_ST_NOT_FOUND;
}
return capabilities;
}
-static int hw_set_configuration(int device_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int capability, void *value)
{
struct sr_dev_inst *sdi;
struct la8 *la8;
sr_spew("la8: entering %s", __func__);
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("la8: %s: sdi was NULL", __func__);
return SR_ERR; /* TODO: SR_ERR_ARG? */
}
return TRUE;
}
-static int hw_start_acquisition(int device_index, gpointer session_data)
+static int hw_start_acquisition(int dev_index, gpointer session_data)
{
struct sr_dev_inst *sdi;
struct la8 *la8;
sr_spew("la8: entering %s", __func__);
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("la8: %s: sdi was NULL", __func__);
return SR_ERR; /* TODO: SR_ERR_ARG? */
}
return SR_OK;
}
-static int hw_stop_acquisition(int device_index, gpointer session_data)
+static int hw_stop_acquisition(int dev_index, gpointer session_data)
{
struct sr_dev_inst *sdi;
struct la8 *la8;
sr_dbg("la8: stopping acquisition");
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("la8: %s: sdi was NULL", __func__);
return SR_ERR_BUG;
}
return SR_OK;
}
-SR_PRIV struct sr_device_plugin chronovu_la8_plugin_info = {
+SR_PRIV struct sr_dev_plugin chronovu_la8_plugin_info = {
.name = "chronovu-la8",
.longname = "ChronoVu LA8",
.api_version = 1,
.cleanup = hw_cleanup,
.opendev = hw_opendev,
.closedev = hw_closedev,
- .get_device_info = hw_get_device_info,
+ .get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
.get_capabilities = hw_get_capabilities,
.set_configuration = hw_set_configuration,
uint8_t sample_generator;
uint8_t thread_running;
uint64_t samples_counter;
- int device_index;
+ int dev_index;
gpointer session_data;
GTimer *timer;
};
static int capabilities[] = {
SR_HWCAP_LOGIC_ANALYZER,
- SR_HWCAP_DEMO_DEVICE,
+ SR_HWCAP_DEMO_DEV,
SR_HWCAP_SAMPLERATE,
SR_HWCAP_PATTERN_MODE,
SR_HWCAP_LIMIT_SAMPLES,
static GThread *my_thread;
static int thread_running;
-static int hw_stop_acquisition(int device_index, gpointer session_data);
+static int hw_stop_acquisition(int dev_index, gpointer session_data);
-static int hw_init(const char *deviceinfo)
+static int hw_init(const char *devinfo)
{
struct sr_dev_inst *sdi;
/* Avoid compiler warnings. */
- (void)deviceinfo;
+ (void)devinfo;
sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
if (!sdi) {
return 1;
}
-static int hw_opendev(int device_index)
+static int hw_opendev(int dev_index)
{
/* Avoid compiler warnings. */
- (void)device_index;
+ (void)dev_index;
/* Nothing needed so far. */
return SR_OK;
}
-static int hw_closedev(int device_index)
+static int hw_closedev(int dev_index)
{
/* Avoid compiler warnings. */
- (void)device_index;
+ (void)dev_index;
/* Nothing needed so far. */
return SR_OK;
}
-static void *hw_get_device_info(int device_index, int device_info_id)
+static void *hw_get_dev_info(int dev_index, int dev_info_id)
{
struct sr_dev_inst *sdi;
void *info = NULL;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("demo: %s: sdi was NULL", __func__);
return NULL;
}
- switch (device_info_id) {
+ switch (dev_info_id) {
case SR_DI_INSTANCE:
info = sdi;
break;
return info;
}
-static int hw_get_status(int device_index)
+static int hw_get_status(int dev_index)
{
/* Avoid compiler warnings. */
- (void)device_index;
+ (void)dev_index;
return SR_ST_ACTIVE;
}
return capabilities;
}
-static int hw_set_configuration(int device_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int capability, void *value)
{
int ret;
char *stropt;
/* Avoid compiler warnings. */
- (void)device_index;
+ (void)dev_index;
if (capability == SR_HWCAP_PROBECONFIG) {
/* Nothing to do, but must be supported */
return TRUE;
}
-static int hw_start_acquisition(int device_index, gpointer session_data)
+static int hw_start_acquisition(int dev_index, gpointer session_data)
{
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
mydata->sample_generator = default_pattern;
mydata->session_data = session_data;
- mydata->device_index = device_index;
+ mydata->dev_index = dev_index;
mydata->samples_counter = 0;
if (pipe(mydata->pipe_fds)) {
return SR_OK;
}
-static int hw_stop_acquisition(int device_index, gpointer session_data)
+static int hw_stop_acquisition(int dev_index, gpointer session_data)
{
/* Avoid compiler warnings. */
- (void)device_index;
+ (void)dev_index;
(void)session_data;
/* Stop generate thread. */
return SR_OK;
}
-SR_PRIV struct sr_device_plugin demo_plugin_info = {
+SR_PRIV struct sr_dev_plugin demo_plugin_info = {
.name = "demo",
.longname = "Demo driver and pattern generator",
.api_version = 1,
.cleanup = hw_cleanup,
.opendev = hw_opendev,
.closedev = hw_closedev,
- .get_device_info = hw_get_device_info,
+ .get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
.get_capabilities = hw_get_capabilities,
.set_configuration = hw_set_configuration,
return SR_OK;
}
-static int hw_init(const char *deviceinfo)
+static int hw_init(const char *devinfo)
{
struct sr_dev_inst *sdi;
int devcnt = 0;
struct udev *udev;
struct udev_enumerate *enumerate;
- struct udev_list_entry *devices, *dev_list_entry;
+ struct udev_list_entry *devs, *dev_list_entry;
struct mso *mso;
- deviceinfo = deviceinfo;
+ devinfo = devinfo;
/* It's easier to map usb<->serial using udev */
/*
enumerate = udev_enumerate_new(udev);
udev_enumerate_add_match_subsystem(enumerate, "usb-serial");
udev_enumerate_scan_devices(enumerate);
- devices = udev_enumerate_get_list_entry(enumerate);
- udev_list_entry_foreach(dev_list_entry, devices) {
+ devs = udev_enumerate_get_list_entry(enumerate);
+ udev_list_entry_foreach(dev_list_entry, devs) {
const char *syspath, *sysname, *idVendor, *idProduct,
*iSerial, *iProduct;
char path[32], manufacturer[32], product[32], hwrev[32];
return ret;
}
-static int hw_opendev(int device_index)
+static int hw_opendev(int dev_index)
{
struct sr_dev_inst *sdi;
struct mso *mso;
int ret = SR_ERR;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return ret;
mso = sdi->priv;
return SR_OK;
}
-static int hw_closedev(int device_index)
+static int hw_closedev(int dev_index)
{
struct sr_dev_inst *sdi;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("mso19: %s: sdi was NULL", __func__);
return SR_ERR; /* TODO: SR_ERR_ARG? */
}
return SR_OK;
}
-static void *hw_get_device_info(int device_index, int device_info_id)
+static void *hw_get_dev_info(int dev_index, int dev_info_id)
{
struct sr_dev_inst *sdi;
struct mso *mso;
void *info = NULL;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return NULL;
mso = sdi->priv;
- switch (device_info_id) {
+ switch (dev_info_id) {
case SR_DI_INSTANCE:
info = sdi;
break;
return info;
}
-static int hw_get_status(int device_index)
+static int hw_get_status(int dev_index)
{
struct sr_dev_inst *sdi;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ST_NOT_FOUND;
return sdi->status;
return capabilities;
}
-static int hw_set_configuration(int device_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int capability, void *value)
{
struct sr_dev_inst *sdi;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
switch (capability) {
return TRUE;
}
-static int hw_start_acquisition(int device_index, gpointer session_device_id)
+static int hw_start_acquisition(int dev_index, gpointer session_dev_id)
{
struct sr_dev_inst *sdi;
struct mso *mso;
struct sr_datafeed_header header;
int ret = SR_ERR;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return ret;
mso = sdi->priv;
if (ret != SR_OK)
return ret;
- mso->session_id = session_device_id;
+ mso->session_id = session_dev_id;
sr_source_add(sdi->serial->fd, G_IO_IN, -1, receive_data, sdi);
packet.type = SR_DF_HEADER;
header.samplerate = mso->cur_rate;
// header.num_analog_probes = 1;
header.num_logic_probes = 8;
- sr_session_bus(session_device_id, &packet);
+ sr_session_bus(session_dev_id, &packet);
return ret;
}
/* FIXME */
-static int hw_stop_acquisition(int device_index, gpointer session_device_id)
+static int hw_stop_acquisition(int dev_index, gpointer session_dev_id)
{
struct sr_datafeed_packet packet;
- device_index = device_index;
+ dev_index = dev_index;
packet.type = SR_DF_END;
- sr_session_bus(session_device_id, &packet);
+ sr_session_bus(session_dev_id, &packet);
return SR_OK;
}
-SR_PRIV struct sr_device_plugin link_mso19_plugin_info = {
+SR_PRIV struct sr_dev_plugin link_mso19_plugin_info = {
.name = "link-mso19",
.longname = "Link Instruments MSO-19",
.api_version = 1,
.cleanup = hw_cleanup,
.opendev = hw_opendev,
.closedev = hw_closedev,
- .get_device_info = hw_get_device_info,
+ .get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
.get_capabilities = hw_get_capabilities,
.set_configuration = hw_set_configuration,
return SR_OK;
}
-static int configure_probes(struct ols_device *ols, GSList *probes)
+static int configure_probes(struct ols_dev *ols, GSList *probes)
{
struct sr_probe *probe;
GSList *l;
return out;
}
-static struct ols_device *ols_device_new(void)
+static struct ols_dev *ols_dev_new(void)
{
- struct ols_device *ols;
+ struct ols_dev *ols;
/* TODO: Is 'ols' ever g_free()'d? */
- if (!(ols = g_try_malloc0(sizeof(struct ols_device)))) {
+ if (!(ols = g_try_malloc0(sizeof(struct ols_dev)))) {
sr_err("ols: %s: ols malloc failed", __func__);
return NULL;
}
static struct sr_dev_inst *get_metadata(int fd)
{
struct sr_dev_inst *sdi;
- struct ols_device *ols;
+ struct ols_dev *ols;
uint32_t tmp_int;
uint8_t key, type, token;
- GString *tmp_str, *devicename, *version;
+ GString *tmp_str, *devname, *version;
gchar tmp_c;
sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, NULL, NULL, NULL);
- ols = ols_device_new();
+ ols = ols_dev_new();
sdi->priv = ols;
- devicename = g_string_new("");
+ devname = g_string_new("");
version = g_string_new("");
key = 0xff;
switch (token) {
case 0x01:
/* Device name */
- devicename = g_string_append(devicename, tmp_str->str);
+ devname = g_string_append(devname, tmp_str->str);
break;
case 0x02:
/* FPGA firmware version */
}
}
- sdi->model = devicename->str;
+ sdi->model = devname->str;
sdi->version = version->str;
- g_string_free(devicename, FALSE);
+ g_string_free(devname, FALSE);
g_string_free(version, FALSE);
return sdi;
}
-static int hw_init(const char *deviceinfo)
+static int hw_init(const char *devinfo)
{
struct sr_dev_inst *sdi;
- struct ols_device *ols;
+ struct ols_dev *ols;
GSList *ports, *l;
GPollFD *fds, probefd;
int devcnt, final_devcnt, num_ports, fd, ret, i;
- char buf[8], **device_names, **serial_params;
+ char buf[8], **dev_names, **serial_params;
final_devcnt = 0;
- if (deviceinfo)
- ports = g_slist_append(NULL, g_strdup(deviceinfo));
+ if (devinfo)
+ ports = g_slist_append(NULL, g_strdup(devinfo));
else
/* No specific device given, so scan all serial ports. */
ports = list_serial_ports();
goto hw_init_free_ports; /* TODO: SR_ERR_MALLOC. */
}
- if (!(device_names = g_try_malloc(num_ports * sizeof(char *)))) {
- sr_err("ols: %s: device_names malloc failed", __func__);
+ if (!(dev_names = g_try_malloc(num_ports * sizeof(char *)))) {
+ sr_err("ols: %s: dev_names malloc failed", __func__);
goto hw_init_free_fds; /* TODO: SR_ERR_MALLOC. */
}
if (!(serial_params = g_try_malloc(num_ports * sizeof(char *)))) {
sr_err("ols: %s: serial_params malloc failed", __func__);
- goto hw_init_free_device_names; /* TODO: SR_ERR_MALLOC. */
+ goto hw_init_free_dev_names; /* TODO: SR_ERR_MALLOC. */
}
devcnt = 0;
send_shortcommand(fd, CMD_ID);
fds[devcnt].fd = fd;
fds[devcnt].events = G_IO_IN;
- device_names[devcnt] = g_strdup(l->data);
+ dev_names[devcnt] = g_strdup(l->data);
devcnt++;
}
g_free(l->data);
/* not an OLS -- some other board that uses the sump protocol */
sdi = sr_dev_inst_new(final_devcnt, SR_ST_INACTIVE,
"Sump", "Logic Analyzer", "v1.0");
- ols = ols_device_new();
+ ols = ols_dev_new();
ols->num_probes = 32;
sdi->priv = ols;
}
- ols->serial = sr_serial_dev_inst_new(device_names[i], -1);
+ ols->serial = sr_serial_dev_inst_new(dev_names[i], -1);
dev_insts = g_slist_append(dev_insts, sdi);
final_devcnt++;
serial_close(fds[i].fd);
serial_close(fds[i].fd);
}
g_free(serial_params[i]);
- g_free(device_names[i]);
+ g_free(dev_names[i]);
}
g_free(serial_params);
-hw_init_free_device_names:
- g_free(device_names);
+hw_init_free_dev_names:
+ g_free(dev_names);
hw_init_free_fds:
g_free(fds);
hw_init_free_ports:
return final_devcnt;
}
-static int hw_opendev(int device_index)
+static int hw_opendev(int dev_index)
{
struct sr_dev_inst *sdi;
- struct ols_device *ols;
+ struct ols_dev *ols;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
ols = sdi->priv;
return SR_OK;
}
-static int hw_closedev(int device_index)
+static int hw_closedev(int dev_index)
{
struct sr_dev_inst *sdi;
- struct ols_device *ols;
+ struct ols_dev *ols;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("ols: %s: sdi was NULL", __func__);
return SR_ERR; /* TODO: SR_ERR_ARG? */
}
{
GSList *l;
struct sr_dev_inst *sdi;
- struct ols_device *ols;
+ struct ols_dev *ols;
int ret = SR_OK;
/* Properly close and free all devices. */
return ret;
}
-static void *hw_get_device_info(int device_index, int device_info_id)
+static void *hw_get_dev_info(int dev_index, int dev_info_id)
{
struct sr_dev_inst *sdi;
- struct ols_device *ols;
+ struct ols_dev *ols;
void *info;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return NULL;
ols = sdi->priv;
info = NULL;
- switch (device_info_id) {
+ switch (dev_info_id) {
case SR_DI_INSTANCE:
info = sdi;
break;
return info;
}
-static int hw_get_status(int device_index)
+static int hw_get_status(int dev_index)
{
struct sr_dev_inst *sdi;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ST_NOT_FOUND;
return sdi->status;
static int set_configuration_samplerate(struct sr_dev_inst *sdi,
uint64_t samplerate)
{
- struct ols_device *ols;
+ struct ols_dev *ols;
ols = sdi->priv;
if (ols->max_samplerate) {
return SR_OK;
}
-static int hw_set_configuration(int device_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int capability, void *value)
{
struct sr_dev_inst *sdi;
- struct ols_device *ols;
+ struct ols_dev *ols;
int ret;
uint64_t *tmp_u64;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
ols = sdi->priv;
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
struct sr_dev_inst *sdi;
- struct ols_device *ols;
+ struct ols_dev *ols;
GSList *l;
int num_channels, offset, i, j;
unsigned char byte;
- /* find this device's ols_device struct by its fd */
+ /* find this device's ols_dev struct by its fd */
ols = NULL;
for (l = dev_insts; l; l = l->next) {
sdi = l->data;
return TRUE;
}
-static int hw_start_acquisition(int device_index, gpointer session_data)
+static int hw_start_acquisition(int dev_index, gpointer session_data)
{
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
struct sr_dev_inst *sdi;
- struct ols_device *ols;
+ struct ols_dev *ols;
uint32_t trigger_config[4];
uint32_t data;
uint16_t readcount, delaycount;
int num_channels;
int i;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
ols = sdi->priv;
return SR_OK;
}
-static int hw_stop_acquisition(int device_index, gpointer session_device_id)
+static int hw_stop_acquisition(int dev_index, gpointer session_dev_id)
{
struct sr_datafeed_packet packet;
/* Avoid compiler warnings. */
- (void)device_index;
+ (void)dev_index;
packet.type = SR_DF_END;
- sr_session_bus(session_device_id, &packet);
+ sr_session_bus(session_dev_id, &packet);
return SR_OK;
}
-SR_PRIV struct sr_device_plugin ols_plugin_info = {
+SR_PRIV struct sr_dev_plugin ols_plugin_info = {
.name = "ols",
.longname = "Openbench Logic Sniffer",
.api_version = 1,
.cleanup = hw_cleanup,
.opendev = hw_opendev,
.closedev = hw_closedev,
- .get_device_info = hw_get_device_info,
+ .get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
.get_capabilities = hw_get_capabilities,
.set_configuration = hw_set_configuration,
#define FLAG_CLOCK_INVERTED 0x80
#define FLAG_RLE 0x0100
-struct ols_device {
+struct ols_dev {
uint32_t max_samplerate;
uint32_t max_samples;
uint32_t protocol_version;
static int new_saleae_logic_firmware = 0;
-static int hw_set_configuration(int device_index, int capability, void *value);
-static int hw_stop_acquisition(int device_index, gpointer session_device_id);
+static int hw_set_configuration(int dev_index, int capability, void *value);
+static int hw_stop_acquisition(int dev_index, gpointer session_dev_id);
/**
* Check the USB configuration to determine if this is a Saleae Logic.
return ret;
}
-static int sl_open_device(int device_index)
+static int sl_open_dev(int dev_index)
{
libusb_device **devlist;
struct libusb_device_descriptor des;
struct sr_dev_inst *sdi;
- struct fx2_device *fx2;
+ struct fx2_dev *fx2;
int err, skip, i;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
fx2 = sdi->priv;
continue;
if (sdi->status == SR_ST_INITIALIZING) {
- if (skip != device_index) {
+ if (skip != dev_index) {
/* Skip devices of this type that aren't the one we want. */
skip += 1;
continue;
return SR_OK;
}
-static void close_device(struct sr_dev_inst *sdi)
+static void close_dev(struct sr_dev_inst *sdi)
{
- struct fx2_device *fx2;
+ struct fx2_dev *fx2;
fx2 = sdi->priv;
sdi->status = SR_ST_INACTIVE;
}
-static int configure_probes(struct fx2_device *fx2, GSList *probes)
+static int configure_probes(struct fx2_dev *fx2, GSList *probes)
{
struct sr_probe *probe;
GSList *l;
return SR_OK;
}
-static struct fx2_device *fx2_device_new(void)
+static struct fx2_dev *fx2_dev_new(void)
{
- struct fx2_device *fx2;
+ struct fx2_dev *fx2;
- if (!(fx2 = g_try_malloc0(sizeof(struct fx2_device)))) {
+ if (!(fx2 = g_try_malloc0(sizeof(struct fx2_dev)))) {
sr_err("logic: %s: fx2 malloc failed", __func__);
return NULL;
}
* API callbacks
*/
-static int hw_init(const char *deviceinfo)
+static int hw_init(const char *devinfo)
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
struct fx2_profile *fx2_prof;
- struct fx2_device *fx2;
+ struct fx2_dev *fx2;
libusb_device **devlist;
int err, devcnt, i, j;
/* Avoid compiler warnings. */
- (void)deviceinfo;
+ (void)devinfo;
if (libusb_init(&usb_context) != 0) {
sr_err("logic: Failed to initialize USB.");
fx2_prof->vendor, fx2_prof->model, fx2_prof->model_version);
if (!sdi)
return 0;
- fx2 = fx2_device_new();
+ fx2 = fx2_dev_new();
fx2->profile = fx2_prof;
sdi->priv = fx2;
dev_insts = g_slist_append(dev_insts, sdi);
return devcnt;
}
-static int hw_opendev(int device_index)
+static int hw_opendev(int dev_index)
{
GTimeVal cur_time;
struct sr_dev_inst *sdi;
- struct fx2_device *fx2;
+ struct fx2_dev *fx2;
int timediff, err;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
fx2 = sdi->priv;
g_usleep(300 * 1000);
timediff = 0;
while (timediff < MAX_RENUM_DELAY) {
- if ((err = sl_open_device(device_index)) == SR_OK)
+ if ((err = sl_open_dev(dev_index)) == SR_OK)
break;
g_usleep(100 * 1000);
g_get_current_time(&cur_time);
}
sr_info("logic: device came back after %d ms", timediff);
} else {
- err = sl_open_device(device_index);
+ err = sl_open_dev(dev_index);
}
if (err != SR_OK) {
if (fx2->cur_samplerate == 0) {
/* Samplerate hasn't been set; default to the slowest one. */
- if (hw_set_configuration(device_index, SR_HWCAP_SAMPLERATE,
+ if (hw_set_configuration(dev_index, SR_HWCAP_SAMPLERATE,
&supported_samplerates[0]) == SR_ERR)
return SR_ERR;
}
return SR_OK;
}
-static int hw_closedev(int device_index)
+static int hw_closedev(int dev_index)
{
struct sr_dev_inst *sdi;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("logic: %s: sdi was NULL", __func__);
return SR_ERR; /* TODO: SR_ERR_ARG? */
}
/* TODO */
- close_device(sdi);
+ close_dev(sdi);
return SR_OK;
}
{
GSList *l;
struct sr_dev_inst *sdi;
- struct fx2_device *fx2;
+ struct fx2_dev *fx2;
int ret = SR_OK;
/* Properly close and free all devices. */
ret = SR_ERR_BUG;
continue;
}
- close_device(sdi);
+ close_dev(sdi);
sr_usb_dev_inst_free(fx2->usb);
sr_dev_inst_free(sdi);
}
return ret;
}
-static void *hw_get_device_info(int device_index, int device_info_id)
+static void *hw_get_dev_info(int dev_index, int dev_info_id)
{
struct sr_dev_inst *sdi;
- struct fx2_device *fx2;
+ struct fx2_dev *fx2;
void *info = NULL;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return NULL;
fx2 = sdi->priv;
- switch (device_info_id) {
+ switch (dev_info_id) {
case SR_DI_INSTANCE:
info = sdi;
break;
return info;
}
-static int hw_get_status(int device_index)
+static int hw_get_status(int dev_index)
{
struct sr_dev_inst *sdi;
- sdi = sr_dev_inst_get(dev_insts, device_index);
+ sdi = sr_dev_inst_get(dev_insts, dev_index);
if (sdi)
return sdi->status;
else
static int set_configuration_samplerate(struct sr_dev_inst *sdi,
uint64_t samplerate)
{
- struct fx2_device *fx2;
+ struct fx2_dev *fx2;
uint8_t divider;
int ret, result, i;
unsigned char buf[2];
return SR_OK;
}
-static int hw_set_configuration(int device_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int capability, void *value)
{
struct sr_dev_inst *sdi;
- struct fx2_device *fx2;
+ struct fx2_dev *fx2;
int ret;
uint64_t *tmp_u64;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
fx2 = sdi->priv;
static void receive_transfer(struct libusb_transfer *transfer)
{
- /* TODO: these statics have to move to fx2_device struct */
+ /* TODO: these statics have to move to fx2_dev struct */
static int num_samples = 0;
static int empty_transfer_count = 0;
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
- struct fx2_device *fx2;
+ struct fx2_dev *fx2;
int cur_buflen, trigger_offset, i;
unsigned char *cur_buf, *new_buf;
}
}
-static int hw_start_acquisition(int device_index, gpointer session_data)
+static int hw_start_acquisition(int dev_index, gpointer session_data)
{
struct sr_dev_inst *sdi;
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
- struct fx2_device *fx2;
+ struct fx2_dev *fx2;
struct libusb_transfer *transfer;
const struct libusb_pollfd **lupfd;
int size, i;
unsigned char *buf;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
fx2 = sdi->priv;
fx2->session_data = session_data;
return SR_OK;
}
-/* This stops acquisition on ALL devices, ignoring device_index. */
-static int hw_stop_acquisition(int device_index, gpointer session_data)
+/* This stops acquisition on ALL devices, ignoring dev_index. */
+static int hw_stop_acquisition(int dev_index, gpointer session_data)
{
struct sr_datafeed_packet packet;
/* Avoid compiler warnings. */
- (void)device_index;
+ (void)dev_index;
packet.type = SR_DF_END;
sr_session_bus(session_data, &packet);
return SR_OK;
}
-SR_PRIV struct sr_device_plugin saleae_logic_plugin_info = {
+SR_PRIV struct sr_dev_plugin saleae_logic_plugin_info = {
.name = "saleae-logic",
.longname = "Saleae Logic",
.api_version = 1,
.cleanup = hw_cleanup,
.opendev = hw_opendev,
.closedev = hw_closedev,
- .get_device_info = hw_get_device_info,
+ .get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
.get_capabilities = hw_get_capabilities,
.set_configuration = hw_set_configuration,
int num_probes;
};
-struct fx2_device {
+struct fx2_dev {
struct fx2_profile *profile;
/*
- * Since we can't keep track of a Saleae Logic device after upgrading the
- * firmware (it re-enumerates into a different device address after the
- * upgrade) this is like a global lock. No device will open until a proper
- * delay after the last device was upgraded.
+ * Since we can't keep track of a Saleae Logic device after upgrading
+ * the firmware (it re-enumerates into a different device address
+ * after the upgrade) this is like a global lock. No device will open
+ * until a proper delay after the last device was upgraded.
*/
GTimeVal fw_updated;
/* device/capture settings */
HARD_DATA_CHECK_SUM = 0x00,
PASS_WORD,
- DEVICE_ID0 = 0x10,
- DEVICE_ID1,
+ DEV_ID0 = 0x10,
+ DEV_ID1,
START_STATUS = 0x20,
- DEVICE_STATUS = 0x21,
+ DEV_STATUS = 0x21,
FREQUENCY_REG0 = 0x30,
FREQUENCY_REG1,
FREQUENCY_REG2,
{
int status;
while (1) {
- status = gl_reg_read(devh, DEVICE_STATUS);
+ status = gl_reg_read(devh, DEV_STATUS);
if ((status & set) && ((status & unset) == 0))
return;
}
SR_PRIV unsigned int analyzer_read_id(libusb_device_handle *devh)
{
- return gl_reg_read(devh, DEVICE_ID1) << 8 | gl_reg_read(devh,
- DEVICE_ID0);
+ return gl_reg_read(devh, DEV_ID1) << 8 | gl_reg_read(devh, DEV_ID0);
}
SR_PRIV unsigned int analyzer_get_stop_address(libusb_device_handle *devh)
struct sr_usb_dev_inst *usb;
};
-static int hw_set_configuration(int device_index, int capability, void *value);
+static int hw_set_configuration(int dev_index, int capability, void *value);
static unsigned int get_memory_size(int type)
{
return 0;
}
-static struct sr_dev_inst *zp_open_device(int device_index)
+static struct sr_dev_inst *zp_open_dev(int dev_index)
{
struct sr_dev_inst *sdi;
libusb_device **devlist;
struct libusb_device_descriptor des;
int err, i;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index)))
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return NULL;
libusb_get_device_list(usb_context, &devlist);
return sdi;
}
-static void close_device(struct sr_dev_inst *sdi)
+static void close_dev(struct sr_dev_inst *sdi)
{
struct zp *zp;
* API callbacks
*/
-static int hw_init(const char *deviceinfo)
+static int hw_init(const char *devinfo)
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
struct zp *zp;
/* Avoid compiler warnings. */
- (void)deviceinfo;
+ (void)devinfo;
/* Allocate memory for our private driver context. */
if (!(zp = g_try_malloc(sizeof(struct zp)))) {
return devcnt;
}
-static int hw_opendev(int device_index)
+static int hw_opendev(int dev_index)
{
struct sr_dev_inst *sdi;
struct zp *zp;
int err;
- if (!(sdi = zp_open_device(device_index))) {
+ if (!(sdi = zp_open_dev(dev_index))) {
sr_err("zp: unable to open device");
return SR_ERR;
}
- /* TODO: Note: sdi is retrieved in zp_open_device(). */
+ /* TODO: Note: sdi is retrieved in zp_open_dev(). */
if (!(zp = sdi->priv)) {
sr_err("zp: %s: sdi->priv was NULL", __func__);
if (zp->cur_samplerate == 0) {
/* Samplerate hasn't been set. Default to the slowest one. */
- if (hw_set_configuration(device_index, SR_HWCAP_SAMPLERATE,
+ if (hw_set_configuration(dev_index, SR_HWCAP_SAMPLERATE,
&samplerates.list[0]) == SR_ERR)
return SR_ERR;
}
return SR_OK;
}
-static int hw_closedev(int device_index)
+static int hw_closedev(int dev_index)
{
struct sr_dev_inst *sdi;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("zp: %s: sdi was NULL", __func__);
return SR_ERR; /* TODO: SR_ERR_ARG? */
}
/* TODO */
- close_device(sdi);
+ close_dev(sdi);
return SR_OK;
}
for (l = dev_insts; l; l = l->next) {
sdi = l->data;
/* Properly close all devices... */
- close_device(sdi);
+ close_dev(sdi);
/* ...and free all their memory. */
sr_dev_inst_free(sdi);
}
return SR_OK;
}
-static void *hw_get_device_info(int device_index, int device_info_id)
+static void *hw_get_dev_info(int dev_index, int dev_info_id)
{
struct sr_dev_inst *sdi;
struct zp *zp;
void *info;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("zp: %s: sdi was NULL", __func__);
return NULL;
}
return NULL;
}
- switch (device_info_id) {
+ switch (dev_info_id) {
case SR_DI_INSTANCE:
info = sdi;
break;
return info;
}
-static int hw_get_status(int device_index)
+static int hw_get_status(int dev_index)
{
struct sr_dev_inst *sdi;
- sdi = sr_dev_inst_get(dev_insts, device_index);
+ sdi = sr_dev_inst_get(dev_insts, dev_index);
if (sdi)
return sdi->status;
else
return SR_OK;
}
-static int hw_set_configuration(int device_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int capability, void *value)
{
struct sr_dev_inst *sdi;
uint64_t *tmp_u64;
struct zp *zp;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("zp: %s: sdi was NULL", __func__);
return SR_ERR;
}
}
}
-static int hw_start_acquisition(int device_index, gpointer session_data)
+static int hw_start_acquisition(int dev_index, gpointer session_data)
{
struct sr_dev_inst *sdi;
struct sr_datafeed_packet packet;
unsigned char *buf;
struct zp *zp;
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("zp: %s: sdi was NULL", __func__);
return SR_ERR;
}
return SR_OK;
}
-/* This stops acquisition on ALL devices, ignoring device_index. */
-static int hw_stop_acquisition(int device_index, gpointer session_device_id)
+/* This stops acquisition on ALL devices, ignoring dev_index. */
+static int hw_stop_acquisition(int dev_index, gpointer session_dev_id)
{
struct sr_datafeed_packet packet;
struct sr_dev_inst *sdi;
struct zp *zp;
packet.type = SR_DF_END;
- sr_session_bus(session_device_id, &packet);
+ sr_session_bus(session_dev_id, &packet);
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("zp: %s: sdi was NULL", __func__);
return SR_ERR_BUG;
}
return SR_OK;
}
-SR_PRIV struct sr_device_plugin zeroplus_logic_cube_plugin_info = {
+SR_PRIV struct sr_dev_plugin zeroplus_logic_cube_plugin_info = {
.name = "zeroplus-logic-cube",
.longname = "Zeroplus Logic Cube LAP-C series",
.api_version = 1,
.cleanup = hw_cleanup,
.opendev = hw_opendev,
.closedev = hw_closedev,
- .get_device_info = hw_get_device_info,
+ .get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
.get_capabilities = hw_get_capabilities,
.set_configuration = hw_set_configuration,
};
#ifdef HAVE_LA_DEMO
-extern struct sr_device_plugin demo_plugin_info;
+extern struct sr_dev_plugin demo_plugin_info;
#endif
#ifdef HAVE_LA_SALEAE_LOGIC
-extern struct sr_device_plugin saleae_logic_plugin_info;
+extern struct sr_dev_plugin saleae_logic_plugin_info;
#endif
#ifdef HAVE_LA_OLS
-extern struct sr_device_plugin ols_plugin_info;
+extern struct sr_dev_plugin ols_plugin_info;
#endif
#ifdef HAVE_LA_ZEROPLUS_LOGIC_CUBE
-extern struct sr_device_plugin zeroplus_logic_cube_plugin_info;
+extern struct sr_dev_plugin zeroplus_logic_cube_plugin_info;
#endif
#ifdef HAVE_LA_ASIX_SIGMA
-extern struct sr_device_plugin asix_sigma_plugin_info;
+extern struct sr_dev_plugin asix_sigma_plugin_info;
#endif
#ifdef HAVE_LA_CHRONOVU_LA8
-extern SR_PRIV struct device_plugin chronovu_la8_plugin_info;
+extern SR_PRIV struct dev_plugin chronovu_la8_plugin_info;
#endif
#ifdef HAVE_LA_LINK_MSO19
-extern struct sr_device_plugin link_mso19_plugin_info;
+extern struct sr_dev_plugin link_mso19_plugin_info;
#endif
#ifdef HAVE_LA_ALSA
-extern struct sr_device_plugin alsa_plugin_info;
+extern struct sr_dev_plugin alsa_plugin_info;
#endif
/* TODO: No linked list needed, this can be a simple array. */
*
* @return The number of devices found and instantiated by the plugin.
*/
-SR_API int sr_hw_init(struct sr_device_plugin *plugin)
+SR_API int sr_hw_init(struct sr_dev_plugin *plugin)
{
- int num_devices, num_probes, i, j;
- int num_initialized_devices = 0;
- struct sr_device *device;
+ int num_devs, num_probes, i, j;
+ int num_initialized_devs = 0;
+ struct sr_dev *dev;
char **probe_names;
sr_dbg("initializing %s plugin", plugin->name);
- num_devices = plugin->init(NULL);
- for (i = 0; i < num_devices; i++) {
+ num_devs = plugin->init(NULL);
+ for (i = 0; i < num_devs; i++) {
num_probes = GPOINTER_TO_INT(
- plugin->get_device_info(i, SR_DI_NUM_PROBES));
- probe_names = (char **)plugin->get_device_info(i,
+ plugin->get_dev_info(i, SR_DI_NUM_PROBES));
+ probe_names = (char **)plugin->get_dev_info(i,
SR_DI_PROBE_NAMES);
if (!probe_names) {
continue;
}
- device = sr_dev_new(plugin, i);
+ dev = sr_dev_new(plugin, i);
for (j = 0; j < num_probes; j++)
- sr_dev_probe_add(device, probe_names[j]);
- num_initialized_devices++;
+ sr_dev_probe_add(dev, probe_names[j]);
+ num_initialized_devs++;
}
- return num_initialized_devices;
+ return num_initialized_devs;
}
SR_PRIV void sr_hw_cleanup_all(void)
{
- struct sr_device_plugin *plugin;
+ struct sr_dev_plugin *plugin;
GSList *l;
for (l = plugins; l; l = l->next) {
return sdi;
}
-SR_PRIV struct sr_dev_inst *sr_dev_inst_get(GSList *dev_insts, int device_index)
+SR_PRIV struct sr_dev_inst *sr_dev_inst_get(GSList *dev_insts, int dev_index)
{
struct sr_dev_inst *sdi;
GSList *l;
for (l = dev_insts; l; l = l->next) {
sdi = (struct sr_dev_inst *)(l->data);
- if (sdi->index == device_index)
+ if (sdi->index == dev_index)
return sdi;
}
- sr_warn("could not find device index %d instance", device_index);
+ sr_warn("could not find device index %d instance", dev_index);
return NULL;
}
*
* @return TRUE if found, FALSE otherwise.
*/
-SR_API gboolean sr_hw_has_hwcap(struct sr_device_plugin *plugin, int hwcap)
+SR_API gboolean sr_hw_has_hwcap(struct sr_dev_plugin *plugin, int hwcap)
{
int *capabilities, i;
}
/* Create a virtual device. */
- in->vdevice = sr_dev_new(NULL, 0);
+ in->vdev = sr_dev_new(NULL, 0);
for (i = 0; i < num_probes; i++) {
snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i);
/* TODO: Check return value. */
- sr_dev_probe_add(in->vdevice, name);
+ sr_dev_probe_add(in->vdev, name);
}
return SR_OK;
if ((fd = open(filename, O_RDONLY)) == -1)
return SR_ERR;
- num_probes = g_slist_length(in->vdevice->probes);
+ num_probes = g_slist_length(in->vdev->probes);
/* send header */
header.feed_version = 1;
gettimeofday(&header.starttime, NULL);
packet.type = SR_DF_HEADER;
packet.payload = &header;
- sr_session_bus(in->vdevice, &packet);
+ sr_session_bus(in->vdev, &packet);
/* chop up the input file into chunks and feed it into the session bus */
packet.type = SR_DF_LOGIC;
logic.data = buffer;
while ((size = read(fd, buffer, CHUNKSIZE)) > 0) {
logic.length = size;
- sr_session_bus(in->vdevice, &packet);
+ sr_session_bus(in->vdev, &packet);
}
close(fd);
/* end of stream */
packet.type = SR_DF_END;
- sr_session_bus(in->vdevice, &packet);
+ sr_session_bus(in->vdev, &packet);
return SR_OK;
}
}
/* Create a virtual device. */
- in->vdevice = sr_dev_new(NULL, 0);
+ in->vdev = sr_dev_new(NULL, 0);
for (i = 0; i < num_probes; i++) {
snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i);
/* TODO: Check return value. */
- sr_dev_probe_add(in->vdevice, name);
+ sr_dev_probe_add(in->vdev, name);
}
return SR_OK;
return SR_ERR;
}
- num_probes = g_slist_length(in->vdevice->probes);
+ num_probes = g_slist_length(in->vdev->probes);
/* Seek to the end of the file, and read the divcount byte. */
divcount = 0x00; /* TODO: Don't hardcode! */
gettimeofday(&header.starttime, NULL);
header.num_logic_probes = num_probes;
header.samplerate = samplerate;
- sr_session_bus(in->vdevice, &packet);
+ sr_session_bus(in->vdev, &packet);
/* TODO: Handle trigger point. */
/* TODO: Handle errors, handle incomplete reads. */
size = read(fd, buf, PACKET_SIZE);
logic.length = PACKET_SIZE;
- sr_session_bus(in->vdevice, &packet);
+ sr_session_bus(in->vdev, &packet);
}
close(fd); /* FIXME */
sr_dbg("la8 in: %s: sending SR_DF_END", __func__);
packet.type = SR_DF_END;
packet.payload = NULL;
- sr_session_bus(in->vdevice, &packet);
+ sr_session_bus(in->vdev, &packet);
return SR_OK;
}
o->internal = ctx;
ctx->num_enabled_probes = 0;
- for (l = o->device->probes; l; l = l->next) {
+ for (l = o->dev->probes; l; l = l->next) {
probe = l->data;
if (!probe->enabled)
continue;
}
snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
- num_probes = g_slist_length(o->device->probes);
- if (o->device->plugin && sr_dev_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
- samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
+ num_probes = g_slist_length(o->dev->probes);
+ if (o->dev->plugin && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
+ samplerate = *((uint64_t *) o->dev->plugin->get_dev_info(
+ o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(samplerate_s = sr_samplerate_string(samplerate))) {
g_free(ctx->header);
g_free(ctx);
return SR_ERR_ARG;
}
- if (!o->device) {
- sr_warn("la8 out: %s: o->device was NULL", __func__);
+ if (!o->dev) {
+ sr_warn("la8 out: %s: o->dev was NULL", __func__);
return SR_ERR_ARG;
}
- if (!o->device->plugin) {
- sr_warn("la8 out: %s: o->device->plugin was NULL", __func__);
+ if (!o->dev->plugin) {
+ sr_warn("la8 out: %s: o->dev->plugin was NULL", __func__);
return SR_ERR_ARG;
}
/* Get the number of probes, their names, and the unitsize. */
/* TODO: Error handling. */
- for (l = o->device->probes; l; l = l->next) {
+ for (l = o->dev->probes; l; l = l->next) {
probe = l->data;
if (!probe->enabled)
continue;
ctx->probelist[ctx->num_enabled_probes] = 0;
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8;
- num_probes = g_slist_length(o->device->probes);
+ num_probes = g_slist_length(o->dev->probes);
- if (sr_dev_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
- samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
+ if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
+ samplerate = *((uint64_t *) o->dev->plugin->get_dev_info(
+ o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
/* TODO: Error checks. */
} else {
samplerate = 0; /* TODO: Error or set some value? */
return SR_ERR_ARG;
}
- if (!o->device) {
- sr_err("csv out: %s: o->device was NULL", __func__);
+ if (!o->dev) {
+ sr_err("csv out: %s: o->dev was NULL", __func__);
return SR_ERR_ARG;
}
- if (!o->device->plugin) {
- sr_err("csv out: %s: o->device->plugin was NULL", __func__);
+ if (!o->dev->plugin) {
+ sr_err("csv out: %s: o->dev->plugin was NULL", __func__);
return SR_ERR_ARG;
}
/* Get the number of probes, their names, and the unitsize. */
/* TODO: Error handling. */
- for (l = o->device->probes; l; l = l->next) {
+ for (l = o->dev->probes; l; l = l->next) {
probe = l->data;
if (!probe->enabled)
continue;
ctx->probelist[ctx->num_enabled_probes] = 0;
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8;
- num_probes = g_slist_length(o->device->probes);
+ num_probes = g_slist_length(o->dev->probes);
- if (sr_dev_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
- samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
+ if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
+ samplerate = *((uint64_t *) o->dev->plugin->get_dev_info(
+ o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
/* TODO: Error checks. */
} else {
samplerate = 0; /* TODO: Error or set some value? */
return SR_ERR_ARG;
}
- if (!o->device) {
- sr_err("gnuplot out: %s: o->device was NULL", __func__);
+ if (!o->dev) {
+ sr_err("gnuplot out: %s: o->dev was NULL", __func__);
return SR_ERR_ARG;
}
- if (!o->device->plugin) {
- sr_err("gnuplot out: %s: o->device->plugin was NULL", __func__);
+ if (!o->dev->plugin) {
+ sr_err("gnuplot out: %s: o->dev->plugin was NULL", __func__);
return SR_ERR_ARG;
}
o->internal = ctx;
ctx->num_enabled_probes = 0;
- for (l = o->device->probes; l; l = l->next) {
+ for (l = o->dev->probes; l; l = l->next) {
probe = l->data; /* TODO: Error checks. */
if (!probe->enabled)
continue;
ctx->probelist[ctx->num_enabled_probes] = 0;
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8;
- num_probes = g_slist_length(o->device->probes);
+ num_probes = g_slist_length(o->dev->probes);
comment[0] = '\0';
- if (sr_dev_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
- samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
+ if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
+ samplerate = *((uint64_t *) o->dev->plugin->get_dev_info(
+ o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(frequency_s = sr_samplerate_string(samplerate))) {
sr_err("gnuplot out: %s: sr_samplerate_string failed",
__func__);
o->internal = ctx;
ctx->num_enabled_probes = 0;
- for (l = o->device->probes; l; l = l->next) {
+ for (l = o->dev->probes; l; l = l->next) {
probe = l->data;
if (!probe->enabled)
continue;
ctx->unitsize = sizeof(struct sr_analog_sample) +
(ctx->num_enabled_probes * sizeof(struct sr_analog_probe));
- num_probes = g_slist_length(o->device->probes);
+ num_probes = g_slist_length(o->dev->probes);
comment[0] = '\0';
- if (o->device->plugin && sr_dev_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
- samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
+ if (o->dev->plugin && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
+ samplerate = *((uint64_t *) o->dev->plugin->get_dev_info(
+ o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(frequency_s = sr_samplerate_string(samplerate))) {
g_free(ctx->header);
g_free(ctx);
ctx->num_samples = 0;
num_enabled_probes = 0;
- for (l = o->device->probes; l; l = l->next) {
+ for (l = o->dev->probes; l; l = l->next) {
probe = l->data;
if (probe->enabled)
num_enabled_probes++;
}
ctx->unitsize = (num_enabled_probes + 7) / 8;
- if (o->device->plugin && sr_dev_has_hwcap(o->device, SR_HWCAP_SAMPLERATE))
- samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
+ if (o->dev->plugin && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE))
+ samplerate = *((uint64_t *) o->dev->plugin->get_dev_info(
+ o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
else
samplerate = 0;
o->internal = ctx;
ctx->num_enabled_probes = 0;
- for (l = o->device->probes; l; l = l->next) {
+ for (l = o->dev->probes; l; l = l->next) {
probe = l->data;
if (!probe->enabled)
continue;
}
snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
- num_probes = g_slist_length(o->device->probes);
- if (o->device->plugin || sr_dev_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
- samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
+ num_probes = g_slist_length(o->dev->probes);
+ if (o->dev->plugin || sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
+ samplerate = *((uint64_t *) o->dev->plugin->get_dev_info(
+ o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(samplerate_s = sr_samplerate_string(samplerate))) {
g_free(ctx->header);
g_free(ctx);
o->internal = ctx;
ctx->num_enabled_probes = 0;
- for (l = o->device->probes; l; l = l->next) {
+ for (l = o->dev->probes; l; l = l->next) {
probe = l->data;
if (!probe->enabled)
continue;
ctx->probelist[ctx->num_enabled_probes] = 0;
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8;
ctx->header = g_string_sized_new(512);
- num_probes = g_slist_length(o->device->probes);
+ num_probes = g_slist_length(o->dev->probes);
/* timestamp */
t = time(NULL);
g_string_append_printf(ctx->header, "$version %s %s $end\n",
PACKAGE, PACKAGE_VERSION);
- if (o->device->plugin && sr_dev_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
- ctx->samplerate = *((uint64_t *) o->device->plugin->get_device_info(
- o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
+ if (o->dev->plugin && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
+ ctx->samplerate = *((uint64_t *) o->dev->plugin->get_dev_info(
+ o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) {
g_string_free(ctx->header, TRUE);
g_free(ctx);
return SR_ERR_BUG;
}
- g_slist_free(session->devices);
- session->devices = NULL;
+ g_slist_free(session->devs);
+ session->devs = NULL;
/* TODO: Error checks needed? */
*
* @return SR_OK upon success, SR_ERR_BUG if no session exists.
*/
-SR_API int sr_session_device_clear(void)
+SR_API int sr_session_dev_clear(void)
{
if (!session) {
sr_err("session: %s: session was NULL", __func__);
return SR_ERR_BUG;
}
- g_slist_free(session->devices);
- session->devices = NULL;
+ g_slist_free(session->devs);
+ session->devs = NULL;
return SR_OK;
}
/**
* Add a device to the current session.
*
- * @param device The device to add to the current session. Must not be NULL.
- * Also, device->plugin and device->plugin->opendev must not
- * be NULL.
+ * @param dev The device to add to the current session. Must not be NULL.
+ * Also, dev->plugin and dev->plugin->opendev must not be NULL.
*
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
*/
-SR_API int sr_session_device_add(struct sr_device *device)
+SR_API int sr_session_dev_add(struct sr_dev *dev)
{
int ret;
- if (!device) {
- sr_err("session: %s: device was NULL", __func__);
+ if (!dev) {
+ sr_err("session: %s: dev was NULL", __func__);
return SR_ERR_ARG;
}
- if (!device->plugin) {
- sr_err("session: %s: device->plugin was NULL", __func__);
+ if (!dev->plugin) {
+ sr_err("session: %s: dev->plugin was NULL", __func__);
return SR_ERR_ARG;
}
- if (!device->plugin->opendev) {
- sr_err("session: %s: device->plugin->opendev was NULL",
+ if (!dev->plugin->opendev) {
+ sr_err("session: %s: dev->plugin->opendev was NULL",
__func__);
return SR_ERR_ARG;
}
return SR_ERR; /* TODO: SR_ERR_BUG? */
}
- if ((ret = device->plugin->opendev(device->plugin_index)) != SR_OK) {
+ if ((ret = dev->plugin->opendev(dev->plugin_index)) != SR_OK) {
sr_err("session: %s: opendev failed (%d)", __func__, ret);
return ret;
}
- session->devices = g_slist_append(session->devices, device);
+ session->devs = g_slist_append(session->devs, dev);
return SR_OK;
}
*/
SR_API int sr_session_start(void)
{
- struct sr_device *device;
+ struct sr_dev *dev;
GSList *l;
int ret;
return SR_ERR; /* TODO: SR_ERR_BUG? */
}
- if (!session->devices) {
+ if (!session->devs) {
/* TODO: Actually the case? */
- sr_err("session: %s: session->devices was NULL; a session "
+ sr_err("session: %s: session->devs was NULL; a session "
"cannot be started without devices.", __func__);
return SR_ERR; /* TODO: SR_ERR_BUG? */
}
sr_info("session: starting");
- for (l = session->devices; l; l = l->next) {
- device = l->data;
- /* TODO: Check for device != NULL. */
- if ((ret = device->plugin->start_acquisition(
- device->plugin_index, device)) != SR_OK) {
+ for (l = session->devs; l; l = l->next) {
+ dev = l->data;
+ /* TODO: Check for dev != NULL. */
+ if ((ret = dev->plugin->start_acquisition(
+ dev->plugin_index, dev)) != SR_OK) {
sr_err("session: %s: could not start an acquisition "
"(%d)", __func__, ret);
break;
return SR_ERR_BUG;
}
- if (!session->devices) {
+ if (!session->devs) {
/* TODO: Actually the case? */
- sr_err("session: %s: session->devices was NULL; a session "
+ sr_err("session: %s: session->devs was NULL; a session "
"cannot be run without devices.", __func__);
return SR_ERR_BUG;
}
*/
SR_API int sr_session_stop(void)
{
- struct sr_device *device;
+ struct sr_dev *dev;
GSList *l;
if (!session) {
sr_info("session: stopping");
session->running = FALSE;
- for (l = session->devices; l; l = l->next) {
- device = l->data;
- /* Check for device != NULL. */
- if (device->plugin) {
- if (device->plugin->stop_acquisition)
- device->plugin->stop_acquisition(device->plugin_index, device);
- if (device->plugin->cleanup)
- device->plugin->cleanup();
+ for (l = session->devs; l; l = l->next) {
+ dev = l->data;
+ /* Check for dev != NULL. */
+ if (dev->plugin) {
+ if (dev->plugin->stop_acquisition)
+ dev->plugin->stop_acquisition(dev->plugin_index, dev);
+ if (dev->plugin->cleanup)
+ dev->plugin->cleanup();
}
}
*
* Hardware drivers use this to send a data packet to the frontend.
*
- * @param device TODO.
+ * @param dev TODO.
* @param packet TODO.
*
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
*/
-SR_PRIV int sr_session_bus(struct sr_device *device,
+SR_PRIV int sr_session_bus(struct sr_dev *dev,
struct sr_datafeed_packet *packet)
{
GSList *l;
sr_datafeed_callback cb;
- if (!device) {
- sr_err("session: %s: device was NULL", __func__);
+ if (!dev) {
+ sr_err("session: %s: dev was NULL", __func__);
return SR_ERR_ARG;
}
- if (!device->plugin) {
- sr_err("session: %s: device->plugin was NULL", __func__);
+ if (!dev->plugin) {
+ sr_err("session: %s: dev->plugin was NULL", __func__);
return SR_ERR_ARG;
}
datafeed_dump(packet);
cb = l->data;
/* TODO: Check for cb != NULL. */
- cb(device, packet);
+ cb(dev, packet);
}
return SR_OK;
/* size of payloads sent across the session bus */
#define CHUNKSIZE (512 * 1024)
-struct session_vdevice {
+struct session_vdev {
char *capturefile;
struct zip *archive;
struct zip_file *capfile;
/**
* TODO.
*
- * @param device_index TODO.
+ * @param dev_index TODO.
*/
-static struct session_vdevice *get_vdevice_by_index(int device_index)
+static struct session_vdev *get_vdev_by_index(int dev_index)
{
struct sr_dev_inst *sdi;
- struct session_vdevice *vdevice;
+ struct session_vdev *vdev;
- /* TODO: Sanity checks on device_index. */
+ /* TODO: Sanity checks on dev_index. */
- if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) {
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("session driver: %s: device instance with device "
- "index %d was not found", __func__, device_index);
+ "index %d was not found", __func__, dev_index);
return NULL;
}
/* TODO: Is sdi->priv == NULL valid? */
- vdevice = sdi->priv;
+ vdev = sdi->priv;
- return vdevice;
+ return vdev;
}
/**
static int feed_chunk(int fd, int revents, void *session_data)
{
struct sr_dev_inst *sdi;
- struct session_vdevice *vdevice;
+ struct session_vdev *vdev;
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
GSList *l;
got_data = FALSE;
for (l = dev_insts; l; l = l->next) {
sdi = l->data;
- vdevice = sdi->priv;
- if (!vdevice)
+ vdev = sdi->priv;
+ if (!vdev)
/* already done with this instance */
continue;
return FALSE; /* TODO: SR_ERR_MALLOC */
}
- ret = zip_fread(vdevice->capfile, buf, CHUNKSIZE);
+ ret = zip_fread(vdev->capfile, buf, CHUNKSIZE);
if (ret > 0) {
got_data = TRUE;
packet.type = SR_DF_LOGIC;
packet.payload = &logic;
logic.length = ret;
- logic.unitsize = vdevice->unitsize;
+ logic.unitsize = vdev->unitsize;
logic.data = buf;
- vdevice->bytes_read += ret;
+ vdev->bytes_read += ret;
sr_session_bus(session_data, &packet);
} else {
/* done with this capture file */
- zip_fclose(vdevice->capfile);
- g_free(vdevice->capturefile);
- g_free(vdevice);
+ zip_fclose(vdev->capfile);
+ g_free(vdev->capturefile);
+ g_free(vdev);
sdi->priv = NULL;
}
}
/**
* TODO.
*
- * @param deviceinfo TODO.
+ * @param devinfo TODO.
*
* @return TODO.
*/
-static int hw_init(const char *deviceinfo)
+static int hw_init(const char *devinfo)
{
- sessionfile = g_strdup(deviceinfo);
+ sessionfile = g_strdup(devinfo);
return 0;
}
return SR_OK;
}
-static int hw_opendev(int device_index)
+static int hw_opendev(int dev_index)
{
struct sr_dev_inst *sdi;
- sdi = sr_dev_inst_new(device_index, SR_ST_INITIALIZING,
+ sdi = sr_dev_inst_new(dev_index, SR_ST_INITIALIZING,
NULL, NULL, NULL);
if (!sdi)
return SR_ERR;
- if (!(sdi->priv = g_try_malloc0(sizeof(struct session_vdevice)))) {
+ if (!(sdi->priv = g_try_malloc0(sizeof(struct session_vdev)))) {
sr_err("session driver: %s: sdi->priv malloc failed", __func__);
return SR_ERR_MALLOC;
}
return SR_OK;
}
-static void *hw_get_device_info(int device_index, int device_info_id)
+static void *hw_get_dev_info(int dev_index, int dev_info_id)
{
- struct session_vdevice *vdevice;
+ struct session_vdev *vdev;
void *info;
- if (device_info_id != SR_DI_CUR_SAMPLERATE)
+ if (dev_info_id != SR_DI_CUR_SAMPLERATE)
return NULL;
- if (!(vdevice = get_vdevice_by_index(device_index)))
+ if (!(vdev = get_vdev_by_index(dev_index)))
return NULL;
- info = &vdevice->samplerate;
+ info = &vdev->samplerate;
return info;
}
-static int hw_get_status(int device_index)
+static int hw_get_status(int dev_index)
{
/* Avoid compiler warnings. */
- (void)device_index;
+ (void)dev_index;
if (sr_dev_list() != NULL)
return SR_OK;
return capabilities;
}
-static int hw_set_configuration(int device_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int capability, void *value)
{
- struct session_vdevice *vdevice;
+ struct session_vdev *vdev;
uint64_t *tmp_u64;
- if (!(vdevice = get_vdevice_by_index(device_index)))
+ if (!(vdev = get_vdev_by_index(dev_index)))
return SR_ERR;
switch (capability) {
case SR_HWCAP_SAMPLERATE:
tmp_u64 = value;
- vdevice->samplerate = *tmp_u64;
+ vdev->samplerate = *tmp_u64;
sr_info("session driver: setting samplerate to %" PRIu64,
- vdevice->samplerate);
+ vdev->samplerate);
break;
case SR_HWCAP_CAPTUREFILE:
- vdevice->capturefile = g_strdup(value);
+ vdev->capturefile = g_strdup(value);
sr_info("session driver: setting capturefile to %s",
- vdevice->capturefile);
+ vdev->capturefile);
break;
case SR_HWCAP_CAPTURE_UNITSIZE:
tmp_u64 = value;
- vdevice->unitsize = *tmp_u64;
+ vdev->unitsize = *tmp_u64;
break;
case SR_HWCAP_CAPTURE_NUM_PROBES:
tmp_u64 = value;
- vdevice->num_probes = *tmp_u64;
+ vdev->num_probes = *tmp_u64;
break;
default:
sr_err("session driver: %s: unknown capability %d requested",
return SR_OK;
}
-static int hw_start_acquisition(int device_index, gpointer session_device_id)
+static int hw_start_acquisition(int dev_index, gpointer session_dev_id)
{
struct zip_stat zs;
- struct session_vdevice *vdevice;
+ struct session_vdev *vdev;
struct sr_datafeed_header *header;
struct sr_datafeed_packet *packet;
int err;
/* Avoid compiler warnings. */
- (void)session_device_id;
+ (void)session_dev_id;
- if (!(vdevice = get_vdevice_by_index(device_index)))
+ if (!(vdev = get_vdev_by_index(dev_index)))
return SR_ERR;
sr_info("session_driver: opening archive %s file %s", sessionfile,
- vdevice->capturefile);
+ vdev->capturefile);
- if (!(vdevice->archive = zip_open(sessionfile, 0, &err))) {
+ if (!(vdev->archive = zip_open(sessionfile, 0, &err))) {
sr_err("session driver: Failed to open session file '%s': "
"zip error %d\n", sessionfile, err);
return SR_ERR;
}
- if (zip_stat(vdevice->archive, vdevice->capturefile, 0, &zs) == -1) {
+ if (zip_stat(vdev->archive, vdev->capturefile, 0, &zs) == -1) {
sr_err("session driver: Failed to check capture file '%s' in "
- "session file '%s'.", vdevice->capturefile, sessionfile);
+ "session file '%s'.", vdev->capturefile, sessionfile);
return SR_ERR;
}
- if (!(vdevice->capfile = zip_fopen(vdevice->archive,
- vdevice->capturefile, 0))) {
+ if (!(vdev->capfile = zip_fopen(vdev->archive, vdev->capturefile, 0))) {
sr_err("session driver: Failed to open capture file '%s' in "
- "session file '%s'.", vdevice->capturefile, sessionfile);
+ "session file '%s'.", vdev->capturefile, sessionfile);
return SR_ERR;
}
/* freewheeling source */
- sr_session_source_add(-1, 0, 0, feed_chunk, session_device_id);
+ sr_session_source_add(-1, 0, 0, feed_chunk, session_dev_id);
if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
sr_err("session driver: %s: packet malloc failed", __func__);
packet->payload = (unsigned char *)header;
header->feed_version = 1;
gettimeofday(&header->starttime, NULL);
- header->samplerate = vdevice->samplerate;
- header->num_logic_probes = vdevice->num_probes;
- sr_session_bus(session_device_id, packet);
+ header->samplerate = vdev->samplerate;
+ header->num_logic_probes = vdev->num_probes;
+ sr_session_bus(session_dev_id, packet);
g_free(header);
g_free(packet);
return SR_OK;
}
-SR_PRIV struct sr_device_plugin session_driver = {
+SR_PRIV struct sr_dev_plugin session_driver = {
"session",
"Session-emulating driver",
1,
hw_cleanup,
hw_opendev,
NULL,
- hw_get_device_info,
+ hw_get_dev_info,
hw_get_status,
hw_get_capabilities,
hw_set_configuration,
#include "sigrok-internal.h"
extern struct sr_session *session;
-extern SR_PRIV struct sr_device_plugin session_driver;
+extern SR_PRIV struct sr_dev_plugin session_driver;
/**
* Load the session from the specified filename.
struct zip_file *zf;
struct zip_stat zs;
struct sr_session *session;
- struct sr_device *device;
+ struct sr_dev *dev;
struct sr_probe *probe;
int ret, err, probenum, devcnt, i, j;
uint64_t tmp_u64, total_probes, enabled_probes, p;
continue;
if (!strncmp(sections[i], "device ", 7)) {
/* device section */
- device = NULL;
+ dev = NULL;
enabled_probes = 0;
keys = g_key_file_get_keys(kf, sections[i], NULL, NULL);
for (j = 0; keys[j]; j++) {
val = g_key_file_get_string(kf, sections[i], keys[j], NULL);
if (!strcmp(keys[j], "capturefile")) {
- device = sr_dev_new(&session_driver, devcnt);
+ dev = sr_dev_new(&session_driver, devcnt);
if (devcnt == 0)
/* first device, init the plugin */
- device->plugin->init((char *)filename);
- sr_session_device_add(device);
- device->plugin->set_configuration(devcnt, SR_HWCAP_CAPTUREFILE, val);
+ dev->plugin->init((char *)filename);
+ sr_session_dev_add(dev);
+ dev->plugin->set_configuration(devcnt, SR_HWCAP_CAPTUREFILE, val);
g_ptr_array_add(capturefiles, val);
} else if (!strcmp(keys[j], "samplerate")) {
sr_parse_sizestring(val, &tmp_u64);
- device->plugin->set_configuration(devcnt, SR_HWCAP_SAMPLERATE, &tmp_u64);
+ dev->plugin->set_configuration(devcnt, SR_HWCAP_SAMPLERATE, &tmp_u64);
} else if (!strcmp(keys[j], "unitsize")) {
tmp_u64 = strtoull(val, NULL, 10);
- device->plugin->set_configuration(devcnt, SR_HWCAP_CAPTURE_UNITSIZE, &tmp_u64);
+ dev->plugin->set_configuration(devcnt, SR_HWCAP_CAPTURE_UNITSIZE, &tmp_u64);
} else if (!strcmp(keys[j], "total probes")) {
total_probes = strtoull(val, NULL, 10);
- device->plugin->set_configuration(devcnt, SR_HWCAP_CAPTURE_NUM_PROBES, &total_probes);
+ dev->plugin->set_configuration(devcnt, SR_HWCAP_CAPTURE_NUM_PROBES, &total_probes);
for (p = 0; p < total_probes; p++) {
snprintf(probename, SR_MAX_PROBENAME_LEN, "%" PRIu64, p);
- sr_dev_probe_add(device, probename);
+ sr_dev_probe_add(dev, probename);
}
} else if (!strncmp(keys[j], "probe", 5)) {
- if (!device)
+ if (!dev)
continue;
enabled_probes++;
tmp_u64 = strtoul(keys[j]+5, NULL, 10);
- sr_dev_probe_name(device, tmp_u64, val);
+ sr_dev_probe_name(dev, tmp_u64, val);
} else if (!strncmp(keys[j], "trigger", 7)) {
probenum = strtoul(keys[j]+7, NULL, 10);
- sr_dev_trigger_set(device, probenum, val);
+ sr_dev_trigger_set(dev, probenum, val);
}
}
g_strfreev(keys);
for (p = enabled_probes; p < total_probes; p++) {
- probe = g_slist_nth_data(device->probes, p);
+ probe = g_slist_nth_data(dev->probes, p);
probe->enabled = FALSE;
}
}
{
GSList *l, *p, *d;
FILE *meta;
- struct sr_device *device;
+ struct sr_dev *dev;
struct sr_probe *probe;
struct sr_datastore *ds;
struct zip *zipfile;
/* all datastores in all devices */
devcnt = 1;
- for (l = session->devices; l; l = l->next) {
- device = l->data;
+ for (l = session->devs; l; l = l->next) {
+ dev = l->data;
/* metadata */
fprintf(meta, "[device %d]\n", devcnt);
- if (device->plugin)
- fprintf(meta, "driver = %s\n", device->plugin->name);
+ if (dev->plugin)
+ fprintf(meta, "driver = %s\n", dev->plugin->name);
- ds = device->datastore;
+ ds = dev->datastore;
if (ds) {
/* metadata */
fprintf(meta, "capturefile = logic-%d\n", devcnt);
fprintf(meta, "unitsize = %d\n", ds->ds_unitsize);
- fprintf(meta, "total probes = %d\n", g_slist_length(device->probes));
- if (sr_dev_has_hwcap(device, SR_HWCAP_SAMPLERATE)) {
- samplerate = *((uint64_t *) device->plugin->get_device_info(
- device->plugin_index, SR_DI_CUR_SAMPLERATE));
+ fprintf(meta, "total probes = %d\n", g_slist_length(dev->probes));
+ if (sr_dev_has_hwcap(dev, SR_HWCAP_SAMPLERATE)) {
+ samplerate = *((uint64_t *) dev->plugin->get_dev_info(
+ dev->plugin_index, SR_DI_CUR_SAMPLERATE));
s = sr_samplerate_string(samplerate);
fprintf(meta, "samplerate = %s\n", s);
g_free(s);
}
probecnt = 1;
- for (p = device->probes; p; p = p->next) {
+ for (p = dev->probes; p; p = p->next) {
probe = p->data;
if (probe->enabled) {
if (probe->name)
/*--- session.c -------------------------------------------------------------*/
-SR_PRIV int sr_session_bus(struct sr_device *device,
+SR_PRIV int sr_session_bus(struct sr_dev *dev,
struct sr_datafeed_packet *packet);
/* Generic device instances */
SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
const char *vendor, const char *model, const char *version);
-SR_PRIV struct sr_dev_inst *sr_dev_inst_get(GSList *dev_insts,
- int device_index);
+SR_PRIV struct sr_dev_inst *sr_dev_inst_get(GSList *dev_insts, int dev_index);
SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi);
SR_PRIV void sr_source_remove(int fd);
/*--- hardware/common/misc.c ------------------------------------------------*/
#ifdef HAVE_LIBUSB_1_0
-SR_PRIV int opendev2(int device_index, struct sr_dev_inst **sdi,
+SR_PRIV int opendev2(int dev_index, struct sr_dev_inst **sdi,
libusb_device *dev, struct libusb_device_descriptor *des,
int *skip, uint16_t vid, uint16_t pid, int interface);
SR_PRIV int opendev3(struct sr_dev_inst **sdi, libusb_device *dev,
SR_API int sr_dev_scan(void);
SR_API GSList *sr_dev_list(void);
-SR_API struct sr_device *sr_dev_new(const struct sr_device_plugin *plugin,
- int plugin_index);
-SR_API int sr_dev_probe_add(struct sr_device *device, const char *name);
-SR_API struct sr_probe *sr_dev_probe_find(const struct sr_device *device,
- int probenum);
-SR_API int sr_dev_probe_name(struct sr_device *device, int probenum,
- const char *name);
-SR_API int sr_dev_trigger_clear(struct sr_device *device);
-SR_API int sr_dev_trigger_set(struct sr_device *device, int probenum,
- const char *trigger);
-SR_API gboolean sr_dev_has_hwcap(const struct sr_device *device, int hwcap);
-SR_API int sr_dev_info_get(const struct sr_device *device, int id,
- const void **data);
+SR_API struct sr_dev *sr_dev_new(const struct sr_dev_plugin *plugin,
+ int plugin_index);
+SR_API int sr_dev_probe_add(struct sr_dev *dev, const char *name);
+SR_API struct sr_probe *sr_dev_probe_find(const struct sr_dev *dev,
+ int probenum);
+SR_API int sr_dev_probe_name(struct sr_dev *dev, int probenum,
+ const char *name);
+SR_API int sr_dev_trigger_clear(struct sr_dev *dev);
+SR_API int sr_dev_trigger_set(struct sr_dev *dev, int probenum,
+ const char *trigger);
+SR_API gboolean sr_dev_has_hwcap(const struct sr_dev *dev, int hwcap);
+SR_API int sr_dev_info_get(const struct sr_dev *dev, int id, const void **data);
/*--- filter.c --------------------------------------------------------------*/
/*--- hwplugin.c ------------------------------------------------------------*/
SR_API GSList *sr_hw_list(void);
-SR_API int sr_hw_init(struct sr_device_plugin *plugin);
-SR_API gboolean sr_hw_has_hwcap(struct sr_device_plugin *plugin, int hwcap);
+SR_API int sr_hw_init(struct sr_dev_plugin *plugin);
+SR_API gboolean sr_hw_has_hwcap(struct sr_dev_plugin *plugin, int hwcap);
SR_API struct sr_hwcap_option *sr_hw_hwcap_get(int hwcap);
/*--- session.c -------------------------------------------------------------*/
-typedef void (*sr_datafeed_callback) (struct sr_device *device,
+typedef void (*sr_datafeed_callback) (struct sr_dev *dev,
struct sr_datafeed_packet *packet);
/* Session setup */
SR_API int sr_session_load(const char *filename);
SR_API struct sr_session *sr_session_new(void);
SR_API int sr_session_destroy(void);
-SR_API int sr_session_device_clear(void);
-SR_API int sr_session_device_add(struct sr_device *device);
+SR_API int sr_session_dev_clear(void);
+SR_API int sr_session_dev_add(struct sr_dev *dev);
/* Datafeed setup */
SR_API int sr_session_datafeed_callback_clear(void);
SR_API struct sr_output_format **sr_output_list(void);
-/*--- strutil.c -------------------------------------------------------*/
+/*--- strutil.c -------------------------------------------------------------*/
SR_API char *sr_samplerate_string(uint64_t samplerate);
SR_API char *sr_period_string(uint64_t frequency);
-SR_API char **sr_parse_triggerstring(struct sr_device *device,
+SR_API char **sr_parse_triggerstring(struct sr_dev *dev,
const char *triggerstring);
SR_API int sr_parse_sizestring(const char *sizestring, uint64_t *size);
SR_API uint64_t sr_parse_timestring(const char *timestring);
struct sr_input {
struct sr_input_format *format;
char *param;
- struct sr_device *vdevice;
+ struct sr_dev *vdev;
};
struct sr_input_format {
struct sr_output {
struct sr_output_format *format;
- struct sr_device *device;
+ struct sr_dev *dev;
char *param;
void *internal;
};
* This represents a generic device connected to the system.
* For device-specific information, ask the plugin. The plugin_index refers
* to the device index within that plugin; it may be handling more than one
- * device. All relevant plugin calls take a device_index parameter for this.
+ * device. All relevant plugin calls take a dev_index parameter for this.
*/
-struct sr_device {
+struct sr_dev {
/* Which plugin handles this device */
- struct sr_device_plugin *plugin;
+ struct sr_dev_plugin *plugin;
/* A plugin may handle multiple devices of the same type */
int plugin_index;
/* List of struct sr_probe* */
/*--- Device types --------------------------------------------------*/
/** The device is demo device. */
- SR_HWCAP_DEMO_DEVICE,
+ SR_HWCAP_DEMO_DEV,
/*--- Device options ------------------------------------------------*/
uint64_t *list;
};
-struct sr_device_plugin {
+struct sr_dev_plugin {
/* Plugin-specific */
char *name;
char *longname;
int api_version;
- int (*init) (const char *deviceinfo);
+ int (*init) (const char *devinfo);
int (*cleanup) (void);
/* Device-specific */
- int (*opendev) (int device_index);
- int (*closedev) (int device_index);
- void *(*get_device_info) (int device_index, int device_info_id);
- int (*get_status) (int device_index);
+ int (*opendev) (int dev_index);
+ int (*closedev) (int dev_index);
+ void *(*get_dev_info) (int dev_index, int dev_info_id);
+ int (*get_status) (int dev_index);
int *(*get_capabilities) (void);
- int (*set_configuration) (int device_index, int capability, void *value);
- int (*start_acquisition) (int device_index, gpointer session_device_id);
- int (*stop_acquisition) (int device_index, gpointer session_device_id);
+ int (*set_configuration) (int dev_index, int capability, void *value);
+ int (*start_acquisition) (int dev_index, gpointer session_dev_id);
+ int (*stop_acquisition) (int dev_index, gpointer session_dev_id);
};
struct sr_session {
- /* List of struct sr_device* */
- GSList *devices;
+ /* List of struct sr_dev* */
+ GSList *devs;
/* list of sr_receive_data_callback */
GSList *datafeed_callbacks;
GTimeVal starttime;
/**
* TODO
*
- * @param device TODO
+ * @param dev TODO
* @param triggerstring TODO
*
* @return TODO
*/
-SR_API char **sr_parse_triggerstring(struct sr_device *device,
+SR_API char **sr_parse_triggerstring(struct sr_dev *dev,
const char *triggerstring)
{
GSList *l;
char **tokens, **triggerlist, *trigger, *tc, *trigger_types;
gboolean error;
- max_probes = g_slist_length(device->probes);
+ max_probes = g_slist_length(dev->probes);
error = FALSE;
if (!(triggerlist = g_try_malloc0(max_probes * sizeof(char *)))) {
}
tokens = g_strsplit(triggerstring, ",", max_probes);
- trigger_types = device->plugin->get_device_info(0, SR_DI_TRIGGER_TYPES);
+ trigger_types = dev->plugin->get_dev_info(0, SR_DI_TRIGGER_TYPES);
if (trigger_types == NULL)
return NULL;
if (tokens[i][0] < '0' || tokens[i][0] > '9') {
/* Named probe */
probenum = 0;
- for (l = device->probes; l; l = l->next) {
+ for (l = dev->probes; l; l = l->next) {
probe = (struct sr_probe *)l->data;
if (probe->enabled
&& !strncmp(probe->name, tokens[i],