]> sigrok.org Git - libsigrok.git/blobdiff - libsigrok-internal.h
sysclk-lwla: Advertise SR_CONF_CONN option.
[libsigrok.git] / libsigrok-internal.h
index 61978c297911b73a91c4f7bce4f98058d06eadf6..aa8283f1c070c5eca237e46334692caca589f329 100644 (file)
  * @param x a pointer to the input memory
  * @return the corresponding integer
  */
-#define RB16(x)  ((((const uint8_t*)(x))[0] <<  8) |  \
-                   ((const uint8_t*)(x))[1])
+#define RB16(x)  (((unsigned)((const uint8_t*)(x))[0] <<  8) |  \
+                   (unsigned)((const uint8_t*)(x))[1])
 
 /**
  * Read a 16 bits little endian integer out of memory.
  * @param x a pointer to the input memory
  * @return the corresponding integer
  */
-#define RL16(x)  ((((const uint8_t*)(x))[1] <<  8) |  \
-                   ((const uint8_t*)(x))[0])
+#define RL16(x)  (((unsigned)((const uint8_t*)(x))[1] <<  8) | \
+                   (unsigned)((const uint8_t*)(x))[0])
 
 /**
  * Read a 32 bits big endian integer out of memory.
  * @param x a pointer to the input memory
  * @return the corresponding integer
  */
-#define RB32(x)  ((((const uint8_t*)(x))[0] << 24) |  \
-                  (((const uint8_t*)(x))[1] << 16) |  \
-                  (((const uint8_t*)(x))[2] <<  8) |  \
-                   ((const uint8_t*)(x))[3])
+#define RB32(x)  (((unsigned)((const uint8_t*)(x))[0] << 24) | \
+                  ((unsigned)((const uint8_t*)(x))[1] << 16) |  \
+                  ((unsigned)((const uint8_t*)(x))[2] <<  8) |  \
+                   (unsigned)((const uint8_t*)(x))[3])
 
 /**
  * Read a 32 bits little endian integer out of memory.
  * @param x a pointer to the input memory
  * @return the corresponding integer
  */
-#define RL32(x)  ((((const uint8_t*)(x))[3] << 24) |  \
-                  (((const uint8_t*)(x))[2] << 16) |  \
-                  (((const uint8_t*)(x))[1] <<  8) |  \
-                   ((const uint8_t*)(x))[0])
+#define RL32(x)  (((unsigned)((const uint8_t*)(x))[3] << 24) | \
+                  ((unsigned)((const uint8_t*)(x))[2] << 16) |  \
+                  ((unsigned)((const uint8_t*)(x))[1] <<  8) |  \
+                   (unsigned)((const uint8_t*)(x))[0])
 
 /* Portability fixes for FreeBSD. */
 #ifdef __FreeBSD__
@@ -174,6 +174,14 @@ SR_PRIV int sr_err(const char *format, ...);
 
 /*--- device.c --------------------------------------------------------------*/
 
+/** Values for the changes argument of sr_dev_driver.config_probe_set. */
+enum {
+       /** The enabled state of the probe has been changed. */
+       SR_PROBE_SET_ENABLED = 1 << 0,
+       /** The trigger setup of the probe has been changed. */
+       SR_PROBE_SET_TRIGGER = 1 << 1,
+};
+
 SR_PRIV struct sr_probe *sr_probe_new(int index, int type,
                gboolean enabled, const char *name);
 
@@ -273,6 +281,7 @@ SR_PRIV int sr_atol(const char *str, long *ret);
 SR_PRIV int sr_atoi(const char *str, int *ret);
 SR_PRIV int sr_atod(const char *str, double *ret);
 SR_PRIV int sr_atof(const char *str, float *ret);
+SR_PRIV int sr_atof_ascii(const char *str, float *ret);
 
 /*--- hardware/common/serial.c ----------------------------------------------*/
 
@@ -290,8 +299,16 @@ SR_PRIV int serial_close(struct sr_serial_dev_inst *serial);
 SR_PRIV int serial_flush(struct sr_serial_dev_inst *serial);
 SR_PRIV int serial_write(struct sr_serial_dev_inst *serial,
                const void *buf, size_t count);
+SR_PRIV int serial_write_blocking(struct sr_serial_dev_inst *serial,
+               const void *buf, size_t count);
+SR_PRIV int serial_write_nonblocking(struct sr_serial_dev_inst *serial,
+               const void *buf, size_t count);
 SR_PRIV int serial_read(struct sr_serial_dev_inst *serial, void *buf,
                size_t count);
+SR_PRIV int serial_read_blocking(struct sr_serial_dev_inst *serial, void *buf,
+               size_t count);
+SR_PRIV int serial_read_nonblocking(struct sr_serial_dev_inst *serial, void *buf,
+               size_t count);
 SR_PRIV int serial_set_params(struct sr_serial_dev_inst *serial, int baudrate,
                int bits, int parity, int stopbits, int flowcontrol, int rts, int dtr);
 SR_PRIV int serial_set_paramstr(struct sr_serial_dev_inst *serial,
@@ -356,6 +373,8 @@ enum {
        SCPI_CMD_SET_DIG_POD_STATE,
        SCPI_CMD_GET_ANALOG_DATA,
        SCPI_CMD_GET_DIG_DATA,
+       SCPI_CMD_GET_SAMPLE_RATE,
+       SCPI_CMD_GET_SAMPLE_RATE_LIVE,
 };
 
 struct sr_scpi_hw_info {
@@ -366,18 +385,26 @@ struct sr_scpi_hw_info {
 };
 
 struct sr_scpi_dev_inst {
+       const char *name;
+       const char *prefix;
+       int priv_size;
+       int (*dev_inst_new)(void *priv, const char *resource, char **params,
+               const char *serialcomm);
        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 (*read_begin)(void *priv);
+       int (*read_data)(void *priv, char *buf, int maxlen);
+       int (*read_complete)(void *priv);
        int (*close)(void *priv);
        void (*free)(void *priv);
        void *priv;
 };
 
+SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(const char *resource,
+               const char *serialcomm);
 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);
@@ -386,9 +413,9 @@ 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_read_begin(struct sr_scpi_dev_inst *scpi);
+SR_PRIV int sr_scpi_read_data(struct sr_scpi_dev_inst *scpi, char *buf, int maxlen);
+SR_PRIV int sr_scpi_read_complete(struct sr_scpi_dev_inst *scpi);
 SR_PRIV int sr_scpi_close(struct sr_scpi_dev_inst *scpi);
 SR_PRIV void sr_scpi_free(struct sr_scpi_dev_inst *scpi);
 
@@ -411,39 +438,6 @@ 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 -----------------------------------------*/
 
 /**
@@ -470,6 +464,9 @@ struct es519xx_info {
 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_2400_11b_altfn_packet_valid(const uint8_t *buf);
+SR_PRIV int sr_es519xx_2400_11b_altfn_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);
@@ -522,6 +519,7 @@ SR_PRIV void sr_fs9721_00_temp_c(struct sr_datafeed_analog *analog, void *info);
 SR_PRIV void sr_fs9721_01_temp_c(struct sr_datafeed_analog *analog, void *info);
 SR_PRIV void sr_fs9721_10_temp_c(struct sr_datafeed_analog *analog, void *info);
 SR_PRIV void sr_fs9721_01_10_temp_f_c(struct sr_datafeed_analog *analog, void *info);
+SR_PRIV void sr_fs9721_max_c_min(struct sr_datafeed_analog *analog, void *info);
 
 /*--- hardware/common/dmm/m2110.c -----------------------------------------*/