arachnid-labs-re-load-pro: Add support for setting SR_CONF_ENABLED.
The firmware has "on\n" and "off\n" commands since 1.10, so use them. Apparently you can only set the state (on/off) of the load, but it's not possible to query the current state.
This commit is contained in:
parent
6e68da5140
commit
8501448cfe
|
@ -43,7 +43,7 @@ static const uint32_t devopts[] = {
|
|||
};
|
||||
|
||||
static const uint32_t devopts_cg[] = {
|
||||
SR_CONF_ENABLED | SR_CONF_GET,
|
||||
SR_CONF_ENABLED | SR_CONF_SET,
|
||||
SR_CONF_REGULATION | SR_CONF_GET,
|
||||
SR_CONF_VOLTAGE | SR_CONF_GET,
|
||||
SR_CONF_CURRENT | SR_CONF_GET,
|
||||
|
@ -242,6 +242,7 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
* - SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD
|
||||
* - SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE
|
||||
* - SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD
|
||||
* - SR_CONF_ENABLED (state cannot be queried, only set)
|
||||
*/
|
||||
|
||||
ret = SR_OK;
|
||||
|
@ -252,9 +253,6 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
case SR_CONF_LIMIT_MSEC:
|
||||
*data = g_variant_new_uint64(devc->limit_msec);
|
||||
break;
|
||||
case SR_CONF_ENABLED:
|
||||
*data = g_variant_new_boolean(TRUE); /* Always on. */
|
||||
break;
|
||||
case SR_CONF_REGULATION:
|
||||
*data = g_variant_new_string("CC"); /* Always CC mode. */
|
||||
break;
|
||||
|
@ -312,6 +310,9 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
case SR_CONF_LIMIT_MSEC:
|
||||
devc->limit_msec = g_variant_get_uint64(data);
|
||||
break;
|
||||
case SR_CONF_ENABLED:
|
||||
ret = reloadpro_set_on_off(sdi, g_variant_get_boolean(data));
|
||||
break;
|
||||
case SR_CONF_CURRENT_LIMIT:
|
||||
ret = reloadpro_set_current_limit(sdi,
|
||||
g_variant_get_double(data));
|
||||
|
|
|
@ -89,6 +89,21 @@ SR_PRIV int reloadpro_set_current_limit(const struct sr_dev_inst *sdi,
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
SR_PRIV int reloadpro_set_on_off(const struct sr_dev_inst *sdi, gboolean on)
|
||||
{
|
||||
int ret;
|
||||
char buf[100];
|
||||
const char *cmd;
|
||||
|
||||
cmd = (on) ? "on\n" : "off\n";
|
||||
if ((ret = send_cmd(sdi, cmd, (char *)&buf, sizeof(buf))) < 0) {
|
||||
sr_err("Error sending on/off command: %d.", ret);
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
SR_PRIV int reloadpro_get_current_limit(const struct sr_dev_inst *sdi,
|
||||
float *current)
|
||||
{
|
||||
|
|
|
@ -43,6 +43,7 @@ struct dev_context {
|
|||
|
||||
SR_PRIV int reloadpro_set_current_limit(const struct sr_dev_inst *sdi,
|
||||
float current);
|
||||
SR_PRIV int reloadpro_set_on_off(const struct sr_dev_inst *sdi, gboolean on);
|
||||
SR_PRIV int reloadpro_get_current_limit(const struct sr_dev_inst *sdi,
|
||||
float *current);
|
||||
SR_PRIV int reloadpro_get_voltage_current(const struct sr_dev_inst *sdi,
|
||||
|
|
Loading…
Reference in New Issue