*data = g_variant_new_double(devc->voltage);
break;
case SR_CONF_VOLTAGE_TARGET:
- korad_kaxxxxp_get_value(sdi->conn, KAXXXXP_VOLTAGE_MAX, devc);
- *data = g_variant_new_double(devc->voltage_max);
+ korad_kaxxxxp_get_value(sdi->conn, KAXXXXP_VOLTAGE_TARGET, devc);
+ *data = g_variant_new_double(devc->voltage_target);
break;
case SR_CONF_CURRENT:
korad_kaxxxxp_get_value(sdi->conn, KAXXXXP_CURRENT, devc);
*data = g_variant_new_double(devc->current);
break;
case SR_CONF_CURRENT_LIMIT:
- korad_kaxxxxp_get_value(sdi->conn, KAXXXXP_CURRENT_MAX, devc);
- *data = g_variant_new_double(devc->current_max);
+ korad_kaxxxxp_get_value(sdi->conn, KAXXXXP_CURRENT_LIMIT, devc);
+ *data = g_variant_new_double(devc->current_limit);
break;
case SR_CONF_ENABLED:
korad_kaxxxxp_get_value(sdi->conn, KAXXXXP_OUTPUT, devc);
dval = g_variant_get_double(data);
if (dval < devc->model->voltage[0] || dval > devc->model->voltage[1])
return SR_ERR_ARG;
- devc->voltage_max = dval;
- if (korad_kaxxxxp_set_value(sdi->conn, KAXXXXP_VOLTAGE_MAX, devc) < 0)
+ devc->set_voltage_target = dval;
+ if (korad_kaxxxxp_set_value(sdi->conn, KAXXXXP_VOLTAGE_TARGET, devc) < 0)
return SR_ERR;
break;
case SR_CONF_CURRENT_LIMIT:
dval = g_variant_get_double(data);
if (dval < devc->model->current[0] || dval > devc->model->current[1])
return SR_ERR_ARG;
- devc->current_max = dval;
- if (korad_kaxxxxp_set_value(sdi->conn, KAXXXXP_CURRENT_MAX, devc) < 0)
+ devc->set_current_limit = dval;
+ if (korad_kaxxxxp_set_value(sdi->conn, KAXXXXP_CURRENT_LIMIT, devc) < 0)
return SR_ERR;
break;
case SR_CONF_ENABLED:
bval = g_variant_get_boolean(data);
/* Set always so it is possible turn off with sigrok-cli. */
- devc->output_enabled = bval;
+ devc->set_output_enabled = bval;
if (korad_kaxxxxp_set_value(sdi->conn, KAXXXXP_OUTPUT, devc) < 0)
return SR_ERR;
break;
case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
bval = g_variant_get_boolean(data);
- devc->ocp_enabled = bval;
+ devc->set_ocp_enabled = bval;
if (korad_kaxxxxp_set_value(sdi->conn, KAXXXXP_OCP, devc) < 0)
return SR_ERR;
break;
case SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED:
bval = g_variant_get_boolean(data);
- devc->ovp_enabled = bval;
+ devc->set_ovp_enabled = bval;
if (korad_kaxxxxp_set_value(sdi->conn, KAXXXXP_OVP, devc) < 0)
return SR_ERR;
break;
sr_err("Can't set measurable parameter %d.", target);
g_mutex_unlock(&devc->rw_mutex);
return SR_ERR;
- case KAXXXXP_CURRENT_MAX:
+ case KAXXXXP_CURRENT_LIMIT:
cmd = "ISET1:%05.3f";
- value = devc->current_max;
+ value = devc->set_current_limit;
break;
- case KAXXXXP_VOLTAGE_MAX:
+ case KAXXXXP_VOLTAGE_TARGET:
cmd = "VSET1:%05.2f";
- value = devc->voltage_max;
+ value = devc->set_voltage_target;
break;
case KAXXXXP_OUTPUT:
cmd = "OUT%01.0f";
- value = (devc->output_enabled) ? 1 : 0;
+ value = (devc->set_output_enabled) ? 1 : 0;
+ /* Set value back to recognize changes */
+ devc->output_enabled = devc->set_output_enabled;
break;
case KAXXXXP_BEEP:
cmd = "BEEP%01.0f";
- value = (devc->beep_enabled) ? 1 : 0;
+ value = (devc->set_beep_enabled) ? 1 : 0;
break;
case KAXXXXP_OCP:
cmd = "OCP%01.0f";
- value = (devc->ocp_enabled) ? 1 : 0;
+ value = (devc->set_ocp_enabled) ? 1 : 0;
+ /* Set value back to recognize changes */
+ devc->ocp_enabled = devc->set_ocp_enabled;
break;
case KAXXXXP_OVP:
cmd = "OVP%01.0f";
- value = (devc->ovp_enabled) ? 1 : 0;
+ value = (devc->set_ovp_enabled) ? 1 : 0;
+ /* Set value back to recognize changes */
+ devc->ovp_enabled = devc->set_ovp_enabled;
break;
case KAXXXXP_SAVE:
cmd = "SAV%01.0f";
ret = korad_kaxxxxp_send_cmd(serial, "IOUT1?");
value = &(devc->current);
break;
- case KAXXXXP_CURRENT_MAX:
+ case KAXXXXP_CURRENT_LIMIT:
/* Read set current from device. */
ret = korad_kaxxxxp_send_cmd(serial, "ISET1?");
- value = &(devc->current_max);
+ value = &(devc->current_limit);
break;
case KAXXXXP_VOLTAGE:
/* Read voltage from device. */
ret = korad_kaxxxxp_send_cmd(serial, "VOUT1?");
value = &(devc->voltage);
break;
- case KAXXXXP_VOLTAGE_MAX:
+ case KAXXXXP_VOLTAGE_TARGET:
/* Read set voltage from device. */
ret = korad_kaxxxxp_send_cmd(serial, "VSET1?");
- value = &(devc->voltage_max);
+ value = &(devc->voltage_target);
break;
case KAXXXXP_STATUS:
case KAXXXXP_OUTPUT:
sr_spew("Status: CH1: constant %s CH2: constant %s. "
"Tracking would be %s. Device is "
"%s and %s. Buttons are %s. Output is %s "
- "and extra byte is %s.",
+ "and extra bit is %s.",
(status_byte & (1 << 0)) ? "voltage" : "current",
(status_byte & (1 << 1)) ? "voltage" : "current",
(status_byte & (1 << 2)) ? "parallel" : "series",
}
/* Read the sixth byte from ISET? BUG workaround. */
- if (target == KAXXXXP_CURRENT_MAX)
+ if (target == KAXXXXP_CURRENT_LIMIT)
serial_read_blocking(serial, &status_byte, 1, 10);
g_mutex_unlock(&devc->rw_mutex);
/* Reply targets */
enum {
KAXXXXP_CURRENT,
- KAXXXXP_CURRENT_MAX,
+ KAXXXXP_CURRENT_LIMIT,
KAXXXXP_VOLTAGE,
- KAXXXXP_VOLTAGE_MAX,
+ KAXXXXP_VOLTAGE_TARGET,
KAXXXXP_STATUS,
KAXXXXP_OUTPUT,
KAXXXXP_BEEP,
GMutex rw_mutex;
float current; /**< Last current value [A] read from device. */
- float current_max; /**< Output current set. */
+ float current_limit; /**< Output current set. */
float voltage; /**< Last voltage value [V] read from device. */
- float voltage_max; /**< Output voltage set. */
+ float voltage_target; /**< Output voltage set. */
gboolean cc_mode[2]; /**< Device is in CC mode (otherwise CV). */
gboolean output_enabled; /**< Is the output enabled? */
int acquisition_target; /**< What reply to expect. */
int program; /**< Program to store or recall. */
+
+ float set_current_limit; /**< New output current to set. */
+ float set_voltage_target; /**< New output voltage to set. */
+ gboolean set_output_enabled; /**< New output enabled to set. */
+ gboolean set_beep_enabled; /**< New enable beeper to set. */
+ gboolean set_ocp_enabled; /**< New OCP enabled to set. */
+ gboolean set_ovp_enabled; /**< New OVP enabled to set. */
};
SR_PRIV int korad_kaxxxxp_send_cmd(struct sr_serial_dev_inst *serial,