dev_acquisition_{start,stop}(): Drop duplicate 'cb_data' parameter.
These are always 'sdi', which is passed in already.
This commit is contained in:
parent
208c1d3543
commit
695dc859c1
|
@ -1156,11 +1156,9 @@ struct sr_dev_driver {
|
||||||
/** Close device */
|
/** Close device */
|
||||||
int (*dev_close) (struct sr_dev_inst *sdi);
|
int (*dev_close) (struct sr_dev_inst *sdi);
|
||||||
/** Begin data acquisition on the specified device. */
|
/** Begin data acquisition on the specified device. */
|
||||||
int (*dev_acquisition_start) (const struct sr_dev_inst *sdi,
|
int (*dev_acquisition_start) (const struct sr_dev_inst *sdi);
|
||||||
void *cb_data);
|
|
||||||
/** End data acquisition on the specified device. */
|
/** End data acquisition on the specified device. */
|
||||||
int (*dev_acquisition_stop) (struct sr_dev_inst *sdi,
|
int (*dev_acquisition_stop) (struct sr_dev_inst *sdi);
|
||||||
void *cb_data);
|
|
||||||
|
|
||||||
/* Dynamic */
|
/* Dynamic */
|
||||||
/** Device driver context, considered private. Initialized by init(). */
|
/** Device driver context, considered private. Initialized by init(). */
|
||||||
|
|
|
@ -55,9 +55,6 @@ struct dev_context {
|
||||||
uint64_t limit_samples;
|
uint64_t limit_samples;
|
||||||
uint64_t limit_msec;
|
uint64_t limit_msec;
|
||||||
|
|
||||||
/* Opaque pointer passed in by the frontend. */
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/* Runtime. */
|
/* Runtime. */
|
||||||
uint64_t num_samples;
|
uint64_t num_samples;
|
||||||
int64_t jobqueue[8];
|
int64_t jobqueue[8];
|
||||||
|
|
|
@ -227,18 +227,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
|
||||||
struct sr_serial_dev_inst *serial;
|
struct sr_serial_dev_inst *serial;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
|
||||||
|
|
||||||
/* Poll every 100ms, or whenever some data comes in. */
|
/* Poll every 100ms, or whenever some data comes in. */
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
|
@ -248,9 +244,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
|
return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
|
||||||
sdi->conn, LOG_PREFIX);
|
sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ SR_PRIV int agdmm_receive_data(int fd, int revents, void *cb_data)
|
||||||
dispatch(sdi);
|
dispatch(sdi);
|
||||||
|
|
||||||
if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
|
if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ static int recv_fetc(const struct sr_dev_inst *sdi, GMatchInfo *match)
|
||||||
analog.data = &fvalue;
|
analog.data = &fvalue;
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
|
|
||||||
|
|
|
@ -225,7 +225,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct sr_serial_dev_inst *serial;
|
struct sr_serial_dev_inst *serial;
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
@ -235,7 +235,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->session_cb_data = cb_data;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reset the number of samples to take. If we've already collected our
|
* Reset the number of samples to take. If we've already collected our
|
||||||
|
@ -245,7 +244,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
devc->num_samples = 0;
|
devc->num_samples = 0;
|
||||||
devc->start_time = g_get_monotonic_time();
|
devc->start_time = g_get_monotonic_time();
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Poll every 50ms, or whenever some data comes in. */
|
/* Poll every 50ms, or whenever some data comes in. */
|
||||||
serial_source_add(sdi->session, serial, G_IO_IN, 50,
|
serial_source_add(sdi->session, serial, G_IO_IN, 50,
|
||||||
|
@ -254,9 +253,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data,
|
return std_serial_dev_acquisition_stop(sdi, sdi,
|
||||||
std_serial_dev_close, sdi->conn, LOG_PREFIX);
|
std_serial_dev_close, sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ static void appa_55ii_live_data(struct sr_dev_inst *sdi, const uint8_t *buf)
|
||||||
|
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(devc->session_cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_slist_free(analog.channels);
|
g_slist_free(analog.channels);
|
||||||
|
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
|
@ -172,7 +172,7 @@ static void appa_55ii_log_data_parse(struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(devc->session_cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_slist_free(analog.channels);
|
g_slist_free(analog.channels);
|
||||||
|
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
|
@ -216,7 +216,7 @@ static void appa_55ii_log_end(struct sr_dev_inst *sdi)
|
||||||
if (devc->data_source != DATA_SOURCE_MEMORY)
|
if (devc->data_source != DATA_SOURCE_MEMORY)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sdi->driver->dev_acquisition_stop(sdi, devc->session_cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const uint8_t *appa_55ii_parse_data(struct sr_dev_inst *sdi,
|
static const uint8_t *appa_55ii_parse_data(struct sr_dev_inst *sdi,
|
||||||
|
@ -303,7 +303,7 @@ SR_PRIV int appa_55ii_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
||||||
sr_info("Requested number of samples reached.");
|
sr_info("Requested number of samples reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, devc->session_cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,8 +311,7 @@ SR_PRIV int appa_55ii_receive_data(int fd, int revents, void *cb_data)
|
||||||
time = (g_get_monotonic_time() - devc->start_time) / 1000;
|
time = (g_get_monotonic_time() - devc->start_time) / 1000;
|
||||||
if (time > (int64_t)devc->limit_msec) {
|
if (time > (int64_t)devc->limit_msec) {
|
||||||
sr_info("Requested time limit reached.");
|
sr_info("Requested time limit reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi,
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
devc->session_cb_data);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ struct dev_context {
|
||||||
uint64_t limit_samples; /**< The sampling limit (in number of samples). */
|
uint64_t limit_samples; /**< The sampling limit (in number of samples). */
|
||||||
uint64_t limit_msec; /**< The time limit (in milliseconds). */
|
uint64_t limit_msec; /**< The time limit (in milliseconds). */
|
||||||
gboolean data_source; /**< Whether to read live samples or memory */
|
gboolean data_source; /**< Whether to read live samples or memory */
|
||||||
void *session_cb_data; /**< Opaque pointer passed in by the frontend. */
|
|
||||||
|
|
||||||
/* Operational state */
|
/* Operational state */
|
||||||
uint64_t num_samples; /**< The number of already received samples. */
|
uint64_t num_samples; /**< The number of already received samples. */
|
||||||
|
|
|
@ -340,14 +340,12 @@ static int config_set(uint32_t key, GVariant *data,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_serial_dev_inst *serial;
|
struct sr_serial_dev_inst *serial;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
@ -366,7 +364,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
serial_source_add(sdi->session, serial, G_IO_IN, 100,
|
serial_source_add(sdi->session, serial, G_IO_IN, 100,
|
||||||
reloadpro_receive_data, (void *)sdi);
|
reloadpro_receive_data, (void *)sdi);
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
memset(devc->buf, 0, RELOADPRO_BUFSIZE);
|
memset(devc->buf, 0, RELOADPRO_BUFSIZE);
|
||||||
devc->buflen = 0;
|
devc->buflen = 0;
|
||||||
|
@ -376,9 +374,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data,
|
return std_serial_dev_acquisition_stop(sdi, sdi,
|
||||||
std_serial_dev_close, sdi->conn, LOG_PREFIX);
|
std_serial_dev_close, sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -266,7 +266,7 @@ SR_PRIV int reloadpro_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
|
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
|
||||||
sr_info("Requested number of samples reached.");
|
sr_info("Requested number of samples reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ SR_PRIV int reloadpro_receive_data(int fd, int revents, void *cb_data)
|
||||||
t = (g_get_monotonic_time() - devc->starttime) / 1000;
|
t = (g_get_monotonic_time() - devc->starttime) / 1000;
|
||||||
if (t > (int64_t)devc->limit_msec) {
|
if (t > (int64_t)devc->limit_msec) {
|
||||||
sr_info("Requested time limit reached.");
|
sr_info("Requested time limit reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct clockselect_50 clockselect;
|
struct clockselect_50 clockselect;
|
||||||
|
@ -398,8 +398,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
gettimeofday(&devc->start_tv, 0);
|
gettimeofday(&devc->start_tv, 0);
|
||||||
sigma_set_register(WRITE_MODE, 0x0d, devc);
|
sigma_set_register(WRITE_MODE, 0x0d, devc);
|
||||||
|
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
std_session_send_df_header(sdi, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Add capture source. */
|
/* Add capture source. */
|
||||||
|
@ -410,12 +408,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->state.state = SIGMA_IDLE;
|
devc->state.state = SIGMA_IDLE;
|
||||||
|
|
||||||
|
|
|
@ -908,7 +908,7 @@ static int download_capture(struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
std_session_send_df_end(sdi, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
sdi->driver->dev_acquisition_stop(sdi, sdi);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
|
|
||||||
g_free(dram_line);
|
g_free(dram_line);
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,6 @@ struct dev_context {
|
||||||
struct sigma_trigger trigger;
|
struct sigma_trigger trigger;
|
||||||
int use_triggers;
|
int use_triggers;
|
||||||
struct sigma_state state;
|
struct sigma_state state;
|
||||||
void *cb_data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SR_PRIV const uint64_t samplerates[];
|
extern SR_PRIV const uint64_t samplerates[];
|
||||||
|
|
|
@ -460,14 +460,12 @@ static int dev_close(struct sr_dev_inst *sdi)
|
||||||
return std_serial_dev_close(sdi);
|
return std_serial_dev_close(sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int 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;
|
||||||
uint8_t packet[PACKET_SIZE];
|
uint8_t packet[PACKET_SIZE];
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
@ -480,7 +478,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
serial_source_add(sdi->session, serial, G_IO_IN, 50,
|
serial_source_add(sdi->session, serial, G_IO_IN, 50,
|
||||||
atten_pps3xxx_receive_data, (void *)sdi);
|
atten_pps3xxx_receive_data, (void *)sdi);
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Send a "channel" configuration packet now. */
|
/* Send a "channel" configuration packet now. */
|
||||||
memset(packet, 0, PACKET_SIZE);
|
memset(packet, 0, PACKET_SIZE);
|
||||||
|
@ -491,12 +489,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ static int dev_acquisition_open(const struct sr_dev_inst *sdi)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct itimerspec tspec = {
|
struct itimerspec tspec = {
|
||||||
|
@ -357,8 +357,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
.it_value = { 0, 0 }
|
.it_value = { 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
@ -398,12 +396,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
|
|
@ -750,7 +750,7 @@ SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data)
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < nrexpiration; i++) {
|
for (i = 0; i < nrexpiration; i++) {
|
||||||
framep.type = SR_DF_FRAME_BEGIN;
|
framep.type = SR_DF_FRAME_BEGIN;
|
||||||
sr_session_send(cb_data, &framep);
|
sr_session_send(sdi, &framep);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Due to different units used in each channel we're sending
|
* Due to different units used in each channel we're sending
|
||||||
|
@ -773,18 +773,18 @@ SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data)
|
||||||
chp->val = read_sample(ch);
|
chp->val = read_sample(ch);
|
||||||
|
|
||||||
analog.data = &chp->val;
|
analog.data = &chp->val;
|
||||||
sr_session_send(cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
framep.type = SR_DF_FRAME_END;
|
framep.type = SR_DF_FRAME_END;
|
||||||
sr_session_send(cb_data, &framep);
|
sr_session_send(sdi, &framep);
|
||||||
}
|
}
|
||||||
|
|
||||||
devc->samples_read++;
|
devc->samples_read++;
|
||||||
if (devc->limit_samples > 0 &&
|
if (devc->limit_samples > 0 &&
|
||||||
devc->samples_read >= devc->limit_samples) {
|
devc->samples_read >= devc->limit_samples) {
|
||||||
sr_info("Requested number of samples reached.");
|
sr_info("Requested number of samples reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
devc->last_sample_fin = g_get_monotonic_time();
|
devc->last_sample_fin = g_get_monotonic_time();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (devc->limit_msec > 0) {
|
} else if (devc->limit_msec > 0) {
|
||||||
|
@ -793,7 +793,7 @@ SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
if (elapsed_time >= devc->limit_msec) {
|
if (elapsed_time >= devc->limit_msec) {
|
||||||
sr_info("Sampling time limit reached.");
|
sr_info("Sampling time limit reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
devc->last_sample_fin = g_get_monotonic_time();
|
devc->last_sample_fin = g_get_monotonic_time();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -337,19 +337,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
#define BUFUNIT_TIMEOUT_MS(devc) (100 + ((devc->bufunitsize * 1000) / \
|
#define BUFUNIT_TIMEOUT_MS(devc) (100 + ((devc->bufunitsize * 1000) / \
|
||||||
(uint32_t)(devc->cur_samplerate)))
|
(uint32_t)(devc->cur_samplerate)))
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc = sdi->priv;
|
struct dev_context *devc = sdi->priv;
|
||||||
struct sr_trigger *trigger;
|
struct sr_trigger *trigger;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
/* Save user pointer */
|
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
/* Clear capture state */
|
/* Clear capture state */
|
||||||
devc->bytes_read = 0;
|
devc->bytes_read = 0;
|
||||||
devc->offset = 0;
|
devc->offset = 0;
|
||||||
|
@ -370,7 +365,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
devc->trigger_fired = FALSE;
|
devc->trigger_fired = FALSE;
|
||||||
} else
|
} else
|
||||||
devc->trigger_fired = TRUE;
|
devc->trigger_fired = TRUE;
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Trigger and add poll on file */
|
/* Trigger and add poll on file */
|
||||||
beaglelogic_start(devc);
|
beaglelogic_start(devc);
|
||||||
|
@ -381,12 +376,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc = sdi->priv;
|
struct dev_context *devc = sdi->priv;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ SR_PRIV int beaglelogic_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
if (devc->trigger_fired) {
|
if (devc->trigger_fired) {
|
||||||
/* Send the incoming transfer to the session bus. */
|
/* Send the incoming transfer to the session bus. */
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
} else {
|
} else {
|
||||||
/* Check for trigger */
|
/* Check for trigger */
|
||||||
trigger_offset = soft_trigger_logic_check(devc->stl,
|
trigger_offset = soft_trigger_logic_check(devc->stl,
|
||||||
|
@ -76,7 +76,7 @@ SR_PRIV int beaglelogic_receive_data(int fd, int revents, void *cb_data)
|
||||||
bytes_remaining);
|
bytes_remaining);
|
||||||
logic.data += trigger_offset;
|
logic.data += trigger_offset;
|
||||||
|
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
devc->trigger_fired = TRUE;
|
devc->trigger_fired = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ SR_PRIV int beaglelogic_receive_data(int fd, int revents, void *cb_data)
|
||||||
if (devc->bytes_read >= devc->limit_samples * logic.unitsize ||
|
if (devc->bytes_read >= devc->limit_samples * logic.unitsize ||
|
||||||
packetsize == 0) {
|
packetsize == 0) {
|
||||||
/* Send EOA Packet, stop polling */
|
/* Send EOA Packet, stop polling */
|
||||||
std_session_send_df_end(devc->cb_data, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
sr_session_source_remove_pollfd(sdi->session, &devc->pollfd);
|
sr_session_source_remove_pollfd(sdi->session, &devc->pollfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,6 @@ struct dev_context {
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
uint8_t *sample_buf; /* mmap'd kernel buffer here */
|
uint8_t *sample_buf; /* mmap'd kernel buffer here */
|
||||||
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/* Trigger logic */
|
/* Trigger logic */
|
||||||
struct soft_trigger_logic *stl;
|
struct soft_trigger_logic *stl;
|
||||||
gboolean trigger_fired;
|
gboolean trigger_fired;
|
||||||
|
|
|
@ -249,12 +249,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
@ -269,10 +267,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
|
|
@ -330,7 +330,7 @@ SR_PRIV int brymen_bm86x_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
||||||
sr_info("Requested number of samples reached, stopping.");
|
sr_info("Requested number of samples reached, stopping.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ SR_PRIV int brymen_bm86x_receive_data(int fd, int revents, void *cb_data)
|
||||||
time = (g_get_monotonic_time() - devc->start_time) / 1000;
|
time = (g_get_monotonic_time() - devc->start_time) / 1000;
|
||||||
if (time > (int64_t)devc->limit_msec) {
|
if (time > (int64_t)devc->limit_msec) {
|
||||||
sr_info("Requested time limit reached, stopping.");
|
sr_info("Requested time limit reached, stopping.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int 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;
|
||||||
|
@ -203,7 +203,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reset the number of samples to take. If we've already collected our
|
* Reset the number of samples to take. If we've already collected our
|
||||||
|
@ -213,7 +212,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
devc->num_samples = 0;
|
devc->num_samples = 0;
|
||||||
devc->starttime = g_get_monotonic_time();
|
devc->starttime = g_get_monotonic_time();
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Poll every 50ms, or whenever some data comes in. */
|
/* Poll every 50ms, or whenever some data comes in. */
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
|
@ -223,9 +222,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
|
return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
|
||||||
sdi->conn, LOG_PREFIX);
|
sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi)
|
||||||
/* Got a measurement. */
|
/* Got a measurement. */
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ SR_PRIV int brymen_dmm_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
||||||
sr_info("Requested number of samples reached, stopping.");
|
sr_info("Requested number of samples reached, stopping.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ SR_PRIV int brymen_dmm_receive_data(int fd, int revents, void *cb_data)
|
||||||
time = (g_get_monotonic_time() - devc->starttime) / 1000;
|
time = (g_get_monotonic_time() - devc->starttime) / 1000;
|
||||||
if (time > (int64_t)devc->limit_msec) {
|
if (time > (int64_t)devc->limit_msec) {
|
||||||
sr_info("Requested time limit reached, stopping.");
|
sr_info("Requested time limit reached, stopping.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,6 @@ struct dev_context {
|
||||||
/** The current sampling limit (in ms). */
|
/** The current sampling limit (in ms). */
|
||||||
uint64_t limit_msec;
|
uint64_t limit_msec;
|
||||||
|
|
||||||
/** Opaque pointer passed in by the frontend. */
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/** The current number of already received samples. */
|
/** The current number of already received samples. */
|
||||||
uint64_t num_samples;
|
uint64_t num_samples;
|
||||||
|
|
||||||
|
|
|
@ -378,7 +378,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int 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;
|
||||||
|
@ -387,12 +387,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
devc->state = ST_INIT;
|
devc->state = ST_INIT;
|
||||||
devc->num_samples = 0;
|
devc->num_samples = 0;
|
||||||
devc->buf_len = 0;
|
devc->buf_len = 0;
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Poll every 100ms, or whenever some data comes in. */
|
/* Poll every 100ms, or whenever some data comes in. */
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
|
@ -402,12 +401,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
|
return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
|
||||||
sdi->conn, LOG_PREFIX);
|
sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,12 +140,11 @@ static void process_mset(const struct sr_dev_inst *sdi)
|
||||||
analog.data = &devc->last_spl;
|
analog.data = &devc->last_spl;
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
|
if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
|
||||||
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
|
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
|
||||||
devc->cb_data);
|
|
||||||
break;
|
break;
|
||||||
case TOKEN_RECORDING_ON:
|
case TOKEN_RECORDING_ON:
|
||||||
devc->recording = TRUE;
|
devc->recording = TRUE;
|
||||||
|
@ -199,12 +198,11 @@ static void send_data(const struct sr_dev_inst *sdi, unsigned char *data,
|
||||||
analog.data = fbuf;
|
analog.data = fbuf;
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
devc->num_samples += analog.num_samples;
|
devc->num_samples += analog.num_samples;
|
||||||
if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
|
if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
|
||||||
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
|
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
|
||||||
devc->cb_data);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -317,8 +315,7 @@ static void process_byte(const struct sr_dev_inst *sdi, const unsigned char c,
|
||||||
* records. Otherwise the frontend would have no
|
* records. Otherwise the frontend would have no
|
||||||
* way to tell where stored data ends and live
|
* way to tell where stored data ends and live
|
||||||
* measurements begin. */
|
* measurements begin. */
|
||||||
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
|
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
|
||||||
devc->cb_data);
|
|
||||||
} else if (c == RECORD_DATA) {
|
} else if (c == RECORD_DATA) {
|
||||||
devc->buf_len = 0;
|
devc->buf_len = 0;
|
||||||
devc->state = ST_GET_LOG_RECORD_DATA;
|
devc->state = ST_GET_LOG_RECORD_DATA;
|
||||||
|
@ -342,7 +339,7 @@ static void process_byte(const struct sr_dev_inst *sdi, const unsigned char c,
|
||||||
src = sr_config_new(SR_CONF_SAMPLE_INTERVAL,
|
src = sr_config_new(SR_CONF_SAMPLE_INTERVAL,
|
||||||
g_variant_new_uint64(devc->buf[7] * 1000));
|
g_variant_new_uint64(devc->buf[7] * 1000));
|
||||||
meta.config = g_slist_append(NULL, src);
|
meta.config = g_slist_append(NULL, src);
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_free(src);
|
g_free(src);
|
||||||
devc->buf_len = 0;
|
devc->buf_len = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,6 @@ struct dev_context {
|
||||||
gboolean enable_data_source_memory;
|
gboolean enable_data_source_memory;
|
||||||
|
|
||||||
/* Temporary state across callbacks */
|
/* Temporary state across callbacks */
|
||||||
void *cb_data;
|
|
||||||
unsigned char cmd;
|
unsigned char cmd;
|
||||||
unsigned char token;
|
unsigned char token;
|
||||||
int buf_len;
|
int buf_len;
|
||||||
|
|
|
@ -204,8 +204,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx)
|
||||||
void *cb_data, int idx)
|
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_serial_dev_inst *serial;
|
struct sr_serial_dev_inst *serial;
|
||||||
|
@ -214,11 +213,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
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();
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Poll every 500ms, or whenever some data comes in. */
|
/* Poll every 500ms, or whenever some data comes in. */
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
|
@ -228,9 +226,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data,
|
return std_serial_dev_acquisition_stop(sdi, sdi,
|
||||||
std_serial_dev_close, sdi->conn, LOG_PREFIX);
|
std_serial_dev_close, sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,8 +249,8 @@ static GSList *dev_list_##X(const struct sr_dev_driver *d) { \
|
||||||
static int dev_clear_##X(const struct sr_dev_driver *d) { \
|
static int dev_clear_##X(const struct sr_dev_driver *d) { \
|
||||||
(void)d; return dev_clear(X); }
|
(void)d; return dev_clear(X); }
|
||||||
#define HW_DEV_ACQUISITION_START(X) \
|
#define HW_DEV_ACQUISITION_START(X) \
|
||||||
static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
|
static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \
|
||||||
void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }
|
) { return dev_acquisition_start(sdi, X); }
|
||||||
|
|
||||||
/* Driver structs and API function wrappers */
|
/* Driver structs and API function wrappers */
|
||||||
#define DRV(ID, ID_UPPER, NAME, LONGNAME) \
|
#define DRV(ID, ID_UPPER, NAME, LONGNAME) \
|
||||||
|
|
|
@ -153,7 +153,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
|
||||||
l = g_slist_append(l, g_slist_nth_data(sdi->channels, i));
|
l = g_slist_append(l, g_slist_nth_data(sdi->channels, i));
|
||||||
analog.channels = l;
|
analog.channels = l;
|
||||||
analog.data = &(info.temp[i]);
|
analog.data = &(info.temp[i]);
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_slist_free(l);
|
g_slist_free(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
|
||||||
|
|
||||||
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
||||||
sr_info("Requested number of samples reached.");
|
sr_info("Requested number of samples reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
|
||||||
t = (g_get_monotonic_time() - devc->starttime) / 1000;
|
t = (g_get_monotonic_time() - devc->starttime) / 1000;
|
||||||
if (t > (int64_t)devc->limit_msec) {
|
if (t > (int64_t)devc->limit_msec) {
|
||||||
sr_info("Requested time limit reached.");
|
sr_info("Requested time limit reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,6 @@ struct dev_context {
|
||||||
/** The current sampling limit (in ms). */
|
/** The current sampling limit (in ms). */
|
||||||
uint64_t limit_msec;
|
uint64_t limit_msec;
|
||||||
|
|
||||||
/** Opaque pointer passed in by the frontend. */
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/** The current number of already received samples. */
|
/** The current number of already received samples. */
|
||||||
uint64_t num_samples;
|
uint64_t num_samples;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ static const int32_t trigger_matches[] = {
|
||||||
SR_TRIGGER_FALLING,
|
SR_TRIGGER_FALLING,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi);
|
||||||
|
|
||||||
static void clear_helper(void *priv)
|
static void clear_helper(void *priv)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +92,6 @@ static int add_device(int model, struct libusb_device_descriptor *des,
|
||||||
devc->cur_samplerate = 0; /* Set later (different for LA8/LA16). */
|
devc->cur_samplerate = 0; /* Set later (different for LA8/LA16). */
|
||||||
devc->limit_msec = 0;
|
devc->limit_msec = 0;
|
||||||
devc->limit_samples = 0;
|
devc->limit_samples = 0;
|
||||||
devc->cb_data = NULL;
|
|
||||||
memset(devc->mangled_buf, 0, BS);
|
memset(devc->mangled_buf, 0, BS);
|
||||||
devc->final_buf = NULL;
|
devc->final_buf = NULL;
|
||||||
devc->trigger_pattern = 0x0000; /* Irrelevant, see trigger_mask. */
|
devc->trigger_pattern = 0x0000; /* Irrelevant, see trigger_mask. */
|
||||||
|
@ -478,7 +477,7 @@ static int receive_data(int fd, int revents, void *cb_data)
|
||||||
/* Get one block of data. */
|
/* Get one block of data. */
|
||||||
if ((ret = cv_read_block(devc)) < 0) {
|
if ((ret = cv_read_block(devc)) < 0) {
|
||||||
sr_err("Failed to read data block: %d.", ret);
|
sr_err("Failed to read data block: %d.", ret);
|
||||||
dev_acquisition_stop(sdi, sdi);
|
dev_acquisition_stop(sdi);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,14 +498,14 @@ static int receive_data(int fd, int revents, void *cb_data)
|
||||||
* full 8MByte first, only then the whole buffer contains valid data.
|
* full 8MByte first, only then the whole buffer contains valid data.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < NUM_BLOCKS; i++)
|
for (i = 0; i < NUM_BLOCKS; i++)
|
||||||
cv_send_block_to_session_bus(devc, i);
|
cv_send_block_to_session_bus(sdi, i);
|
||||||
|
|
||||||
dev_acquisition_stop(sdi, sdi);
|
dev_acquisition_stop(sdi);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
uint8_t buf[8];
|
uint8_t buf[8];
|
||||||
|
@ -562,8 +561,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
|
|
||||||
sr_dbg("Hardware acquisition started successfully.");
|
sr_dbg("Hardware acquisition started successfully.");
|
||||||
|
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
std_session_send_df_header(sdi, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Time when we should be done (for detecting trigger timeouts). */
|
/* Time when we should be done (for detecting trigger timeouts). */
|
||||||
|
@ -578,10 +575,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
sr_dbg("Stopping acquisition.");
|
sr_dbg("Stopping acquisition.");
|
||||||
sr_session_source_remove(sdi->session, -1);
|
sr_session_source_remove(sdi->session, -1);
|
||||||
std_session_send_df_end(sdi, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
|
|
|
@ -401,16 +401,19 @@ SR_PRIV int cv_read_block(struct dev_context *devc)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block)
|
SR_PRIV void cv_send_block_to_session_bus(const struct sr_dev_inst *sdi, int block)
|
||||||
{
|
{
|
||||||
int i, idx;
|
int i, idx;
|
||||||
uint8_t sample, expected_sample, tmp8;
|
uint8_t sample, expected_sample, tmp8;
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
struct sr_datafeed_logic logic;
|
struct sr_datafeed_logic logic;
|
||||||
int trigger_point; /* Relative trigger point (in this block). */
|
int trigger_point; /* Relative trigger point (in this block). */
|
||||||
|
struct dev_context *devc;
|
||||||
|
|
||||||
/* Note: Caller ensures devc/devc->ftdic != NULL and block > 0. */
|
/* Note: Caller ensures devc/devc->ftdic != NULL and block > 0. */
|
||||||
|
|
||||||
|
devc = sdi->priv;
|
||||||
|
|
||||||
/* TODO: Implement/test proper trigger support for the LA16. */
|
/* TODO: Implement/test proper trigger support for the LA16. */
|
||||||
|
|
||||||
/* Check if we can find the trigger condition in this block. */
|
/* Check if we can find the trigger condition in this block. */
|
||||||
|
@ -458,7 +461,7 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block)
|
||||||
logic.length = BS;
|
logic.length = BS;
|
||||||
logic.unitsize = devc->prof->num_channels / 8;
|
logic.unitsize = devc->prof->num_channels / 8;
|
||||||
logic.data = devc->final_buf + (block * BS);
|
logic.data = devc->final_buf + (block * BS);
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,7 +484,7 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block)
|
||||||
logic.length = trigger_point;
|
logic.length = trigger_point;
|
||||||
logic.unitsize = devc->prof->num_channels / 8;
|
logic.unitsize = devc->prof->num_channels / 8;
|
||||||
logic.data = devc->final_buf + (block * BS);
|
logic.data = devc->final_buf + (block * BS);
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send the SR_DF_TRIGGER packet to the session bus. */
|
/* Send the SR_DF_TRIGGER packet to the session bus. */
|
||||||
|
@ -489,7 +492,7 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block)
|
||||||
(block * BS) + trigger_point);
|
(block * BS) + trigger_point);
|
||||||
packet.type = SR_DF_TRIGGER;
|
packet.type = SR_DF_TRIGGER;
|
||||||
packet.payload = NULL;
|
packet.payload = NULL;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
/* If at least one sample is located after the trigger... */
|
/* If at least one sample is located after the trigger... */
|
||||||
if (trigger_point < (BS - 1)) {
|
if (trigger_point < (BS - 1)) {
|
||||||
|
@ -502,6 +505,6 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block)
|
||||||
logic.length = BS - trigger_point;
|
logic.length = BS - trigger_point;
|
||||||
logic.unitsize = devc->prof->num_channels / 8;
|
logic.unitsize = devc->prof->num_channels / 8;
|
||||||
logic.data = devc->final_buf + (block * BS) + trigger_point;
|
logic.data = devc->final_buf + (block * BS) + trigger_point;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,6 @@ struct dev_context {
|
||||||
/** The current sampling limit (in number of samples). */
|
/** The current sampling limit (in number of samples). */
|
||||||
uint64_t limit_samples;
|
uint64_t limit_samples;
|
||||||
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A buffer containing some (mangled) samples from the device.
|
* A buffer containing some (mangled) samples from the device.
|
||||||
* Format: Pretty mangled-up (due to hardware reasons), see code.
|
* Format: Pretty mangled-up (due to hardware reasons), see code.
|
||||||
|
@ -137,6 +135,6 @@ SR_PRIV int cv_write(struct dev_context *devc, uint8_t *buf, int size);
|
||||||
SR_PRIV int cv_convert_trigger(const struct sr_dev_inst *sdi);
|
SR_PRIV int cv_convert_trigger(const struct sr_dev_inst *sdi);
|
||||||
SR_PRIV int cv_set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate);
|
SR_PRIV int cv_set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate);
|
||||||
SR_PRIV int cv_read_block(struct dev_context *devc);
|
SR_PRIV int cv_read_block(struct dev_context *devc);
|
||||||
SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block);
|
SR_PRIV void cv_send_block_to_session_bus(const struct sr_dev_inst *sdi, int block);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -171,18 +171,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
|
||||||
struct sr_serial_dev_inst *serial;
|
struct sr_serial_dev_inst *serial;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
|
||||||
|
|
||||||
/* Poll every 150ms, or whenever some data comes in. */
|
/* Poll every 150ms, or whenever some data comes in. */
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
|
@ -192,9 +188,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
|
return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
|
||||||
sdi->conn, LOG_PREFIX);
|
sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,13 +169,11 @@ static void process_packet(const struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
if (devc->num_samples >= devc->limit_samples)
|
if (devc->num_samples >= devc->limit_samples)
|
||||||
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
|
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
|
||||||
devc->cb_data);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV int colead_slm_receive_data(int fd, int revents, void *cb_data)
|
SR_PRIV int colead_slm_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
|
@ -39,9 +39,6 @@ struct dev_context {
|
||||||
/** The current sampling limit (in ms). */
|
/** The current sampling limit (in ms). */
|
||||||
uint64_t limit_msec;
|
uint64_t limit_msec;
|
||||||
|
|
||||||
/** Opaque pointer passed in by the frontend. */
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/** The current number of already received samples. */
|
/** The current number of already received samples. */
|
||||||
uint64_t num_samples;
|
uint64_t num_samples;
|
||||||
int state;
|
int state;
|
||||||
|
|
|
@ -182,20 +182,16 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ static const uint8_t pattern_sigrok[] = {
|
||||||
|
|
||||||
SR_PRIV struct sr_dev_driver demo_driver_info;
|
SR_PRIV struct sr_dev_driver demo_driver_info;
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi);
|
||||||
|
|
||||||
static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
|
static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
|
||||||
{
|
{
|
||||||
|
@ -757,7 +757,7 @@ static int prepare_data(int fd, int revents, void *cb_data)
|
||||||
if (devc->cur_samplerate <= 0 || devc->logic_unitsize <= 0
|
if (devc->cur_samplerate <= 0 || devc->logic_unitsize <= 0
|
||||||
|| (devc->num_logic_channels <= 0
|
|| (devc->num_logic_channels <= 0
|
||||||
&& devc->num_analog_channels <= 0)) {
|
&& devc->num_analog_channels <= 0)) {
|
||||||
dev_acquisition_stop(sdi, sdi);
|
dev_acquisition_stop(sdi);
|
||||||
return G_SOURCE_CONTINUE;
|
return G_SOURCE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,20 +841,18 @@ static int prepare_data(int fd, int revents, void *cb_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sr_dbg("Requested number of samples reached.");
|
sr_dbg("Requested number of samples reached.");
|
||||||
dev_acquisition_stop(sdi, sdi);
|
dev_acquisition_stop(sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
return G_SOURCE_CONTINUE;
|
return G_SOURCE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
void *value;
|
void *value;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
@ -877,10 +875,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
sr_dbg("Stopping acquisition.");
|
sr_dbg("Stopping acquisition.");
|
||||||
sr_session_source_remove(sdi->session, -1);
|
sr_session_source_remove(sdi->session, -1);
|
||||||
std_session_send_df_end(sdi, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
|
|
|
@ -251,7 +251,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int 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;
|
||||||
|
@ -260,9 +260,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Poll every 100ms, or whenever some data comes in. */
|
/* Poll every 100ms, or whenever some data comes in. */
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
|
@ -279,9 +278,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
|
return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
|
||||||
sdi->conn, LOG_PREFIX);
|
sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,6 @@ struct dev_context {
|
||||||
uint64_t limit_samples;
|
uint64_t limit_samples;
|
||||||
uint64_t limit_msec;
|
uint64_t limit_msec;
|
||||||
|
|
||||||
/* Opaque pointer passed in by the frontend. */
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/* Runtime. */
|
/* Runtime. */
|
||||||
uint64_t num_samples;
|
uint64_t num_samples;
|
||||||
char buf[FLUKEDMM_BUFSIZE];
|
char buf[FLUKEDMM_BUFSIZE];
|
||||||
|
|
|
@ -399,7 +399,7 @@ static void handle_qm_19x_data(const struct sr_dev_inst *sdi, char **tokens)
|
||||||
analog.mqflags = 0;
|
analog.mqflags = 0;
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -467,7 +467,7 @@ static void handle_line(const struct sr_dev_inst *sdi)
|
||||||
/* Got a measurement. */
|
/* Got a measurement. */
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = analog;
|
packet.payload = analog;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
g_free(analog->data);
|
g_free(analog->data);
|
||||||
g_free(analog);
|
g_free(analog);
|
||||||
|
@ -509,7 +509,7 @@ SR_PRIV int fluke_receive_data(int fd, int revents, void *cb_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -457,12 +457,10 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
@ -473,8 +471,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
|
|
||||||
ftdi_set_bitmode(devc->ftdic, 0, BITMODE_BITBANG);
|
ftdi_set_bitmode(devc->ftdic, 0, BITMODE_BITBANG);
|
||||||
|
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
/* Properly reset internal variables before every new acquisition. */
|
/* Properly reset internal variables before every new acquisition. */
|
||||||
devc->samples_sent = 0;
|
devc->samples_sent = 0;
|
||||||
devc->bytes_received = 0;
|
devc->bytes_received = 0;
|
||||||
|
@ -488,10 +484,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
|
|
@ -20,19 +20,22 @@
|
||||||
#include <ftdi.h>
|
#include <ftdi.h>
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
|
||||||
static void send_samples(struct dev_context *devc, uint64_t samples_to_send)
|
static void send_samples(struct sr_dev_inst *sdi, uint64_t samples_to_send)
|
||||||
{
|
{
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
struct sr_datafeed_logic logic;
|
struct sr_datafeed_logic logic;
|
||||||
|
struct dev_context *devc;
|
||||||
|
|
||||||
sr_spew("Sending %" PRIu64 " samples.", samples_to_send);
|
sr_spew("Sending %" PRIu64 " samples.", samples_to_send);
|
||||||
|
|
||||||
|
devc = sdi->priv;
|
||||||
|
|
||||||
packet.type = SR_DF_LOGIC;
|
packet.type = SR_DF_LOGIC;
|
||||||
packet.payload = &logic;
|
packet.payload = &logic;
|
||||||
logic.length = samples_to_send;
|
logic.length = samples_to_send;
|
||||||
logic.unitsize = 1;
|
logic.unitsize = 1;
|
||||||
logic.data = devc->data_buf;
|
logic.data = devc->data_buf;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
devc->samples_sent += samples_to_send;
|
devc->samples_sent += samples_to_send;
|
||||||
devc->bytes_received -= samples_to_send;
|
devc->bytes_received -= samples_to_send;
|
||||||
|
@ -76,7 +79,7 @@ SR_PRIV int ftdi_la_receive_data(int fd, int revents, void *cb_data)
|
||||||
if (bytes_read < 0) {
|
if (bytes_read < 0) {
|
||||||
sr_err("Failed to read FTDI data (%d): %s.",
|
sr_err("Failed to read FTDI data (%d): %s.",
|
||||||
bytes_read, ftdi_get_error_string(devc->ftdic));
|
bytes_read, ftdi_get_error_string(devc->ftdic));
|
||||||
sdi->driver->dev_acquisition_stop(sdi, sdi);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (bytes_read == 0) {
|
if (bytes_read == 0) {
|
||||||
|
@ -89,12 +92,12 @@ SR_PRIV int ftdi_la_receive_data(int fd, int revents, void *cb_data)
|
||||||
n = devc->samples_sent + devc->bytes_received;
|
n = devc->samples_sent + devc->bytes_received;
|
||||||
|
|
||||||
if (devc->limit_samples && (n >= devc->limit_samples)) {
|
if (devc->limit_samples && (n >= devc->limit_samples)) {
|
||||||
send_samples(devc, devc->limit_samples - devc->samples_sent);
|
send_samples(sdi, devc->limit_samples - devc->samples_sent);
|
||||||
sr_info("Requested number of samples reached.");
|
sr_info("Requested number of samples reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
send_samples(devc, devc->bytes_received);
|
send_samples(sdi, devc->bytes_received);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -48,7 +48,6 @@ struct dev_context {
|
||||||
unsigned char *data_buf;
|
unsigned char *data_buf;
|
||||||
uint64_t samples_sent;
|
uint64_t samples_sent;
|
||||||
uint64_t bytes_received;
|
uint64_t bytes_received;
|
||||||
void *cb_data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SR_PRIV int ftdi_la_set_samplerate(struct dev_context *devc);
|
SR_PRIV int ftdi_la_set_samplerate(struct dev_context *devc);
|
||||||
|
|
|
@ -844,7 +844,7 @@ static int configure_channels(const struct sr_dev_inst *sdi)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct sr_dev_driver *di;
|
struct sr_dev_driver *di;
|
||||||
struct drv_context *drvc;
|
struct drv_context *drvc;
|
||||||
|
@ -860,7 +860,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
devc->ctx = drvc->sr_ctx;
|
devc->ctx = drvc->sr_ctx;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
devc->sent_samples = 0;
|
devc->sent_samples = 0;
|
||||||
devc->empty_transfer_count = 0;
|
devc->empty_transfer_count = 0;
|
||||||
devc->acq_aborted = FALSE;
|
devc->acq_aborted = FALSE;
|
||||||
|
@ -894,12 +893,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
if (devc->dslogic)
|
if (devc->dslogic)
|
||||||
|
|
|
@ -385,10 +385,14 @@ static void resubmit_transfer(struct libusb_transfer *transfer)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV void mso_send_data_proc(struct dev_context *devc,
|
SR_PRIV void mso_send_data_proc(struct sr_dev_inst *sdi,
|
||||||
uint8_t *data, size_t length, size_t sample_width)
|
uint8_t *data, size_t length, size_t sample_width)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
struct dev_context *devc;
|
||||||
|
|
||||||
|
devc = sdi->priv;
|
||||||
|
|
||||||
sample_width = sample_width;
|
sample_width = sample_width;
|
||||||
length /= 2;
|
length /= 2;
|
||||||
|
|
||||||
|
@ -409,7 +413,8 @@ SR_PRIV void mso_send_data_proc(struct dev_context *devc,
|
||||||
.type = SR_DF_LOGIC,
|
.type = SR_DF_LOGIC,
|
||||||
.payload = &logic
|
.payload = &logic
|
||||||
};
|
};
|
||||||
sr_session_send(devc->cb_data, &logic_packet);
|
|
||||||
|
sr_session_send(sdi, &logic_packet);
|
||||||
|
|
||||||
const struct sr_datafeed_analog_old analog = {
|
const struct sr_datafeed_analog_old analog = {
|
||||||
.channels = devc->enabled_analog_channels,
|
.channels = devc->enabled_analog_channels,
|
||||||
|
@ -424,11 +429,11 @@ SR_PRIV void mso_send_data_proc(struct dev_context *devc,
|
||||||
.type = SR_DF_ANALOG_OLD,
|
.type = SR_DF_ANALOG_OLD,
|
||||||
.payload = &analog
|
.payload = &analog
|
||||||
};
|
};
|
||||||
sr_session_send(devc->cb_data, &analog_packet);
|
|
||||||
|
|
||||||
|
sr_session_send(sdi, &analog_packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV void la_send_data_proc(struct dev_context *devc,
|
SR_PRIV void la_send_data_proc(struct sr_dev_inst *sdi,
|
||||||
uint8_t *data, size_t length, size_t sample_width)
|
uint8_t *data, size_t length, size_t sample_width)
|
||||||
{
|
{
|
||||||
const struct sr_datafeed_logic logic = {
|
const struct sr_datafeed_logic logic = {
|
||||||
|
@ -442,7 +447,7 @@ SR_PRIV void la_send_data_proc(struct dev_context *devc,
|
||||||
.payload = &logic
|
.payload = &logic
|
||||||
};
|
};
|
||||||
|
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transfer)
|
SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transfer)
|
||||||
|
@ -512,10 +517,8 @@ SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transf
|
||||||
else
|
else
|
||||||
num_samples = cur_sample_count;
|
num_samples = cur_sample_count;
|
||||||
|
|
||||||
devc->send_data_proc(devc,
|
devc->send_data_proc(sdi, (uint8_t *)transfer->buffer,
|
||||||
(uint8_t*)transfer->buffer,
|
num_samples * unitsize, unitsize);
|
||||||
num_samples * unitsize,
|
|
||||||
unitsize);
|
|
||||||
devc->sent_samples += num_samples;
|
devc->sent_samples += num_samples;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -528,10 +531,9 @@ SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transf
|
||||||
num_samples > devc->limit_samples - devc->sent_samples)
|
num_samples > devc->limit_samples - devc->sent_samples)
|
||||||
num_samples = devc->limit_samples - devc->sent_samples;
|
num_samples = devc->limit_samples - devc->sent_samples;
|
||||||
|
|
||||||
devc->send_data_proc(devc,
|
devc->send_data_proc(sdi, (uint8_t *)transfer->buffer
|
||||||
(uint8_t*)transfer->buffer + trigger_offset * unitsize,
|
+ trigger_offset * unitsize,
|
||||||
num_samples * unitsize,
|
num_samples * unitsize, unitsize);
|
||||||
unitsize);
|
|
||||||
devc->sent_samples += num_samples;
|
devc->sent_samples += num_samples;
|
||||||
|
|
||||||
devc->trigger_fired = TRUE;
|
devc->trigger_fired = TRUE;
|
||||||
|
|
|
@ -122,11 +122,10 @@ struct dev_context {
|
||||||
int submitted_transfers;
|
int submitted_transfers;
|
||||||
int empty_transfer_count;
|
int empty_transfer_count;
|
||||||
|
|
||||||
void *cb_data;
|
|
||||||
unsigned int num_transfers;
|
unsigned int num_transfers;
|
||||||
struct libusb_transfer **transfers;
|
struct libusb_transfer **transfers;
|
||||||
struct sr_context *ctx;
|
struct sr_context *ctx;
|
||||||
void (*send_data_proc)(struct dev_context *devc,
|
void (*send_data_proc)(struct sr_dev_inst *sdi,
|
||||||
uint8_t *data, size_t length, size_t sample_width);
|
uint8_t *data, size_t length, size_t sample_width);
|
||||||
uint8_t *logic_buffer;
|
uint8_t *logic_buffer;
|
||||||
float *analog_buffer;
|
float *analog_buffer;
|
||||||
|
@ -148,9 +147,9 @@ SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transf
|
||||||
SR_PRIV size_t fx2lafw_get_buffer_size(struct dev_context *devc);
|
SR_PRIV size_t fx2lafw_get_buffer_size(struct dev_context *devc);
|
||||||
SR_PRIV unsigned int fx2lafw_get_number_of_transfers(struct dev_context *devc);
|
SR_PRIV unsigned int fx2lafw_get_number_of_transfers(struct dev_context *devc);
|
||||||
SR_PRIV unsigned int fx2lafw_get_timeout(struct dev_context *devc);
|
SR_PRIV unsigned int fx2lafw_get_timeout(struct dev_context *devc);
|
||||||
SR_PRIV void la_send_data_proc(struct dev_context *devc, uint8_t *data, size_t length,
|
SR_PRIV void la_send_data_proc(struct sr_dev_inst *sdi, uint8_t *data,
|
||||||
size_t sample_width);
|
size_t length, size_t sample_width);
|
||||||
SR_PRIV void mso_send_data_proc(struct dev_context *devc, uint8_t *data, size_t length,
|
SR_PRIV void mso_send_data_proc(struct sr_dev_inst *sdi, uint8_t *data,
|
||||||
size_t sample_width);
|
size_t length, size_t sample_width);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -460,8 +460,7 @@ static int config_list_bd(uint32_t key, GVariant **data, const struct sr_dev_ins
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi,
|
static int dev_acquisition_start_1x_2x_rs232(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;
|
||||||
|
@ -470,11 +469,10 @@ static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi,
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
devc->settings_ok = FALSE;
|
devc->settings_ok = FALSE;
|
||||||
devc->buflen = 0;
|
devc->buflen = 0;
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Start timer, if required. */
|
/* Start timer, if required. */
|
||||||
if (devc->limit_msec)
|
if (devc->limit_msec)
|
||||||
|
@ -488,8 +486,7 @@ static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi,
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi,
|
static int dev_acquisition_start_2x_bd232(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;
|
||||||
|
@ -498,11 +495,10 @@ static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi,
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
devc->settings_ok = FALSE;
|
devc->settings_ok = FALSE;
|
||||||
devc->buflen = 0;
|
devc->buflen = 0;
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Start timer, if required. */
|
/* Start timer, if required. */
|
||||||
if (devc->limit_msec)
|
if (devc->limit_msec)
|
||||||
|
@ -517,7 +513,7 @@ static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi,
|
||||||
return req_meas14(sdi);
|
return req_meas14(sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
|
@ -525,7 +521,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
||||||
if (sdi && (devc = sdi->priv) && devc->limit_msec)
|
if (sdi && (devc = sdi->priv) && devc->limit_msec)
|
||||||
g_timer_stop(devc->elapsed_msec);
|
g_timer_stop(devc->elapsed_msec);
|
||||||
|
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data, dev_close,
|
return std_serial_dev_acquisition_stop(sdi, sdi, dev_close,
|
||||||
sdi->conn, LOG_PREFIX);
|
sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -668,7 +668,7 @@ static void send_value(struct sr_dev_inst *sdi)
|
||||||
memset(&packet, 0, sizeof(struct sr_datafeed_packet));
|
memset(&packet, 0, sizeof(struct sr_datafeed_packet));
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
}
|
}
|
||||||
|
@ -1173,12 +1173,12 @@ SR_PRIV int gmc_mh_1x_2x_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
/* If number of samples or time limit reached, stop acquisition. */
|
/* If number of samples or time limit reached, stop acquisition. */
|
||||||
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples))
|
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples))
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
|
|
||||||
if (devc->limit_msec) {
|
if (devc->limit_msec) {
|
||||||
elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL);
|
elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL);
|
||||||
if ((elapsed_s * 1000) >= devc->limit_msec)
|
if ((elapsed_s * 1000) >= devc->limit_msec)
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1224,12 +1224,12 @@ SR_PRIV int gmc_mh_2x_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
/* If number of samples or time limit reached, stop acquisition. */
|
/* If number of samples or time limit reached, stop acquisition. */
|
||||||
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples))
|
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples))
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
|
|
||||||
if (devc->limit_msec) {
|
if (devc->limit_msec) {
|
||||||
elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL);
|
elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL);
|
||||||
if ((elapsed_s * 1000) >= devc->limit_msec)
|
if ((elapsed_s * 1000) >= devc->limit_msec)
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Request next data set, if required */
|
/* Request next data set, if required */
|
||||||
|
|
|
@ -90,9 +90,6 @@ struct dev_context {
|
||||||
uint64_t limit_samples; /**< Target number of samples */
|
uint64_t limit_samples; /**< Target number of samples */
|
||||||
uint64_t limit_msec; /**< Target sampling time */
|
uint64_t limit_msec; /**< Target sampling time */
|
||||||
|
|
||||||
/* Opaque pointer passed in by frontend. */
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/* Operational state */
|
/* Operational state */
|
||||||
gboolean settings_ok; /**< Settings msg received yet. */
|
gboolean settings_ok; /**< Settings msg received yet. */
|
||||||
int msg_type; /**< Message type (MSGID_INF, ...). */
|
int msg_type; /**< Message type (MSGID_INF, ...). */
|
||||||
|
|
|
@ -209,13 +209,11 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct sr_scpi_dev_inst *scpi;
|
struct sr_scpi_dev_inst *scpi;
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
scpi = sdi->conn;
|
scpi = sdi->conn;
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
|
@ -231,14 +229,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct sr_scpi_dev_inst *scpi;
|
struct sr_scpi_dev_inst *scpi;
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
scpi = sdi->conn;
|
scpi = sdi->conn;
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#define ANALOG_CHANNELS 2
|
#define ANALOG_CHANNELS 2
|
||||||
#define VERTICAL_DIVISIONS 10
|
#define VERTICAL_DIVISIONS 10
|
||||||
|
|
||||||
static int read_data(struct sr_dev_inst *sdi, void *cb_data,
|
static int read_data(struct sr_dev_inst *sdi,
|
||||||
struct sr_scpi_dev_inst *scpi, struct dev_context *devc,
|
struct sr_scpi_dev_inst *scpi, struct dev_context *devc,
|
||||||
int data_size)
|
int data_size)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ static int read_data(struct sr_dev_inst *sdi, void *cb_data,
|
||||||
data_size - devc->cur_rcv_buffer_position);
|
data_size - devc->cur_rcv_buffer_position);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
sr_err("Read data error.");
|
sr_err("Read data error.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
devc->cur_rcv_buffer_position = 0;
|
devc->cur_rcv_buffer_position = 0;
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ static int read_data(struct sr_dev_inst *sdi, void *cb_data,
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
} else {
|
} else {
|
||||||
sr_err("Too many bytes read.");
|
sr_err("Too many bytes read.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
devc->cur_rcv_buffer_position = 0;
|
devc->cur_rcv_buffer_position = 0;
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
@ -92,17 +92,17 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
|
||||||
case START_ACQUISITION:
|
case START_ACQUISITION:
|
||||||
if (sr_scpi_send(scpi, ":TRIG:MOD 3") != SR_OK) {
|
if (sr_scpi_send(scpi, ":TRIG:MOD 3") != SR_OK) {
|
||||||
sr_err("Failed to set trigger mode to SINGLE.");
|
sr_err("Failed to set trigger mode to SINGLE.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (sr_scpi_send(scpi, ":STOP") != SR_OK) {
|
if (sr_scpi_send(scpi, ":STOP") != SR_OK) {
|
||||||
sr_err("Failed to put the trigger system into STOP state.");
|
sr_err("Failed to put the trigger system into STOP state.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (sr_scpi_send(scpi, ":RUN") != SR_OK) {
|
if (sr_scpi_send(scpi, ":RUN") != SR_OK) {
|
||||||
sr_err("Failed to put the trigger system into RUN state.");
|
sr_err("Failed to put the trigger system into RUN state.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,12 +113,12 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
|
||||||
if (((struct sr_channel *)g_slist_nth_data(sdi->channels, devc->cur_acq_channel))->enabled) {
|
if (((struct sr_channel *)g_slist_nth_data(sdi->channels, devc->cur_acq_channel))->enabled) {
|
||||||
if (sr_scpi_send(scpi, ":ACQ%d:MEM?", devc->cur_acq_channel+1) != SR_OK) {
|
if (sr_scpi_send(scpi, ":ACQ%d:MEM?", devc->cur_acq_channel+1) != SR_OK) {
|
||||||
sr_err("Failed to acquire memory.");
|
sr_err("Failed to acquire memory.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (sr_scpi_read_begin(scpi) != SR_OK) {
|
if (sr_scpi_read_begin(scpi) != SR_OK) {
|
||||||
sr_err("Could not begin reading SCPI response.");
|
sr_err("Could not begin reading SCPI response.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
devc->state = WAIT_FOR_TRANSFER_OF_BEGIN_TRANSMISSION_COMPLETE;
|
devc->state = WAIT_FOR_TRANSFER_OF_BEGIN_TRANSMISSION_COMPLETE;
|
||||||
|
@ -132,7 +132,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
|
||||||
/* All frames accquired. */
|
/* All frames accquired. */
|
||||||
sr_spew("All frames acquired.");
|
sr_spew("All frames acquired.");
|
||||||
|
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
/* Start acquiring next frame. */
|
/* Start acquiring next frame. */
|
||||||
|
@ -154,19 +154,19 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WAIT_FOR_TRANSFER_OF_BEGIN_TRANSMISSION_COMPLETE:
|
case WAIT_FOR_TRANSFER_OF_BEGIN_TRANSMISSION_COMPLETE:
|
||||||
if (read_data(sdi, cb_data, scpi, devc, 1) == SR_OK) {
|
if (read_data(sdi, scpi, devc, 1) == SR_OK) {
|
||||||
if (devc->rcv_buffer[0] == '#')
|
if (devc->rcv_buffer[0] == '#')
|
||||||
devc->state = WAIT_FOR_TRANSFER_OF_DATA_SIZE_DIGIT_COMPLETE;
|
devc->state = WAIT_FOR_TRANSFER_OF_DATA_SIZE_DIGIT_COMPLETE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WAIT_FOR_TRANSFER_OF_DATA_SIZE_DIGIT_COMPLETE:
|
case WAIT_FOR_TRANSFER_OF_DATA_SIZE_DIGIT_COMPLETE:
|
||||||
if (read_data(sdi, cb_data, scpi, devc, 1) == SR_OK) {
|
if (read_data(sdi, scpi, devc, 1) == SR_OK) {
|
||||||
if (devc->rcv_buffer[0] != '4' &&
|
if (devc->rcv_buffer[0] != '4' &&
|
||||||
devc->rcv_buffer[0] != '5' &&
|
devc->rcv_buffer[0] != '5' &&
|
||||||
devc->rcv_buffer[0] != '6') {
|
devc->rcv_buffer[0] != '6') {
|
||||||
sr_err("Data size digits is not 4, 5 or 6 but "
|
sr_err("Data size digits is not 4, 5 or 6 but "
|
||||||
"'%c'.", devc->rcv_buffer[0]);
|
"'%c'.", devc->rcv_buffer[0]);
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
devc->data_size_digits = devc->rcv_buffer[0] - '0';
|
devc->data_size_digits = devc->rcv_buffer[0] - '0';
|
||||||
|
@ -175,18 +175,18 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WAIT_FOR_TRANSFER_OF_DATA_SIZE_COMPLETE:
|
case WAIT_FOR_TRANSFER_OF_DATA_SIZE_COMPLETE:
|
||||||
if (read_data(sdi, cb_data, scpi, devc, devc->data_size_digits) == SR_OK) {
|
if (read_data(sdi, scpi, devc, devc->data_size_digits) == SR_OK) {
|
||||||
devc->rcv_buffer[devc->data_size_digits] = 0;
|
devc->rcv_buffer[devc->data_size_digits] = 0;
|
||||||
if (sr_atoi(devc->rcv_buffer, &devc->data_size) != SR_OK) {
|
if (sr_atoi(devc->rcv_buffer, &devc->data_size) != SR_OK) {
|
||||||
sr_err("Could not parse data size '%s'", devc->rcv_buffer);
|
sr_err("Could not parse data size '%s'", devc->rcv_buffer);
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else
|
} else
|
||||||
devc->state = WAIT_FOR_TRANSFER_OF_SAMPLE_RATE_COMPLETE;
|
devc->state = WAIT_FOR_TRANSFER_OF_SAMPLE_RATE_COMPLETE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WAIT_FOR_TRANSFER_OF_SAMPLE_RATE_COMPLETE:
|
case WAIT_FOR_TRANSFER_OF_SAMPLE_RATE_COMPLETE:
|
||||||
if (read_data(sdi, cb_data, scpi, devc, sizeof(float)) == SR_OK) {
|
if (read_data(sdi, scpi, devc, sizeof(float)) == SR_OK) {
|
||||||
/*
|
/*
|
||||||
* Contrary to the documentation, this field is
|
* Contrary to the documentation, this field is
|
||||||
* transfered with most significant byte first!
|
* transfered with most significant byte first!
|
||||||
|
@ -206,21 +206,21 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WAIT_FOR_TRANSFER_OF_CHANNEL_INDICATOR_COMPLETE:
|
case WAIT_FOR_TRANSFER_OF_CHANNEL_INDICATOR_COMPLETE:
|
||||||
if (read_data(sdi, cb_data, scpi, devc, 1) == SR_OK)
|
if (read_data(sdi, scpi, devc, 1) == SR_OK)
|
||||||
devc->state = WAIT_FOR_TRANSFER_OF_RESERVED_DATA_COMPLETE;
|
devc->state = WAIT_FOR_TRANSFER_OF_RESERVED_DATA_COMPLETE;
|
||||||
break;
|
break;
|
||||||
case WAIT_FOR_TRANSFER_OF_RESERVED_DATA_COMPLETE:
|
case WAIT_FOR_TRANSFER_OF_RESERVED_DATA_COMPLETE:
|
||||||
if (read_data(sdi, cb_data, scpi, devc, 3) == SR_OK)
|
if (read_data(sdi, scpi, devc, 3) == SR_OK)
|
||||||
devc->state = WAIT_FOR_TRANSFER_OF_CHANNEL_DATA_COMPLETE;
|
devc->state = WAIT_FOR_TRANSFER_OF_CHANNEL_DATA_COMPLETE;
|
||||||
break;
|
break;
|
||||||
case WAIT_FOR_TRANSFER_OF_CHANNEL_DATA_COMPLETE:
|
case WAIT_FOR_TRANSFER_OF_CHANNEL_DATA_COMPLETE:
|
||||||
if (read_data(sdi, cb_data, scpi, devc, devc->data_size - 8) == SR_OK) {
|
if (read_data(sdi, scpi, devc, devc->data_size - 8) == SR_OK) {
|
||||||
/* Fetch data needed for conversion from device. */
|
/* Fetch data needed for conversion from device. */
|
||||||
snprintf(command, sizeof(command), ":CHAN%d:SCAL?",
|
snprintf(command, sizeof(command), ":CHAN%d:SCAL?",
|
||||||
devc->cur_acq_channel + 1);
|
devc->cur_acq_channel + 1);
|
||||||
if (sr_scpi_get_string(scpi, command, &response) != SR_OK) {
|
if (sr_scpi_get_string(scpi, command, &response) != SR_OK) {
|
||||||
sr_err("Failed to get volts per division.");
|
sr_err("Failed to get volts per division.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
volts_per_division = g_ascii_strtod(response, &end_ptr);
|
volts_per_division = g_ascii_strtod(response, &end_ptr);
|
||||||
|
@ -245,7 +245,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
|
||||||
analog.mqflags = 0;
|
analog.mqflags = 0;
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_slist_free(analog.channels);
|
g_slist_free(analog.channels);
|
||||||
|
|
||||||
/* All channels acquired. */
|
/* All channels acquired. */
|
||||||
|
@ -255,7 +255,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
|
||||||
if (devc->cur_acq_frame == devc->frame_limit - 1) {
|
if (devc->cur_acq_frame == devc->frame_limit - 1) {
|
||||||
/* All frames acquired. */
|
/* All frames acquired. */
|
||||||
sr_spew("All frames acquired.");
|
sr_spew("All frames acquired.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
/* Start acquiring next frame. */
|
/* Start acquiring next frame. */
|
||||||
|
|
|
@ -710,7 +710,7 @@ static int hmo_setup_channels(const struct sr_dev_inst *sdi)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
GSList *l;
|
GSList *l;
|
||||||
gboolean digital_added;
|
gboolean digital_added;
|
||||||
|
@ -757,20 +757,18 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50,
|
sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50,
|
||||||
hmo_receive_data, (void *)sdi);
|
hmo_receive_data, (void *)sdi);
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
devc->current_channel = devc->enabled_channels;
|
devc->current_channel = devc->enabled_channels;
|
||||||
|
|
||||||
return hmo_request_data(sdi);
|
return hmo_request_data(sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_scpi_dev_inst *scpi;
|
struct sr_scpi_dev_inst *scpi;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
std_session_send_df_end(sdi, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
|
|
|
@ -773,7 +773,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
|
||||||
analog.mqflags = 0;
|
analog.mqflags = 0;
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_slist_free(analog.channels);
|
g_slist_free(analog.channels);
|
||||||
g_array_free(data, TRUE);
|
g_array_free(data, TRUE);
|
||||||
data = NULL;
|
data = NULL;
|
||||||
|
@ -792,7 +792,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
|
||||||
logic.data = data->data;
|
logic.data = data->data;
|
||||||
packet.type = SR_DF_LOGIC;
|
packet.type = SR_DF_LOGIC;
|
||||||
packet.payload = &logic;
|
packet.payload = &logic;
|
||||||
sr_session_send(cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_array_free(data, TRUE);
|
g_array_free(data, TRUE);
|
||||||
data = NULL;
|
data = NULL;
|
||||||
break;
|
break;
|
||||||
|
@ -808,7 +808,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
|
||||||
devc->current_channel = devc->current_channel->next;
|
devc->current_channel = devc->current_channel->next;
|
||||||
hmo_request_data(sdi);
|
hmo_request_data(sdi);
|
||||||
} else if (++devc->num_frames == devc->frame_limit) {
|
} else if (++devc->num_frames == devc->frame_limit) {
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
} else {
|
} else {
|
||||||
devc->current_channel = devc->enabled_channels;
|
devc->current_channel = devc->enabled_channels;
|
||||||
hmo_request_data(sdi);
|
hmo_request_data(sdi);
|
||||||
|
|
|
@ -78,7 +78,7 @@ SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info;
|
||||||
|
|
||||||
static int read_channel(const struct sr_dev_inst *sdi, uint32_t amount);
|
static int read_channel(const struct sr_dev_inst *sdi, uint32_t amount);
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi);
|
||||||
|
|
||||||
static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile *prof)
|
static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile *prof)
|
||||||
{
|
{
|
||||||
|
@ -611,7 +611,7 @@ static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf,
|
||||||
analog.data[data_offset++] = (ch2_bit * *(buf + i * 2 + 1) - ch2_center);
|
analog.data[data_offset++] = (ch2_bit * *(buf + i * 2 + 1) - ch2_center);
|
||||||
}
|
}
|
||||||
|
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_free(analog.data);
|
g_free(analog.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,7 +699,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
|
||||||
PRIu64 " <= %" PRIu64, devc->limit_samples,
|
PRIu64 " <= %" PRIu64, devc->limit_samples,
|
||||||
devc->samp_received);
|
devc->samp_received);
|
||||||
send_data(sdi, devc->sample_buf, devc->limit_samples);
|
send_data(sdi, devc->sample_buf, devc->limit_samples);
|
||||||
sdi->driver->dev_acquisition_stop(sdi, NULL);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
} else if (devc->limit_msec && (g_get_monotonic_time() -
|
} else if (devc->limit_msec && (g_get_monotonic_time() -
|
||||||
devc->aq_started) / 1000 >= devc->limit_msec) {
|
devc->aq_started) / 1000 >= devc->limit_msec) {
|
||||||
sr_info("Requested time limit reached, stopping. %d <= %d",
|
sr_info("Requested time limit reached, stopping. %d <= %d",
|
||||||
|
@ -708,7 +708,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
|
||||||
send_data(sdi, devc->sample_buf, devc->samp_received);
|
send_data(sdi, devc->sample_buf, devc->samp_received);
|
||||||
g_free(devc->sample_buf);
|
g_free(devc->sample_buf);
|
||||||
devc->sample_buf = NULL;
|
devc->sample_buf = NULL;
|
||||||
sdi->driver->dev_acquisition_stop(sdi, NULL);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
} else {
|
} else {
|
||||||
read_channel(sdi, data_amount(sdi));
|
read_channel(sdi, data_amount(sdi));
|
||||||
}
|
}
|
||||||
|
@ -770,7 +770,7 @@ static int handle_event(int fd, int revents, void *cb_data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_dev_driver *di = sdi->driver;
|
struct sr_dev_driver *di = sdi->driver;
|
||||||
|
@ -780,7 +780,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
if (configure_channels(sdi) != SR_OK) {
|
if (configure_channels(sdi) != SR_OK) {
|
||||||
sr_err("Failed to configure channels.");
|
sr_err("Failed to configure channels.");
|
||||||
|
@ -790,7 +789,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
if (hantek_6xxx_init(sdi) != SR_OK)
|
if (hantek_6xxx_init(sdi) != SR_OK)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
devc->samp_received = 0;
|
devc->samp_received = 0;
|
||||||
devc->dev_state = FLUSH;
|
devc->dev_state = FLUSH;
|
||||||
|
@ -805,12 +804,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,6 @@ struct hantek_6xxx_profile {
|
||||||
|
|
||||||
struct dev_context {
|
struct dev_context {
|
||||||
const struct hantek_6xxx_profile *profile;
|
const struct hantek_6xxx_profile *profile;
|
||||||
void *cb_data;
|
|
||||||
GSList *enabled_channels;
|
GSList *enabled_channels;
|
||||||
/*
|
/*
|
||||||
* We can't keep track of an FX2-based device after upgrading
|
* We can't keep track of an FX2-based device after upgrading
|
||||||
|
|
|
@ -162,7 +162,7 @@ static const char *coupling[] = {
|
||||||
|
|
||||||
SR_PRIV struct sr_dev_driver hantek_dso_driver_info;
|
SR_PRIV struct sr_dev_driver hantek_dso_driver_info;
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi);
|
||||||
|
|
||||||
static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
|
static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
|
||||||
{
|
{
|
||||||
|
@ -755,7 +755,7 @@ static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf,
|
||||||
analog.data[data_offset++] = ch2;
|
analog.data[data_offset++] = ch2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_free(analog.data);
|
g_free(analog.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -844,7 +844,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
|
||||||
|
|
||||||
/* Mark the end of this frame. */
|
/* Mark the end of this frame. */
|
||||||
packet.type = SR_DF_FRAME_END;
|
packet.type = SR_DF_FRAME_END;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
if (devc->limit_frames && ++devc->num_frames == devc->limit_frames) {
|
if (devc->limit_frames && ++devc->num_frames == devc->limit_frames) {
|
||||||
/* Terminate session */
|
/* Terminate session */
|
||||||
|
@ -967,7 +967,7 @@ static int handle_event(int fd, int revents, void *cb_data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_dev_driver *di = sdi->driver;
|
struct sr_dev_driver *di = sdi->driver;
|
||||||
|
@ -977,7 +977,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
if (configure_channels(sdi) != SR_OK) {
|
if (configure_channels(sdi) != SR_OK) {
|
||||||
sr_err("Failed to configure channels.");
|
sr_err("Failed to configure channels.");
|
||||||
|
@ -993,17 +992,15 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
devc->dev_state = CAPTURE;
|
devc->dev_state = CAPTURE;
|
||||||
usb_source_add(sdi->session, drvc->sr_ctx, TICK, handle_event, (void *)sdi);
|
usb_source_add(sdi->session, drvc->sr_ctx, TICK, handle_event, (void *)sdi);
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,6 @@ struct dso_profile {
|
||||||
|
|
||||||
struct dev_context {
|
struct dev_context {
|
||||||
const struct dso_profile *profile;
|
const struct dso_profile *profile;
|
||||||
void *cb_data;
|
|
||||||
uint64_t limit_frames;
|
uint64_t limit_frames;
|
||||||
uint64_t num_frames;
|
uint64_t num_frames;
|
||||||
GSList *enabled_channels;
|
GSList *enabled_channels;
|
||||||
|
|
|
@ -376,7 +376,7 @@ static void create_channel_index_list(GSList *channels, GArray **arr)
|
||||||
* channel in the scan list to the A/D converter. This way, we do not need to
|
* channel in the scan list to the A/D converter. This way, we do not need to
|
||||||
* occupy the HP-IB bus to send channel select commands.
|
* occupy the HP-IB bus to send channel select commands.
|
||||||
*/
|
*/
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
gboolean front_selected, rear_selected;
|
gboolean front_selected, rear_selected;
|
||||||
|
@ -387,8 +387,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
GArray *ch_list;
|
GArray *ch_list;
|
||||||
GSList *channels;
|
GSList *channels;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
@ -448,16 +446,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
|
||||||
return SR_ERR_DEV_CLOSED;
|
|
||||||
|
|
||||||
g_slist_free(devc->active_channels);
|
g_slist_free(devc->active_channels);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
|
|
|
@ -388,7 +388,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data)
|
||||||
struct sr_scpi_dev_inst *scpi;
|
struct sr_scpi_dev_inst *scpi;
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct channel_context *chanc;
|
struct channel_context *chanc;
|
||||||
struct sr_dev_inst *sdi = cb_data;
|
struct sr_dev_inst *sdi;
|
||||||
|
|
||||||
(void)fd;
|
(void)fd;
|
||||||
(void)revents;
|
(void)revents;
|
||||||
|
@ -435,7 +435,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data)
|
||||||
ret = sr_scpi_get_double(scpi, NULL, &devc->last_channel_sync);
|
ret = sr_scpi_get_double(scpi, NULL, &devc->last_channel_sync);
|
||||||
if (ret != SR_OK) {
|
if (ret != SR_OK) {
|
||||||
sr_err("Cannot check channel synchronization.");
|
sr_err("Cannot check channel synchronization.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
devc->acq_state = ACQ_GOT_CHANNEL_SYNC;
|
devc->acq_state = ACQ_GOT_CHANNEL_SYNC;
|
||||||
|
@ -456,7 +456,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data)
|
||||||
sr_err("Expected channel %u, but device says %u",
|
sr_err("Expected channel %u, but device says %u",
|
||||||
chanc->index,
|
chanc->index,
|
||||||
(unsigned int)devc->last_channel_sync);
|
(unsigned int)devc->last_channel_sync);
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
/* All is good. Back to business. */
|
/* All is good. Back to business. */
|
||||||
|
@ -464,7 +464,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
|
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -686,7 +686,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc = sdi->priv;
|
struct dev_context *devc = sdi->priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -702,7 +702,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
devc->factor /= relays[(devc->cctl[devc->channel - 1] >> 4) & 0x03];
|
devc->factor /= relays[(devc->cctl[devc->channel - 1] >> 4) & 0x03];
|
||||||
}
|
}
|
||||||
devc->frame = 0;
|
devc->frame = 0;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
devc->state_known = TRUE;
|
devc->state_known = TRUE;
|
||||||
devc->step = 0;
|
devc->step = 0;
|
||||||
devc->adc2 = FALSE;
|
devc->adc2 = FALSE;
|
||||||
|
@ -712,7 +711,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
if (ret != SR_OK)
|
if (ret != SR_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
sr_session_source_add(sdi->session, -1, 0, 8,
|
sr_session_source_add(sdi->session, -1, 0, 8,
|
||||||
hung_chang_dso_2100_poll, (void *)sdi);
|
hung_chang_dso_2100_poll, (void *)sdi);
|
||||||
|
@ -720,22 +719,21 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi,
|
SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi)
|
||||||
void *cb_data)
|
|
||||||
{
|
{
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
std_session_send_df_end(cb_data, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
sr_session_source_remove(sdi->session, -1);
|
sr_session_source_remove(sdi->session, -1);
|
||||||
hung_chang_dso_2100_move_to(sdi, 1);
|
hung_chang_dso_2100_move_to(sdi, 1);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
return hung_chang_dso_2100_dev_acquisition_stop(sdi, cb_data);
|
return hung_chang_dso_2100_dev_acquisition_stop(sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV struct sr_dev_driver hung_chang_dso_2100_driver_info = {
|
SR_PRIV struct sr_dev_driver hung_chang_dso_2100_driver_info = {
|
||||||
|
|
|
@ -348,7 +348,7 @@ static void push_samples(const struct sr_dev_inst *sdi, uint8_t *buf, size_t num
|
||||||
while (num--)
|
while (num--)
|
||||||
data[num] = (buf[num] - 0x80) * factor;
|
data[num] = (buf[num] - 0x80) * factor;
|
||||||
|
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_subframe(const struct sr_dev_inst *sdi, uint8_t *buf)
|
static int read_subframe(const struct sr_dev_inst *sdi, uint8_t *buf)
|
||||||
|
@ -393,7 +393,7 @@ static int read_subframe(const struct sr_dev_inst *sdi, uint8_t *buf)
|
||||||
};
|
};
|
||||||
|
|
||||||
push_samples(sdi, buf, 6);
|
push_samples(sdi, buf, 6);
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
buf += 6;
|
buf += 6;
|
||||||
num -= 6;
|
num -= 6;
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,7 @@ SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
if (devc->channel) {
|
if (devc->channel) {
|
||||||
while (read_subframe(sdi, buf)) {
|
while (read_subframe(sdi, buf)) {
|
||||||
|
@ -453,10 +453,10 @@ SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.type = SR_DF_FRAME_END;
|
packet.type = SR_DF_FRAME_END;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
if (++devc->frame >= devc->frame_limit)
|
if (++devc->frame >= devc->frame_limit)
|
||||||
hung_chang_dso_2100_dev_acquisition_stop(sdi, devc->cb_data);
|
hung_chang_dso_2100_dev_acquisition_stop(sdi);
|
||||||
else
|
else
|
||||||
hung_chang_dso_2100_move_to(sdi, 0x21);
|
hung_chang_dso_2100_move_to(sdi, 0x21);
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ struct dev_context {
|
||||||
gboolean adc2;
|
gboolean adc2;
|
||||||
|
|
||||||
/* Temporary state across callbacks */
|
/* Temporary state across callbacks */
|
||||||
void *cb_data;
|
|
||||||
float *samples;
|
float *samples;
|
||||||
float factor;
|
float factor;
|
||||||
gboolean state_known;
|
gboolean state_known;
|
||||||
|
@ -64,6 +63,6 @@ SR_PRIV void hung_chang_dso_2100_write_mbox(struct parport *port, uint8_t val);
|
||||||
SR_PRIV uint8_t hung_chang_dso_2100_read_mbox(struct parport *port, float timeout);
|
SR_PRIV uint8_t hung_chang_dso_2100_read_mbox(struct parport *port, float timeout);
|
||||||
SR_PRIV int hung_chang_dso_2100_move_to(const struct sr_dev_inst *sdi, uint8_t target);
|
SR_PRIV int hung_chang_dso_2100_move_to(const struct sr_dev_inst *sdi, uint8_t target);
|
||||||
SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data);
|
SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data);
|
||||||
SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi, void *cb_data);
|
SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -383,7 +383,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct sr_dev_driver *di = sdi->driver;
|
struct sr_dev_driver *di = sdi->driver;
|
||||||
struct drv_context *drvc;
|
struct drv_context *drvc;
|
||||||
|
@ -398,7 +398,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
drvc = di->context;
|
drvc = di->context;
|
||||||
|
|
||||||
devc->cb_data = cb_data;
|
|
||||||
devc->wait_data_ready_locked = TRUE;
|
devc->wait_data_ready_locked = TRUE;
|
||||||
devc->stopping_in_progress = FALSE;
|
devc->stopping_in_progress = FALSE;
|
||||||
devc->transfer_error = FALSE;
|
devc->transfer_error = FALSE;
|
||||||
|
@ -466,17 +465,15 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
|
|
||||||
sr_dbg("Acquisition started successfully.");
|
sr_dbg("Acquisition started successfully.");
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
devc->next_state = STATE_SAMPLE;
|
devc->next_state = STATE_SAMPLE;
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
|
|
@ -27,14 +27,11 @@ extern uint64_t sl2_samplerates[NUM_SAMPLERATES];
|
||||||
static void stop_acquisition(struct sr_dev_inst *sdi)
|
static void stop_acquisition(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct drv_context *drvc = sdi->driver->context;
|
struct drv_context *drvc = sdi->driver->context;
|
||||||
struct dev_context *devc;
|
|
||||||
|
|
||||||
devc = sdi->priv;
|
|
||||||
|
|
||||||
/* Remove USB file descriptors from polling. */
|
/* Remove USB file descriptors from polling. */
|
||||||
usb_source_remove(sdi->session, drvc->sr_ctx);
|
usb_source_remove(sdi->session, drvc->sr_ctx);
|
||||||
|
|
||||||
std_session_send_df_end(devc->cb_data, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
sdi->status = SR_ST_ACTIVE;
|
sdi->status = SR_ST_ACTIVE;
|
||||||
}
|
}
|
||||||
|
@ -42,14 +39,11 @@ static void stop_acquisition(struct sr_dev_inst *sdi)
|
||||||
static void abort_acquisition(struct sr_dev_inst *sdi)
|
static void abort_acquisition(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct drv_context *drvc = sdi->driver->context;
|
struct drv_context *drvc = sdi->driver->context;
|
||||||
struct dev_context *devc;
|
|
||||||
|
|
||||||
devc = sdi->priv;
|
|
||||||
|
|
||||||
/* Remove USB file descriptors from polling. */
|
/* Remove USB file descriptors from polling. */
|
||||||
usb_source_remove(sdi->session, drvc->sr_ctx);
|
usb_source_remove(sdi->session, drvc->sr_ctx);
|
||||||
|
|
||||||
std_session_send_df_end(devc->cb_data, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
sdi->driver->dev_close(sdi);
|
sdi->driver->dev_close(sdi);
|
||||||
}
|
}
|
||||||
|
@ -134,7 +128,7 @@ static void process_sample_data(const struct sr_dev_inst *sdi)
|
||||||
if (devc->trigger_type != TRIGGER_TYPE_NONE &&
|
if (devc->trigger_type != TRIGGER_TYPE_NONE &&
|
||||||
devc->pre_trigger_samples == 0) {
|
devc->pre_trigger_samples == 0) {
|
||||||
packet.type = SR_DF_TRIGGER;
|
packet.type = SR_DF_TRIGGER;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,10 +166,10 @@ static void process_sample_data(const struct sr_dev_inst *sdi)
|
||||||
logic.length = n;
|
logic.length = n;
|
||||||
logic.unitsize = 1;
|
logic.unitsize = 1;
|
||||||
logic.data = buffer;
|
logic.data = buffer;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
packet.type = SR_DF_TRIGGER;
|
packet.type = SR_DF_TRIGGER;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +182,7 @@ static void process_sample_data(const struct sr_dev_inst *sdi)
|
||||||
logic.length = n;
|
logic.length = n;
|
||||||
logic.unitsize = 1;
|
logic.unitsize = 1;
|
||||||
logic.data = buffer;
|
logic.data = buffer;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,8 +147,6 @@ struct dev_context {
|
||||||
/* Time that the trigger will be delayed in milliseconds. */
|
/* Time that the trigger will be delayed in milliseconds. */
|
||||||
uint16_t after_trigger_delay;
|
uint16_t after_trigger_delay;
|
||||||
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/* Array to provide an index based access to all channels. */
|
/* Array to provide an index based access to all channels. */
|
||||||
const struct sr_channel *channels[NUM_CHANNELS];
|
const struct sr_channel *channels[NUM_CHANNELS];
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ static const uint64_t samplerates[1] = { SR_MHZ(100) };
|
||||||
|
|
||||||
SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info;
|
SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info;
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi);
|
||||||
|
|
||||||
static void clear_helper(void *priv)
|
static void clear_helper(void *priv)
|
||||||
{
|
{
|
||||||
|
@ -350,7 +350,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
@ -365,8 +365,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
|
|
||||||
/* TODO: Configure channels later (thresholds etc.). */
|
/* TODO: Configure channels later (thresholds etc.). */
|
||||||
|
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
/* Properly reset internal variables before every new acquisition. */
|
/* Properly reset internal variables before every new acquisition. */
|
||||||
devc->compressed_bytes_ignored = 0;
|
devc->compressed_bytes_ignored = 0;
|
||||||
devc->samples_sent = 0;
|
devc->samples_sent = 0;
|
||||||
|
@ -386,10 +384,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
sr_dbg("Stopping acquisition.");
|
sr_dbg("Stopping acquisition.");
|
||||||
sr_session_source_remove(sdi->session, -1);
|
sr_session_source_remove(sdi->session, -1);
|
||||||
std_session_send_df_end(sdi, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
|
|
|
@ -107,10 +107,13 @@ static void scanaplus_uncompress_block(struct dev_context *devc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_samples(struct dev_context *devc, uint64_t samples_to_send)
|
static void send_samples(const struct sr_dev_inst *sdi, uint64_t samples_to_send)
|
||||||
{
|
{
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
struct sr_datafeed_logic logic;
|
struct sr_datafeed_logic logic;
|
||||||
|
struct dev_context *devc;
|
||||||
|
|
||||||
|
devc = sdi->priv;
|
||||||
|
|
||||||
sr_spew("Sending %" PRIu64 " samples.", samples_to_send);
|
sr_spew("Sending %" PRIu64 " samples.", samples_to_send);
|
||||||
|
|
||||||
|
@ -119,7 +122,7 @@ static void send_samples(struct dev_context *devc, uint64_t samples_to_send)
|
||||||
logic.length = samples_to_send * 2;
|
logic.length = samples_to_send * 2;
|
||||||
logic.unitsize = 2; /* We need 2 bytes for 9 channels. */
|
logic.unitsize = 2; /* We need 2 bytes for 9 channels. */
|
||||||
logic.data = devc->sample_buf;
|
logic.data = devc->sample_buf;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
devc->samples_sent += samples_to_send;
|
devc->samples_sent += samples_to_send;
|
||||||
devc->bytes_received -= samples_to_send * 2;
|
devc->bytes_received -= samples_to_send * 2;
|
||||||
|
@ -317,7 +320,7 @@ SR_PRIV int scanaplus_receive_data(int fd, int revents, void *cb_data)
|
||||||
if (bytes_read < 0) {
|
if (bytes_read < 0) {
|
||||||
sr_err("Failed to read FTDI data (%d): %s.",
|
sr_err("Failed to read FTDI data (%d): %s.",
|
||||||
bytes_read, ftdi_get_error_string(devc->ftdic));
|
bytes_read, ftdi_get_error_string(devc->ftdic));
|
||||||
sdi->driver->dev_acquisition_stop(sdi, sdi);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (bytes_read == 0) {
|
if (bytes_read == 0) {
|
||||||
|
@ -354,17 +357,17 @@ SR_PRIV int scanaplus_receive_data(int fd, int revents, void *cb_data)
|
||||||
max = (SR_MHZ(100) / 1000) * devc->limit_msec;
|
max = (SR_MHZ(100) / 1000) * devc->limit_msec;
|
||||||
|
|
||||||
if (devc->limit_samples && (n >= devc->limit_samples)) {
|
if (devc->limit_samples && (n >= devc->limit_samples)) {
|
||||||
send_samples(devc, devc->limit_samples - devc->samples_sent);
|
send_samples(sdi, devc->limit_samples - devc->samples_sent);
|
||||||
sr_info("Requested number of samples reached.");
|
sr_info("Requested number of samples reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (devc->limit_msec && (n >= max)) {
|
} else if (devc->limit_msec && (n >= max)) {
|
||||||
send_samples(devc, max - devc->samples_sent);
|
send_samples(sdi, max - devc->samples_sent);
|
||||||
sr_info("Requested time limit reached.");
|
sr_info("Requested time limit reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
send_samples(devc, devc->bytes_received / 2);
|
send_samples(sdi, devc->bytes_received / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -43,8 +43,6 @@ struct dev_context {
|
||||||
/** The current sampling limit (in number of samples). */
|
/** The current sampling limit (in number of samples). */
|
||||||
uint64_t limit_samples;
|
uint64_t limit_samples;
|
||||||
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
uint8_t *compressed_buf;
|
uint8_t *compressed_buf;
|
||||||
uint64_t compressed_bytes_ignored;
|
uint64_t compressed_bytes_ignored;
|
||||||
uint8_t *sample_buf;
|
uint8_t *sample_buf;
|
||||||
|
|
|
@ -413,7 +413,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct sr_dev_driver *di = sdi->driver;
|
struct sr_dev_driver *di = sdi->driver;
|
||||||
struct drv_context *drvc;
|
struct drv_context *drvc;
|
||||||
|
@ -434,10 +434,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
usb = sdi->conn;
|
usb = sdi->conn;
|
||||||
|
|
||||||
devc->cb_data = cb_data;
|
|
||||||
devc->num_samples = 0;
|
devc->num_samples = 0;
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
if (devc->data_source == DATA_SOURCE_LIVE) {
|
if (devc->data_source == DATA_SOURCE_LIVE) {
|
||||||
/* Force configuration. */
|
/* Force configuration. */
|
||||||
|
@ -460,7 +459,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
devc->stored_samples = (buf[7] << 8) | buf[8];
|
devc->stored_samples = (buf[7] << 8) | buf[8];
|
||||||
if (devc->stored_samples == 0) {
|
if (devc->stored_samples == 0) {
|
||||||
/* Notify frontend of empty log by sending start/end packets. */
|
/* Notify frontend of empty log by sending start/end packets. */
|
||||||
std_session_send_df_end(cb_data, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +474,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
packet.type = SR_DF_META;
|
packet.type = SR_DF_META;
|
||||||
packet.payload = &meta;
|
packet.payload = &meta;
|
||||||
meta.config = g_slist_append(NULL, src);
|
meta.config = g_slist_append(NULL, src);
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_free(src);
|
g_free(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,12 +521,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)
|
||||||
if (sdi->status == SR_ST_STOPPING) {
|
if (sdi->status == SR_ST_STOPPING) {
|
||||||
libusb_free_transfer(devc->xfer);
|
libusb_free_transfer(devc->xfer);
|
||||||
usb_source_remove(sdi->session, drvc->sr_ctx);
|
usb_source_remove(sdi->session, drvc->sr_ctx);
|
||||||
std_session_send_df_end(cb_data, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
sdi->status = SR_ST_ACTIVE;
|
sdi->status = SR_ST_ACTIVE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,7 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)
|
||||||
if (ret != 0 || len != 1) {
|
if (ret != 0 || len != 1) {
|
||||||
sr_dbg("Failed to request new acquisition: %s",
|
sr_dbg("Failed to request new acquisition: %s",
|
||||||
libusb_error_name(ret));
|
libusb_error_name(ret));
|
||||||
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
devc->cb_data);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
libusb_submit_transfer(devc->xfer);
|
libusb_submit_transfer(devc->xfer);
|
||||||
|
@ -91,8 +90,7 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)
|
||||||
if (ret != 0 || len != 4) {
|
if (ret != 0 || len != 4) {
|
||||||
sr_dbg("Failed to request next chunk: %s",
|
sr_dbg("Failed to request next chunk: %s",
|
||||||
libusb_error_name(ret));
|
libusb_error_name(ret));
|
||||||
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
devc->cb_data);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
libusb_submit_transfer(devc->xfer);
|
libusb_submit_transfer(devc->xfer);
|
||||||
|
@ -119,8 +117,7 @@ static void send_data(const struct sr_dev_inst *sdi, void *buf, unsigned int buf
|
||||||
analog.data = buf;
|
analog.data = buf;
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer *transfer)
|
SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer *transfer)
|
||||||
|
@ -137,8 +134,7 @@ SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer
|
||||||
switch (transfer->status) {
|
switch (transfer->status) {
|
||||||
case LIBUSB_TRANSFER_NO_DEVICE:
|
case LIBUSB_TRANSFER_NO_DEVICE:
|
||||||
/* USB device was unplugged. */
|
/* USB device was unplugged. */
|
||||||
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
devc->cb_data);
|
|
||||||
return;
|
return;
|
||||||
case LIBUSB_TRANSFER_COMPLETED:
|
case LIBUSB_TRANSFER_COMPLETED:
|
||||||
case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */
|
case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */
|
||||||
|
@ -159,8 +155,7 @@ SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer
|
||||||
send_data(sdi, fvalue, 1);
|
send_data(sdi, fvalue, 1);
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
||||||
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
devc->cb_data);
|
|
||||||
} else {
|
} else {
|
||||||
/* let USB event handler fire off another
|
/* let USB event handler fire off another
|
||||||
* request when the time is right. */
|
* request when the time is right. */
|
||||||
|
@ -180,8 +175,7 @@ SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer
|
||||||
send_data(sdi, fvalue, 1);
|
send_data(sdi, fvalue, 1);
|
||||||
devc->num_samples += num_samples;
|
devc->num_samples += num_samples;
|
||||||
if (devc->num_samples >= devc->stored_samples) {
|
if (devc->num_samples >= devc->stored_samples) {
|
||||||
sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
devc->cb_data);
|
|
||||||
} else {
|
} else {
|
||||||
/* let USB event handler fire off another
|
/* let USB event handler fire off another
|
||||||
* request when the time is right. */
|
* request when the time is right. */
|
||||||
|
|
|
@ -81,7 +81,6 @@ struct dev_context {
|
||||||
gboolean config_dirty;
|
gboolean config_dirty;
|
||||||
uint64_t num_samples;
|
uint64_t num_samples;
|
||||||
uint64_t stored_samples;
|
uint64_t stored_samples;
|
||||||
void *cb_data;
|
|
||||||
struct libusb_transfer *xfer;
|
struct libusb_transfer *xfer;
|
||||||
unsigned char buf[128];
|
unsigned char buf[128];
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int 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;
|
||||||
|
@ -192,7 +192,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
|
|
||||||
sr_spew("Set O1 mode (continuous values, stable and unstable ones).");
|
sr_spew("Set O1 mode (continuous values, stable and unstable ones).");
|
||||||
|
@ -203,7 +202,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
devc->num_samples = 0;
|
devc->num_samples = 0;
|
||||||
devc->starttime = g_get_monotonic_time();
|
devc->starttime = g_get_monotonic_time();
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Poll every 50ms, or whenever some data comes in. */
|
/* Poll every 50ms, or whenever some data comes in. */
|
||||||
serial_source_add(sdi->session, serial, G_IO_IN, 50,
|
serial_source_add(sdi->session, serial, G_IO_IN, 50,
|
||||||
|
@ -212,9 +211,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
|
return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
|
||||||
sdi->conn, LOG_PREFIX);
|
sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi,
|
||||||
/* Got a measurement. */
|
/* Got a measurement. */
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ SR_PRIV int kern_scale_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
||||||
sr_info("Requested number of samples reached.");
|
sr_info("Requested number of samples reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ SR_PRIV int kern_scale_receive_data(int fd, int revents, void *cb_data)
|
||||||
time = (g_get_monotonic_time() - devc->starttime) / 1000;
|
time = (g_get_monotonic_time() - devc->starttime) / 1000;
|
||||||
if (time > (int64_t)devc->limit_msec) {
|
if (time > (int64_t)devc->limit_msec) {
|
||||||
sr_info("Requested time limit reached.");
|
sr_info("Requested time limit reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,6 @@ struct dev_context {
|
||||||
/** The time limit (in milliseconds). */
|
/** The time limit (in milliseconds). */
|
||||||
uint64_t limit_msec;
|
uint64_t limit_msec;
|
||||||
|
|
||||||
/** Opaque pointer passed in by the frontend. */
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/** The current number of already received samples. */
|
/** The current number of already received samples. */
|
||||||
uint64_t num_samples;
|
uint64_t num_samples;
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,7 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int 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;
|
||||||
|
@ -390,9 +390,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
devc->starttime = g_get_monotonic_time();
|
devc->starttime = g_get_monotonic_time();
|
||||||
devc->num_samples = 0;
|
devc->num_samples = 0;
|
||||||
|
@ -406,12 +405,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data,
|
return std_serial_dev_acquisition_stop(sdi, sdi,
|
||||||
std_serial_dev_close, sdi->conn, LOG_PREFIX);
|
std_serial_dev_close, sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -378,7 +378,7 @@ SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
|
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
|
||||||
sr_info("Requested number of samples reached.");
|
sr_info("Requested number of samples reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data)
|
||||||
t = (g_get_monotonic_time() - devc->starttime) / 1000;
|
t = (g_get_monotonic_time() - devc->starttime) / 1000;
|
||||||
if (t > (int64_t)devc->limit_msec) {
|
if (t > (int64_t)devc->limit_msec) {
|
||||||
sr_info("Requested time limit reached.");
|
sr_info("Requested time limit reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,6 @@ struct dev_context {
|
||||||
int64_t req_sent_at;
|
int64_t req_sent_at;
|
||||||
gboolean reply_pending;
|
gboolean reply_pending;
|
||||||
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/* Operational state */
|
/* Operational state */
|
||||||
float current; /**< Last current value [A] read from device. */
|
float current; /**< Last current value [A] read from device. */
|
||||||
float current_max; /**< Output current set. */
|
float current_max; /**< Output current set. */
|
||||||
|
|
|
@ -323,7 +323,7 @@ static int lascar_proc_config(const struct sr_dev_inst *sdi)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct sr_dev_driver *di = sdi->driver;
|
struct sr_dev_driver *di = sdi->driver;
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
|
@ -349,26 +349,25 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
drvc = di->context;
|
drvc = di->context;
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
usb = sdi->conn;
|
usb = sdi->conn;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
if (lascar_proc_config(sdi) != SR_OK)
|
if (lascar_proc_config(sdi) != SR_OK)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
sr_dbg("Starting log retrieval.");
|
sr_dbg("Starting log retrieval.");
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
interval = (devc->config[0x1c] | (devc->config[0x1d] << 8)) * 1000;
|
interval = (devc->config[0x1c] | (devc->config[0x1d] << 8)) * 1000;
|
||||||
packet.type = SR_DF_META;
|
packet.type = SR_DF_META;
|
||||||
packet.payload = &meta;
|
packet.payload = &meta;
|
||||||
src = sr_config_new(SR_CONF_SAMPLE_INTERVAL, g_variant_new_uint64(interval));
|
src = sr_config_new(SR_CONF_SAMPLE_INTERVAL, g_variant_new_uint64(interval));
|
||||||
meta.config = g_slist_append(NULL, src);
|
meta.config = g_slist_append(NULL, src);
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_free(src);
|
g_free(src);
|
||||||
|
|
||||||
if (devc->logged_samples == 0) {
|
if (devc->logged_samples == 0) {
|
||||||
/* This ensures the frontend knows the session is done. */
|
/* This ensures the frontend knows the session is done. */
|
||||||
std_session_send_df_end(devc->cb_data, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +433,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
|
|
||||||
buf = g_malloc(4096);
|
buf = g_malloc(4096);
|
||||||
libusb_fill_bulk_transfer(xfer_in, usb->devhdl, LASCAR_EP_IN,
|
libusb_fill_bulk_transfer(xfer_in, usb->devhdl, LASCAR_EP_IN,
|
||||||
buf, 4096, lascar_el_usb_receive_transfer, cb_data, 100);
|
buf, 4096, lascar_el_usb_receive_transfer,
|
||||||
|
(struct sr_dev_inst *)sdi, 100);
|
||||||
if ((ret = libusb_submit_transfer(xfer_in) != 0)) {
|
if ((ret = libusb_submit_transfer(xfer_in) != 0)) {
|
||||||
sr_err("Unable to submit transfer: %s.", libusb_error_name(ret));
|
sr_err("Unable to submit transfer: %s.", libusb_error_name(ret));
|
||||||
libusb_free_transfer(xfer_in);
|
libusb_free_transfer(xfer_in);
|
||||||
|
@ -445,10 +445,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct sr_dev_driver *di = sdi->driver;
|
struct sr_dev_driver *di = sdi->driver;
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (!di->context) {
|
if (!di->context) {
|
||||||
sr_err("Driver was not initialized.");
|
sr_err("Driver was not initialized.");
|
||||||
|
|
|
@ -430,7 +430,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
|
||||||
else
|
else
|
||||||
analog.unit = SR_UNIT_CELSIUS;
|
analog.unit = SR_UNIT_CELSIUS;
|
||||||
analog.data = temp;
|
analog.data = temp;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_slist_free(analog.channels);
|
g_slist_free(analog.channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
|
||||||
analog.mq = SR_MQ_RELATIVE_HUMIDITY;
|
analog.mq = SR_MQ_RELATIVE_HUMIDITY;
|
||||||
analog.unit = SR_UNIT_PERCENTAGE;
|
analog.unit = SR_UNIT_PERCENTAGE;
|
||||||
analog.data = rh;
|
analog.data = rh;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_slist_free(analog.channels);
|
g_slist_free(analog.channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
|
||||||
if (analog.data[i] < 0.0)
|
if (analog.data[i] < 0.0)
|
||||||
analog.data[i] = 0.0;
|
analog.data[i] = 0.0;
|
||||||
}
|
}
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_free(analog.data);
|
g_free(analog.data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -487,7 +487,7 @@ SR_PRIV int lascar_el_usb_handle_events(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
if (sdi->status == SR_ST_STOPPING) {
|
if (sdi->status == SR_ST_STOPPING) {
|
||||||
usb_source_remove(sdi->session, drvc->sr_ctx);
|
usb_source_remove(sdi->session, drvc->sr_ctx);
|
||||||
std_session_send_df_end(cb_data, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&tv, 0, sizeof(struct timeval));
|
memset(&tv, 0, sizeof(struct timeval));
|
||||||
|
@ -511,7 +511,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
|
||||||
switch (transfer->status) {
|
switch (transfer->status) {
|
||||||
case LIBUSB_TRANSFER_NO_DEVICE:
|
case LIBUSB_TRANSFER_NO_DEVICE:
|
||||||
/* USB device was unplugged. */
|
/* USB device was unplugged. */
|
||||||
dev_acquisition_stop(sdi, sdi);
|
dev_acquisition_stop(sdi);
|
||||||
return;
|
return;
|
||||||
case LIBUSB_TRANSFER_COMPLETED:
|
case LIBUSB_TRANSFER_COMPLETED:
|
||||||
case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */
|
case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */
|
||||||
|
@ -530,7 +530,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
|
||||||
devc->rcvd_bytes, devc->log_size,
|
devc->rcvd_bytes, devc->log_size,
|
||||||
devc->rcvd_samples, devc->logged_samples);
|
devc->rcvd_samples, devc->logged_samples);
|
||||||
if (devc->rcvd_bytes >= devc->log_size)
|
if (devc->rcvd_bytes >= devc->log_size)
|
||||||
dev_acquisition_stop(sdi, sdi);
|
dev_acquisition_stop(sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdi->status == SR_ST_ACTIVE) {
|
if (sdi->status == SR_ST_ACTIVE) {
|
||||||
|
@ -540,7 +540,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
|
||||||
libusb_error_name(ret));
|
libusb_error_name(ret));
|
||||||
g_free(transfer->buffer);
|
g_free(transfer->buffer);
|
||||||
libusb_free_transfer(transfer);
|
libusb_free_transfer(transfer);
|
||||||
dev_acquisition_stop(sdi, sdi);
|
dev_acquisition_stop(sdi);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* This was the last transfer we're going to receive, so
|
/* This was the last transfer we're going to receive, so
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
|
|
||||||
/** Private, per-device-instance driver context. */
|
/** Private, per-device-instance driver context. */
|
||||||
struct dev_context {
|
struct dev_context {
|
||||||
void *cb_data;
|
|
||||||
const struct elusb_profile *profile;
|
const struct elusb_profile *profile;
|
||||||
/* Generic EL-USB */
|
/* Generic EL-USB */
|
||||||
unsigned char config[MAX_CONFIGBLOCK_SIZE];
|
unsigned char config[MAX_CONFIGBLOCK_SIZE];
|
||||||
|
@ -80,6 +79,6 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
|
||||||
SR_PRIV int lascar_start_logging(const struct sr_dev_inst *sdi);
|
SR_PRIV int lascar_start_logging(const struct sr_dev_inst *sdi);
|
||||||
SR_PRIV int lascar_stop_logging(const struct sr_dev_inst *sdi);
|
SR_PRIV int lascar_stop_logging(const struct sr_dev_inst *sdi);
|
||||||
SR_PRIV int lascar_is_logging(const struct sr_dev_inst *sdi);
|
SR_PRIV int lascar_is_logging(const struct sr_dev_inst *sdi);
|
||||||
SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
|
SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -509,7 +509,7 @@ static int receive_usb_data(int fd, int revents, void *cb_data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct drv_context *drvc;
|
struct drv_context *drvc;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -522,16 +522,14 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
if ((ret = lls_start_acquisition(sdi)) < 0)
|
if ((ret = lls_start_acquisition(sdi)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
return usb_source_add(sdi->session, drvc->sr_ctx, 100,
|
return usb_source_add(sdi->session, drvc->sr_ctx, 100,
|
||||||
receive_usb_data, drvc);
|
receive_usb_data, drvc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
|
|
@ -391,7 +391,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int 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;
|
||||||
|
@ -446,22 +446,20 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
/* Reset trigger state. */
|
/* Reset trigger state. */
|
||||||
devc->trigger_state = 0x00;
|
devc->trigger_state = 0x00;
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Our first channel is analog, the other 8 are of type 'logic'. */
|
/* Our first channel is analog, the other 8 are of type 'logic'. */
|
||||||
/* TODO. */
|
/* TODO. */
|
||||||
|
|
||||||
serial_source_add(sdi->session, devc->serial, G_IO_IN, -1,
|
serial_source_add(sdi->session, devc->serial, G_IO_IN, -1,
|
||||||
mso_receive_data, cb_data);
|
mso_receive_data, sdi);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This stops acquisition on ALL devices, ignoring dev_index. */
|
/* This stops acquisition on ALL devices, ignoring dev_index. */
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
stop_acquisition(sdi);
|
stop_acquisition(sdi);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
|
|
|
@ -416,13 +416,13 @@ SR_PRIV int mso_receive_data(int fd, int revents, void *cb_data)
|
||||||
logic.length = 1024;
|
logic.length = 1024;
|
||||||
logic.unitsize = 1;
|
logic.unitsize = 1;
|
||||||
logic.data = logic_out;
|
logic.data = logic_out;
|
||||||
sr_session_send(cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
devc->num_samples += 1024;
|
devc->num_samples += 1024;
|
||||||
|
|
||||||
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
||||||
sr_info("Requested number of samples reached.");
|
sr_info("Requested number of samples reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi, sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -115,7 +115,6 @@ struct dev_context {
|
||||||
double dso_trigger_voltage;
|
double dso_trigger_voltage;
|
||||||
uint16_t dso_trigger_width;
|
uint16_t dso_trigger_width;
|
||||||
struct mso_prototrig protocol_trigger;
|
struct mso_prototrig protocol_trigger;
|
||||||
void *cb_data;
|
|
||||||
uint16_t buffer_n;
|
uint16_t buffer_n;
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
};
|
};
|
||||||
|
|
|
@ -387,7 +387,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int 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;
|
||||||
|
@ -396,9 +396,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
devc->starttime = g_get_monotonic_time();
|
devc->starttime = g_get_monotonic_time();
|
||||||
devc->num_samples = 0;
|
devc->num_samples = 0;
|
||||||
|
@ -413,9 +412,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data,
|
return std_serial_dev_acquisition_stop(sdi, sdi,
|
||||||
std_serial_dev_close, sdi->conn, LOG_PREFIX);
|
std_serial_dev_close, sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
|
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
|
||||||
sr_info("Requested number of samples reached.");
|
sr_info("Requested number of samples reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data)
|
||||||
t = (g_get_monotonic_time() - devc->starttime) / 1000;
|
t = (g_get_monotonic_time() - devc->starttime) / 1000;
|
||||||
if (t > (int64_t)devc->limit_msec) {
|
if (t > (int64_t)devc->limit_msec) {
|
||||||
sr_info("Requested time limit reached.");
|
sr_info("Requested time limit reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,6 @@ struct dev_context {
|
||||||
int64_t req_sent_at;
|
int64_t req_sent_at;
|
||||||
gboolean reply_pending;
|
gboolean reply_pending;
|
||||||
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
float current; /**< Last current value [A] read from device. */
|
float current; /**< Last current value [A] read from device. */
|
||||||
float current_max; /**< Output current set. */
|
float current_max; /**< Output current set. */
|
||||||
float current_max_device;/**< Device-provided maximum output current. */
|
float current_max_device;/**< Device-provided maximum output current. */
|
||||||
|
|
|
@ -453,14 +453,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_modbus_dev_inst *modbus;
|
struct sr_modbus_dev_inst *modbus;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
@ -479,12 +477,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return maynuo_m97_capture_start(sdi);
|
return maynuo_m97_capture_start(sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct sr_modbus_dev_inst *modbus;
|
struct sr_modbus_dev_inst *modbus;
|
||||||
|
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ SR_PRIV int maynuo_m97_receive_data(int fd, int revents, void *cb_data)
|
||||||
devc->expecting_registers = 0;
|
devc->expecting_registers = 0;
|
||||||
if (sr_modbus_read_holding_registers(modbus, -1, 4, registers) == SR_OK) {
|
if (sr_modbus_read_holding_registers(modbus, -1, 4, registers) == SR_OK) {
|
||||||
packet.type = SR_DF_FRAME_BEGIN;
|
packet.type = SR_DF_FRAME_BEGIN;
|
||||||
sr_session_send(cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
maynuo_m97_session_send_value(sdi, sdi->channels->data,
|
maynuo_m97_session_send_value(sdi, sdi->channels->data,
|
||||||
RBFL(registers + 0),
|
RBFL(registers + 0),
|
||||||
|
@ -188,13 +188,13 @@ SR_PRIV int maynuo_m97_receive_data(int fd, int revents, void *cb_data)
|
||||||
SR_MQ_CURRENT, SR_UNIT_AMPERE);
|
SR_MQ_CURRENT, SR_UNIT_AMPERE);
|
||||||
|
|
||||||
packet.type = SR_DF_FRAME_END;
|
packet.type = SR_DF_FRAME_END;
|
||||||
sr_session_send(cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
|
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
|
||||||
sr_info("Requested number of samples reached.");
|
sr_info("Requested number of samples reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ SR_PRIV int maynuo_m97_receive_data(int fd, int revents, void *cb_data)
|
||||||
t = (g_get_monotonic_time() - devc->starttime) / 1000;
|
t = (g_get_monotonic_time() - devc->starttime) / 1000;
|
||||||
if (t > (int64_t)devc->limit_msec) {
|
if (t > (int64_t)devc->limit_msec) {
|
||||||
sr_info("Requested time limit reached.");
|
sr_info("Requested time limit reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,8 +212,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx)
|
||||||
void *cb_data, int idx)
|
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_serial_dev_inst *serial;
|
struct sr_serial_dev_inst *serial;
|
||||||
|
@ -222,11 +221,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
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();
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Poll every 100ms, or whenever some data comes in. */
|
/* Poll every 100ms, or whenever some data comes in. */
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
|
@ -236,9 +234,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
|
return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
|
||||||
sdi->conn, LOG_PREFIX);
|
sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,8 +261,8 @@ static int config_list_##X(uint32_t key, GVariant **data, \
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { \
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { \
|
||||||
return config_list(key, data, sdi, cg, X); }
|
return config_list(key, data, sdi, cg, X); }
|
||||||
#define HW_DEV_ACQUISITION_START(X) \
|
#define HW_DEV_ACQUISITION_START(X) \
|
||||||
static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
|
static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \
|
||||||
void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }
|
) { return dev_acquisition_start(sdi, X); }
|
||||||
|
|
||||||
/* Driver structs and API function wrappers */
|
/* Driver structs and API function wrappers */
|
||||||
#define DRV(ID, ID_UPPER, NAME, LONGNAME) \
|
#define DRV(ID, ID_UPPER, NAME, LONGNAME) \
|
||||||
|
|
|
@ -127,7 +127,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
|
||||||
meaning.mq = SR_MQ_TEMPERATURE;
|
meaning.mq = SR_MQ_TEMPERATURE;
|
||||||
meaning.unit = SR_UNIT_CELSIUS; /* TODO: Use C/F correctly. */
|
meaning.unit = SR_UNIT_CELSIUS; /* TODO: Use C/F correctly. */
|
||||||
analog.data = &temperature;
|
analog.data = &temperature;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_slist_free(l);
|
g_slist_free(l);
|
||||||
|
|
||||||
/* Humidity. */
|
/* Humidity. */
|
||||||
|
@ -138,7 +138,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
|
||||||
meaning.mq = SR_MQ_RELATIVE_HUMIDITY;
|
meaning.mq = SR_MQ_RELATIVE_HUMIDITY;
|
||||||
meaning.unit = SR_UNIT_PERCENTAGE;
|
meaning.unit = SR_UNIT_PERCENTAGE;
|
||||||
analog.data = &humidity;
|
analog.data = &humidity;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
g_slist_free(l);
|
g_slist_free(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
|
||||||
|
|
||||||
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
|
||||||
sr_info("Requested number of samples reached.");
|
sr_info("Requested number of samples reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
|
||||||
t = (g_get_monotonic_time() - devc->starttime) / 1000;
|
t = (g_get_monotonic_time() - devc->starttime) / 1000;
|
||||||
if (t > (int64_t)devc->limit_msec) {
|
if (t > (int64_t)devc->limit_msec) {
|
||||||
sr_info("Requested time limit reached.");
|
sr_info("Requested time limit reached.");
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,6 @@ struct dev_context {
|
||||||
/** The current sampling limit (in ms). */
|
/** The current sampling limit (in ms). */
|
||||||
uint64_t limit_msec;
|
uint64_t limit_msec;
|
||||||
|
|
||||||
/** Opaque pointer passed in by the frontend. */
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/** The current number of already received samples. */
|
/** The current number of already received samples. */
|
||||||
uint64_t num_samples;
|
uint64_t num_samples;
|
||||||
|
|
||||||
|
|
|
@ -796,7 +796,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int 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;
|
||||||
|
@ -811,7 +811,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
serial = sdi->conn;
|
serial = sdi->conn;
|
||||||
serial_source_add(sdi->session, serial, G_IO_IN, 50,
|
serial_source_add(sdi->session, serial, G_IO_IN, 50,
|
||||||
motech_lps_30x_receive_data, (void *)sdi);
|
motech_lps_30x_receive_data, (void *)sdi);
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Start timer, if required. */
|
/* Start timer, if required. */
|
||||||
if (devc->limit_msec)
|
if (devc->limit_msec)
|
||||||
|
@ -823,7 +823,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
|
@ -831,7 +831,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
||||||
if (sdi && (devc = sdi->priv) && devc->limit_msec)
|
if (sdi && (devc = sdi->priv) && devc->limit_msec)
|
||||||
g_timer_stop(devc->elapsed_msec);
|
g_timer_stop(devc->elapsed_msec);
|
||||||
|
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
|
return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
|
||||||
sdi->conn, LOG_PREFIX);
|
sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,12 +181,12 @@ SR_PRIV int motech_lps_30x_receive_data(int fd, int revents, void *cb_data)
|
||||||
|
|
||||||
/* If number of samples or time limit reached, stop acquisition. */
|
/* If number of samples or time limit reached, stop acquisition. */
|
||||||
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples))
|
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples))
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
|
|
||||||
if (devc->limit_msec) {
|
if (devc->limit_msec) {
|
||||||
elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL);
|
elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL);
|
||||||
if ((elapsed_s * 1000) >= devc->limit_msec)
|
if ((elapsed_s * 1000) >= devc->limit_msec)
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only request the next packet if required. */
|
/* Only request the next packet if required. */
|
||||||
|
|
|
@ -249,7 +249,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int 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;
|
||||||
|
@ -258,9 +258,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
devc->cb_data = cb_data;
|
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Start timer, if required. */
|
/* Start timer, if required. */
|
||||||
if (devc->limit_msec)
|
if (devc->limit_msec)
|
||||||
|
@ -274,7 +273,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
|
@ -282,7 +281,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
||||||
if (sdi && (devc = sdi->priv) && devc->limit_msec)
|
if (sdi && (devc = sdi->priv) && devc->limit_msec)
|
||||||
g_timer_stop(devc->elapsed_msec);
|
g_timer_stop(devc->elapsed_msec);
|
||||||
|
|
||||||
return std_serial_dev_acquisition_stop(sdi, cb_data, dev_close,
|
return std_serial_dev_acquisition_stop(sdi, sdi, dev_close,
|
||||||
sdi->conn, LOG_PREFIX);
|
sdi->conn, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@ static void nma_process_line(const struct sr_dev_inst *sdi)
|
||||||
memset(&packet, 0, sizeof(struct sr_datafeed_packet));
|
memset(&packet, 0, sizeof(struct sr_datafeed_packet));
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG_OLD;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
/* Finish processing. */
|
/* Finish processing. */
|
||||||
devc->num_samples++;
|
devc->num_samples++;
|
||||||
|
@ -414,14 +414,14 @@ SR_PRIV int norma_dmm_receive_data(int fd, int revents, void *cb_data)
|
||||||
/* If number of samples or time limit reached, stop acquisition. */
|
/* If number of samples or time limit reached, stop acquisition. */
|
||||||
terminating = FALSE;
|
terminating = FALSE;
|
||||||
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
|
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
terminating = TRUE;
|
terminating = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (devc->limit_msec) {
|
if (devc->limit_msec) {
|
||||||
elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL);
|
elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL);
|
||||||
if ((elapsed_s * 1000) >= devc->limit_msec) {
|
if ((elapsed_s * 1000) >= devc->limit_msec) {
|
||||||
sdi->driver->dev_acquisition_stop(sdi, cb_data);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
terminating = TRUE;
|
terminating = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,6 @@ struct dev_context {
|
||||||
uint64_t limit_samples; /**< Target number of samples */
|
uint64_t limit_samples; /**< Target number of samples */
|
||||||
uint64_t limit_msec; /**< Target sampling time */
|
uint64_t limit_msec; /**< Target sampling time */
|
||||||
|
|
||||||
/* Opaque pointer passed in by frontend. */
|
|
||||||
void *cb_data;
|
|
||||||
|
|
||||||
/* Operational state */
|
/* Operational state */
|
||||||
int last_req; /**< Last request. */
|
int last_req; /**< Last request. */
|
||||||
int64_t req_sent_at; /**< Request sent. */
|
int64_t req_sent_at; /**< Request sent. */
|
||||||
|
|
|
@ -463,7 +463,7 @@ static int set_trigger(const struct sr_dev_inst *sdi, int stage)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int 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;
|
||||||
|
@ -569,21 +569,19 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
devc->cnt_bytes = devc->cnt_samples = devc->cnt_samples_rle = 0;
|
devc->cnt_bytes = devc->cnt_samples = devc->cnt_samples_rle = 0;
|
||||||
memset(devc->sample, 0, 4);
|
memset(devc->sample, 0, 4);
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* If the device stops sending for longer than it takes to send a byte,
|
/* If the device stops sending for longer than it takes to send a byte,
|
||||||
* that means it's finished. But wait at least 100 ms to be safe.
|
* that means it's finished. But wait at least 100 ms to be safe.
|
||||||
*/
|
*/
|
||||||
serial_source_add(sdi->session, serial, G_IO_IN, 100,
|
serial_source_add(sdi->session, serial, G_IO_IN, 100,
|
||||||
ols_receive_data, cb_data);
|
ols_receive_data, (struct sr_dev_inst *)sdi);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)cb_data;
|
|
||||||
|
|
||||||
abort_acquisition(sdi);
|
abort_acquisition(sdi);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
|
|
|
@ -472,12 +472,12 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
|
||||||
logic.unitsize = 4;
|
logic.unitsize = 4;
|
||||||
logic.data = devc->raw_sample_buf +
|
logic.data = devc->raw_sample_buf +
|
||||||
(devc->limit_samples - devc->num_samples) * 4;
|
(devc->limit_samples - devc->num_samples) * 4;
|
||||||
sr_session_send(cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send the trigger. */
|
/* Send the trigger. */
|
||||||
packet.type = SR_DF_TRIGGER;
|
packet.type = SR_DF_TRIGGER;
|
||||||
sr_session_send(cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
/* Send post-trigger samples. */
|
/* Send post-trigger samples. */
|
||||||
packet.type = SR_DF_LOGIC;
|
packet.type = SR_DF_LOGIC;
|
||||||
|
@ -486,7 +486,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
|
||||||
logic.unitsize = 4;
|
logic.unitsize = 4;
|
||||||
logic.data = devc->raw_sample_buf + devc->trigger_at * 4 +
|
logic.data = devc->raw_sample_buf + devc->trigger_at * 4 +
|
||||||
(devc->limit_samples - devc->num_samples) * 4;
|
(devc->limit_samples - devc->num_samples) * 4;
|
||||||
sr_session_send(cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
} else {
|
} else {
|
||||||
/* no trigger was used */
|
/* no trigger was used */
|
||||||
packet.type = SR_DF_LOGIC;
|
packet.type = SR_DF_LOGIC;
|
||||||
|
@ -495,7 +495,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
|
||||||
logic.unitsize = 4;
|
logic.unitsize = 4;
|
||||||
logic.data = devc->raw_sample_buf +
|
logic.data = devc->raw_sample_buf +
|
||||||
(devc->limit_samples - devc->num_samples) * 4;
|
(devc->limit_samples - devc->num_samples) * 4;
|
||||||
sr_session_send(cb_data, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
}
|
}
|
||||||
g_free(devc->raw_sample_buf);
|
g_free(devc->raw_sample_buf);
|
||||||
|
|
||||||
|
|
|
@ -535,7 +535,7 @@ static int disable_trigger(const struct sr_dev_inst *sdi, int stage)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
uint32_t samplecount, readcount, delaycount;
|
uint32_t samplecount, readcount, delaycount;
|
||||||
|
@ -688,16 +688,16 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
devc->cnt_bytes = devc->cnt_samples = devc->cnt_samples_rle = 0;
|
devc->cnt_bytes = devc->cnt_samples = devc->cnt_samples_rle = 0;
|
||||||
memset(devc->sample, 0, 4);
|
memset(devc->sample, 0, 4);
|
||||||
|
|
||||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Hook up a dummy handler to receive data from the device. */
|
/* Hook up a dummy handler to receive data from the device. */
|
||||||
sr_session_source_add(sdi->session, -1, 0, 10, p_ols_receive_data,
|
sr_session_source_add(sdi->session, -1, 0, 10, p_ols_receive_data,
|
||||||
cb_data);
|
(struct sr_dev_inst *)sdi);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
|
@ -712,7 +712,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
||||||
|
|
||||||
sr_session_source_remove(sdi->session, -1);
|
sr_session_source_remove(sdi->session, -1);
|
||||||
|
|
||||||
std_session_send_df_end(cb_data, LOG_PREFIX);
|
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue