korad-kdxxxxp: Rename driver to korad-kaxxxxp.
This matches the supported / supportable devices better.
This commit is contained in:
parent
89b3a0d8d1
commit
16fc7ee29f
|
@ -323,11 +323,11 @@ libsigrok_la_SOURCES += \
|
|||
src/hardware/kern-scale/protocol.c \
|
||||
src/hardware/kern-scale/api.c
|
||||
endif
|
||||
if HW_KORAD_KDXXXXP
|
||||
if HW_KORAD_KAXXXXP
|
||||
libsigrok_la_SOURCES += \
|
||||
src/hardware/korad-kdxxxxp/protocol.h \
|
||||
src/hardware/korad-kdxxxxp/protocol.c \
|
||||
src/hardware/korad-kdxxxxp/api.c
|
||||
src/hardware/korad-kaxxxxp/protocol.h \
|
||||
src/hardware/korad-kaxxxxp/protocol.c \
|
||||
src/hardware/korad-kaxxxxp/api.c
|
||||
endif
|
||||
if HW_LASCAR_EL_USB
|
||||
libsigrok_la_SOURCES += \
|
||||
|
|
|
@ -239,7 +239,7 @@ SR_DRIVER([Ikalogic Scanalogic-2], [ikalogic-scanalogic2], [libusb])
|
|||
SR_DRIVER([Ikalogic Scanaplus], [ikalogic-scanaplus], [libftdi])
|
||||
SR_DRIVER([Kecheng KC-330B], [kecheng-kc-330b], [libusb])
|
||||
SR_DRIVER([KERN scale], [kern-scale], [libserialport])
|
||||
SR_DRIVER([Korad KDxxxxP], [korad-kdxxxxp], [libserialport])
|
||||
SR_DRIVER([Korad KAxxxxP], [korad-kaxxxxp], [libserialport])
|
||||
SR_DRIVER([Lascar EL-USB], [lascar-el-usb], [libusb])
|
||||
SR_DRIVER([Manson HCS-3xxx], [manson-hcs-3xxx], [libserialport])
|
||||
SR_DRIVER([maynuo-m97], [maynuo-m97])
|
||||
|
|
|
@ -102,8 +102,8 @@ extern SR_PRIV struct sr_dev_driver kecheng_kc_330b_driver_info;
|
|||
#ifdef HAVE_HW_KERN_SCALE
|
||||
extern SR_PRIV struct sr_dev_driver *kern_scale_drivers[];
|
||||
#endif
|
||||
#ifdef HAVE_HW_KORAD_KDXXXXP
|
||||
extern SR_PRIV struct sr_dev_driver korad_kdxxxxp_driver_info;
|
||||
#ifdef HAVE_HW_KORAD_KAXXXXP
|
||||
extern SR_PRIV struct sr_dev_driver korad_kaxxxxp_driver_info;
|
||||
#endif
|
||||
#ifdef HAVE_HW_LASCAR_EL_USB
|
||||
extern SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info;
|
||||
|
@ -263,8 +263,8 @@ SR_PRIV struct sr_dev_driver **drivers_lists[] = {
|
|||
#ifdef HAVE_HW_KERN_SCALE
|
||||
kern_scale_drivers,
|
||||
#endif
|
||||
#ifdef HAVE_HW_KORAD_KDXXXXP
|
||||
(DRVS) {&korad_kdxxxxp_driver_info, NULL},
|
||||
#ifdef HAVE_HW_KORAD_KAXXXXP
|
||||
(DRVS) {&korad_kaxxxxp_driver_info, NULL},
|
||||
#endif
|
||||
#ifdef HAVE_HW_LASCAR_EL_USB
|
||||
(DRVS) {&lascar_el_usb_driver_info, NULL},
|
||||
|
|
|
@ -48,14 +48,14 @@ static const uint32_t devopts[] = {
|
|||
SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
|
||||
};
|
||||
|
||||
static const struct korad_kdxxxxp_model models[] = {
|
||||
static const struct korad_kaxxxxp_model models[] = {
|
||||
/* Device enum, vendor, model, ID reply, channels, voltage, current */
|
||||
{VELLEMAN_LABPS_3005D, "Velleman", "LABPS3005D",
|
||||
"VELLEMANLABPS3005DV2.0", 1, {0, 31, 0.01}, {0, 5, 0.001}},
|
||||
{0, NULL, NULL, NULL, 0, {0, 0, 0}, {0, 0, 0}}
|
||||
};
|
||||
|
||||
SR_PRIV struct sr_dev_driver korad_kdxxxxp_driver_info;
|
||||
SR_PRIV struct sr_dev_driver korad_kaxxxxp_driver_info;
|
||||
|
||||
static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
|
||||
{
|
||||
|
@ -115,11 +115,11 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
}
|
||||
memset(&reply, 0, sizeof(reply));
|
||||
sr_dbg("Want max %d bytes.", len);
|
||||
if ((korad_kdxxxxp_send_cmd(serial, "*IDN?") < 0))
|
||||
if ((korad_kaxxxxp_send_cmd(serial, "*IDN?") < 0))
|
||||
return NULL;
|
||||
|
||||
/* i is used here for debug purposes only. */
|
||||
if ((i = korad_kdxxxxp_read_chars(serial, len, reply)) < 0)
|
||||
if ((i = korad_kaxxxxp_read_chars(serial, len, reply)) < 0)
|
||||
return NULL;
|
||||
sr_dbg("Received: %d, %s", i, reply);
|
||||
model_id = -1;
|
||||
|
@ -151,7 +151,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
sdi->priv = devc;
|
||||
|
||||
/* Get current status of device. */
|
||||
if (korad_kdxxxxp_get_all_values(serial, devc) < 0)
|
||||
if (korad_kaxxxxp_get_all_values(serial, devc) < 0)
|
||||
goto exit_err;
|
||||
drvc->instances = g_slist_append(drvc->instances, sdi);
|
||||
devices = g_slist_append(devices, sdi);
|
||||
|
@ -267,8 +267,8 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
if (dval < devc->model->voltage[0] || dval > devc->model->voltage[1])
|
||||
return SR_ERR_ARG;
|
||||
devc->voltage_max = dval;
|
||||
devc->target = KDXXXXP_VOLTAGE_MAX;
|
||||
if (korad_kdxxxxp_set_value(sdi->conn, devc) < 0)
|
||||
devc->target = KAXXXXP_VOLTAGE_MAX;
|
||||
if (korad_kaxxxxp_set_value(sdi->conn, devc) < 0)
|
||||
return SR_ERR;
|
||||
break;
|
||||
case SR_CONF_CURRENT_LIMIT:
|
||||
|
@ -276,30 +276,30 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
if (dval < devc->model->current[0] || dval > devc->model->current[1])
|
||||
return SR_ERR_ARG;
|
||||
devc->current_max = dval;
|
||||
devc->target = KDXXXXP_CURRENT_MAX;
|
||||
if (korad_kdxxxxp_set_value(sdi->conn, devc) < 0)
|
||||
devc->target = KAXXXXP_CURRENT_MAX;
|
||||
if (korad_kaxxxxp_set_value(sdi->conn, 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->target = KDXXXXP_OUTPUT;
|
||||
if (korad_kdxxxxp_set_value(sdi->conn, devc) < 0)
|
||||
devc->target = KAXXXXP_OUTPUT;
|
||||
if (korad_kaxxxxp_set_value(sdi->conn, devc) < 0)
|
||||
return SR_ERR;
|
||||
break;
|
||||
case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
|
||||
bval = g_variant_get_boolean(data);
|
||||
devc->ocp_enabled = bval;
|
||||
devc->target = KDXXXXP_OCP;
|
||||
if (korad_kdxxxxp_set_value(sdi->conn, devc) < 0)
|
||||
devc->target = KAXXXXP_OCP;
|
||||
if (korad_kaxxxxp_set_value(sdi->conn, devc) < 0)
|
||||
return SR_ERR;
|
||||
break;
|
||||
case SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED:
|
||||
bval = g_variant_get_boolean(data);
|
||||
devc->ovp_enabled = bval;
|
||||
devc->target = KDXXXXP_OVP;
|
||||
if (korad_kdxxxxp_set_value(sdi->conn, devc) < 0)
|
||||
devc->target = KAXXXXP_OVP;
|
||||
if (korad_kaxxxxp_set_value(sdi->conn, devc) < 0)
|
||||
return SR_ERR;
|
||||
break;
|
||||
default:
|
||||
|
@ -393,8 +393,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
devc->req_sent_at = 0;
|
||||
serial = sdi->conn;
|
||||
serial_source_add(sdi->session, serial, G_IO_IN,
|
||||
KDXXXXP_POLL_INTERVAL_MS,
|
||||
korad_kdxxxxp_receive_data, (void *)sdi);
|
||||
KAXXXXP_POLL_INTERVAL_MS,
|
||||
korad_kaxxxxp_receive_data, (void *)sdi);
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
@ -408,9 +408,9 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
|||
std_serial_dev_close, sdi->conn, LOG_PREFIX);
|
||||
}
|
||||
|
||||
SR_PRIV struct sr_dev_driver korad_kdxxxxp_driver_info = {
|
||||
.name = "korad-kdxxxxp",
|
||||
.longname = "Korad KDxxxxP",
|
||||
SR_PRIV struct sr_dev_driver korad_kaxxxxp_driver_info = {
|
||||
.name = "korad-kaxxxxp",
|
||||
.longname = "Korad KAxxxxP",
|
||||
.api_version = 1,
|
||||
.init = init,
|
||||
.cleanup = cleanup,
|
|
@ -23,7 +23,7 @@
|
|||
#define REQ_TIMEOUT_MS 500
|
||||
#define DEVICE_PROCESSING_TIME_MS 80
|
||||
|
||||
SR_PRIV int korad_kdxxxxp_send_cmd(struct sr_serial_dev_inst *serial,
|
||||
SR_PRIV int korad_kaxxxxp_send_cmd(struct sr_serial_dev_inst *serial,
|
||||
const char *cmd)
|
||||
{
|
||||
int ret;
|
||||
|
@ -37,7 +37,7 @@ SR_PRIV int korad_kdxxxxp_send_cmd(struct sr_serial_dev_inst *serial,
|
|||
return ret;
|
||||
}
|
||||
|
||||
SR_PRIV int korad_kdxxxxp_read_chars(struct sr_serial_dev_inst *serial,
|
||||
SR_PRIV int korad_kaxxxxp_read_chars(struct sr_serial_dev_inst *serial,
|
||||
int count, char *buf)
|
||||
{
|
||||
int ret, received, turns;
|
||||
|
@ -77,7 +77,7 @@ static void give_device_time_to_process(struct dev_context *devc)
|
|||
}
|
||||
}
|
||||
|
||||
SR_PRIV int korad_kdxxxxp_set_value(struct sr_serial_dev_inst *serial,
|
||||
SR_PRIV int korad_kaxxxxp_set_value(struct sr_serial_dev_inst *serial,
|
||||
struct dev_context *devc)
|
||||
{
|
||||
char msg[21];
|
||||
|
@ -89,36 +89,36 @@ SR_PRIV int korad_kdxxxxp_set_value(struct sr_serial_dev_inst *serial,
|
|||
|
||||
msg[20] = 0;
|
||||
switch(devc->target){
|
||||
case KDXXXXP_CURRENT:
|
||||
case KDXXXXP_VOLTAGE:
|
||||
case KDXXXXP_STATUS:
|
||||
case KAXXXXP_CURRENT:
|
||||
case KAXXXXP_VOLTAGE:
|
||||
case KAXXXXP_STATUS:
|
||||
sr_err("Can't set measurable parameter.");
|
||||
return SR_ERR;
|
||||
case KDXXXXP_CURRENT_MAX:
|
||||
case KAXXXXP_CURRENT_MAX:
|
||||
cmd = "ISET1:%05.3f";
|
||||
value = devc->current_max;
|
||||
break;
|
||||
case KDXXXXP_VOLTAGE_MAX:
|
||||
case KAXXXXP_VOLTAGE_MAX:
|
||||
cmd = "VSET1:%05.2f";
|
||||
value = devc->voltage_max;
|
||||
break;
|
||||
case KDXXXXP_OUTPUT:
|
||||
case KAXXXXP_OUTPUT:
|
||||
cmd = "OUT%01.0f";
|
||||
value = (devc->output_enabled) ? 1 : 0;
|
||||
break;
|
||||
case KDXXXXP_BEEP:
|
||||
case KAXXXXP_BEEP:
|
||||
cmd = "BEEP%01.0f";
|
||||
value = (devc->beep_enabled) ? 1 : 0;
|
||||
break;
|
||||
case KDXXXXP_OCP:
|
||||
case KAXXXXP_OCP:
|
||||
cmd = "OCP%01.0f";
|
||||
value = (devc->ocp_enabled) ? 1 : 0;
|
||||
break;
|
||||
case KDXXXXP_OVP:
|
||||
case KAXXXXP_OVP:
|
||||
cmd = "OVP%01.0f";
|
||||
value = (devc->ovp_enabled) ? 1 : 0;
|
||||
break;
|
||||
case KDXXXXP_SAVE:
|
||||
case KAXXXXP_SAVE:
|
||||
cmd = "SAV%01.0f";
|
||||
if (devc->program < 1 || devc->program > 5) {
|
||||
sr_err("Only programs 1-5 supported and %d isn't "
|
||||
|
@ -127,7 +127,7 @@ SR_PRIV int korad_kdxxxxp_set_value(struct sr_serial_dev_inst *serial,
|
|||
}
|
||||
value = devc->program;
|
||||
break;
|
||||
case KDXXXXP_RECALL:
|
||||
case KAXXXXP_RECALL:
|
||||
cmd = "RCL%01.0f";
|
||||
if (devc->program < 1 || devc->program > 5) {
|
||||
sr_err("Only programs 1-5 supported and %d isn't "
|
||||
|
@ -144,14 +144,14 @@ SR_PRIV int korad_kdxxxxp_set_value(struct sr_serial_dev_inst *serial,
|
|||
if (cmd)
|
||||
snprintf(msg, 20, cmd, value);
|
||||
|
||||
ret = korad_kdxxxxp_send_cmd(serial, msg);
|
||||
ret = korad_kaxxxxp_send_cmd(serial, msg);
|
||||
devc->req_sent_at = g_get_monotonic_time();
|
||||
devc->reply_pending = FALSE;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SR_PRIV int korad_kdxxxxp_query_value(struct sr_serial_dev_inst *serial,
|
||||
SR_PRIV int korad_kaxxxxp_query_value(struct sr_serial_dev_inst *serial,
|
||||
struct dev_context *devc)
|
||||
{
|
||||
int ret;
|
||||
|
@ -159,26 +159,26 @@ SR_PRIV int korad_kdxxxxp_query_value(struct sr_serial_dev_inst *serial,
|
|||
give_device_time_to_process(devc);
|
||||
|
||||
switch(devc->target){
|
||||
case KDXXXXP_CURRENT:
|
||||
case KAXXXXP_CURRENT:
|
||||
/* Read current from device. */
|
||||
ret = korad_kdxxxxp_send_cmd(serial, "IOUT1?");
|
||||
ret = korad_kaxxxxp_send_cmd(serial, "IOUT1?");
|
||||
break;
|
||||
case KDXXXXP_CURRENT_MAX:
|
||||
case KAXXXXP_CURRENT_MAX:
|
||||
/* Read set current from device. */
|
||||
ret = korad_kdxxxxp_send_cmd(serial, "ISET1?");
|
||||
ret = korad_kaxxxxp_send_cmd(serial, "ISET1?");
|
||||
break;
|
||||
case KDXXXXP_VOLTAGE:
|
||||
case KAXXXXP_VOLTAGE:
|
||||
/* Read voltage from device. */
|
||||
ret = korad_kdxxxxp_send_cmd(serial, "VOUT1?");
|
||||
ret = korad_kaxxxxp_send_cmd(serial, "VOUT1?");
|
||||
break;
|
||||
case KDXXXXP_VOLTAGE_MAX:
|
||||
case KAXXXXP_VOLTAGE_MAX:
|
||||
/* Read set voltage from device. */
|
||||
ret = korad_kdxxxxp_send_cmd(serial, "VSET1?");
|
||||
ret = korad_kaxxxxp_send_cmd(serial, "VSET1?");
|
||||
break;
|
||||
case KDXXXXP_STATUS:
|
||||
case KDXXXXP_OUTPUT:
|
||||
case KAXXXXP_STATUS:
|
||||
case KAXXXXP_OUTPUT:
|
||||
/* Read status from device. */
|
||||
ret = korad_kdxxxxp_send_cmd(serial, "STATUS?");
|
||||
ret = korad_kaxxxxp_send_cmd(serial, "STATUS?");
|
||||
break;
|
||||
default:
|
||||
sr_err("Don't know how to query %d.", devc->target);
|
||||
|
@ -191,23 +191,23 @@ SR_PRIV int korad_kdxxxxp_query_value(struct sr_serial_dev_inst *serial,
|
|||
return ret;
|
||||
}
|
||||
|
||||
SR_PRIV int korad_kdxxxxp_get_all_values(struct sr_serial_dev_inst *serial,
|
||||
SR_PRIV int korad_kaxxxxp_get_all_values(struct sr_serial_dev_inst *serial,
|
||||
struct dev_context *devc)
|
||||
{
|
||||
int ret;
|
||||
|
||||
for (devc->target = KDXXXXP_CURRENT;
|
||||
devc->target <= KDXXXXP_STATUS; devc->target++) {
|
||||
if ((ret = korad_kdxxxxp_query_value(serial, devc)) < 0)
|
||||
for (devc->target = KAXXXXP_CURRENT;
|
||||
devc->target <= KAXXXXP_STATUS; devc->target++) {
|
||||
if ((ret = korad_kaxxxxp_query_value(serial, devc)) < 0)
|
||||
return ret;
|
||||
if ((ret = korad_kdxxxxp_get_reply(serial, devc)) < 0)
|
||||
if ((ret = korad_kaxxxxp_get_reply(serial, devc)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SR_PRIV int korad_kdxxxxp_get_reply(struct sr_serial_dev_inst *serial,
|
||||
SR_PRIV int korad_kaxxxxp_get_reply(struct sr_serial_dev_inst *serial,
|
||||
struct dev_context *devc)
|
||||
{
|
||||
double value;
|
||||
|
@ -219,24 +219,24 @@ SR_PRIV int korad_kdxxxxp_get_reply(struct sr_serial_dev_inst *serial,
|
|||
count = 5;
|
||||
|
||||
switch (devc->target) {
|
||||
case KDXXXXP_CURRENT:
|
||||
case KAXXXXP_CURRENT:
|
||||
/* Read current from device. */
|
||||
target = &(devc->current);
|
||||
break;
|
||||
case KDXXXXP_CURRENT_MAX:
|
||||
case KAXXXXP_CURRENT_MAX:
|
||||
/* Read set current from device. */
|
||||
target = &(devc->current_max);
|
||||
break;
|
||||
case KDXXXXP_VOLTAGE:
|
||||
case KAXXXXP_VOLTAGE:
|
||||
/* Read voltage from device. */
|
||||
target = &(devc->voltage);
|
||||
break;
|
||||
case KDXXXXP_VOLTAGE_MAX:
|
||||
case KAXXXXP_VOLTAGE_MAX:
|
||||
/* Read set voltage from device. */
|
||||
target = &(devc->voltage_max);
|
||||
break;
|
||||
case KDXXXXP_STATUS:
|
||||
case KDXXXXP_OUTPUT:
|
||||
case KAXXXXP_STATUS:
|
||||
case KAXXXXP_OUTPUT:
|
||||
/* Read status from device. */
|
||||
count = 1;
|
||||
break;
|
||||
|
@ -244,7 +244,7 @@ SR_PRIV int korad_kdxxxxp_get_reply(struct sr_serial_dev_inst *serial,
|
|||
sr_err("Don't know where to put repply %d.", devc->target);
|
||||
}
|
||||
|
||||
if ((ret = korad_kdxxxxp_read_chars(serial, count, devc->reply)) < 0)
|
||||
if ((ret = korad_kaxxxxp_read_chars(serial, count, devc->reply)) < 0)
|
||||
return ret;
|
||||
|
||||
devc->reply[count] = 0;
|
||||
|
@ -255,7 +255,7 @@ SR_PRIV int korad_kdxxxxp_get_reply(struct sr_serial_dev_inst *serial,
|
|||
for (i = 1; i < count; i++)
|
||||
devc->reply[i - 1] = devc->reply[i];
|
||||
/* Get the last character. */
|
||||
if ((i = korad_kdxxxxp_read_chars(serial, 1,
|
||||
if ((i = korad_kaxxxxp_read_chars(serial, 1,
|
||||
&(devc->reply[count]))) < 0)
|
||||
return i;
|
||||
}
|
||||
|
@ -302,34 +302,34 @@ SR_PRIV int korad_kdxxxxp_get_reply(struct sr_serial_dev_inst *serial,
|
|||
static void next_measurement(struct dev_context *devc)
|
||||
{
|
||||
switch (devc->target) {
|
||||
case KDXXXXP_CURRENT:
|
||||
devc->target = KDXXXXP_VOLTAGE;
|
||||
case KAXXXXP_CURRENT:
|
||||
devc->target = KAXXXXP_VOLTAGE;
|
||||
break;
|
||||
case KDXXXXP_CURRENT_MAX:
|
||||
devc->target = KDXXXXP_CURRENT;
|
||||
case KAXXXXP_CURRENT_MAX:
|
||||
devc->target = KAXXXXP_CURRENT;
|
||||
break;
|
||||
case KDXXXXP_VOLTAGE:
|
||||
devc->target = KDXXXXP_STATUS;
|
||||
case KAXXXXP_VOLTAGE:
|
||||
devc->target = KAXXXXP_STATUS;
|
||||
break;
|
||||
case KDXXXXP_VOLTAGE_MAX:
|
||||
devc->target = KDXXXXP_CURRENT;
|
||||
case KAXXXXP_VOLTAGE_MAX:
|
||||
devc->target = KAXXXXP_CURRENT;
|
||||
break;
|
||||
/* Read back what was set. */
|
||||
case KDXXXXP_BEEP:
|
||||
case KDXXXXP_OCP:
|
||||
case KDXXXXP_OVP:
|
||||
case KDXXXXP_OUTPUT:
|
||||
devc->target = KDXXXXP_STATUS;
|
||||
case KAXXXXP_BEEP:
|
||||
case KAXXXXP_OCP:
|
||||
case KAXXXXP_OVP:
|
||||
case KAXXXXP_OUTPUT:
|
||||
devc->target = KAXXXXP_STATUS;
|
||||
break;
|
||||
case KDXXXXP_STATUS:
|
||||
devc->target = KDXXXXP_CURRENT;
|
||||
case KAXXXXP_STATUS:
|
||||
devc->target = KAXXXXP_CURRENT;
|
||||
break;
|
||||
default:
|
||||
devc->target = KDXXXXP_CURRENT;
|
||||
devc->target = KAXXXXP_CURRENT;
|
||||
}
|
||||
}
|
||||
|
||||
SR_PRIV int korad_kdxxxxp_receive_data(int fd, int revents, void *cb_data)
|
||||
SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct dev_context *devc;
|
||||
|
@ -350,21 +350,21 @@ SR_PRIV int korad_kdxxxxp_receive_data(int fd, int revents, void *cb_data)
|
|||
|
||||
if (revents == G_IO_IN) {
|
||||
/* Get the value. */
|
||||
korad_kdxxxxp_get_reply(serial, devc);
|
||||
korad_kaxxxxp_get_reply(serial, devc);
|
||||
|
||||
/* Send the value forward. */
|
||||
packet.type = SR_DF_ANALOG_OLD;
|
||||
packet.payload = &analog;
|
||||
analog.channels = sdi->channels;
|
||||
analog.num_samples = 1;
|
||||
if (devc->target == KDXXXXP_CURRENT) {
|
||||
if (devc->target == KAXXXXP_CURRENT) {
|
||||
analog.mq = SR_MQ_CURRENT;
|
||||
analog.unit = SR_UNIT_AMPERE;
|
||||
analog.mqflags = 0;
|
||||
analog.data = &devc->current;
|
||||
sr_session_send(sdi, &packet);
|
||||
}
|
||||
if (devc->target == KDXXXXP_VOLTAGE) {
|
||||
if (devc->target == KAXXXXP_VOLTAGE) {
|
||||
analog.mq = SR_MQ_VOLTAGE;
|
||||
analog.unit = SR_UNIT_VOLT;
|
||||
analog.mqflags = SR_MQFLAG_DC;
|
||||
|
@ -376,7 +376,7 @@ SR_PRIV int korad_kdxxxxp_receive_data(int fd, int revents, void *cb_data)
|
|||
} else {
|
||||
/* Time out */
|
||||
if (!devc->reply_pending) {
|
||||
if (korad_kdxxxxp_query_value(serial, devc) < 0)
|
||||
if (korad_kaxxxxp_query_value(serial, devc) < 0)
|
||||
return TRUE;
|
||||
devc->req_sent_at = g_get_monotonic_time();
|
||||
devc->reply_pending = TRUE;
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Korad KDxxxxP power supply driver
|
||||
* Korad KAxxxxP power supply driver
|
||||
* @internal
|
||||
*/
|
||||
|
||||
#ifndef LIBSIGROK_HARDWARE_KORAD_KDXXXXP_PROTOCOL_H
|
||||
#define LIBSIGROK_HARDWARE_KORAD_KDXXXXP_PROTOCOL_H
|
||||
#ifndef LIBSIGROK_HARDWARE_KORAD_KAXXXXP_PROTOCOL_H
|
||||
#define LIBSIGROK_HARDWARE_KORAD_KAXXXXP_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
@ -32,9 +32,9 @@
|
|||
#include <libsigrok/libsigrok.h>
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
#define LOG_PREFIX "korad-kdxxxxp"
|
||||
#define LOG_PREFIX "korad-kaxxxxp"
|
||||
|
||||
#define KDXXXXP_POLL_INTERVAL_MS 80
|
||||
#define KAXXXXP_POLL_INTERVAL_MS 80
|
||||
|
||||
enum {
|
||||
VELLEMAN_LABPS_3005D,
|
||||
|
@ -42,7 +42,7 @@ enum {
|
|||
};
|
||||
|
||||
/* Information on single model */
|
||||
struct korad_kdxxxxp_model {
|
||||
struct korad_kaxxxxp_model {
|
||||
int model_id; /**< Model info */
|
||||
const char *vendor; /**< Vendor name */
|
||||
const char *name; /**< Model name */
|
||||
|
@ -54,23 +54,23 @@ struct korad_kdxxxxp_model {
|
|||
|
||||
/* Reply targets */
|
||||
enum {
|
||||
KDXXXXP_CURRENT,
|
||||
KDXXXXP_CURRENT_MAX,
|
||||
KDXXXXP_VOLTAGE,
|
||||
KDXXXXP_VOLTAGE_MAX,
|
||||
KDXXXXP_STATUS,
|
||||
KDXXXXP_OUTPUT,
|
||||
KDXXXXP_BEEP,
|
||||
KDXXXXP_OCP,
|
||||
KDXXXXP_OVP,
|
||||
KDXXXXP_SAVE,
|
||||
KDXXXXP_RECALL,
|
||||
KAXXXXP_CURRENT,
|
||||
KAXXXXP_CURRENT_MAX,
|
||||
KAXXXXP_VOLTAGE,
|
||||
KAXXXXP_VOLTAGE_MAX,
|
||||
KAXXXXP_STATUS,
|
||||
KAXXXXP_OUTPUT,
|
||||
KAXXXXP_BEEP,
|
||||
KAXXXXP_OCP,
|
||||
KAXXXXP_OVP,
|
||||
KAXXXXP_SAVE,
|
||||
KAXXXXP_RECALL,
|
||||
};
|
||||
|
||||
/** Private, per-device-instance driver context. */
|
||||
struct dev_context {
|
||||
/* Model-specific information */
|
||||
const struct korad_kdxxxxp_model *model; /**< Model information. */
|
||||
const struct korad_kaxxxxp_model *model; /**< Model information. */
|
||||
|
||||
/* Acquisition settings */
|
||||
uint64_t limit_samples;
|
||||
|
@ -100,18 +100,18 @@ struct dev_context {
|
|||
char reply[6];
|
||||
};
|
||||
|
||||
SR_PRIV int korad_kdxxxxp_send_cmd(struct sr_serial_dev_inst *serial,
|
||||
SR_PRIV int korad_kaxxxxp_send_cmd(struct sr_serial_dev_inst *serial,
|
||||
const char *cmd);
|
||||
SR_PRIV int korad_kdxxxxp_read_chars(struct sr_serial_dev_inst *serial,
|
||||
SR_PRIV int korad_kaxxxxp_read_chars(struct sr_serial_dev_inst *serial,
|
||||
int count, char *buf);
|
||||
SR_PRIV int korad_kdxxxxp_set_value(struct sr_serial_dev_inst *serial,
|
||||
SR_PRIV int korad_kaxxxxp_set_value(struct sr_serial_dev_inst *serial,
|
||||
struct dev_context *devc);
|
||||
SR_PRIV int korad_kdxxxxp_query_value(struct sr_serial_dev_inst *serial,
|
||||
SR_PRIV int korad_kaxxxxp_query_value(struct sr_serial_dev_inst *serial,
|
||||
struct dev_context *devc);
|
||||
SR_PRIV int korad_kdxxxxp_get_reply(struct sr_serial_dev_inst *serial,
|
||||
SR_PRIV int korad_kaxxxxp_get_reply(struct sr_serial_dev_inst *serial,
|
||||
struct dev_context *devc);
|
||||
SR_PRIV int korad_kdxxxxp_get_all_values(struct sr_serial_dev_inst *serial,
|
||||
SR_PRIV int korad_kaxxxxp_get_all_values(struct sr_serial_dev_inst *serial,
|
||||
struct dev_context *devc);
|
||||
SR_PRIV int korad_kdxxxxp_receive_data(int fd, int revents, void *cb_data);
|
||||
SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue