};
/*
- * Probes are numbered 0 to 7.
+ * Channels are numbered 0 to 7.
*
* See also: http://www.linkinstruments.com/images/mso19_1113.gif
*/
-SR_PRIV const char *mso19_probe_names[NUM_PROBES + 1] = {
+SR_PRIV const char *mso19_channel_names[NUM_CHANNELS + 1] = {
/* Note: DSO needs to be first. */
"DSO", "0", "1", "2", "3", "4", "5", "6", "7", NULL,
};
SR_PRIV struct sr_dev_driver link_mso19_driver_info;
static struct sr_dev_driver *di = &link_mso19_driver_info;
+/* TODO: Use sr_dev_inst to store connection handle & use std_dev_clear(). */
+static int dev_clear(void)
+{
+ GSList *l;
+ struct sr_dev_inst *sdi;
+ struct drv_context *drvc;
+ struct dev_context *devc;
+ int ret = SR_OK;
+
+ if (!(drvc = di->priv))
+ return SR_OK;
+
+ /* Properly close and free all devices. */
+ for (l = drvc->instances; l; l = l->next) {
+ if (!(sdi = l->data)) {
+ /* Log error, but continue cleaning up the rest. */
+ sr_err("%s: sdi was NULL, continuing", __func__);
+ ret = SR_ERR_BUG;
+ continue;
+ }
+ if (!(devc = sdi->priv)) {
+ /* Log error, but continue cleaning up the rest. */
+ sr_err("%s: sdi->priv was NULL, continuing", __func__);
+ ret = SR_ERR_BUG;
+ continue;
+ }
+ std_serial_dev_close(sdi);
+ sr_serial_dev_inst_free(devc->serial);
+ sr_dev_inst_free(sdi);
+ }
+ g_slist_free(drvc->instances);
+ drvc->instances = NULL;
+
+ return ret;
+}
+
static int init(struct sr_context *sr_ctx)
{
- return std_hw_init(sr_ctx, di, LOG_PREFIX);
+ return std_init(sr_ctx, di, LOG_PREFIX);
}
static GSList *scan(GSList *options)
GSList *l;
struct sr_config *src;
struct udev *udev;
- int ptype;
+ int chtype;
for (l = options; l; l = l->next) {
src = l->data;
sdi->driver = di;
sdi->priv = devc;
- for (i = 0; i < NUM_PROBES; i++) {
- struct sr_probe *probe;
- ptype = (i == 0) ? SR_PROBE_ANALOG : SR_PROBE_LOGIC;
- if (!(probe = sr_probe_new(i, ptype, TRUE,
- mso19_probe_names[i])))
+ for (i = 0; i < NUM_CHANNELS; i++) {
+ struct sr_channel *ch;
+ chtype = (i == 0) ? SR_CHANNEL_ANALOG : SR_CHANNEL_LOGIC;
+ if (!(ch = sr_channel_new(i, chtype, TRUE,
+ mso19_channel_names[i])))
return 0;
- sdi->probes = g_slist_append(sdi->probes, probe);
+ sdi->channels = g_slist_append(sdi->channels, ch);
}
//Add the driver
return SR_OK;
}
-static int dev_close(struct sr_dev_inst *sdi)
-{
- struct dev_context *devc;
-
- devc = sdi->priv;
-
- if (devc->serial && devc->serial->fd != -1) {
- serial_close(devc->serial);
- sdi->status = SR_ST_INACTIVE;
- }
-
- return SR_OK;
-}
-
static int cleanup(void)
{
- GSList *l;
- struct sr_dev_inst *sdi;
- struct drv_context *drvc;
- struct dev_context *devc;
- int ret = SR_OK;
-
- if (!(drvc = di->priv))
- return SR_OK;
-
- /* Properly close and free all devices. */
- for (l = drvc->instances; l; l = l->next) {
- if (!(sdi = l->data)) {
- /* Log error, but continue cleaning up the rest. */
- sr_err("%s: sdi was NULL, continuing", __func__);
- ret = SR_ERR_BUG;
- continue;
- }
- if (!(devc = sdi->priv)) {
- /* Log error, but continue cleaning up the rest. */
- sr_err("%s: sdi->priv was NULL, continuing", __func__);
- ret = SR_ERR_BUG;
- continue;
- }
- dev_close(sdi);
- sr_serial_dev_inst_free(devc->serial);
- sr_dev_inst_free(sdi);
- }
- g_slist_free(drvc->instances);
- drvc->instances = NULL;
-
- return ret;
+ return dev_clear();
}
-static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi)
+static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
+ const struct sr_channel_group *cg)
{
struct dev_context *devc;
+ (void)cg;
+
switch (id) {
case SR_CONF_SAMPLERATE:
if (sdi) {
return SR_OK;
}
-static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
+static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
+ const struct sr_channel_group *cg)
{
int ret;
struct dev_context *devc;
- uint64_t num_samples, slope;
+ uint64_t num_samples;
+ const char *slope;
int trigger_pos;
double pos;
+ (void)cg;
devc = sdi->priv;
if (sdi->status != SR_ST_ACTIVE)
ret = SR_OK;
break;
case SR_CONF_TRIGGER_SLOPE:
- slope = g_variant_get_uint64(data);
- if (slope != SLOPE_NEGATIVE && slope != SLOPE_POSITIVE) {
+ slope = g_variant_get_string(data, NULL);
+
+ if (!slope || !(slope[0] == 'f' || slope[0] == 'r'))
sr_err("Invalid trigger slope");
ret = SR_ERR_ARG;
} else {
- devc->trigger_slope = slope;
+ devc->trigger_slope = (slope[0] == 'r')
+ ? SLOPE_POSITIVE : SLOPE_NEGATIVE;
ret = SR_OK;
}
break;
return ret;
}
-static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
+static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
+ const struct sr_channel_group *cg)
{
GVariant *gvar;
GVariantBuilder gvb;
+ (void)cg;
(void)sdi;
switch (key) {
devc = sdi->priv;
- if (mso_configure_probes(sdi) != SR_OK) {
- sr_err("Failed to configure probes.");
+ if (mso_configure_channels(sdi) != SR_OK) {
+ sr_err("Failed to configure channels.");
return SR_ERR;
}
/* Send header packet to the session bus. */
std_session_send_df_header(cb_data, LOG_PREFIX);
- /* Our first probe is analog, the other 8 are of type 'logic'. */
+ /* Our first channel is analog, the other 8 are of type 'logic'. */
/* TODO. */
- sr_source_add(devc->serial->fd, G_IO_IN, -1, mso_receive_data, cb_data);
+ serial_source_add(devc->serial, G_IO_IN, -1, mso_receive_data, cb_data);
return SR_OK;
}
.cleanup = cleanup,
.scan = scan,
.dev_list = dev_list,
- .dev_clear = cleanup,
+ .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_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop,
.priv = NULL,