]> sigrok.org Git - libsigrok.git/blobdiff - src/libsigrok-internal.h
session: Allow multiple poll FDs per event source
[libsigrok.git] / src / libsigrok-internal.h
index 4b3daf441151c9d5ed1cfef08c83a4855febc77d..86a6326a76f52e881315cea54f3ccdb9b26084bd 100644 (file)
@@ -632,6 +632,8 @@ enum {
 
 SR_PRIV struct sr_channel *sr_channel_new(struct sr_dev_inst *sdi,
                int index, int type, gboolean enabled, const char *name);
+SR_PRIV struct sr_channel *sr_next_enabled_channel(const struct sr_dev_inst *sdi,
+               struct sr_channel *cur_channel);
 
 /** Device instance data */
 struct sr_dev_inst {
@@ -716,20 +718,19 @@ struct sr_session {
        GSList *datafeed_callbacks;
        GSList *transforms;
        struct sr_trigger *trigger;
-       GTimeVal starttime;
-       gboolean running;
 
-       unsigned int num_sources;
+       gboolean running;
 
        /*
-        * Both "sources" and "pollfds" are of the same size and contain pairs
-        * of descriptor and callback function. We can not embed the GPollFD
-        * into the source struct since we want to be able to pass the array
-        * of all poll descriptors to g_poll().
+        * Event sources and poll FDs are stored in the same order in the
+        * the sources and pollfds arrays. However, each source may cover
+        * any number of associated poll FDs, so the indices do not match.
+        *
+        * We cannot embed the GPollFD into the source struct since we want
+        * to be able to pass the array of all poll descriptors to g_poll().
         */
-       struct source *sources;
-       GPollFD *pollfds;
-       int source_timeout;
+       GArray *sources;
+       GArray *pollfds;
 
        /*
         * These are our synchronization primitives for stopping the session in
@@ -742,6 +743,12 @@ struct sr_session {
        gboolean abort_session;
 };
 
+SR_PRIV int sr_session_source_add_internal(struct sr_session *session,
+               const GPollFD *pollfds, int num_fds, int timeout,
+               sr_receive_data_callback cb, void *cb_data,
+               gintptr poll_object);
+SR_PRIV int sr_session_source_remove_internal(struct sr_session *session,
+               gintptr poll_object);
 SR_PRIV int sr_session_send(const struct sr_dev_inst *sdi,
                const struct sr_datafeed_packet *packet);
 SR_PRIV int sr_session_stop_sync(struct sr_session *session);
@@ -866,6 +873,7 @@ SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration,
 #ifdef HAVE_LIBUSB_1_0
 SR_PRIV GSList *sr_usb_find(libusb_context *usb_ctx, const char *conn);
 SR_PRIV int sr_usb_open(libusb_context *usb_ctx, struct sr_usb_dev_inst *usb);
+SR_PRIV void sr_usb_close(struct sr_usb_dev_inst *usb);
 SR_PRIV int usb_source_add(struct sr_session *session, struct sr_context *ctx,
                int timeout, sr_receive_data_callback cb, void *cb_data);
 SR_PRIV int usb_source_remove(struct sr_session *session, struct sr_context *ctx);
@@ -1126,4 +1134,17 @@ SR_PRIV gboolean sr_ut372_packet_valid(const uint8_t *buf);
 SR_PRIV int sr_ut372_parse(const uint8_t *buf, float *floatval,
                struct sr_datafeed_analog *analog, void *info);
 
+/*--- hardware/scale/kern.c -------------------------------------------------*/
+
+struct kern_info {
+       gboolean is_gram, is_carat, is_ounce, is_pound, is_troy_ounce;
+       gboolean is_pennyweight, is_grain, is_tael, is_momme, is_tola;
+       gboolean is_percentage, is_piece, is_unstable, is_stable, is_error;
+       int buflen;
+};
+
+SR_PRIV gboolean sr_kern_packet_valid(const uint8_t *buf);
+SR_PRIV int sr_kern_parse(const uint8_t *buf, float *floatval,
+               struct sr_datafeed_analog *analog, void *info);
+
 #endif