X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Flibsigrok-internal.h;h=1d45eea304564c6cd30b7e1487dd319ff10d602a;hb=6cfc6c5c7a2fbb8be10b282b0b2bfe9ce9653984;hp=fcb0527a22f43f5473594052d1a79cf44b7d88b5;hpb=b79c3422789d181ad47d4a3707d18d7feea73b5d;p=libsigrok.git diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index fcb0527a..1d45eea3 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -17,12 +17,6 @@ * along with this program. If not, see . */ -/** - * @file - * - * @internal - */ - #ifndef LIBSIGROK_LIBSIGROK_INTERNAL_H #define LIBSIGROK_LIBSIGROK_INTERNAL_H @@ -62,6 +56,13 @@ struct zip_stat; #define ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a) #endif +#ifndef G_SOURCE_FUNC +#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f)) /* Since 2.58. */ +#endif + +#define SR_RECEIVE_DATA_CALLBACK(f) \ + ((sr_receive_data_callback) (void (*)(void)) (f)) + /** * Read a 8 bits unsigned integer out of memory. * @param x a pointer to the input memory @@ -279,7 +280,7 @@ struct zip_stat; #ifdef __APPLE__ #define SR_DRIVER_LIST_SECTION "__DATA,__sr_driver_list" #else -#define SR_DRIVER_LIST_SECTION "sr_driver_list" +#define SR_DRIVER_LIST_SECTION "__sr_driver_list" #endif /** @@ -732,6 +733,8 @@ struct sr_serial_dev_inst; struct ser_lib_functions; struct ser_hid_chip_functions; struct sr_bt_desc; +typedef void (*serial_rx_chunk_callback)(struct sr_serial_dev_inst *serial, + void *cb_data, const void *buf, size_t count); struct sr_serial_dev_inst { /** Port name, e.g. '/dev/tty42'. */ char *port; @@ -745,6 +748,8 @@ struct sr_serial_dev_inst { int stop_bits; } comm_params; GString *rcv_buffer; + serial_rx_chunk_callback rx_chunk_cb_func; + void *rx_chunk_cb_data; #ifdef HAVE_LIBSERIALPORT /** libserialport port handle */ struct sp_port *sp_data; @@ -752,7 +757,9 @@ struct sr_serial_dev_inst { #ifdef HAVE_LIBHIDAPI enum ser_hid_chip_t { SER_HID_CHIP_UNKNOWN, /**!< place holder */ + SER_HID_CHIP_BTC_BU86X, /**!< Brymen BU86x */ SER_HID_CHIP_SIL_CP2110, /**!< SiLabs CP2110 */ + SER_HID_CHIP_VICTOR_DMM, /**!< Victor 70/86 DMM cable */ SER_HID_CHIP_WCH_CH9325, /**!< WCH CH9325 */ SER_HID_CHIP_LAST, /**!< sentinel */ } hid_chip; @@ -1030,8 +1037,9 @@ SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi); #endif SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi); SR_PRIV int std_session_send_df_end(const struct sr_dev_inst *sdi); -SR_PRIV int std_session_send_frame_begin(const struct sr_dev_inst *sdi); -SR_PRIV int std_session_send_frame_end(const struct sr_dev_inst *sdi); +SR_PRIV int std_session_send_df_trigger(const struct sr_dev_inst *sdi); +SR_PRIV int std_session_send_df_frame_begin(const struct sr_dev_inst *sdi); +SR_PRIV int std_session_send_df_frame_end(const struct sr_dev_inst *sdi); SR_PRIV int std_dev_clear_with_callback(const struct sr_dev_driver *driver, std_dev_clear_callback clear_private); SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver); @@ -1081,6 +1089,10 @@ SR_PRIV int std_double_tuple_idx_d0(const double d, const double a[][2], unsigne SR_PRIV int std_cg_idx(const struct sr_channel_group *cg, struct sr_channel_group *a[], unsigned int n); +SR_PRIV int std_dummy_set_params(struct sr_serial_dev_inst *serial, + int baudrate, int bits, int parity, int stopbits, + int flowcontrol, int rts, int dtr); + /*--- resource.c ------------------------------------------------------------*/ SR_PRIV int64_t sr_file_get_size(FILE *file); @@ -1159,6 +1171,8 @@ SR_PRIV int serial_read_blocking(struct sr_serial_dev_inst *serial, void *buf, size_t count, unsigned int timeout_ms); SR_PRIV int serial_read_nonblocking(struct sr_serial_dev_inst *serial, void *buf, size_t count); +SR_PRIV int serial_set_read_chunk_cb(struct sr_serial_dev_inst *serial, + serial_rx_chunk_callback cb, void *cb_data); 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, @@ -1169,7 +1183,7 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial, uint8_t *buf, size_t *buflen, size_t packet_size, packet_valid_callback is_valid, - uint64_t timeout_ms, int baudrate); + uint64_t timeout_ms); SR_PRIV int sr_serial_extract_options(GSList *options, const char **serial_device, const char **serial_options); SR_PRIV int serial_source_add(struct sr_session *session, @@ -1224,7 +1238,6 @@ extern SR_PRIV struct ser_lib_functions *ser_lib_funcs_bt; struct vid_pid_item { uint16_t vid, pid; }; -#define VID_PID_TERM ALL_ZERO struct ser_hid_chip_functions { const char *chipname; @@ -1241,8 +1254,10 @@ struct ser_hid_chip_functions { int (*flush)(struct sr_serial_dev_inst *serial); int (*drain)(struct sr_serial_dev_inst *serial); }; +extern SR_PRIV struct ser_hid_chip_functions *ser_hid_chip_funcs_bu86x; extern SR_PRIV struct ser_hid_chip_functions *ser_hid_chip_funcs_ch9325; extern SR_PRIV struct ser_hid_chip_functions *ser_hid_chip_funcs_cp2110; +extern SR_PRIV struct ser_hid_chip_functions *ser_hid_chip_funcs_victor; SR_PRIV const char *ser_hid_chip_find_name_vid_pid(uint16_t vid, uint16_t pid); #endif #endif @@ -1560,6 +1575,20 @@ SR_PRIV gboolean sr_brymen_bm25x_packet_valid(const uint8_t *buf); SR_PRIV int sr_brymen_bm25x_parse(const uint8_t *buf, float *floatval, struct sr_datafeed_analog *analog, void *info); +/*--- dmm/bm86x.c -----------------------------------------------------------*/ + +#define BRYMEN_BM86X_PACKET_SIZE 24 +#define BRYMEN_BM86X_DISPLAY_COUNT 2 + +struct brymen_bm86x_info { size_t ch_idx; }; + +#ifdef HAVE_SERIAL_COMM +SR_PRIV int sr_brymen_bm86x_packet_request(struct sr_serial_dev_inst *serial); +#endif +SR_PRIV gboolean sr_brymen_bm86x_packet_valid(const uint8_t *buf); +SR_PRIV int sr_brymen_bm86x_parse(const uint8_t *buf, float *floatval, + struct sr_datafeed_analog *analog, void *info); + /*--- dmm/ut71x.c -----------------------------------------------------------*/ #define UT71X_PACKET_SIZE 11 @@ -1613,21 +1642,53 @@ SR_PRIV int sr_vc96_parse(const uint8_t *buf, float *floatval, /*--- lcr/es51919.c ---------------------------------------------------------*/ -SR_PRIV void es51919_serial_clean(void *priv); -SR_PRIV struct sr_dev_inst *es51919_serial_scan(GSList *options, - const char *vendor, - const char *model); -SR_PRIV int es51919_serial_config_get(uint32_t key, GVariant **data, - const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg); -SR_PRIV int es51919_serial_config_set(uint32_t key, GVariant *data, - const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg); -SR_PRIV int es51919_serial_config_list(uint32_t key, GVariant **data, - const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg); -SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi); -SR_PRIV int es51919_serial_acquisition_stop(struct sr_dev_inst *sdi); +/* Acquisition details which apply to all supported serial-lcr devices. */ +struct lcr_parse_info { + size_t ch_idx; + uint64_t output_freq; + const char *circuit_model; +}; + +#define ES51919_PACKET_SIZE 17 +#define ES51919_CHANNEL_COUNT 2 +#define ES51919_COMM_PARAM "9600/8n1/rts=1/dtr=1" + +SR_PRIV int es51919_config_get(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg); +SR_PRIV int es51919_config_set(uint32_t key, GVariant *data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg); +SR_PRIV int es51919_config_list(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg); +SR_PRIV gboolean es51919_packet_valid(const uint8_t *pkt); +SR_PRIV int es51919_packet_parse(const uint8_t *pkt, float *floatval, + struct sr_datafeed_analog *analog, void *info); + +/*--- lcr/vc4080.c ----------------------------------------------------------*/ + +/* Note: Also uses 'struct lcr_parse_info' from es51919 above. */ + +#define VC4080_PACKET_SIZE 39 +#define VC4080_COMM_PARAM "1200/8n1" +#define VC4080_WITH_DQ_CHANS 0 /* Enable separate D/Q channels? */ + +enum vc4080_display { + VC4080_DISPLAY_PRIMARY, + VC4080_DISPLAY_SECONDARY, +#if VC4080_WITH_DQ_CHANS + VC4080_DISPLAY_D_VALUE, + VC4080_DISPLAY_Q_VALUE, +#endif + VC4080_CHANNEL_COUNT, +}; + +extern SR_PRIV const char *vc4080_channel_formats[VC4080_CHANNEL_COUNT]; + +SR_PRIV int vc4080_config_list(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg); +SR_PRIV int vc4080_packet_request(struct sr_serial_dev_inst *serial); +SR_PRIV gboolean vc4080_packet_valid(const uint8_t *pkt); +SR_PRIV int vc4080_packet_parse(const uint8_t *pkt, float *floatval, + struct sr_datafeed_analog *analog, void *info); /*--- dmm/ut372.c -----------------------------------------------------------*/ @@ -1704,10 +1765,8 @@ struct eev121gw_info { extern SR_PRIV const char *eev121gw_channel_formats[]; SR_PRIV gboolean sr_eev121gw_packet_valid(const uint8_t *buf); -SR_PRIV int sr_eev121gw_parse(const uint8_t *buf, float *floatval, - struct sr_datafeed_analog *analog, void *info); SR_PRIV int sr_eev121gw_3displays_parse(const uint8_t *buf, float *floatval, - struct sr_datafeed_analog *analog, void *info); + struct sr_datafeed_analog *analog, void *info); /*--- scale/kern.c ----------------------------------------------------------*/ @@ -1726,8 +1785,10 @@ SR_PRIV int sr_kern_parse(const uint8_t *buf, float *floatval, struct sr_sw_limits { uint64_t limit_samples; + uint64_t limit_frames; uint64_t limit_msec; uint64_t samples_read; + uint64_t frames_read; uint64_t start_time; }; @@ -1739,6 +1800,8 @@ SR_PRIV void sr_sw_limits_acquisition_start(struct sr_sw_limits *limits); SR_PRIV gboolean sr_sw_limits_check(struct sr_sw_limits *limits); SR_PRIV void sr_sw_limits_update_samples_read(struct sr_sw_limits *limits, uint64_t samples_read); +SR_PRIV void sr_sw_limits_update_frames_read(struct sr_sw_limits *limits, + uint64_t frames_read); SR_PRIV void sr_sw_limits_init(struct sr_sw_limits *limits); #endif