protocol.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * This file is part of the libsigrok project.
  3. *
  4. * Copyright (C) 2012-2013 Uwe Hermann <uwe@hermann-uwe.de>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef LIBSIGROK_HARDWARE_UNI_T_DMM_PROTOCOL_H
  21. #define LIBSIGROK_HARDWARE_UNI_T_DMM_PROTOCOL_H
  22. #include <stdint.h>
  23. #include <glib.h>
  24. #include <libusb.h>
  25. #include "libsigrok.h"
  26. #include "libsigrok-internal.h"
  27. #define LOG_PREFIX "uni-t-dmm"
  28. enum {
  29. TECPEL_DMM_8061,
  30. UNI_T_UT60A,
  31. UNI_T_UT60E,
  32. UNI_T_UT60G,
  33. UNI_T_UT61B,
  34. UNI_T_UT61C,
  35. UNI_T_UT61D,
  36. UNI_T_UT61E,
  37. VOLTCRAFT_VC820,
  38. VOLTCRAFT_VC830,
  39. VOLTCRAFT_VC840,
  40. TENMA_72_7745,
  41. TENMA_72_7750,
  42. };
  43. struct dmm_info {
  44. char *vendor;
  45. char *device;
  46. uint32_t baudrate;
  47. int packet_size;
  48. gboolean (*packet_valid)(const uint8_t *);
  49. int (*packet_parse)(const uint8_t *, float *,
  50. struct sr_datafeed_analog *, void *);
  51. void (*dmm_details)(struct sr_datafeed_analog *, void *);
  52. struct sr_dev_driver *di;
  53. int (*receive_data)(int, int, void *);
  54. };
  55. #define CHUNK_SIZE 8
  56. #define DMM_BUFSIZE 256
  57. /** Private, per-device-instance driver context. */
  58. struct dev_context {
  59. /** The current sampling limit (in number of samples). */
  60. uint64_t limit_samples;
  61. /** The current sampling limit (in ms). */
  62. uint64_t limit_msec;
  63. /** Opaque pointer passed in by the frontend. */
  64. void *cb_data;
  65. /** The current number of already received samples. */
  66. uint64_t num_samples;
  67. int64_t starttime;
  68. gboolean first_run;
  69. uint8_t protocol_buf[DMM_BUFSIZE];
  70. uint8_t bufoffset;
  71. uint8_t buflen;
  72. };
  73. SR_PRIV int receive_data_TECPEL_DMM_8061(int fd, int revents, void *cb_data);
  74. SR_PRIV int receive_data_UNI_T_UT60A(int fd, int revents, void *cb_data);
  75. SR_PRIV int receive_data_UNI_T_UT60E(int fd, int revents, void *cb_data);
  76. SR_PRIV int receive_data_UNI_T_UT60G(int fd, int revents, void *cb_data);
  77. SR_PRIV int receive_data_UNI_T_UT61B(int fd, int revents, void *cb_data);
  78. SR_PRIV int receive_data_UNI_T_UT61C(int fd, int revents, void *cb_data);
  79. SR_PRIV int receive_data_UNI_T_UT61D(int fd, int revents, void *cb_data);
  80. SR_PRIV int receive_data_UNI_T_UT61E(int fd, int revents, void *cb_data);
  81. SR_PRIV int receive_data_VOLTCRAFT_VC820(int fd, int revents, void *cb_data);
  82. SR_PRIV int receive_data_VOLTCRAFT_VC830(int fd, int revents, void *cb_data);
  83. SR_PRIV int receive_data_VOLTCRAFT_VC840(int fd, int revents, void *cb_data);
  84. SR_PRIV int receive_data_TENMA_72_7745(int fd, int revents, void *cb_data);
  85. SR_PRIV int receive_data_TENMA_72_7750(int fd, int revents, void *cb_data);
  86. #endif