2 * This file is part of the libsigrok project.
4 * Copyright (C) 2015 Hannu Vuolasaho <vuokkosetae@gmail.com>
5 * Copyright (C) 2018 Frank Stettner <frank-stettner@gmx.net>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef LIBSIGROK_HARDWARE_KORAD_KAXXXXP_PROTOCOL_H
22 #define LIBSIGROK_HARDWARE_KORAD_KAXXXXP_PROTOCOL_H
27 #include <libsigrok/libsigrok.h>
28 #include "libsigrok-internal.h"
30 #define LOG_PREFIX "korad-kaxxxxp"
32 #define KAXXXXP_POLL_INTERVAL_MS 80
41 KORAD_KD3005P_V20_NOSP,
46 /* Support for future devices with this protocol. */
49 /* Information on single model */
50 struct korad_kaxxxxp_model {
51 int model_id; /**< Model info */
52 const char *vendor; /**< Vendor name */
53 const char *name; /**< Model name */
54 const char *id; /**< Model ID, as delivered by interface */
55 int channels; /**< Number of channels */
56 double voltage[3]; /**< Min, max, step */
57 double current[3]; /**< Min, max, step */
76 const struct korad_kaxxxxp_model *model; /**< Model information. */
78 struct sr_sw_limits limits;
82 float current; /**< Last current value [A] read from device. */
83 float current_max; /**< Output current set. */
84 float voltage; /**< Last voltage value [V] read from device. */
85 float voltage_max; /**< Output voltage set. */
86 gboolean cc_mode[2]; /**< Device is in CC mode (otherwise CV). */
88 gboolean output_enabled; /**< Is the output enabled? */
89 gboolean beep_enabled; /**< Enable beeper. */
90 gboolean ocp_enabled; /**< Output current protection enabled. */
91 gboolean ovp_enabled; /**< Output voltage protection enabled. */
93 int acquisition_target; /**< What reply to expect. */
94 int program; /**< Program to store or recall. */
97 SR_PRIV int korad_kaxxxxp_send_cmd(struct sr_serial_dev_inst *serial,
99 SR_PRIV int korad_kaxxxxp_read_chars(struct sr_serial_dev_inst *serial,
100 int count, char *buf);
101 SR_PRIV int korad_kaxxxxp_set_value(struct sr_serial_dev_inst *serial,
102 int target, struct dev_context *devc);
103 SR_PRIV int korad_kaxxxxp_get_value(struct sr_serial_dev_inst *serial,
104 int target, struct dev_context *devc);
105 SR_PRIV int korad_kaxxxxp_get_all_values(struct sr_serial_dev_inst *serial,
106 struct dev_context *devc);
107 SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data);