X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=hardware%2Fnorma-dmm%2Fprotocol.h;h=951734e8f99667b7502375e4e0eab500309e9d5d;hp=70a777afc4a6908a61cb182a05810717e121e1be;hb=43cd4637285833706f8a404ca027bcf0ee75b9ae;hpb=f8e76e2e74bf09024af50d68a0e90a558be126b9 diff --git a/hardware/norma-dmm/protocol.h b/hardware/norma-dmm/protocol.h index 70a777af..951734e8 100644 --- a/hardware/norma-dmm/protocol.h +++ b/hardware/norma-dmm/protocol.h @@ -21,32 +21,35 @@ #define LIBSIGROK_HARDWARE_NORMA_DMM_PROTOCOL_H #include +#include +#include +#include +#include #include #include "libsigrok.h" #include "libsigrok-internal.h" -/* Message logging helpers with subsystem-specific prefix string. */ -#define LOG_PREFIX "norma-dmm: " -#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args) -#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args) -#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args) -#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args) -#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args) -#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args) +/** @file + * Norma DM9x0/Siemens B102x DMMs driver. + * @internal + */ + +#define LOG_PREFIX "norma-dmm" #define NMADMM_BUFSIZE 256 -/** Norma DMM request types (used ones only, the multimeters support about 50). - */ -enum nmadmm_req_t { +#define NMADMM_TIMEOUT_MS 2000 /**< Request timeout. */ + +/** Norma DMM request types (used ones only, the DMMs support about 50). */ +enum { NMADMM_REQ_IDN = 0, /**< Request identity */ NMADMM_REQ_STATUS, /**< Request device status (value + ...) */ }; /** Defines requests used to communicate with device. */ struct nmadmm_req { - enum nmadmm_req_t req_t; /** Request type. */ - const char* reqstr; /** Request string */ + int req_type; /**< Request type. */ + const char *req_str; /**< Request string. */ }; /** Strings for requests. */ @@ -55,8 +58,9 @@ extern const struct nmadmm_req nmadmm_requests[]; /** Private, per-device-instance driver context. */ struct dev_context { /* Model-specific information */ - char* version; /**< Version string */ - int type; /**< DM9x0, e.g. 5 = DM950 */ + char *version; /**< Version string */ + int type; /**< DM9x0, e.g. 5 = DM950 */ + /* Acquisition settings */ uint64_t limit_samples; /**< Target number of samples */ uint64_t limit_msec; /**< Target sampling time */ @@ -65,13 +69,15 @@ struct dev_context { void *cb_data; /* Operational state */ - enum nmadmm_req_t last_req; /**< Last request. */ - gboolean last_req_pending; /**< Last request not answered yet.*/ - int lowbatt; /**< Low battery. 1=low, 2=critical.*/ + int last_req; /**< Last request. */ + int64_t req_sent_at; /**< Request sent. */ + gboolean last_req_pending; /**< Last request not answered yet. */ + int lowbatt; /**< Low battery. 1=low, 2=critical. */ + /* Temporary state across callbacks */ uint64_t num_samples; /**< Current #samples. */ - GTimer* elapsed_msec; /**< Used for sampling with limit_msec*/ - unsigned char buf[NMADMM_BUFSIZE]; /**< Buffer for read callback */ + GTimer *elapsed_msec; /**< Used for limit_msec */ + uint8_t buf[NMADMM_BUFSIZE]; /**< Buffer for read callback */ int buflen; /**< Data len in buf */ };