From: Uwe Hermann Date: Tue, 9 Feb 2016 00:09:39 +0000 (+0100) Subject: arachnid-labs-re-load-pro: Handle undervoltage condition. X-Git-Tag: libsigrok-0.5.0~560 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2217be1dd452ec00ac3c59e2db60f6b088593761;p=libsigrok.git arachnid-labs-re-load-pro: Handle undervoltage condition. Support the SR_CONF_UNDER_VOLTAGE_CONDITION* keys. Undervoltage (and overtemperature) conditions now emit a warning-level message as well. --- diff --git a/src/hardware/arachnid-labs-re-load-pro/api.c b/src/hardware/arachnid-labs-re-load-pro/api.c index 4dc594a5..86d34a47 100644 --- a/src/hardware/arachnid-labs-re-load-pro/api.c +++ b/src/hardware/arachnid-labs-re-load-pro/api.c @@ -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; } diff --git a/src/hardware/arachnid-labs-re-load-pro/protocol.c b/src/hardware/arachnid-labs-re-load-pro/protocol.c index 1f2e0dd4..7ba13540 100644 --- a/src/hardware/arachnid-labs-re-load-pro/protocol.c +++ b/src/hardware/arachnid-labs-re-load-pro/protocol.c @@ -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; diff --git a/src/hardware/arachnid-labs-re-load-pro/protocol.h b/src/hardware/arachnid-labs-re-load-pro/protocol.h index 94b62691..35a7a5be 100644 --- a/src/hardware/arachnid-labs-re-load-pro/protocol.h +++ b/src/hardware/arachnid-labs-re-load-pro/protocol.h @@ -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,