]> sigrok.org Git - libsigrok.git/blobdiff - src/libsigrok-internal.h
Add protocol decoder for Cyrustek ES51919 LCR meter chip.
[libsigrok.git] / src / libsigrok-internal.h
index 67c0aab6a2bab877d12e01a866ef0042e0d03171..75b9d5a4761a2605623eedb8264d089dbe1db929 100644 (file)
@@ -211,6 +211,7 @@ struct sr_input {
        const struct sr_input_module *module;
        GString *buf;
        struct sr_dev_inst *sdi;
+       gboolean sdi_ready;
        void *priv;
 };
 
@@ -264,7 +265,7 @@ struct sr_input_module {
         * @param[in] metadata Metadata the module can use to identify the stream.
         *
         * @retval SR_OK This module knows the format.
-        * @retval SR_OK_CONTINUE There wasn't enough data for this module to
+        * @retval SR_ERR_NA There wasn't enough data for this module to
         *   positively identify the format.
         * @retval SR_ERR_DATA This module knows the format, but cannot handle it.
         *   This means the stream is either corrupt, or indicates a feature
@@ -276,47 +277,47 @@ struct sr_input_module {
        /**
         * Initialize the input module.
         *
-        * @param in A pointer to a valid 'struct sr_input' that the caller
-        *           has to allocate and provide to this function. It is also
-        *           the responsibility of the caller to free it later.
-        * @param[in] filename The name (and path) of the file to use.
-        *
         * @retval SR_OK Success
         * @retval other Negative error code.
         */
        int (*init) (struct sr_input *in, GHashTable *options);
 
        /**
-        * Load a file, parsing the input according to the file's format.
-        *
-        * This function will send datafeed packets to the session bus, so
-        * the calling frontend must have registered its session callbacks
-        * beforehand.
+        * Send data to the specified input instance.
         *
-        * The packet types sent across the session bus by this function must
-        * include at least SR_DF_HEADER, SR_DF_END, and an appropriate data
-        * type such as SR_DF_LOGIC. It may also send a SR_DF_TRIGGER packet
-        * if appropriate.
+        * When an input module instance is created with sr_input_new(), this
+        * function is used to feed data to the instance.
         *
-        * @param in A pointer to a valid 'struct sr_input' that the caller
-        *           has to allocate and provide to this function. It is also
-        *           the responsibility of the caller to free it later.
-        * @param f The name (and path) of the file to use.
+        * As enough data gets fed into this function to completely populate
+        * the device instance associated with this input instance, this is
+        * guaranteed to return the moment it's ready. This gives the caller
+        * the chance to examine the device instance, attach session callbacks
+        * and so on.
         *
         * @retval SR_OK Success
         * @retval other Negative error code.
         */
-       int (*receive) (const struct sr_input *in, GString *buf);
+       int (*receive) (struct sr_input *in, GString *buf);
+
+       /**
+        * Signal the input module no more data will come.
+        *
+        * This will cause the module to process any data it may have buffered.
+        * The SR_DF_END packet will also typically be sent at this time.
+        */
+       int (*end) (struct sr_input *in);
 
        /**
         * This function is called after the caller is finished using
         * the input module, and can be used to free any internal
         * resources the module may keep.
         *
+        * This function is optional.
+        *
         * @retval SR_OK Success
         * @retval other Negative error code.
         */
-       int (*cleanup) (struct sr_input *in);
+       void (*cleanup) (struct sr_input *in);
 };
 
 /** Output module instance. */
@@ -629,11 +630,11 @@ SR_PRIV int serial_open(struct sr_serial_dev_inst *serial, int flags);
 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_blocking(struct sr_serial_dev_inst *serial,
-               const void *buf, size_t count);
+               const void *buf, size_t count, unsigned int timeout_ms);
 SR_PRIV int serial_write_nonblocking(struct sr_serial_dev_inst *serial,
                const void *buf, size_t count);
 SR_PRIV int serial_read_blocking(struct sr_serial_dev_inst *serial, void *buf,
-               size_t count);
+               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_params(struct sr_serial_dev_inst *serial, int baudrate,
@@ -655,6 +656,7 @@ SR_PRIV int serial_source_add(struct sr_session *session,
 SR_PRIV int serial_source_remove(struct sr_session *session,
                struct sr_serial_dev_inst *serial);
 SR_PRIV GSList *sr_serial_find_usb(uint16_t vendor_id, uint16_t product_id);
+SR_PRIV int serial_timeout(struct sr_serial_dev_inst *port, int num_bytes);
 #endif
 
 /*--- hardware/common/ezusb.c -----------------------------------------------*/
@@ -675,7 +677,7 @@ SR_PRIV int sr_usb_open(libusb_context *usb_ctx, 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);
-SR_PRIV int usb_get_port_path(libusb_device *dev, const char *path, int path_len);
+SR_PRIV int usb_get_port_path(libusb_device *dev, char *path, int path_len);
 #endif
 
 /*--- hardware/common/scpi.c ------------------------------------------------*/
@@ -733,6 +735,7 @@ struct sr_scpi_dev_inst {
        int (*read_complete)(void *priv);
        int (*close)(void *priv);
        void (*free)(void *priv);
+       unsigned int read_timeout_ms;
        void *priv;
 };
 
@@ -907,4 +910,24 @@ 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);
 
+/*--- hardware/common/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,
+                                            void *cb_data);
+SR_PRIV int es51919_serial_acquisition_stop(struct sr_dev_inst *sdi,
+                                           void *cb_data);
+
 #endif