protocol.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * This file is part of the libsigrok project.
  3. *
  4. * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
  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 3 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, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef LIBSIGROK_HARDWARE_SERIAL_DMM_PROTOCOL_H
  20. #define LIBSIGROK_HARDWARE_SERIAL_DMM_PROTOCOL_H
  21. #define LOG_PREFIX "serial-dmm"
  22. enum {
  23. BBCGM_M2110,
  24. DIGITEK_DT4000ZC,
  25. TEKPOWER_TP4000ZC,
  26. METEX_ME31,
  27. PEAKTECH_3410,
  28. MASTECH_MAS345,
  29. VA_VA18B,
  30. VA_VA40B,
  31. METEX_M3640D,
  32. METEX_M4650CR,
  33. PEAKTECH_4370,
  34. PCE_PCE_DM32,
  35. RADIOSHACK_22_168,
  36. RADIOSHACK_22_805,
  37. RADIOSHACK_22_812,
  38. TECPEL_DMM_8061_SER,
  39. VOLTCRAFT_M3650CR,
  40. VOLTCRAFT_M3650D,
  41. VOLTCRAFT_M4650CR,
  42. VOLTCRAFT_ME42,
  43. VOLTCRAFT_VC820_SER,
  44. VOLTCRAFT_VC830_SER,
  45. VOLTCRAFT_VC840_SER,
  46. UNI_T_UT60A_SER,
  47. UNI_T_UT60E_SER,
  48. UNI_T_UT60G_SER,
  49. UNI_T_UT61B_SER,
  50. UNI_T_UT61C_SER,
  51. UNI_T_UT61D_SER,
  52. UNI_T_UT61E_SER,
  53. ISO_TECH_IDM103N,
  54. TENMA_72_7745_SER,
  55. TENMA_72_7750_SER,
  56. };
  57. struct dmm_info {
  58. /** Manufacturer/brand. */
  59. char *vendor;
  60. /** Model. */
  61. char *device;
  62. /** serialconn string. */
  63. char *conn;
  64. /** Baud rate. */
  65. uint32_t baudrate;
  66. /** Packet size in bytes. */
  67. int packet_size;
  68. /** Packet request function. */
  69. int (*packet_request)(struct sr_serial_dev_inst *);
  70. /** Packet validation function. */
  71. gboolean (*packet_valid)(const uint8_t *);
  72. /** Packet parsing function. */
  73. int (*packet_parse)(const uint8_t *, float *,
  74. struct sr_datafeed_analog *, void *);
  75. /** */
  76. void (*dmm_details)(struct sr_datafeed_analog *, void *);
  77. /** libsigrok driver info struct. */
  78. struct sr_dev_driver *di;
  79. /** Data reception function. */
  80. int (*receive_data)(int, int, void *);
  81. };
  82. extern SR_PRIV struct dmm_info dmms[];
  83. #define DMM_BUFSIZE 256
  84. /** Private, per-device-instance driver context. */
  85. struct dev_context {
  86. /** The current sampling limit (in number of samples). */
  87. uint64_t limit_samples;
  88. /** The time limit (in milliseconds). */
  89. uint64_t limit_msec;
  90. /** Opaque pointer passed in by the frontend. */
  91. void *cb_data;
  92. /** The current number of already received samples. */
  93. uint64_t num_samples;
  94. int64_t starttime;
  95. uint8_t buf[DMM_BUFSIZE];
  96. int bufoffset;
  97. int buflen;
  98. };
  99. SR_PRIV int receive_data_BBCGM_M2110(int fd, int revents, void *cb_data);
  100. SR_PRIV int receive_data_DIGITEK_DT4000ZC(int fd, int revents, void *cb_data);
  101. SR_PRIV int receive_data_TEKPOWER_TP4000ZC(int fd, int revents, void *cb_data);
  102. SR_PRIV int receive_data_METEX_ME31(int fd, int revents, void *cb_data);
  103. SR_PRIV int receive_data_PEAKTECH_3410(int fd, int revents, void *cb_data);
  104. SR_PRIV int receive_data_MASTECH_MAS345(int fd, int revents, void *cb_data);
  105. SR_PRIV int receive_data_VA_VA18B(int fd, int revents, void *cb_data);
  106. SR_PRIV int receive_data_VA_VA40B(int fd, int revents, void *cb_data);
  107. SR_PRIV int receive_data_METEX_M3640D(int fd, int revents, void *cb_data);
  108. SR_PRIV int receive_data_METEX_M4650CR(int fd, int revents, void *cb_data);
  109. SR_PRIV int receive_data_PEAKTECH_4370(int fd, int revents, void *cb_data);
  110. SR_PRIV int receive_data_PCE_PCE_DM32(int fd, int revents, void *cb_data);
  111. SR_PRIV int receive_data_RADIOSHACK_22_168(int fd, int revents, void *cb_data);
  112. SR_PRIV int receive_data_RADIOSHACK_22_805(int fd, int revents, void *cb_data);
  113. SR_PRIV int receive_data_RADIOSHACK_22_812(int fd, int revents, void *cb_data);
  114. SR_PRIV int receive_data_TECPEL_DMM_8061_SER(int fd, int revents, void *cb_data);
  115. SR_PRIV int receive_data_VOLTCRAFT_M3650CR(int fd, int revents, void *cb_data);
  116. SR_PRIV int receive_data_VOLTCRAFT_M3650D(int fd, int revents, void *cb_data);
  117. SR_PRIV int receive_data_VOLTCRAFT_M4650CR(int fd, int revents, void *cb_data);
  118. SR_PRIV int receive_data_VOLTCRAFT_ME42(int fd, int revents, void *cb_data);
  119. SR_PRIV int receive_data_VOLTCRAFT_VC820_SER(int fd, int revents, void *cb_data);
  120. SR_PRIV int receive_data_VOLTCRAFT_VC830_SER(int fd, int revents, void *cb_data);
  121. SR_PRIV int receive_data_VOLTCRAFT_VC840_SER(int fd, int revents, void *cb_data);
  122. SR_PRIV int receive_data_UNI_T_UT60A_SER(int fd, int revents, void *cb_data);
  123. SR_PRIV int receive_data_UNI_T_UT60E_SER(int fd, int revents, void *cb_data);
  124. SR_PRIV int receive_data_UNI_T_UT60G_SER(int fd, int revents, void *cb_data);
  125. SR_PRIV int receive_data_UNI_T_UT61B_SER(int fd, int revents, void *cb_data);
  126. SR_PRIV int receive_data_UNI_T_UT61C_SER(int fd, int revents, void *cb_data);
  127. SR_PRIV int receive_data_UNI_T_UT61D_SER(int fd, int revents, void *cb_data);
  128. SR_PRIV int receive_data_UNI_T_UT61E_SER(int fd, int revents, void *cb_data);
  129. SR_PRIV int receive_data_ISO_TECH_IDM103N(int fd, int revents, void *cb_data);
  130. SR_PRIV int receive_data_TENMA_72_7745_SER(int fd, int revents, void *cb_data);
  131. SR_PRIV int receive_data_TENMA_72_7750_SER(int fd, int revents, void *cb_data);
  132. #endif