2013-10-15 18:45:14 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the libsigrok project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 poljar (Damir Jelić) <poljarinho@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
#include <stdlib.h>
|
2013-10-15 18:45:14 +00:00
|
|
|
#include "protocol.h"
|
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
#define SERIALCOMM "115200/8n1/flow=1"
|
|
|
|
|
2013-12-09 13:35:29 +00:00
|
|
|
SR_PRIV struct sr_dev_driver hameg_hmo_driver_info;
|
|
|
|
static struct sr_dev_driver *di = &hameg_hmo_driver_info;
|
|
|
|
|
|
|
|
static const char *manufacturers[] = {
|
|
|
|
"HAMEG",
|
|
|
|
};
|
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
static const int32_t hwopts[] = {
|
|
|
|
SR_CONF_CONN,
|
|
|
|
SR_CONF_SERIALCOMM,
|
|
|
|
};
|
|
|
|
|
2013-12-03 15:58:34 +00:00
|
|
|
enum {
|
|
|
|
PG_INVALID = -1,
|
|
|
|
PG_NONE,
|
|
|
|
PG_ANALOG,
|
|
|
|
PG_DIGITAL,
|
|
|
|
};
|
|
|
|
|
2013-10-15 18:45:14 +00:00
|
|
|
static int init(struct sr_context *sr_ctx)
|
|
|
|
{
|
|
|
|
return std_init(sr_ctx, di, LOG_PREFIX);
|
|
|
|
}
|
|
|
|
|
2013-12-09 13:35:29 +00:00
|
|
|
static int check_manufacturer(const char *manufacturer)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(manufacturers); ++i)
|
|
|
|
if (!strcmp(manufacturer, manufacturers[i]))
|
|
|
|
return SR_OK;
|
|
|
|
|
|
|
|
return SR_ERR;
|
|
|
|
}
|
|
|
|
|
2014-02-02 20:50:14 +00:00
|
|
|
static struct sr_dev_inst *hmo_probe_serial_device(struct sr_scpi_dev_inst *scpi)
|
2013-12-09 13:35:29 +00:00
|
|
|
{
|
|
|
|
struct sr_dev_inst *sdi;
|
|
|
|
struct dev_context *devc;
|
|
|
|
struct sr_scpi_hw_info *hw_info;
|
|
|
|
|
|
|
|
sdi = NULL;
|
|
|
|
devc = NULL;
|
|
|
|
hw_info = NULL;
|
|
|
|
|
|
|
|
if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) {
|
|
|
|
sr_info("Couldn't get IDN response.");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (check_manufacturer(hw_info->manufacturer) != SR_OK)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (!(sdi = sr_dev_inst_new(0, SR_ST_ACTIVE,
|
|
|
|
hw_info->manufacturer, hw_info->model,
|
|
|
|
hw_info->firmware_version))) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
sr_scpi_hw_info_free(hw_info);
|
|
|
|
hw_info = NULL;
|
|
|
|
|
|
|
|
if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
sdi->driver = di;
|
|
|
|
sdi->priv = devc;
|
|
|
|
sdi->inst_type = SR_INST_SCPI;
|
|
|
|
sdi->conn = scpi;
|
|
|
|
|
|
|
|
if (hmo_init_device(sdi) != SR_OK)
|
|
|
|
goto fail;
|
|
|
|
|
2014-01-16 14:28:51 +00:00
|
|
|
sr_scpi_close(sdi->conn);
|
|
|
|
|
|
|
|
sdi->status = SR_ST_INACTIVE;
|
|
|
|
|
2013-12-09 13:35:29 +00:00
|
|
|
return sdi;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (hw_info)
|
|
|
|
sr_scpi_hw_info_free(hw_info);
|
|
|
|
if (sdi)
|
|
|
|
sr_dev_inst_free(sdi);
|
|
|
|
if (devc)
|
|
|
|
g_free(devc);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-10-15 18:45:14 +00:00
|
|
|
static GSList *scan(GSList *options)
|
|
|
|
{
|
2014-02-02 20:50:14 +00:00
|
|
|
return sr_scpi_scan(di->priv, options, hmo_probe_serial_device);
|
2013-10-15 18:45:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GSList *dev_list(void)
|
|
|
|
{
|
|
|
|
return ((struct drv_context *)(di->priv))->instances;
|
|
|
|
}
|
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
static void clear_helper(void *priv)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
struct dev_context *devc;
|
|
|
|
struct scope_config *model;
|
|
|
|
|
|
|
|
devc = priv;
|
|
|
|
model = devc->model_config;
|
|
|
|
|
2013-12-03 15:58:34 +00:00
|
|
|
hmo_scope_state_free(devc->model_state);
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2013-12-03 15:48:21 +00:00
|
|
|
for (i = 0; i < model->analog_channels; ++i)
|
2014-03-14 20:21:09 +00:00
|
|
|
g_slist_free(devc->analog_groups[i].channels);
|
2013-10-25 16:15:00 +00:00
|
|
|
|
|
|
|
for (i = 0; i < model->digital_pods; ++i) {
|
2014-03-14 20:21:09 +00:00
|
|
|
g_slist_free(devc->digital_groups[i].channels);
|
2013-10-25 16:15:00 +00:00
|
|
|
g_free(devc->digital_groups[i].name);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free(devc->analog_groups);
|
|
|
|
g_free(devc->digital_groups);
|
|
|
|
|
|
|
|
g_free(devc);
|
|
|
|
}
|
|
|
|
|
2013-10-15 18:45:14 +00:00
|
|
|
static int dev_clear(void)
|
|
|
|
{
|
2013-10-25 16:15:00 +00:00
|
|
|
return std_dev_clear(di, clear_helper);
|
2013-10-15 18:45:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int dev_open(struct sr_dev_inst *sdi)
|
|
|
|
{
|
2013-12-03 20:40:19 +00:00
|
|
|
if (sdi->status != SR_ST_ACTIVE && sr_scpi_open(sdi->conn) != SR_OK)
|
2013-10-25 16:15:00 +00:00
|
|
|
return SR_ERR;
|
2013-10-15 18:45:14 +00:00
|
|
|
|
2013-12-03 15:58:34 +00:00
|
|
|
if (hmo_scope_state_get(sdi) != SR_OK)
|
2013-10-25 16:15:00 +00:00
|
|
|
return SR_ERR;
|
2013-10-15 18:45:14 +00:00
|
|
|
|
|
|
|
sdi->status = SR_ST_ACTIVE;
|
|
|
|
|
|
|
|
return SR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dev_close(struct sr_dev_inst *sdi)
|
|
|
|
{
|
2013-10-25 16:15:00 +00:00
|
|
|
if (sdi->status == SR_ST_INACTIVE)
|
|
|
|
return SR_OK;
|
2013-10-15 18:45:14 +00:00
|
|
|
|
2013-12-03 20:40:19 +00:00
|
|
|
sr_scpi_close(sdi->conn);
|
2013-10-15 18:45:14 +00:00
|
|
|
|
|
|
|
sdi->status = SR_ST_INACTIVE;
|
|
|
|
|
|
|
|
return SR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cleanup(void)
|
|
|
|
{
|
|
|
|
dev_clear();
|
|
|
|
|
|
|
|
return SR_OK;
|
|
|
|
}
|
|
|
|
|
2014-03-14 20:09:37 +00:00
|
|
|
static int check_channel_group(struct dev_context *devc,
|
2014-03-20 20:58:01 +00:00
|
|
|
const struct sr_channel_group *cg)
|
2013-10-25 16:15:00 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
struct scope_config *model;
|
|
|
|
|
|
|
|
model = devc->model_config;
|
|
|
|
|
2014-03-20 20:58:01 +00:00
|
|
|
if (!cg)
|
2013-10-25 16:15:00 +00:00
|
|
|
return PG_NONE;
|
|
|
|
|
|
|
|
for (i = 0; i < model->analog_channels; ++i)
|
2014-03-20 20:58:01 +00:00
|
|
|
if (cg == &devc->analog_groups[i])
|
2013-10-25 16:15:00 +00:00
|
|
|
return PG_ANALOG;
|
|
|
|
|
|
|
|
for (i = 0; i < model->digital_pods; ++i)
|
2014-03-20 20:58:01 +00:00
|
|
|
if (cg == &devc->digital_groups[i])
|
2013-10-25 16:15:00 +00:00
|
|
|
return PG_DIGITAL;
|
|
|
|
|
2014-03-14 20:09:37 +00:00
|
|
|
sr_err("Invalid channel group specified.");
|
2013-12-03 15:48:21 +00:00
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
return PG_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
2014-03-20 20:58:01 +00:00
|
|
|
const struct sr_channel_group *cg)
|
2013-10-15 18:45:14 +00:00
|
|
|
{
|
2013-12-03 15:48:21 +00:00
|
|
|
int ret, pg_type;
|
2013-10-25 16:15:00 +00:00
|
|
|
unsigned int i;
|
|
|
|
struct dev_context *devc;
|
|
|
|
struct scope_config *model;
|
2014-01-16 14:28:55 +00:00
|
|
|
struct scope_state *state;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
|
|
|
if (!sdi || !(devc = sdi->priv))
|
|
|
|
return SR_ERR_ARG;
|
|
|
|
|
2014-03-20 20:58:01 +00:00
|
|
|
if ((pg_type = check_channel_group(devc, cg)) == PG_INVALID)
|
2013-10-25 16:15:00 +00:00
|
|
|
return SR_ERR;
|
2013-10-15 18:45:14 +00:00
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
ret = SR_ERR_NA;
|
|
|
|
model = devc->model_config;
|
2014-01-16 14:28:55 +00:00
|
|
|
state = devc->model_state;
|
2013-10-15 18:45:14 +00:00
|
|
|
|
|
|
|
switch (key) {
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_CONF_NUM_TIMEBASE:
|
|
|
|
*data = g_variant_new_int32(model->num_xdivs);
|
|
|
|
ret = SR_OK;
|
|
|
|
break;
|
2014-03-25 16:44:38 +00:00
|
|
|
case SR_CONF_TIMEBASE:
|
|
|
|
*data = g_variant_new("(tt)", (*model->timebases)[state->timebase][0],
|
|
|
|
(*model->timebases)[state->timebase][1]);
|
|
|
|
ret = SR_OK;
|
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_CONF_NUM_VDIV:
|
|
|
|
if (pg_type == PG_NONE) {
|
2014-03-14 20:09:37 +00:00
|
|
|
sr_err("No channel group specified.");
|
|
|
|
return SR_ERR_CHANNEL_GROUP;
|
2013-10-25 16:15:00 +00:00
|
|
|
} else if (pg_type == PG_ANALOG) {
|
|
|
|
for (i = 0; i < model->analog_channels; ++i) {
|
2014-03-20 20:58:01 +00:00
|
|
|
if (cg != &devc->analog_groups[i])
|
2013-12-03 16:13:50 +00:00
|
|
|
continue;
|
|
|
|
*data = g_variant_new_int32(model->num_ydivs);
|
|
|
|
ret = SR_OK;
|
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 16:44:38 +00:00
|
|
|
} else {
|
|
|
|
ret = SR_ERR_NA;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SR_CONF_VDIV:
|
|
|
|
if (pg_type == PG_NONE) {
|
|
|
|
sr_err("No probe group specified.");
|
|
|
|
return SR_ERR_PROBE_GROUP;
|
|
|
|
} else if (pg_type == PG_ANALOG) {
|
|
|
|
for (i = 0; i < model->analog_channels; ++i) {
|
|
|
|
if (probe_group != &devc->analog_groups[i])
|
|
|
|
continue;
|
|
|
|
*data = g_variant_new("(tt)",
|
|
|
|
(*model->vdivs)[state->analog_channels[i].vdiv][0],
|
|
|
|
(*model->vdivs)[state->analog_channels[i].vdiv][1]);
|
|
|
|
ret = SR_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-01-16 14:28:58 +00:00
|
|
|
} else {
|
|
|
|
ret = SR_ERR_NA;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SR_CONF_TRIGGER_SOURCE:
|
|
|
|
*data = g_variant_new_string((*model->trigger_sources)[state->trigger_source]);
|
|
|
|
ret = SR_OK;
|
|
|
|
break;
|
2014-03-25 16:44:38 +00:00
|
|
|
case SR_CONF_TRIGGER_SLOPE:
|
|
|
|
*data = g_variant_new_string((*model->trigger_slopes)[state->trigger_slope]);
|
|
|
|
ret = SR_OK;
|
|
|
|
break;
|
|
|
|
case SR_CONF_HORIZ_TRIGGERPOS:
|
|
|
|
*data = g_variant_new_double(state->horiz_triggerpos);
|
|
|
|
ret = SR_OK;
|
|
|
|
break;
|
2014-01-16 14:28:58 +00:00
|
|
|
case SR_CONF_COUPLING:
|
|
|
|
if (pg_type == PG_NONE) {
|
2014-03-14 20:09:37 +00:00
|
|
|
sr_err("No channel group specified.");
|
|
|
|
return SR_ERR_CHANNEL_GROUP;
|
2014-01-16 14:28:58 +00:00
|
|
|
} else if (pg_type == PG_ANALOG) {
|
|
|
|
for (i = 0; i < model->analog_channels; ++i) {
|
2014-03-20 20:58:01 +00:00
|
|
|
if (cg != &devc->analog_groups[i])
|
2014-01-16 14:28:58 +00:00
|
|
|
continue;
|
|
|
|
*data = g_variant_new_string((*model->coupling_options)[state->analog_channels[i].coupling]);
|
|
|
|
ret = SR_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
} else {
|
|
|
|
ret = SR_ERR_NA;
|
|
|
|
}
|
|
|
|
break;
|
2014-01-16 14:28:55 +00:00
|
|
|
case SR_CONF_SAMPLERATE:
|
|
|
|
*data = g_variant_new_uint64(state->sample_rate);
|
|
|
|
ret = SR_OK;
|
|
|
|
break;
|
2013-10-15 18:45:14 +00:00
|
|
|
default:
|
2013-10-25 16:15:00 +00:00
|
|
|
ret = SR_ERR_NA;
|
2013-10-15 18:45:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
static GVariant *build_tuples(const uint64_t (*array)[][2], unsigned int n)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
GVariant *rational[2];
|
|
|
|
GVariantBuilder gvb;
|
|
|
|
|
|
|
|
g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
rational[0] = g_variant_new_uint64((*array)[i][0]);
|
|
|
|
rational[1] = g_variant_new_uint64((*array)[i][1]);
|
|
|
|
|
2013-12-03 15:48:21 +00:00
|
|
|
/* FIXME: Valgrind reports a memory leak here. */
|
2013-10-25 16:15:00 +00:00
|
|
|
g_variant_builder_add_value(&gvb, g_variant_new_tuple(rational, 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_variant_builder_end(&gvb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
|
2014-03-20 20:58:01 +00:00
|
|
|
const struct sr_channel_group *cg)
|
2013-10-15 18:45:14 +00:00
|
|
|
{
|
2013-12-03 15:48:21 +00:00
|
|
|
int ret, pg_type;
|
|
|
|
unsigned int i, j;
|
2014-01-16 14:28:50 +00:00
|
|
|
char command[MAX_COMMAND_SIZE], float_str[30];
|
2013-10-25 16:15:00 +00:00
|
|
|
struct dev_context *devc;
|
|
|
|
struct scope_config *model;
|
|
|
|
struct scope_state *state;
|
2013-12-03 15:48:21 +00:00
|
|
|
const char *tmp;
|
2014-01-26 23:22:01 +00:00
|
|
|
uint64_t p, q;
|
2013-12-03 15:48:21 +00:00
|
|
|
double tmp_d;
|
2014-01-16 14:28:56 +00:00
|
|
|
gboolean update_sample_rate;
|
2013-10-15 18:45:14 +00:00
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
if (!sdi || !(devc = sdi->priv))
|
|
|
|
return SR_ERR_ARG;
|
|
|
|
|
2014-03-20 20:58:01 +00:00
|
|
|
if ((pg_type = check_channel_group(devc, cg)) == PG_INVALID)
|
2013-10-25 16:15:00 +00:00
|
|
|
return SR_ERR;
|
|
|
|
|
|
|
|
model = devc->model_config;
|
|
|
|
state = devc->model_state;
|
2014-01-16 14:28:56 +00:00
|
|
|
update_sample_rate = FALSE;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
|
|
|
ret = SR_ERR_NA;
|
2013-10-15 18:45:14 +00:00
|
|
|
|
|
|
|
switch (key) {
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_CONF_LIMIT_FRAMES:
|
|
|
|
devc->frame_limit = g_variant_get_uint64(data);
|
|
|
|
ret = SR_OK;
|
|
|
|
break;
|
|
|
|
case SR_CONF_TRIGGER_SOURCE:
|
|
|
|
tmp = g_variant_get_string(data, NULL);
|
|
|
|
for (i = 0; (*model->trigger_sources)[i]; i++) {
|
2013-12-03 16:13:50 +00:00
|
|
|
if (g_strcmp0(tmp, (*model->trigger_sources)[i]) != 0)
|
|
|
|
continue;
|
|
|
|
state->trigger_source = i;
|
|
|
|
g_snprintf(command, sizeof(command),
|
|
|
|
(*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SOURCE],
|
|
|
|
(*model->trigger_sources)[i]);
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2013-12-03 16:13:50 +00:00
|
|
|
ret = sr_scpi_send(sdi->conn, command);
|
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
}
|
2013-12-03 15:48:21 +00:00
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_CONF_VDIV:
|
|
|
|
if (pg_type == PG_NONE) {
|
2014-03-14 20:09:37 +00:00
|
|
|
sr_err("No channel group specified.");
|
|
|
|
return SR_ERR_CHANNEL_GROUP;
|
2013-10-25 16:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_variant_get(data, "(tt)", &p, &q);
|
|
|
|
|
|
|
|
for (i = 0; i < model->num_vdivs; i++) {
|
2013-12-03 16:13:50 +00:00
|
|
|
if (p != (*model->vdivs)[i][0] ||
|
|
|
|
q != (*model->vdivs)[i][1])
|
|
|
|
continue;
|
|
|
|
for (j = 1; j <= model->analog_channels; ++j) {
|
2014-03-20 20:58:01 +00:00
|
|
|
if (cg != &devc->analog_groups[j - 1])
|
2013-12-03 16:13:50 +00:00
|
|
|
continue;
|
2014-01-16 14:28:53 +00:00
|
|
|
state->analog_channels[j - 1].vdiv = i;
|
2014-01-16 14:28:50 +00:00
|
|
|
g_ascii_formatd(float_str, sizeof(float_str), "%E", (float) p / q);
|
2013-12-03 16:13:50 +00:00
|
|
|
g_snprintf(command, sizeof(command),
|
|
|
|
(*model->scpi_dialect)[SCPI_CMD_SET_VERTICAL_DIV],
|
2014-01-16 14:28:50 +00:00
|
|
|
j, float_str);
|
2013-12-03 16:13:50 +00:00
|
|
|
|
|
|
|
if (sr_scpi_send(sdi->conn, command) != SR_OK ||
|
|
|
|
sr_scpi_get_opc(sdi->conn) != SR_OK)
|
|
|
|
return SR_ERR;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2013-12-03 16:13:50 +00:00
|
|
|
|
|
|
|
ret = SR_OK;
|
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
}
|
2013-12-03 15:48:21 +00:00
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_CONF_TIMEBASE:
|
|
|
|
g_variant_get(data, "(tt)", &p, &q);
|
|
|
|
|
|
|
|
for (i = 0; i < model->num_timebases; i++) {
|
2013-12-03 16:13:50 +00:00
|
|
|
if (p != (*model->timebases)[i][0] ||
|
|
|
|
q != (*model->timebases)[i][1])
|
|
|
|
continue;
|
2014-01-16 14:28:53 +00:00
|
|
|
state->timebase = i;
|
2014-01-16 14:28:50 +00:00
|
|
|
g_ascii_formatd(float_str, sizeof(float_str), "%E", (float) p / q);
|
2013-12-03 16:13:50 +00:00
|
|
|
g_snprintf(command, sizeof(command),
|
|
|
|
(*model->scpi_dialect)[SCPI_CMD_SET_TIMEBASE],
|
2014-01-16 14:28:50 +00:00
|
|
|
float_str);
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2013-12-03 16:13:50 +00:00
|
|
|
ret = sr_scpi_send(sdi->conn, command);
|
2014-01-16 14:28:56 +00:00
|
|
|
update_sample_rate = TRUE;
|
2013-12-03 16:13:50 +00:00
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
}
|
2013-12-03 15:48:21 +00:00
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_CONF_HORIZ_TRIGGERPOS:
|
2013-12-03 15:48:21 +00:00
|
|
|
tmp_d = g_variant_get_double(data);
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2013-12-03 15:48:21 +00:00
|
|
|
if (tmp_d < 0.0 || tmp_d > 1.0)
|
2013-10-25 16:15:00 +00:00
|
|
|
return SR_ERR;
|
|
|
|
|
2014-03-25 16:44:36 +00:00
|
|
|
state->horiz_triggerpos = tmp_d;
|
|
|
|
tmp_d = -(tmp_d - 0.5) *
|
|
|
|
((double) (*model->timebases)[state->timebase][0] /
|
|
|
|
(*model->timebases)[state->timebase][1])
|
|
|
|
* model->num_xdivs;
|
|
|
|
|
|
|
|
g_ascii_formatd(float_str, sizeof(float_str), "%E", tmp_d);
|
2013-10-25 16:15:00 +00:00
|
|
|
g_snprintf(command, sizeof(command),
|
|
|
|
(*model->scpi_dialect)[SCPI_CMD_SET_HORIZ_TRIGGERPOS],
|
2014-03-25 16:44:36 +00:00
|
|
|
float_str);
|
2013-10-25 16:15:00 +00:00
|
|
|
|
|
|
|
ret = sr_scpi_send(sdi->conn, command);
|
2013-12-03 15:48:21 +00:00
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_CONF_TRIGGER_SLOPE:
|
2014-01-26 23:22:01 +00:00
|
|
|
tmp = g_variant_get_string(data, NULL);
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2014-01-26 23:22:01 +00:00
|
|
|
if (!tmp || !(tmp[0] == 'f' || tmp[0] == 'r'))
|
|
|
|
return SR_ERR_ARG;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2014-01-26 23:22:01 +00:00
|
|
|
state->trigger_slope = (tmp[0] == 'r') ? 0 : 1;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
|
|
|
g_snprintf(command, sizeof(command),
|
|
|
|
(*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SLOPE],
|
2014-01-26 23:22:01 +00:00
|
|
|
(state->trigger_slope == 0) ? "POS" : "NEG");
|
2013-10-25 16:15:00 +00:00
|
|
|
|
|
|
|
ret = sr_scpi_send(sdi->conn, command);
|
2013-12-03 15:48:21 +00:00
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_CONF_COUPLING:
|
|
|
|
if (pg_type == PG_NONE) {
|
2014-03-14 20:09:37 +00:00
|
|
|
sr_err("No channel group specified.");
|
|
|
|
return SR_ERR_CHANNEL_GROUP;
|
2013-10-25 16:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tmp = g_variant_get_string(data, NULL);
|
|
|
|
|
|
|
|
for (i = 0; (*model->coupling_options)[i]; i++) {
|
2013-12-03 16:13:50 +00:00
|
|
|
if (strcmp(tmp, (*model->coupling_options)[i]) != 0)
|
|
|
|
continue;
|
|
|
|
for (j = 1; j <= model->analog_channels; ++j) {
|
2014-03-20 20:58:01 +00:00
|
|
|
if (cg != &devc->analog_groups[j - 1])
|
2013-12-03 16:13:50 +00:00
|
|
|
continue;
|
|
|
|
state->analog_channels[j-1].coupling = i;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2013-12-03 16:13:50 +00:00
|
|
|
g_snprintf(command, sizeof(command),
|
|
|
|
(*model->scpi_dialect)[SCPI_CMD_SET_COUPLING],
|
|
|
|
j, tmp);
|
|
|
|
|
|
|
|
if (sr_scpi_send(sdi->conn, command) != SR_OK ||
|
|
|
|
sr_scpi_get_opc(sdi->conn) != SR_OK)
|
|
|
|
return SR_ERR;
|
2013-10-25 16:15:00 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-12-03 16:13:50 +00:00
|
|
|
|
|
|
|
ret = SR_OK;
|
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
}
|
2013-12-03 15:48:21 +00:00
|
|
|
break;
|
2013-10-15 18:45:14 +00:00
|
|
|
default:
|
|
|
|
ret = SR_ERR_NA;
|
2013-10-25 16:15:00 +00:00
|
|
|
break;
|
2013-10-15 18:45:14 +00:00
|
|
|
}
|
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
if (ret == SR_OK)
|
|
|
|
ret = sr_scpi_get_opc(sdi->conn);
|
|
|
|
|
2014-01-16 14:28:56 +00:00
|
|
|
if (ret == SR_OK && update_sample_rate)
|
|
|
|
ret = hmo_update_sample_rate(sdi);
|
|
|
|
|
2013-10-15 18:45:14 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
2014-03-20 20:58:01 +00:00
|
|
|
const struct sr_channel_group *cg)
|
2013-10-15 18:45:14 +00:00
|
|
|
{
|
2013-10-25 16:15:00 +00:00
|
|
|
int pg_type;
|
|
|
|
struct dev_context *devc;
|
|
|
|
struct scope_config *model;
|
|
|
|
|
|
|
|
if (!sdi || !(devc = sdi->priv))
|
|
|
|
return SR_ERR_ARG;
|
2013-10-15 18:45:14 +00:00
|
|
|
|
2014-03-20 20:58:01 +00:00
|
|
|
if ((pg_type = check_channel_group(devc, cg)) == PG_INVALID)
|
2013-10-25 16:15:00 +00:00
|
|
|
return SR_ERR;
|
|
|
|
|
|
|
|
model = devc->model_config;
|
2013-10-15 18:45:14 +00:00
|
|
|
|
|
|
|
switch (key) {
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_CONF_DEVICE_OPTIONS:
|
|
|
|
if (pg_type == PG_NONE) {
|
|
|
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
2013-12-03 15:48:21 +00:00
|
|
|
model->hw_caps, model->num_hwcaps,
|
|
|
|
sizeof(int32_t));
|
2013-10-25 16:15:00 +00:00
|
|
|
} else if (pg_type == PG_ANALOG) {
|
|
|
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
2013-12-03 15:48:21 +00:00
|
|
|
model->analog_hwcaps, model->num_analog_hwcaps,
|
|
|
|
sizeof(int32_t));
|
2013-10-25 16:15:00 +00:00
|
|
|
} else {
|
|
|
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
2013-12-03 15:48:21 +00:00
|
|
|
NULL, 0, sizeof(int32_t));
|
2013-10-25 16:15:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SR_CONF_COUPLING:
|
|
|
|
if (pg_type == PG_NONE)
|
2014-03-14 20:09:37 +00:00
|
|
|
return SR_ERR_CHANNEL_GROUP;
|
2013-10-25 16:15:00 +00:00
|
|
|
*data = g_variant_new_strv(*model->coupling_options,
|
2013-12-03 15:48:21 +00:00
|
|
|
g_strv_length((char **)*model->coupling_options));
|
2013-10-25 16:15:00 +00:00
|
|
|
break;
|
|
|
|
case SR_CONF_TRIGGER_SOURCE:
|
|
|
|
*data = g_variant_new_strv(*model->trigger_sources,
|
2013-12-03 15:48:21 +00:00
|
|
|
g_strv_length((char **)*model->trigger_sources));
|
2013-10-25 16:15:00 +00:00
|
|
|
break;
|
2014-03-25 16:44:37 +00:00
|
|
|
case SR_CONF_TRIGGER_SLOPE:
|
|
|
|
*data = g_variant_new_strv(*model->trigger_slopes,
|
|
|
|
g_strv_length((char **)*model->trigger_slopes));
|
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_CONF_TIMEBASE:
|
|
|
|
*data = build_tuples(model->timebases, model->num_timebases);
|
|
|
|
break;
|
|
|
|
case SR_CONF_VDIV:
|
|
|
|
if (pg_type == PG_NONE)
|
2014-03-14 20:09:37 +00:00
|
|
|
return SR_ERR_CHANNEL_GROUP;
|
2013-10-25 16:15:00 +00:00
|
|
|
*data = build_tuples(model->vdivs, model->num_vdivs);
|
|
|
|
break;
|
2013-10-15 18:45:14 +00:00
|
|
|
default:
|
|
|
|
return SR_ERR_NA;
|
|
|
|
}
|
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
return SR_OK;
|
2013-10-15 18:45:14 +00:00
|
|
|
}
|
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
SR_PRIV int hmo_request_data(const struct sr_dev_inst *sdi)
|
2013-10-15 18:45:14 +00:00
|
|
|
{
|
2013-10-25 16:15:00 +00:00
|
|
|
char command[MAX_COMMAND_SIZE];
|
2014-03-24 20:34:20 +00:00
|
|
|
struct sr_channel *ch;
|
2013-10-25 16:15:00 +00:00
|
|
|
struct dev_context *devc;
|
|
|
|
struct scope_config *model;
|
|
|
|
|
|
|
|
devc = sdi->priv;
|
|
|
|
model = devc->model_config;
|
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
ch = devc->current_channel->data;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
switch (ch->type) {
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_PROBE_ANALOG:
|
|
|
|
g_snprintf(command, sizeof(command),
|
|
|
|
(*model->scpi_dialect)[SCPI_CMD_GET_ANALOG_DATA],
|
2014-03-24 20:34:20 +00:00
|
|
|
ch->index + 1);
|
2013-10-25 16:15:00 +00:00
|
|
|
break;
|
|
|
|
case SR_PROBE_LOGIC:
|
|
|
|
g_snprintf(command, sizeof(command),
|
|
|
|
(*model->scpi_dialect)[SCPI_CMD_GET_DIG_DATA],
|
2014-03-24 20:34:20 +00:00
|
|
|
ch->index < 8 ? 1 : 2);
|
2013-10-25 16:15:00 +00:00
|
|
|
break;
|
|
|
|
default:
|
2014-03-24 20:34:20 +00:00
|
|
|
sr_err("Invalid channel type.");
|
2013-10-25 16:15:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sr_scpi_send(sdi->conn, command);
|
|
|
|
}
|
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
static int hmo_check_channels(GSList *channels)
|
2013-10-25 16:15:00 +00:00
|
|
|
{
|
|
|
|
GSList *l;
|
2014-03-24 20:34:20 +00:00
|
|
|
struct sr_channel *ch;
|
2013-12-03 15:48:21 +00:00
|
|
|
gboolean enabled_pod1, enabled_pod2, enabled_chan3, enabled_chan4;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2013-12-03 15:48:21 +00:00
|
|
|
enabled_pod1 = enabled_pod2 = enabled_chan3 = enabled_chan4 = FALSE;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
for (l = channels; l; l = l->next) {
|
|
|
|
ch = l->data;
|
|
|
|
switch (ch->type) {
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_PROBE_ANALOG:
|
2014-03-24 20:34:20 +00:00
|
|
|
if (ch->index == 2)
|
2013-10-25 16:15:00 +00:00
|
|
|
enabled_chan3 = TRUE;
|
2014-03-24 20:34:20 +00:00
|
|
|
else if (ch->index == 3)
|
2013-10-25 16:15:00 +00:00
|
|
|
enabled_chan4 = TRUE;
|
|
|
|
break;
|
|
|
|
case SR_PROBE_LOGIC:
|
2014-03-24 20:34:20 +00:00
|
|
|
if (ch->index < 8)
|
2013-10-25 16:15:00 +00:00
|
|
|
enabled_pod1 = TRUE;
|
|
|
|
else
|
|
|
|
enabled_pod2 = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return SR_ERR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((enabled_pod1 && enabled_chan3) ||
|
|
|
|
(enabled_pod2 && enabled_chan4))
|
|
|
|
return SR_ERR;
|
|
|
|
|
|
|
|
return SR_OK;
|
|
|
|
}
|
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
static int hmo_setup_channels(const struct sr_dev_inst *sdi)
|
2013-10-25 16:15:00 +00:00
|
|
|
{
|
|
|
|
GSList *l;
|
|
|
|
unsigned int i;
|
2014-01-16 14:28:56 +00:00
|
|
|
gboolean *pod_enabled, setup_changed;
|
2013-10-25 16:15:00 +00:00
|
|
|
char command[MAX_COMMAND_SIZE];
|
|
|
|
struct scope_state *state;
|
|
|
|
struct scope_config *model;
|
2014-03-24 20:34:20 +00:00
|
|
|
struct sr_channel *ch;
|
2013-10-25 16:15:00 +00:00
|
|
|
struct dev_context *devc;
|
2013-12-03 20:40:19 +00:00
|
|
|
struct sr_scpi_dev_inst *scpi;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
|
|
|
devc = sdi->priv;
|
2013-12-03 20:40:19 +00:00
|
|
|
scpi = sdi->conn;
|
2013-10-25 16:15:00 +00:00
|
|
|
state = devc->model_state;
|
|
|
|
model = devc->model_config;
|
2014-01-16 14:28:56 +00:00
|
|
|
setup_changed = FALSE;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
|
|
|
pod_enabled = g_try_malloc0(sizeof(gboolean) * model->digital_pods);
|
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
for (l = sdi->channels; l; l = l->next) {
|
|
|
|
ch = l->data;
|
|
|
|
switch (ch->type) {
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_PROBE_ANALOG:
|
2014-03-24 20:34:20 +00:00
|
|
|
if (ch->enabled == state->analog_channels[ch->index].state)
|
2013-12-03 16:13:50 +00:00
|
|
|
break;
|
|
|
|
g_snprintf(command, sizeof(command),
|
|
|
|
(*model->scpi_dialect)[SCPI_CMD_SET_ANALOG_CHAN_STATE],
|
2014-03-24 20:34:20 +00:00
|
|
|
ch->index + 1, ch->enabled);
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2013-12-03 20:40:19 +00:00
|
|
|
if (sr_scpi_send(scpi, command) != SR_OK)
|
2013-12-03 16:13:50 +00:00
|
|
|
return SR_ERR;
|
2014-03-24 20:34:20 +00:00
|
|
|
state->analog_channels[ch->index].state = ch->enabled;
|
2014-01-16 14:28:56 +00:00
|
|
|
setup_changed = TRUE;
|
2013-12-03 15:48:21 +00:00
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
case SR_PROBE_LOGIC:
|
|
|
|
/*
|
|
|
|
* A digital POD needs to be enabled for every group of
|
2014-03-24 20:34:20 +00:00
|
|
|
* 8 channels.
|
2013-10-25 16:15:00 +00:00
|
|
|
*/
|
2014-03-24 20:34:20 +00:00
|
|
|
if (ch->enabled)
|
|
|
|
pod_enabled[ch->index < 8 ? 0 : 1] = TRUE;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
if (ch->enabled == state->digital_channels[ch->index])
|
2013-12-03 16:13:50 +00:00
|
|
|
break;
|
|
|
|
g_snprintf(command, sizeof(command),
|
|
|
|
(*model->scpi_dialect)[SCPI_CMD_SET_DIG_CHAN_STATE],
|
2014-03-24 20:34:20 +00:00
|
|
|
ch->index, ch->enabled);
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2013-12-03 20:40:19 +00:00
|
|
|
if (sr_scpi_send(scpi, command) != SR_OK)
|
2013-12-03 16:13:50 +00:00
|
|
|
return SR_ERR;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
state->digital_channels[ch->index] = ch->enabled;
|
2014-01-16 14:28:56 +00:00
|
|
|
setup_changed = TRUE;
|
2013-12-03 15:48:21 +00:00
|
|
|
break;
|
2013-10-25 16:15:00 +00:00
|
|
|
default:
|
|
|
|
return SR_ERR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i <= model->digital_pods; ++i) {
|
2013-12-03 16:13:50 +00:00
|
|
|
if (state->digital_pods[i - 1] == pod_enabled[i - 1])
|
|
|
|
continue;
|
|
|
|
g_snprintf(command, sizeof(command),
|
|
|
|
(*model->scpi_dialect)[SCPI_CMD_SET_DIG_POD_STATE],
|
|
|
|
i, pod_enabled[i - 1]);
|
2013-12-03 20:40:19 +00:00
|
|
|
if (sr_scpi_send(scpi, command) != SR_OK)
|
2013-12-03 16:13:50 +00:00
|
|
|
return SR_ERR;
|
|
|
|
state->digital_pods[i - 1] = pod_enabled[i - 1];
|
2014-01-16 14:28:56 +00:00
|
|
|
setup_changed = TRUE;
|
2013-10-25 16:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free(pod_enabled);
|
|
|
|
|
2014-01-16 14:28:56 +00:00
|
|
|
if (setup_changed && hmo_update_sample_rate(sdi) != SR_OK)
|
|
|
|
return SR_ERR;
|
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
return SR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|
|
|
{
|
|
|
|
GSList *l;
|
|
|
|
gboolean digital_added;
|
2014-03-24 20:34:20 +00:00
|
|
|
struct sr_channel *ch;
|
2013-10-25 16:15:00 +00:00
|
|
|
struct dev_context *devc;
|
2013-12-03 20:40:19 +00:00
|
|
|
struct sr_scpi_dev_inst *scpi;
|
2013-10-15 18:45:14 +00:00
|
|
|
|
|
|
|
if (sdi->status != SR_ST_ACTIVE)
|
|
|
|
return SR_ERR_DEV_CLOSED;
|
|
|
|
|
2013-12-03 20:40:19 +00:00
|
|
|
scpi = sdi->conn;
|
2013-10-25 16:15:00 +00:00
|
|
|
devc = sdi->priv;
|
|
|
|
digital_added = FALSE;
|
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
for (l = sdi->channels; l; l = l->next) {
|
|
|
|
ch = l->data;
|
|
|
|
if (!ch->enabled)
|
2013-12-03 16:13:50 +00:00
|
|
|
continue;
|
2014-03-24 20:34:20 +00:00
|
|
|
/* Only add a single digital channel. */
|
|
|
|
if (ch->type != SR_PROBE_LOGIC || !digital_added) {
|
|
|
|
devc->enabled_channels = g_slist_append(
|
|
|
|
devc->enabled_channels, ch);
|
|
|
|
if (ch->type == SR_PROBE_LOGIC)
|
2013-12-03 16:13:50 +00:00
|
|
|
digital_added = TRUE;
|
2013-10-25 16:15:00 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-15 18:45:14 +00:00
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
if (!devc->enabled_channels)
|
2013-10-25 16:15:00 +00:00
|
|
|
return SR_ERR;
|
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
if (hmo_check_channels(devc->enabled_channels) != SR_OK) {
|
|
|
|
sr_err("Invalid channel configuration specified!");
|
2013-10-25 16:15:00 +00:00
|
|
|
return SR_ERR_NA;
|
|
|
|
}
|
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
if (hmo_setup_channels(sdi) != SR_OK) {
|
|
|
|
sr_err("Failed to setup channel configuration!");
|
2013-10-25 16:15:00 +00:00
|
|
|
return SR_ERR;
|
|
|
|
}
|
|
|
|
|
2013-12-03 20:40:19 +00:00
|
|
|
sr_scpi_source_add(scpi, G_IO_IN, 50, hmo_receive_data, (void *)sdi);
|
2013-10-25 16:15:00 +00:00
|
|
|
|
|
|
|
/* Send header packet to the session bus. */
|
|
|
|
std_session_send_df_header(cb_data, LOG_PREFIX);
|
|
|
|
|
2014-03-24 20:34:20 +00:00
|
|
|
devc->current_channel = devc->enabled_channels;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
|
|
|
return hmo_request_data(sdi);
|
2013-10-15 18:45:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
|
|
|
{
|
2013-10-25 16:15:00 +00:00
|
|
|
struct dev_context *devc;
|
2013-12-03 20:40:19 +00:00
|
|
|
struct sr_scpi_dev_inst *scpi;
|
2014-01-16 14:28:52 +00:00
|
|
|
struct sr_datafeed_packet packet;
|
2013-10-25 16:15:00 +00:00
|
|
|
|
2013-10-15 18:45:14 +00:00
|
|
|
(void)cb_data;
|
|
|
|
|
2014-01-16 14:28:52 +00:00
|
|
|
packet.type = SR_DF_END;
|
|
|
|
packet.payload = NULL;
|
|
|
|
sr_session_send(sdi, &packet);
|
|
|
|
|
2013-10-15 18:45:14 +00:00
|
|
|
if (sdi->status != SR_ST_ACTIVE)
|
|
|
|
return SR_ERR_DEV_CLOSED;
|
|
|
|
|
2013-10-25 16:15:00 +00:00
|
|
|
devc = sdi->priv;
|
|
|
|
|
2014-01-16 18:55:00 +00:00
|
|
|
devc->num_frames = 0;
|
2014-03-24 20:34:20 +00:00
|
|
|
g_slist_free(devc->enabled_channels);
|
|
|
|
devc->enabled_channels = NULL;
|
2013-12-03 20:40:19 +00:00
|
|
|
scpi = sdi->conn;
|
|
|
|
sr_scpi_source_remove(scpi);
|
2013-10-15 18:45:14 +00:00
|
|
|
|
|
|
|
return SR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
SR_PRIV struct sr_dev_driver hameg_hmo_driver_info = {
|
|
|
|
.name = "hameg-hmo",
|
2013-12-03 15:48:21 +00:00
|
|
|
.longname = "Hameg HMO",
|
2013-10-15 18:45:14 +00:00
|
|
|
.api_version = 1,
|
|
|
|
.init = init,
|
|
|
|
.cleanup = cleanup,
|
|
|
|
.scan = scan,
|
|
|
|
.dev_list = dev_list,
|
|
|
|
.dev_clear = dev_clear,
|
|
|
|
.config_get = config_get,
|
|
|
|
.config_set = config_set,
|
|
|
|
.config_list = config_list,
|
|
|
|
.dev_open = dev_open,
|
|
|
|
.dev_close = dev_close,
|
|
|
|
.dev_acquisition_start = dev_acquisition_start,
|
|
|
|
.dev_acquisition_stop = dev_acquisition_stop,
|
|
|
|
.priv = NULL,
|
|
|
|
};
|