2 * This file is part of the libsigrok project.
4 * Copyright (C) 2015 Hannu Vuolasaho <vuokkosetae@gmail.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef LIBSIGROK_HARDWARE_KORAD_KAXXXXP_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_KORAD_KAXXXXP_PROTOCOL_H
26 #include <libsigrok/libsigrok.h>
27 #include "libsigrok-internal.h"
29 #define LOG_PREFIX "korad-kaxxxxp"
31 #define KAXXXXP_POLL_INTERVAL_MS 80
39 /* Support for future devices with this protocol. */
42 /* Information on single model */
43 struct korad_kaxxxxp_model {
44 int model_id; /**< Model info */
45 const char *vendor; /**< Vendor name */
46 const char *name; /**< Model name */
47 const char *id; /**< Model ID, as delivered by interface */
48 int channels; /**< Number of channels */
49 double voltage[3]; /**< Min, max, step */
50 double current[3]; /**< Min, max, step */
69 const struct korad_kaxxxxp_model *model; /**< Model information. */
71 struct sr_sw_limits limits;
73 gboolean reply_pending;
75 float current; /**< Last current value [A] read from device. */
76 float current_max; /**< Output current set. */
77 float voltage; /**< Last voltage value [V] read from device. */
78 float voltage_max; /**< Output voltage set. */
79 gboolean cc_mode[2]; /**< Device is in CC mode (otherwise CV). */
81 gboolean output_enabled; /**< Is the output enabled? */
82 gboolean beep_enabled; /**< Enable beeper. */
83 gboolean ocp_enabled; /**< Output current protection enabled. */
84 gboolean ovp_enabled; /**< Output voltage protection enabled. */
86 int target; /**< What reply to expect. */
87 int program; /**< Program to store or recall. */
91 SR_PRIV int korad_kaxxxxp_send_cmd(struct sr_serial_dev_inst *serial,
93 SR_PRIV int korad_kaxxxxp_read_chars(struct sr_serial_dev_inst *serial,
94 int count, char *buf);
95 SR_PRIV int korad_kaxxxxp_set_value(struct sr_serial_dev_inst *serial,
96 struct dev_context *devc);
97 SR_PRIV int korad_kaxxxxp_query_value(struct sr_serial_dev_inst *serial,
98 struct dev_context *devc);
99 SR_PRIV int korad_kaxxxxp_get_reply(struct sr_serial_dev_inst *serial,
100 struct dev_context *devc);
101 SR_PRIV int korad_kaxxxxp_get_all_values(struct sr_serial_dev_inst *serial,
102 struct dev_context *devc);
103 SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data);