X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhardware%2Fmanson-hcs-3xxx%2Fapi.c;h=4015ec76c89ad9413bcf67ba551736e8472f56e4;hb=31bdc10ec2cbcdee6b63df075305b44f0b270b8f;hp=d49f6129312790b637d0c002caa70d2f7c75b6ba;hpb=1b38775baa3016fb4d613c971dce5a4f26cacb7b;p=libsigrok.git
diff --git a/src/hardware/manson-hcs-3xxx/api.c b/src/hardware/manson-hcs-3xxx/api.c
index d49f6129..4015ec76 100644
--- a/src/hardware/manson-hcs-3xxx/api.c
+++ b/src/hardware/manson-hcs-3xxx/api.c
@@ -15,31 +15,32 @@
* 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see .
*/
-/** @file
- * Manson HCS-3xxx series power supply driver
- * @internal
- */
+/**
+ * @file
+ *
+ * Manson HCS-3xxx series power supply driver
+ *
+ * @internal
+ */
#include
#include "protocol.h"
-static const uint32_t drvopts[] = {
- /* Device class */
- SR_CONF_POWER_SUPPLY,
-};
-
static const uint32_t scanopts[] = {
SR_CONF_CONN,
SR_CONF_SERIALCOMM,
};
-static const uint32_t devopts[] = {
+static const uint32_t drvopts[] = {
/* Device class */
SR_CONF_POWER_SUPPLY,
+};
+
+static const uint32_t devopts[] = {
+ /* Device class */
/* Acquisition modes. */
SR_CONF_CONTINUOUS,
SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
@@ -231,13 +232,11 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
(void)cg;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
devc = sdi->priv;
switch (key) {
case SR_CONF_LIMIT_MSEC:
+ case SR_CONF_LIMIT_SAMPLES:
return sr_sw_limits_config_set(&devc->limits, key, data);
case SR_CONF_VOLTAGE_TARGET:
dval = g_variant_get_double(data);
@@ -286,32 +285,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
double dval;
int idx;
- (void)cg;
-
- /* Always available (with or without sdi). */
- if (key == SR_CONF_SCAN_OPTIONS) {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
- return SR_OK;
- }
-
- /* Return drvopts without sdi (and devopts with sdi, see below). */
- if (key == SR_CONF_DEVICE_OPTIONS && !sdi) {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
- return SR_OK;
- }
-
- /* Every other key needs an sdi. */
- if (!sdi)
- return SR_ERR_ARG;
- devc = sdi->priv;
+ devc = (sdi) ? sdi->priv : NULL;
switch (key) {
+ case SR_CONF_SCAN_OPTIONS:
case SR_CONF_DEVICE_OPTIONS:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
- break;
+ return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
case SR_CONF_VOLTAGE_TARGET:
g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
/* Min, max, step. */
@@ -350,9 +329,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->limits);
@@ -369,11 +345,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi)
-{
- return std_serial_dev_acquisition_stop(sdi);
-}
-
static struct sr_dev_driver manson_hcs_3xxx_driver_info = {
.name = "manson-hcs-3xxx",
.longname = "Manson HCS-3xxx",
@@ -382,13 +353,14 @@ static struct sr_dev_driver manson_hcs_3xxx_driver_info = {
.cleanup = std_cleanup,
.scan = scan,
.dev_list = std_dev_list,
+ .dev_clear = std_dev_clear,
.config_get = config_get,
.config_set = config_set,
.config_list = config_list,
.dev_open = std_serial_dev_open,
.dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start,
- .dev_acquisition_stop = dev_acquisition_stop,
+ .dev_acquisition_stop = std_serial_dev_acquisition_stop,
.context = NULL,
};
SR_REGISTER_DEV_DRIVER(manson_hcs_3xxx_driver_info);