};
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,
* - 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;
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;
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));
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)
{
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,