struct dev_context *devc;
if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
+ return SR_ERR_DEV_CLOSED;
if (!(devc = sdi->priv)) {
sr_err("sdi->priv was NULL.");
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!(devc = sdi->priv)) {
sr_err("sdi->priv was NULL.");
return SR_ERR_BUG;
return SR_ERR;
}
+ sdi->status = SR_ST_ACTIVE;
+
return SR_OK;
}
sr_err("Failed to close device: %s.",
snd_strerror(ret));
devc->capture_handle = NULL;
+ sdi->status = SR_ST_INACTIVE;
}
} else {
sr_dbg("No capture handle, no need to close audio device.");
{
struct dev_context *devc;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
devc = sdi->priv;
switch (id) {
int count, ret;
char *endianness;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
devc = sdi->priv;
devc->cb_data = cb_data;
devc->num_samples = 0;
struct dev_context *devc;
int ret;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
devc = sdi->priv;
if (id == SR_CONF_SAMPLERATE) {
struct triggerinout triggerinout_conf;
struct triggerlut lut;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
devc = sdi->priv;
if (configure_probes(sdi) != SR_OK) {
struct dev_context *devc;
int ret;
- if (sdi->status != SR_ST_ACTIVE) {
- sr_err("Device inactive, can't set config options.");
- return SR_ERR;
- }
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
if (!(devc = sdi->priv)) {
sr_err("sdi->priv was NULL.");
{
struct dev_context *devc;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!(devc = sdi->priv)) {
sr_err("sdi->priv was NULL.");
return SR_ERR_BUG;
{
struct dev_context *devc;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!(devc = sdi->priv)) {
sr_err("%s: sdi->priv was NULL.", __func__);
return SR_ERR_BUG;
uint8_t buf[4];
int bytes_written;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!(devc = sdi->priv)) {
sr_err("%s: sdi->priv was NULL.", __func__);
return SR_ERR_BUG;
struct dev_context *devc;
if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
+ return SR_ERR_DEV_CLOSED;
if (!(devc = sdi->priv)) {
sr_err("sdi->priv was NULL.");
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!(devc = sdi->priv)) {
sr_err("sdi->priv was NULL.");
return SR_ERR_BUG;
{
(void)sdi;
- /* Nothing needed so far. */
+ sdi->status = SR_ST_ACTIVE;
return SR_OK;
}
{
(void)sdi;
- /* Nothing needed so far. */
+ sdi->status = SR_ST_INACTIVE;
return SR_OK;
}
struct dev_context *const devc = sdi->priv;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (id == SR_CONF_SAMPLERATE) {
devc->cur_samplerate = g_variant_get_uint64(data);
sr_dbg("%s: setting samplerate to %" PRIu64, __func__,
{
struct dev_context *const devc = sdi->priv;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
devc->cb_data = cb_data;
devc->samples_counter = 0;
struct dev_context *devc;
if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
+ return SR_ERR_DEV_CLOSED;
if (!(devc = sdi->priv)) {
sr_err("sdi->priv was NULL.");
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!(devc = sdi->priv)) {
sr_err("sdi->priv was NULL.");
return SR_ERR_BUG;
struct dev_context *devc;
int ret;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR;
+
devc = sdi->priv;
if (id == SR_CONF_SAMPLERATE) {
unsigned char *buf;
size_t size;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
drvc = di->priv;
devc = sdi->priv;
usb = sdi->conn;
char **targets;
if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
+ return SR_ERR_DEV_CLOSED;
ret = SR_OK;
devc = sdi->priv;
int i;
if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
+ return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
devc->cb_data = cb_data;
struct dev_context *devc;
int ret;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!di->priv) {
sr_err("Driver was not initialized.");
return SR_ERR;
}
- if (sdi->status != SR_ST_ACTIVE) {
- sr_err("Device inactive, can't set config options.");
- return SR_ERR;
- }
devc = sdi->priv;
ret = SR_OK;
int ret, i;
unsigned char cmd[3], resp[4], *buf;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!di->priv) {
sr_err("Driver was not initialized.");
return SR_ERR;
devc = sdi->priv;
if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
+ return SR_ERR_DEV_CLOSED;
switch (id) {
case SR_CONF_SAMPLERATE:
struct dev_context *devc;
int ret = SR_ERR;
- devc = sdi->priv;
-
if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
+ return SR_ERR_DEV_CLOSED;
+
+ devc = sdi->priv;
if (mso_configure_probes(sdi) != SR_OK) {
sr_err("Failed to configure probes.");
struct dev_context *devc;
if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
+ return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
- devc = sdi->priv;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+ devc = sdi->priv;
devc->cb_data = cb_data;
-
devc->num_samples = 0;
devc->starttime = g_get_monotonic_time();
{
/* TODO */
- (void)sdi;
+ sdi->status = SR_ST_ACTIVE;
return SR_OK;
}
{
/* TODO */
- (void)sdi;
+ sdi->status = SR_ST_INACTIVE;
return SR_OK;
}
/* TODO */
(void)data;
- if (sdi->status != SR_ST_ACTIVE) {
- sr_err("Device inactive, can't set config options.");
- return SR_ERR;
- }
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
ret = SR_OK;
switch (id) {
void *cb_data)
{
/* TODO */
- (void)sdi;
(void)cb_data;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
return SR_OK;
}
int ret;
uint64_t tmp_u64;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
devc = sdi->priv;
switch (id) {
int num_channels;
int i;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
devc = sdi->priv;
serial = sdi->conn;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
-
if (ols_configure_probes(sdi) != SR_OK) {
sr_err("Failed to configure probes.");
return SR_ERR;
devc = sdi->priv;
- if (sdi->status != SR_ST_ACTIVE) {
- sr_err("Device inactive, can't set config options.");
- return SR_ERR;
- }
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
ret = SR_OK;
switch (id) {
GSList *l;
char cmd[256];
- (void)cb_data;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
serial = sdi->conn;
devc = sdi->priv;
struct dev_context *devc;
if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
+ return SR_ERR_DEV_CLOSED;
if (!(devc = sdi->priv)) {
sr_err("sdi->priv was NULL.");
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!(devc = sdi->priv)) {
sr_err("sdi->priv was NULL.");
return SR_ERR_BUG;
{
struct dev_context *devc;
- if (sdi->status != SR_ST_ACTIVE) {
- sr_err("Device inactive, can't set config options.");
- return SR_ERR;
- }
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
{
struct dev_context *devc;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
devc = sdi->priv;
devc->cb_data = cb_data;
{
struct drv_context *drvc;
struct dev_context *devc;
+ int ret;
drvc = di->priv;
devc = sdi->priv;
- return sr_usb_open(drvc->sr_ctx->libusb_ctx, devc->usb);
+ if ((ret = sr_usb_open(drvc->sr_ctx->libusb_ctx, devc->usb)) == SR_OK)
+ sdi->status = SR_ST_ACTIVE;
+
+ return ret;
}
static int hw_dev_close(struct sr_dev_inst *sdi)
/* TODO */
+ sdi->status = SR_ST_INACTIVE;
+
return SR_OK;
}
gint64 now;
int ret;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!di->priv) {
sr_err("Driver was not initialized.");
return SR_ERR;
int ret, i;
unsigned char *buf;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!di->priv) {
sr_err("Driver was not initialized.");
return SR_ERR;
{
struct dev_context *devc;
- if (!sdi) {
- sr_err("%s: sdi was NULL", __func__);
- return SR_ERR_ARG;
- }
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
if (!(devc = sdi->priv)) {
sr_err("%s: sdi->priv was NULL", __func__);
unsigned int packet_num, n;
unsigned char *buf;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!(devc = sdi->priv)) {
sr_err("%s: sdi->priv was NULL", __func__);
return SR_ERR_ARG;
SR_ERR_BUG = -4, /**< Errors hinting at internal bugs. */
SR_ERR_SAMPLERATE = -5, /**< Incorrect samplerate. */
SR_ERR_NA = -6, /**< Not applicable. */
+ SR_ERR_DEV_CLOSED = -7, /**< Device is closed, but needs to be open. */
};
#define SR_MAX_NUM_PROBES 64 /* Limited by uint64_t. */