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.
This commit is contained in:
Uwe Hermann 2016-02-09 01:09:39 +01:00
parent 2fe1011f1d
commit 2217be1dd4
3 changed files with 16 additions and 1 deletions

View File

@ -52,6 +52,8 @@ static const uint32_t devopts_cg[] = {
SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET, SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET,
SR_CONF_OVER_TEMPERATURE_PROTECTION | SR_CONF_GET, SR_CONF_OVER_TEMPERATURE_PROTECTION | SR_CONF_GET,
SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE | 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; 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: case SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE:
*data = g_variant_new_boolean(devc->otp_active); *data = g_variant_new_boolean(devc->otp_active);
break; 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: default:
return SR_ERR_NA; return SR_ERR_NA;
} }

View File

@ -159,11 +159,17 @@ static void handle_packet(const struct sr_dev_inst *sdi)
devc = sdi->priv; devc = sdi->priv;
if (g_str_has_prefix((const char *)devc->buf, "overtemp")) { if (g_str_has_prefix((const char *)devc->buf, "overtemp")) {
sr_dbg("Overtemperature condition!"); sr_warn("Overtemperature condition!");
devc->otp_active = TRUE; devc->otp_active = TRUE;
return; 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 ")) { if (!g_str_has_prefix((const char *)devc->buf, "read ")) {
sr_dbg("Unknown packet: '%s'.", devc->buf); sr_dbg("Unknown packet: '%s'.", devc->buf);
return; return;

View File

@ -39,6 +39,7 @@ struct dev_context {
uint8_t buf[RELOADPRO_BUFSIZE]; uint8_t buf[RELOADPRO_BUFSIZE];
int buflen; int buflen;
gboolean otp_active; gboolean otp_active;
gboolean uvc_active;
}; };
SR_PRIV int reloadpro_set_current_limit(const struct sr_dev_inst *sdi, SR_PRIV int reloadpro_set_current_limit(const struct sr_dev_inst *sdi,