]> sigrok.org Git - libsigrok.git/commitdiff
arachnid-labs-re-load-pro: Handle undervoltage condition.
authorUwe Hermann <redacted>
Tue, 9 Feb 2016 00:09:39 +0000 (01:09 +0100)
committerUwe Hermann <redacted>
Thu, 11 Feb 2016 13:42:50 +0000 (14:42 +0100)
Support the SR_CONF_UNDER_VOLTAGE_CONDITION* keys.

Undervoltage (and overtemperature) conditions now emit a
warning-level message as well.

src/hardware/arachnid-labs-re-load-pro/api.c
src/hardware/arachnid-labs-re-load-pro/protocol.c
src/hardware/arachnid-labs-re-load-pro/protocol.h

index 4dc594a58b52143b9f3a33ae7644b0babfb8eb09..86d34a47fa7f9ea2bfa539d89b33d23b5e4cc08c 100644 (file)
@@ -52,6 +52,8 @@ static const uint32_t devopts_cg[] = {
        SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET,
        SR_CONF_OVER_TEMPERATURE_PROTECTION | SR_CONF_GET,
        SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE | SR_CONF_GET,
+       SR_CONF_UNDER_VOLTAGE_CONDITION | SR_CONF_GET,
+       SR_CONF_UNDER_VOLTAGE_CONDITION_ACTIVE | SR_CONF_GET,
 };
 
 SR_PRIV struct sr_dev_driver arachnid_labs_re_load_pro_driver_info;
@@ -290,6 +292,12 @@ static int config_get(uint32_t key, GVariant **data,
        case SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE:
                *data = g_variant_new_boolean(devc->otp_active);
                break;
+       case SR_CONF_UNDER_VOLTAGE_CONDITION:
+               *data = g_variant_new_boolean(TRUE); /* Always on. */
+               break;
+       case SR_CONF_UNDER_VOLTAGE_CONDITION_ACTIVE:
+               *data = g_variant_new_boolean(devc->uvc_active);
+               break;
        default:
                return SR_ERR_NA;
        }
index 1f2e0dd4ecd212493ff1a2213efec26a8a75d4a5..7ba13540cb5530087a5c17ad817e952f1c23f552 100644 (file)
@@ -159,11 +159,17 @@ static void handle_packet(const struct sr_dev_inst *sdi)
        devc = sdi->priv;
 
        if (g_str_has_prefix((const char *)devc->buf, "overtemp")) {
-               sr_dbg("Overtemperature condition!");
+               sr_warn("Overtemperature condition!");
                devc->otp_active = TRUE;
                return;
        }
 
+       if (g_str_has_prefix((const char *)devc->buf, "undervolt")) {
+               sr_warn("Undervoltage condition!");
+               devc->uvc_active = TRUE;
+               return;
+       }
+
        if (!g_str_has_prefix((const char *)devc->buf, "read ")) {
                sr_dbg("Unknown packet: '%s'.", devc->buf);
                return;
index 94b62691c9e179f3a4cf4b259585db360d7b671d..35a7a5be267012cedde72ee58a6e1331898ac964 100644 (file)
@@ -39,6 +39,7 @@ struct dev_context {
        uint8_t buf[RELOADPRO_BUFSIZE];
        int buflen;
        gboolean otp_active;
+       gboolean uvc_active;
 };
 
 SR_PRIV int reloadpro_set_current_limit(const struct sr_dev_inst *sdi,