]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/scpi-pps/api.c
scpi-pps: Add SR_CONF_REGULATION for HP 66xxA power supplies.
[libsigrok.git] / src / hardware / scpi-pps / api.c
index 02a34499ee2d901f244bf4c446ddad781029e04d..8c3490c5a35ca926f24fb1bd25a49d8f61a38ca3 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the libsigrok project.
  *
  * Copyright (C) 2014 Bert Vermeulen <bert@biot.com>
- * Copyright (C) 2017 Frank Stettner <frank-stettner@gmx.net>
+ * Copyright (C) 2017,2019 Frank Stettner <frank-stettner@gmx.net>
  *
  * 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
@@ -152,6 +152,13 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi,
                                for (l = sdi->channels; l; l = l->next) {
                                        ch = l->data;
                                        pch = ch->priv;
+                                       /* Add mqflags from channel_group_spec only to voltage
+                                        * and current channels
+                                        */
+                                       if (pch->mq == SR_MQ_VOLTAGE || pch->mq == SR_MQ_CURRENT)
+                                               pch->mqflags = cgs->mqflags;
+                                       else
+                                               pch->mqflags = 0;
                                        if (pch->hw_output_idx == j)
                                                cg->channels = g_slist_append(cg->channels, ch);
                                }
@@ -452,6 +459,22 @@ static int config_get(uint32_t key, GVariant **data,
                                *data = g_variant_new_string("CC");
                        }
                }
+               if (devc->device->dialect == SCPI_DIALECT_HP_COMP) {
+                       /* Evaluate Status Register from a HP 66xx in COMP mode. */
+                       s = g_variant_get_string(*data, NULL);
+                       sr_atoi(s, &reg);
+                       g_variant_unref(*data);
+                       if (reg & (1 << 0))
+                               *data = g_variant_new_string("CV");
+                       else if (reg & (1 << 1))
+                               *data = g_variant_new_string("CC");
+                       else if (reg & (1 << 2))
+                               *data = g_variant_new_string("UR");
+                       else if (reg & (1 << 9))
+                               *data = g_variant_new_string("CC-");
+                       else
+                               *data = g_variant_new_string("");
+               }
                if (devc->device->dialect == SCPI_DIALECT_HP_66XXB) {
                        /* Evaluate Operational Status Register from a HP 66xxB. */
                        s = g_variant_get_string(*data, NULL);
@@ -468,8 +491,8 @@ static int config_get(uint32_t key, GVariant **data,
                }
 
                s = g_variant_get_string(*data, NULL);
-               if (g_strcmp0(s, "CV") && g_strcmp0(s, "CC") &&
-                       g_strcmp0(s, "CC-") && g_strcmp0(s, "UR")) {
+               if (g_strcmp0(s, "CV") && g_strcmp0(s, "CC") && g_strcmp0(s, "CC-") &&
+                       g_strcmp0(s, "UR") && g_strcmp0(s, "")) {
 
                        sr_err("Unknown response to SCPI_CMD_GET_OUTPUT_REGULATION: %s", s);
                        ret = SR_ERR_DATA;
@@ -705,6 +728,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        /* Prime the pipe with the first channel. */
        devc->cur_acquisition_channel = sr_next_enabled_channel(sdi, NULL);
 
+       /* Device specific initialization before aquisition starts. */
+       if (devc->device->init_aquisition)
+               devc->device->init_aquisition(sdi);
+
        if ((ret = sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 10,
                        scpi_pps_receive_data, (void *)sdi)) != SR_OK)
                return ret;