X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Funi-t-dmm%2Fprotocol.h;h=1f9b169a7fff921650ef77c2eec0b04d58366510;hb=b979d0c9cbf3a697c0ac4b06031ffb18b5f60006;hp=2a76c1c1a93f90989d17ac6962db57e0ce216ff5;hpb=79081ec80c79801c439a1a3756cf5426af0739b8;p=libsigrok.git diff --git a/hardware/uni-t-dmm/protocol.h b/hardware/uni-t-dmm/protocol.h index 2a76c1c1..1f9b169a 100644 --- a/hardware/uni-t-dmm/protocol.h +++ b/hardware/uni-t-dmm/protocol.h @@ -1,7 +1,7 @@ /* - * This file is part of the sigrok project. + * This file is part of the libsigrok project. * - * Copyright (C) 2012 Uwe Hermann + * Copyright (C) 2012-2013 Uwe Hermann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,20 +27,49 @@ #include "libsigrok.h" #include "libsigrok-internal.h" -/* Message logging helpers with driver-specific prefix string. */ -#define DRIVER_LOG_DOMAIN "uni-t-dmm: " -#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args) -#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args) -#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args) -#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args) -#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args) -#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args) +/* Message logging helpers with subsystem-specific prefix string. */ +#define LOG_PREFIX "uni-t-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) -#define UT_D04_CABLE_USB_VID 0x1a86 -#define UT_D04_CABLE_USB_DID 0xe008 +/* Note: When adding entries here, don't forget to update DMM_COUNT. */ +enum { + TECPEL_DMM_8060, + TECPEL_DMM_8061, + UNI_T_UT60A, + UNI_T_UT60E, + UNI_T_UT61D, + UNI_T_UT61E, + VOLTCRAFT_VC820, + VOLTCRAFT_VC830, + VOLTCRAFT_VC840, +}; + +#define DMM_COUNT 9 + +struct dmm_info { + char *vendor; + char *device; + uint32_t baudrate; + int packet_size; + int (*packet_request)(struct sr_serial_dev_inst *); + gboolean (*packet_valid)(const uint8_t *); + int (*packet_parse)(const uint8_t *, float *, + struct sr_datafeed_analog *, void *); + void (*dmm_details)(struct sr_datafeed_analog *, void *); + struct sr_dev_driver *di; + int (*receive_data)(int, int, void *); +}; + +extern SR_PRIV struct dmm_info udmms[DMM_COUNT]; #define CHUNK_SIZE 8 -#define NUM_DATA_BYTES 14 + +#define DMM_BUFSIZE 256 /** Private, per-device-instance driver context. */ struct dev_context { @@ -56,11 +85,23 @@ struct dev_context { /** The current number of already received samples. */ uint64_t num_samples; - struct sr_usb_dev_inst *usb; + int64_t starttime; + + gboolean first_run; - uint8_t protocol_buf[14]; + uint8_t protocol_buf[DMM_BUFSIZE]; + uint8_t bufoffset; + uint8_t buflen; }; -SR_PRIV int uni_t_dmm_receive_data(int fd, int revents, void *cb_data); +SR_PRIV int receive_data_TECPEL_DMM_8060(int fd, int revents, void *cb_data); +SR_PRIV int receive_data_TECPEL_DMM_8061(int fd, int revents, void *cb_data); +SR_PRIV int receive_data_UNI_T_UT60A(int fd, int revents, void *cb_data); +SR_PRIV int receive_data_UNI_T_UT60E(int fd, int revents, void *cb_data); +SR_PRIV int receive_data_UNI_T_UT61D(int fd, int revents, void *cb_data); +SR_PRIV int receive_data_UNI_T_UT61E(int fd, int revents, void *cb_data); +SR_PRIV int receive_data_VOLTCRAFT_VC820(int fd, int revents, void *cb_data); +SR_PRIV int receive_data_VOLTCRAFT_VC830(int fd, int revents, void *cb_data); +SR_PRIV int receive_data_VOLTCRAFT_VC840(int fd, int revents, void *cb_data); #endif