+/*--- hardware/common/scpi.c ------------------------------------------------*/
+
+#define SCPI_CMD_IDN "*IDN?"
+#define SCPI_CMD_OPC "*OPC?"
+
+enum {
+ SCPI_CMD_SET_TRIGGER_SOURCE,
+ SCPI_CMD_SET_TIMEBASE,
+ SCPI_CMD_SET_VERTICAL_DIV,
+ SCPI_CMD_SET_TRIGGER_SLOPE,
+ SCPI_CMD_SET_COUPLING,
+ SCPI_CMD_SET_HORIZ_TRIGGERPOS,
+ SCPI_CMD_GET_ANALOG_CHAN_STATE,
+ SCPI_CMD_GET_DIG_CHAN_STATE,
+ SCPI_CMD_GET_TIMEBASE,
+ SCPI_CMD_GET_VERTICAL_DIV,
+ SCPI_CMD_GET_VERTICAL_OFFSET,
+ SCPI_CMD_GET_TRIGGER_SOURCE,
+ SCPI_CMD_GET_HORIZ_TRIGGERPOS,
+ SCPI_CMD_GET_TRIGGER_SLOPE,
+ SCPI_CMD_GET_COUPLING,
+ SCPI_CMD_SET_ANALOG_CHAN_STATE,
+ SCPI_CMD_SET_DIG_CHAN_STATE,
+ SCPI_CMD_GET_DIG_POD_STATE,
+ SCPI_CMD_SET_DIG_POD_STATE,
+ SCPI_CMD_GET_ANALOG_DATA,
+ SCPI_CMD_GET_DIG_DATA,
+};
+
+struct sr_scpi_hw_info {
+ char *manufacturer;
+ char *model;
+ char *serial_number;
+ char *firmware_version;
+};
+
+struct sr_scpi_dev_inst {
+ int (*open)(void *priv);
+ int (*source_add)(void *priv, int events,
+ int timeout, sr_receive_data_callback_t cb, void *cb_data);
+ int (*source_remove)(void *priv);
+ int (*send)(void *priv, const char *command);
+ int (*receive)(void *priv, char **scpi_response);
+ int (*read)(void *priv, char *buf, int maxlen);
+ int (*close)(void *priv);
+ void (*free)(void *priv);
+ void *priv;
+};
+
+SR_PRIV int sr_scpi_open(struct sr_scpi_dev_inst *scpi);
+SR_PRIV int sr_scpi_source_add(struct sr_scpi_dev_inst *scpi, int events,
+ int timeout, sr_receive_data_callback_t cb, void *cb_data);
+SR_PRIV int sr_scpi_source_remove(struct sr_scpi_dev_inst *scpi);
+SR_PRIV int sr_scpi_send(struct sr_scpi_dev_inst *scpi,
+ const char *format, ...);
+SR_PRIV int sr_scpi_send_variadic(struct sr_scpi_dev_inst *scpi,
+ const char *format, va_list args);
+SR_PRIV int sr_scpi_receive(struct sr_scpi_dev_inst *scpi,
+ char **scpi_response);
+SR_PRIV int sr_scpi_read(struct sr_scpi_dev_inst *scpi, char *buf, int maxlen);
+SR_PRIV int sr_scpi_close(struct sr_scpi_dev_inst *scpi);
+SR_PRIV void sr_scpi_free(struct sr_scpi_dev_inst *scpi);
+
+SR_PRIV int sr_scpi_get_string(struct sr_scpi_dev_inst *scpi,
+ const char *command, char **scpi_response);
+SR_PRIV int sr_scpi_get_bool(struct sr_scpi_dev_inst *scpi,
+ const char *command, gboolean *scpi_response);
+SR_PRIV int sr_scpi_get_int(struct sr_scpi_dev_inst *scpi,
+ const char *command, int *scpi_response);
+SR_PRIV int sr_scpi_get_float(struct sr_scpi_dev_inst *scpi,
+ const char *command, float *scpi_response);
+SR_PRIV int sr_scpi_get_double(struct sr_scpi_dev_inst *scpi,
+ const char *command, double *scpi_response);
+SR_PRIV int sr_scpi_get_opc(struct sr_scpi_dev_inst *scpi);
+SR_PRIV int sr_scpi_get_floatv(struct sr_scpi_dev_inst *scpi,
+ const char *command, GArray **scpi_response);
+SR_PRIV int sr_scpi_get_uint8v(struct sr_scpi_dev_inst *scpi,
+ const char *command, GArray **scpi_response);
+SR_PRIV int sr_scpi_get_hw_id(struct sr_scpi_dev_inst *scpi,
+ struct sr_scpi_hw_info **scpi_response);
+SR_PRIV void sr_scpi_hw_info_free(struct sr_scpi_hw_info *hw_info);
+
+/*--- hardware/common/scpi_serial.c -----------------------------------------*/
+
+#ifdef HAVE_LIBSERIALPORT
+SR_PRIV struct sr_scpi_dev_inst *scpi_serial_dev_inst_new(const char *port,
+ const char *serialcomm);
+#endif
+
+/*--- hardware/common/scpi_tcp.c --------------------------------------------*/
+
+SR_PRIV struct sr_scpi_dev_inst *scpi_tcp_dev_inst_new(const char *address,
+ const char *port);
+
+/*--- hardware/common/scpi_usbtmc.c -----------------------------------------*/
+
+SR_PRIV struct sr_scpi_dev_inst *scpi_usbtmc_dev_inst_new(const char *device);
+
+/*--- hardware/common/dmm/es51922.c -----------------------------------------*/
+
+#define ES51922_PACKET_SIZE 14
+
+struct es51922_info {
+ gboolean is_judge, is_vbar, is_voltage, is_auto, is_micro, is_current;
+ gboolean is_milli, is_resistance, is_continuity, is_diode, is_lpf;
+ gboolean is_frequency, is_duty_cycle, is_capacitance, is_temperature;
+ gboolean is_celsius, is_fahrenheit, is_adp, is_sign, is_batt, is_ol;
+ gboolean is_max, is_min, is_rel, is_rmr, is_ul, is_pmax, is_pmin;
+ gboolean is_dc, is_ac, is_vahz, is_hold, is_nano, is_kilo, is_mega;
+};
+
+SR_PRIV gboolean sr_es51922_packet_valid(const uint8_t *buf);
+SR_PRIV int sr_es51922_parse(const uint8_t *buf, float *floatval,
+ struct sr_datafeed_analog *analog, void *info);
+
+/*--- hardware/common/dmm/es519xx.c -----------------------------------------*/
+
+/**
+ * All 11-byte es519xx chips repeat each block twice for each conversion cycle
+ * so always read 2 blocks at a time.
+ */
+#define ES519XX_11B_PACKET_SIZE (11 * 2)
+#define ES519XX_14B_PACKET_SIZE 14
+
+struct es519xx_info {
+ gboolean is_judge, is_voltage, is_auto, is_micro, is_current;
+ gboolean is_milli, is_resistance, is_continuity, is_diode;
+ gboolean is_frequency, is_rpm, is_capacitance, is_duty_cycle;
+ gboolean is_temperature, is_celsius, is_fahrenheit;
+ gboolean is_adp0, is_adp1, is_adp2, is_adp3;
+ gboolean is_sign, is_batt, is_ol, is_pmax, is_pmin, is_apo;
+ gboolean is_dc, is_ac, is_vahz, is_min, is_max, is_rel, is_hold;
+ gboolean is_digit4, is_ul, is_vasel, is_vbar, is_lpf1, is_lpf0, is_rmr;
+ uint32_t baudrate;
+ int packet_size;
+ gboolean alt_functions, fivedigits, clampmeter, selectable_lpf;
+};
+
+SR_PRIV gboolean sr_es519xx_2400_11b_packet_valid(const uint8_t *buf);
+SR_PRIV int sr_es519xx_2400_11b_parse(const uint8_t *buf, float *floatval,
+ struct sr_datafeed_analog *analog, void *info);
+SR_PRIV gboolean sr_es519xx_19200_11b_5digits_packet_valid(const uint8_t *buf);
+SR_PRIV int sr_es519xx_19200_11b_5digits_parse(const uint8_t *buf,
+ float *floatval, struct sr_datafeed_analog *analog, void *info);
+SR_PRIV gboolean sr_es519xx_19200_11b_clamp_packet_valid(const uint8_t *buf);
+SR_PRIV int sr_es519xx_19200_11b_clamp_parse(const uint8_t *buf,
+ float *floatval, struct sr_datafeed_analog *analog, void *info);
+SR_PRIV gboolean sr_es519xx_19200_11b_packet_valid(const uint8_t *buf);
+SR_PRIV int sr_es519xx_19200_11b_parse(const uint8_t *buf, float *floatval,
+ struct sr_datafeed_analog *analog, void *info);
+SR_PRIV gboolean sr_es519xx_19200_14b_packet_valid(const uint8_t *buf);
+SR_PRIV int sr_es519xx_19200_14b_parse(const uint8_t *buf, float *floatval,
+ struct sr_datafeed_analog *analog, void *info);
+SR_PRIV gboolean sr_es519xx_19200_14b_sel_lpf_packet_valid(const uint8_t *buf);
+SR_PRIV int sr_es519xx_19200_14b_sel_lpf_parse(const uint8_t *buf,
+ float *floatval, struct sr_datafeed_analog *analog, void *info);
+