sr: add sr_dev_probe_enable(), abstraction wrapper around device probes
This commit is contained in:
parent
4d68442739
commit
be5bf44d28
32
device.c
32
device.c
|
@ -273,6 +273,38 @@ SR_API int sr_dev_probe_name_set(struct sr_dev *dev, int probenum,
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable or disable a probe on the specified device.
|
||||||
|
*
|
||||||
|
* @param sdi The device instance the probe is connected to.
|
||||||
|
* @param probenum The probe number, starting from 0.
|
||||||
|
* @param state TRUE to enable the probe, FALSE to disable.
|
||||||
|
*
|
||||||
|
* @return SR_OK on success, or SR_ERR_ARG on invalid arguments.
|
||||||
|
*/
|
||||||
|
SR_API int sr_dev_probe_enable(const struct sr_dev_inst *sdi, int probenum,
|
||||||
|
gboolean state)
|
||||||
|
{
|
||||||
|
GSList *l;
|
||||||
|
struct sr_probe *probe;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!sdi)
|
||||||
|
return SR_ERR_ARG;
|
||||||
|
|
||||||
|
ret = SR_ERR_ARG;
|
||||||
|
for (l = sdi->probes; l; l = l->next) {
|
||||||
|
probe = l->data;
|
||||||
|
if (probe->index == probenum) {
|
||||||
|
probe->enabled = state;
|
||||||
|
ret = SR_OK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all triggers set up for the specified device.
|
* Remove all triggers set up for the specified device.
|
||||||
*
|
*
|
||||||
|
|
2
proto.h
2
proto.h
|
@ -56,6 +56,8 @@ SR_API struct sr_probe *sr_dev_probe_find(const struct sr_dev *dev,
|
||||||
int probenum);
|
int probenum);
|
||||||
SR_API int sr_dev_probe_name_set(struct sr_dev *dev, int probenum,
|
SR_API int sr_dev_probe_name_set(struct sr_dev *dev, int probenum,
|
||||||
const char *name);
|
const char *name);
|
||||||
|
SR_API int sr_dev_probe_enable(const struct sr_dev_inst *sdi, int probenum,
|
||||||
|
gboolean state);
|
||||||
SR_API int sr_dev_trigger_remove_all(struct sr_dev *dev);
|
SR_API int sr_dev_trigger_remove_all(struct sr_dev *dev);
|
||||||
SR_API int sr_dev_trigger_set(const struct sr_dev_inst *sdi, int probenum,
|
SR_API int sr_dev_trigger_set(const struct sr_dev_inst *sdi, int probenum,
|
||||||
const char *trigger);
|
const char *trigger);
|
||||||
|
|
|
@ -151,10 +151,8 @@ SR_API int sr_session_load(const char *filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_strfreev(keys);
|
g_strfreev(keys);
|
||||||
for (p = enabled_probes; p < total_probes; p++) {
|
for (p = enabled_probes; p < total_probes; p++)
|
||||||
probe = g_slist_nth_data(dev->probes, p);
|
sr_dev_probe_enable(sdi, p, FALSE);
|
||||||
probe->enabled = FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
devcnt++;
|
devcnt++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue