]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/baylibre-acme/protocol.c
baylibre-acme: Check for power-switch presence at probe's initialization.
[libsigrok.git] / src / hardware / baylibre-acme / protocol.c
index a50c221993bd31852a57bd5ddac404c14fcea41e..4b4d5e4e6575e5b26390d0e8b8f0694a89e3682c 100644 (file)
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
 #include "protocol.h"
 #include "gpio.h"
 
+enum channel_type {
+       ENRG_PWR = 1,
+       ENRG_CURR,
+       ENRG_VOL,
+       TEMP_IN,
+       TEMP_OUT,
+};
+
 struct channel_group_priv {
        int hwmon_num;
        int probe_type;
        int index;
+       int has_pws;
 };
 
 struct channel_priv {
@@ -228,6 +238,7 @@ SR_PRIV gboolean bl_acme_register_probe(struct sr_dev_inst *sdi, int type,
        cgp->hwmon_num = hwmon;
        cgp->probe_type = type;
        cgp->index = prb_num - 1;
+       cgp->has_pws = sr_gpio_getval_export(pws_info_gpios[cgp->index]);
        cg->name = g_strdup_printf("Probe_%d", prb_num);
        cg->priv = cgp;
 
@@ -258,7 +269,7 @@ SR_PRIV int bl_acme_probe_has_pws(const struct sr_channel_group *cg)
 {
        struct channel_group_priv *cgp = cg->priv;
 
-       return sr_gpio_getval_export(pws_info_gpios[cgp->index]);
+       return cgp->has_pws;
 }
 
 /*
@@ -507,7 +518,7 @@ static float read_sample(struct sr_channel *ch)
 
        len = read(fd, buf, sizeof(buf));
        if (len < 0) {
-               sr_err("Error reading from channel %s (hwmon: %s): %s",
+               sr_err("Error reading from channel %s (hwmon: %d): %s",
                        ch->name, chp->probe->hwmon_num, g_strerror(errno));
                ch->enabled = FALSE;
                return -1.0;