X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=libsigrok-internal.h;h=2577fd0dcd981202b927e9d95dbb5ee633c61d47;hb=fa0d6afe19c3a545f3f940933ed079966525d142;hp=82d6d791c39ff8362ce4a794c5a4abd1c0c5ef76;hpb=e28ef28a3c9a5cd2c86e4ab4de2516ab82d91082;p=libsigrok.git diff --git a/libsigrok-internal.h b/libsigrok-internal.h index 82d6d791..2577fd0d 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -55,36 +55,36 @@ * @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__ @@ -162,6 +162,16 @@ SR_PRIV int sr_info(const char *format, ...); SR_PRIV int sr_warn(const char *format, ...); SR_PRIV int sr_err(const char *format, ...); +/* Message logging helpers with subsystem-specific prefix string. */ +#ifndef NO_LOG_WRAPPERS +#define sr_log(l, s, args...) sr_log(l, "%s: " s, LOG_PREFIX, ## args) +#define sr_spew(s, args...) sr_spew("%s: " s, LOG_PREFIX, ## args) +#define sr_dbg(s, args...) sr_dbg("%s: " s, LOG_PREFIX, ## args) +#define sr_info(s, args...) sr_info("%s: " s, LOG_PREFIX, ## args) +#define sr_warn(s, args...) sr_warn("%s: " s, LOG_PREFIX, ## args) +#define sr_err(s, args...) sr_err("%s: " s, LOG_PREFIX, ## args) +#endif + /*--- device.c --------------------------------------------------------------*/ SR_PRIV struct sr_probe *sr_probe_new(int index, int type, @@ -280,8 +290,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, @@ -361,8 +379,9 @@ struct sr_scpi_dev_inst { 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; @@ -376,9 +395,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); @@ -417,23 +436,6 @@ SR_PRIV struct sr_scpi_dev_inst *scpi_tcp_dev_inst_new(const char *address, 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 -----------------------------------------*/ /** @@ -512,6 +514,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 -----------------------------------------*/