Enforce open device before config_set()/dev_acquisition_start()
This commit is contained in:
parent
efdecf4c05
commit
e73ffd4238
|
@ -231,7 +231,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("sdi->priv was NULL.");
|
sr_err("sdi->priv was NULL.");
|
||||||
|
@ -287,6 +287,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_serial_dev_inst *serial;
|
struct sr_serial_dev_inst *serial;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("sdi->priv was NULL.");
|
sr_err("sdi->priv was NULL.");
|
||||||
return SR_ERR_BUG;
|
return SR_ERR_BUG;
|
||||||
|
|
|
@ -92,6 +92,8 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sdi->status = SR_ST_ACTIVE;
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +110,7 @@ static int hw_dev_close(struct sr_dev_inst *sdi)
|
||||||
sr_err("Failed to close device: %s.",
|
sr_err("Failed to close device: %s.",
|
||||||
snd_strerror(ret));
|
snd_strerror(ret));
|
||||||
devc->capture_handle = NULL;
|
devc->capture_handle = NULL;
|
||||||
|
sdi->status = SR_ST_INACTIVE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sr_dbg("No capture handle, no need to close audio device.");
|
sr_dbg("No capture handle, no need to close audio device.");
|
||||||
|
@ -143,6 +146,9 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
@ -203,6 +209,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
int count, ret;
|
int count, ret;
|
||||||
char *endianness;
|
char *endianness;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
devc->cb_data = cb_data;
|
||||||
devc->num_samples = 0;
|
devc->num_samples = 0;
|
||||||
|
|
|
@ -789,6 +789,9 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
if (id == SR_CONF_SAMPLERATE) {
|
if (id == SR_CONF_SAMPLERATE) {
|
||||||
|
@ -1271,6 +1274,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
struct triggerinout triggerinout_conf;
|
struct triggerinout triggerinout_conf;
|
||||||
struct triggerlut lut;
|
struct triggerlut lut;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
if (configure_probes(sdi) != SR_OK) {
|
if (configure_probes(sdi) != SR_OK) {
|
||||||
|
|
|
@ -216,10 +216,8 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE) {
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
sr_err("Device inactive, can't set config options.");
|
return SR_ERR_DEV_CLOSED;
|
||||||
return SR_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("sdi->priv was NULL.");
|
sr_err("sdi->priv was NULL.");
|
||||||
|
@ -266,6 +264,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("sdi->priv was NULL.");
|
sr_err("sdi->priv was NULL.");
|
||||||
return SR_ERR_BUG;
|
return SR_ERR_BUG;
|
||||||
|
|
|
@ -308,6 +308,9 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("%s: sdi->priv was NULL.", __func__);
|
sr_err("%s: sdi->priv was NULL.", __func__);
|
||||||
return SR_ERR_BUG;
|
return SR_ERR_BUG;
|
||||||
|
@ -433,6 +436,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
uint8_t buf[4];
|
uint8_t buf[4];
|
||||||
int bytes_written;
|
int bytes_written;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("%s: sdi->priv was NULL.", __func__);
|
sr_err("%s: sdi->priv was NULL.", __func__);
|
||||||
return SR_ERR_BUG;
|
return SR_ERR_BUG;
|
||||||
|
|
|
@ -176,7 +176,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("sdi->priv was NULL.");
|
sr_err("sdi->priv was NULL.");
|
||||||
|
@ -233,6 +233,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_serial_dev_inst *serial;
|
struct sr_serial_dev_inst *serial;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("sdi->priv was NULL.");
|
sr_err("sdi->priv was NULL.");
|
||||||
return SR_ERR_BUG;
|
return SR_ERR_BUG;
|
||||||
|
|
|
@ -212,7 +212,7 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)sdi;
|
(void)sdi;
|
||||||
|
|
||||||
/* Nothing needed so far. */
|
sdi->status = SR_ST_ACTIVE;
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ static int hw_dev_close(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)sdi;
|
(void)sdi;
|
||||||
|
|
||||||
/* Nothing needed so far. */
|
sdi->status = SR_ST_INACTIVE;
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
@ -299,6 +299,9 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
struct dev_context *const devc = sdi->priv;
|
struct dev_context *const devc = sdi->priv;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (id == SR_CONF_SAMPLERATE) {
|
if (id == SR_CONF_SAMPLERATE) {
|
||||||
devc->cur_samplerate = g_variant_get_uint64(data);
|
devc->cur_samplerate = g_variant_get_uint64(data);
|
||||||
sr_dbg("%s: setting samplerate to %" PRIu64, __func__,
|
sr_dbg("%s: setting samplerate to %" PRIu64, __func__,
|
||||||
|
@ -460,6 +463,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
{
|
{
|
||||||
struct dev_context *const devc = sdi->priv;
|
struct dev_context *const devc = sdi->priv;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc->cb_data = cb_data;
|
devc->cb_data = cb_data;
|
||||||
devc->samples_counter = 0;
|
devc->samples_counter = 0;
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("sdi->priv was NULL.");
|
sr_err("sdi->priv was NULL.");
|
||||||
|
@ -321,6 +321,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_serial_dev_inst *serial;
|
struct sr_serial_dev_inst *serial;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("sdi->priv was NULL.");
|
sr_err("sdi->priv was NULL.");
|
||||||
return SR_ERR_BUG;
|
return SR_ERR_BUG;
|
||||||
|
|
|
@ -617,6 +617,9 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
if (id == SR_CONF_SAMPLERATE) {
|
if (id == SR_CONF_SAMPLERATE) {
|
||||||
|
@ -948,6 +951,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
drvc = di->priv;
|
drvc = di->priv;
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
usb = sdi->conn;
|
usb = sdi->conn;
|
||||||
|
|
|
@ -473,7 +473,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
char **targets;
|
char **targets;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
ret = SR_OK;
|
ret = SR_OK;
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
@ -926,7 +926,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
devc->cb_data = cb_data;
|
||||||
|
|
|
@ -229,14 +229,13 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!di->priv) {
|
if (!di->priv) {
|
||||||
sr_err("Driver was not initialized.");
|
sr_err("Driver was not initialized.");
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
if (sdi->status != SR_ST_ACTIVE) {
|
|
||||||
sr_err("Device inactive, can't set config options.");
|
|
||||||
return SR_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
ret = SR_OK;
|
ret = SR_OK;
|
||||||
|
@ -369,6 +368,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
int ret, i;
|
int ret, i;
|
||||||
unsigned char cmd[3], resp[4], *buf;
|
unsigned char cmd[3], resp[4], *buf;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!di->priv) {
|
if (!di->priv) {
|
||||||
sr_err("Driver was not initialized.");
|
sr_err("Driver was not initialized.");
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
|
@ -315,7 +315,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
|
@ -405,10 +405,10 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
int ret = SR_ERR;
|
int ret = SR_ERR;
|
||||||
|
|
||||||
devc = sdi->priv;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
devc = sdi->priv;
|
||||||
|
|
||||||
if (mso_configure_probes(sdi) != SR_OK) {
|
if (mso_configure_probes(sdi) != SR_OK) {
|
||||||
sr_err("Failed to configure probes.");
|
sr_err("Failed to configure probes.");
|
||||||
|
|
|
@ -220,7 +220,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
|
@ -268,10 +268,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_serial_dev_inst *serial;
|
struct sr_serial_dev_inst *serial;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
devc->cb_data = cb_data;
|
devc->cb_data = cb_data;
|
||||||
|
|
||||||
devc->num_samples = 0;
|
devc->num_samples = 0;
|
||||||
devc->starttime = g_get_monotonic_time();
|
devc->starttime = g_get_monotonic_time();
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
(void)sdi;
|
sdi->status = SR_ST_ACTIVE;
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ static int hw_dev_close(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
(void)sdi;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
@ -253,10 +253,8 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
/* TODO */
|
/* TODO */
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE) {
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
sr_err("Device inactive, can't set config options.");
|
return SR_ERR_DEV_CLOSED;
|
||||||
return SR_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = SR_OK;
|
ret = SR_OK;
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
@ -285,9 +283,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
void *cb_data)
|
void *cb_data)
|
||||||
{
|
{
|
||||||
/* TODO */
|
/* TODO */
|
||||||
(void)sdi;
|
|
||||||
(void)cb_data;
|
(void)cb_data;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,6 +280,9 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
int ret;
|
int ret;
|
||||||
uint64_t tmp_u64;
|
uint64_t tmp_u64;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
@ -366,12 +369,12 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
int num_channels;
|
int num_channels;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
|
||||||
return SR_ERR;
|
|
||||||
|
|
||||||
if (ols_configure_probes(sdi) != SR_OK) {
|
if (ols_configure_probes(sdi) != SR_OK) {
|
||||||
sr_err("Failed to configure probes.");
|
sr_err("Failed to configure probes.");
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
|
@ -414,10 +414,8 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE) {
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
sr_err("Device inactive, can't set config options.");
|
return SR_ERR_DEV_CLOSED;
|
||||||
return SR_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = SR_OK;
|
ret = SR_OK;
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
@ -575,7 +573,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
GSList *l;
|
GSList *l;
|
||||||
char cmd[256];
|
char cmd[256];
|
||||||
|
|
||||||
(void)cb_data;
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
|
@ -365,7 +365,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("sdi->priv was NULL.");
|
sr_err("sdi->priv was NULL.");
|
||||||
|
@ -417,6 +417,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_serial_dev_inst *serial;
|
struct sr_serial_dev_inst *serial;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("sdi->priv was NULL.");
|
sr_err("sdi->priv was NULL.");
|
||||||
return SR_ERR_BUG;
|
return SR_ERR_BUG;
|
||||||
|
|
|
@ -184,10 +184,8 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE) {
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
sr_err("Device inactive, can't set config options.");
|
return SR_ERR_DEV_CLOSED;
|
||||||
return SR_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
|
@ -230,6 +228,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
devc->cb_data = cb_data;
|
||||||
|
|
||||||
|
|
|
@ -147,11 +147,15 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct drv_context *drvc;
|
struct drv_context *drvc;
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
int ret;
|
||||||
|
|
||||||
drvc = di->priv;
|
drvc = di->priv;
|
||||||
devc = sdi->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)
|
static int hw_dev_close(struct sr_dev_inst *sdi)
|
||||||
|
@ -160,6 +164,8 @@ static int hw_dev_close(struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
|
|
||||||
|
sdi->status = SR_ST_INACTIVE;
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,6 +257,9 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
gint64 now;
|
gint64 now;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!di->priv) {
|
if (!di->priv) {
|
||||||
sr_err("Driver was not initialized.");
|
sr_err("Driver was not initialized.");
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
@ -396,6 +399,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
int ret, i;
|
int ret, i;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!di->priv) {
|
if (!di->priv) {
|
||||||
sr_err("Driver was not initialized.");
|
sr_err("Driver was not initialized.");
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
|
@ -524,10 +524,8 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
if (!sdi) {
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
sr_err("%s: sdi was NULL", __func__);
|
return SR_ERR_DEV_CLOSED;
|
||||||
return SR_ERR_ARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("%s: sdi->priv was NULL", __func__);
|
sr_err("%s: sdi->priv was NULL", __func__);
|
||||||
|
@ -600,6 +598,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
unsigned int packet_num, n;
|
unsigned int packet_num, n;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
|
|
||||||
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
if (!(devc = sdi->priv)) {
|
if (!(devc = sdi->priv)) {
|
||||||
sr_err("%s: sdi->priv was NULL", __func__);
|
sr_err("%s: sdi->priv was NULL", __func__);
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
|
|
|
@ -71,6 +71,7 @@ enum {
|
||||||
SR_ERR_BUG = -4, /**< Errors hinting at internal bugs. */
|
SR_ERR_BUG = -4, /**< Errors hinting at internal bugs. */
|
||||||
SR_ERR_SAMPLERATE = -5, /**< Incorrect samplerate. */
|
SR_ERR_SAMPLERATE = -5, /**< Incorrect samplerate. */
|
||||||
SR_ERR_NA = -6, /**< Not applicable. */
|
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. */
|
#define SR_MAX_NUM_PROBES 64 /* Limited by uint64_t. */
|
||||||
|
|
Loading…
Reference in New Issue