X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fnorma-dmm%2Fprotocol.h;h=e9a956e31115c19eadc55c946e95ab6f78a1e027;hb=0d4405ce5e9373d2dcd90a9188b79d79eaafae5d;hp=a8af261384b78603c568aee89a5c46514e5d2168;hpb=bfd48770fc18dae79d140120e6af3b7ac4bdb2ee;p=libsigrok.git diff --git a/hardware/norma-dmm/protocol.h b/hardware/norma-dmm/protocol.h index a8af2613..e9a956e3 100644 --- a/hardware/norma-dmm/protocol.h +++ b/hardware/norma-dmm/protocol.h @@ -21,6 +21,10 @@ #define LIBSIGROK_HARDWARE_NORMA_DMM_PROTOCOL_H #include +#include +#include +#include +#include #include #include "libsigrok.h" #include "libsigrok-internal.h" @@ -34,18 +38,49 @@ #define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args) #define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args) +#define NMADMM_BUFSIZE 256 + +/** 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 { + int req_type; /**< Request type. */ + const char *req_str; /**< Request string. */ +}; + +/** Strings for requests. */ +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 */ /* 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; /* Operational state */ + int last_req; /**< Last request. */ + 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 limit_msec */ + uint8_t buf[NMADMM_BUFSIZE]; /**< Buffer for read callback */ + int buflen; /**< Data len in buf */ }; SR_PRIV int norma_dmm_receive_data(int fd, int revents, void *cb_data); +SR_PRIV int xgittoint(char xgit); #endif