]> sigrok.org Git - libsigrok.git/blobdiff - src/libsigrok-internal.h
session: Unify handling of I/O and timer sources
[libsigrok.git] / src / libsigrok-internal.h
index 4a696bef0957e0a7233133ba491ffab856801ce1..7023c491cb1591fbfdec85dcdc25757fed41f619 100644 (file)
@@ -718,20 +718,18 @@ 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().
+        * Each I/O source has an entry with the same index in both "sources"
+        * and "pollfds". The "sources" array may be larger than "pollfds",
+        * in which case the excess sources are pure timer sources.
+        * 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().
         */
-       struct source *sources;
-       GPollFD *pollfds;
-       int source_timeout;
+       GArray *sources;
+       GArray *pollfds;
 
        /*
         * These are our synchronization primitives for stopping the session in
@@ -744,6 +742,9 @@ struct sr_session {
        gboolean abort_session;
 };
 
+SR_PRIV int sr_session_source_add_internal(struct sr_session *session,
+               GPollFD *pollfd, int timeout, sr_receive_data_callback cb,
+               void *cb_data, gintptr poll_object, gboolean is_usb);
 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);
@@ -1129,4 +1130,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