]> sigrok.org Git - libsigrok.git/commitdiff
doxygen: Add more input format docs.
authorUwe Hermann <redacted>
Thu, 21 Feb 2013 20:27:27 +0000 (21:27 +0100)
committerUwe Hermann <redacted>
Sun, 24 Feb 2013 13:31:15 +0000 (14:31 +0100)
This is largely taken from the respective wiki page (with some updates
and improvements), which will be removed in favor of the doxygen docs.

input/input.c
libsigrok.h

index 7fcd6502082a2e4e92ea64a0b91abc6e4fb13dbc..e876dfcaa838f9cc703b608c9122d4fedb59a1c9 100644 (file)
  *
  * Input file/data format handling.
  *
+ * libsigrok can process acquisition data in several different ways.
+ * Aside from acquiring data from a hardware device, it can also take it from
+ * a file in various formats (binary, CSV, VCD, and so on).
+ *
+ * Like everything in libsigrok that handles data, processing is done in a
+ * streaming manner -- input should be supplied to libsigrok a chunk at a time.
+ * This way anything that processes data can do so in real time, without the
+ * user having to wait for the whole thing to be finished.
+ *
+ * Every input module is "pluggable", meaning it's handled as being separate
+ * from the main libsigrok, but linked in to it statically. To keep things
+ * modular and separate like this, functions within an input module should be
+ * declared static, with only the respective 'struct sr_input_format' being
+ * exported for use into the wider libsigrok namespace.
+ *
  * @{
  */
 
index b6d2b64046ebbda6f2a438a91ea5bf5fea2c1854..4601f60be40ba5b4527fa6726ea290a3293961c2 100644 (file)
@@ -300,18 +300,71 @@ struct sr_datafeed_analog {
        float *data;
 };
 
+/** Input (file) format struct. */
 struct sr_input {
+       /**
+        * A pointer to this input format's 'struct sr_input_format'.
+        * The frontend can use this to call the module's callbacks.
+        */
        struct sr_input_format *format;
+
        GHashTable *param;
+
        struct sr_dev_inst *sdi;
+
        void *internal;
 };
 
 struct sr_input_format {
+       /** The unique ID for this input format. Must not be NULL. */
        char *id;
+
+       /**
+        * A short description of the input format, which can (for example)
+        * be displayed to the user by frontends. Must not be NULL.
+        */
        char *description;
+
+       /**
+        * Check if this input module can load and parse the specified file.
+        *
+        * @param filename The name (and path) of the file to check.
+        *
+        * @return TRUE if this module knows the format, FALSE if it doesn't.
+        */
        int (*format_match) (const char *filename);
+
+       /**
+        * 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 filename The name (and path) of the file to use.
+        *
+        * @return SR_OK upon success, a negative error code upon failure.
+        */
        int (*init) (struct sr_input *in, const char *filename);
+
+       /**
+        * 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.
+        *
+        * 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.
+        *
+        * @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 filename The name (and path) of the file to use.
+        *
+        * @return SR_OK upon success, a negative error code upon failure.
+        */
        int (*loadfile) (struct sr_input *in, const char *filename);
 };