]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/gmc-mh-1x-2x/protocol.h
agilent-dmm: add support for Keysight branded meters
[libsigrok.git] / src / hardware / gmc-mh-1x-2x / protocol.h
index aa19be38a8a8d161ae7723f88d41b81293140242..49492352f5bfa81f0b36ad4a61e78aba2a9137ba 100644 (file)
 
 #include <stdint.h>
 #include <glib.h>
-#include "libsigrok.h"
+#include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.h"
 
 #define LOG_PREFIX "gmc-mh-1x-2x"
 
-#define GMC_BUFSIZE  266
+#define GMC_BUFSIZE 266
+#define GMC_REPLY_SIZE 14
 
 /** Message ID bits 4, 5 */
 #define MSGID_MASK  0x30 /**< Mask to get message ID bits */
@@ -75,6 +76,7 @@ enum model {
        METRAHIT_26SM           = METRAHIT_25S + 1,     /**< Send mode */
        METRAHIT_26S            = METRAHIT_26SM + 1,    /**< Bidi mode */
        METRAHIT_26M            = METRAHIT_26S + 1,     /**< Bidi mode */
+       /* The Metrahit 27x and 28Cx have a totally different protocol */
        METRAHIT_28S            = METRAHIT_26M + 1,
        METRAHIT_29S            = METRAHIT_28S + 1,
 };
@@ -85,23 +87,18 @@ struct dev_context {
        enum model model;       /**< Model code. */
 
        /* Acquisition settings */
-       uint64_t limit_samples; /**< Target number of samples */
-       uint64_t limit_msec;    /**< Target sampling time */
-
-       /* Opaque pointer passed in by frontend. */
-       void *cb_data;
+       struct sr_sw_limits limits;
 
        /* Operational state */
        gboolean settings_ok;   /**< Settings msg received yet. */
        int msg_type;       /**< Message type (MSGID_INF, ...). */
-       int msg_len;        /**< Message lengh (valid when msg, curr. type known).*/
-       int mq;             /**< Measured quantity */
-       int unit;           /**< Measured unit */
-       uint64_t mqflags;       /**< Measured quantity flags */
+       int msg_len;        /**< Message length (valid when msg, curr. type known).*/
+       enum sr_mq mq;      /**< Measured quantity */
+       enum sr_unit unit;  /**< Measured unit */
+       enum sr_mqflag mqflags; /**< Measured quantity flags */
        float value;            /**< Measured value */
        float scale;            /**< Scale for value. */
        int8_t scale1000;   /**< Additional scale factor 1000x. */
-       gboolean vmains_29S;    /**< Measured ctmv is V mains (29S only). */
        int addr;           /**< Device address (1..15). */
        int cmd_idx;        /**< Parameter "Idx" (Index) of current command, if required. */
        int cmd_seq;        /**< Command sequence. Used to query status every n messages. */
@@ -113,17 +110,13 @@ struct dev_context {
        gboolean response_pending; /**< Request sent, response is pending. */
 
        /* Temporary state across callbacks */
-       uint64_t num_samples;   /**< Current #samples for limit_samples */
-       GTimer *elapsed_msec;   /**< Used for sampling with limit_msec  */
        uint8_t buf[GMC_BUFSIZE];       /**< Buffer for read callback */
        int buflen;                     /**< Data len in buf */
 };
 
 /* Forward declarations */
-SR_PRIV int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
+SR_PRIV int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg);
-SR_PRIV void create_cmd_14(guchar addr, guchar func, guchar* params, guchar* buf);
-SR_PRIV void dump_msg14(guchar* buf, gboolean raw);
 SR_PRIV int gmc_decode_model_bd(uint8_t mcode);
 SR_PRIV int gmc_decode_model_sm(uint8_t mcode);
 SR_PRIV int gmc_mh_1x_2x_receive_data(int fd, int revents, void *cb_data);