]> sigrok.org Git - libsigrok.git/blobdiff - libsigrok-internal.h
Use libserialport for serial port access.
[libsigrok.git] / libsigrok-internal.h
index 2c2cccf40ec5530113164b5c83b716636c77c635..ebbcca9b21d9f51ea4b9baf1b2802339ed0a2436 100644 (file)
@@ -26,6 +26,7 @@
 #ifdef HAVE_LIBUSB_1_0
 #include <libusb.h>
 #endif
+#include <serialport.h>
 
 /**
  * @file
 #define ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a)
 #endif
 
+/* Portability fixes for FreeBSD. */
+#ifdef __FreeBSD__
+#define LIBUSB_CLASS_APPLICATION 0xfe
+#define libusb_handle_events_timeout_completed(ctx, tv, c) \
+       libusb_handle_events_timeout(ctx, tv)
+#endif
+
 struct sr_context {
 #ifdef HAVE_LIBUSB_1_0
        libusb_context *libusb_ctx;
@@ -57,13 +65,14 @@ struct sr_usb_dev_inst {
 };
 #endif
 
-#define SERIAL_PARITY_NONE 0
-#define SERIAL_PARITY_EVEN 1
-#define SERIAL_PARITY_ODD  2
+#define SERIAL_PARITY_NONE SP_PARITY_NONE
+#define SERIAL_PARITY_EVEN SP_PARITY_EVEN
+#define SERIAL_PARITY_ODD  SP_PARITY_ODD
 struct sr_serial_dev_inst {
        char *port;
        char *serialcomm;
        int fd;
+       struct sp_port data;
 };
 
 /* Private driver context. */
@@ -200,7 +209,11 @@ SR_PRIV int sr_es51922_parse(const uint8_t *buf, float *floatval,
 
 /*--- hardware/common/dmm/es519xx.c -----------------------------------------*/
 
-#define ES519XX_11B_PACKET_SIZE 11
+/**
+ * All 11-byte es519xx chips repeat each block twice for each conversion cycle
+ * so always read 2 blocks at a time.
+ */
+#define ES519XX_11B_PACKET_SIZE (11 * 2)
 #define ES519XX_14B_PACKET_SIZE 14
 
 struct es519xx_info {
@@ -280,8 +293,9 @@ SR_PRIV void sr_fs9721_01_10_temp_f_c(struct sr_datafeed_analog *analog, void *i
 struct metex14_info {
        gboolean is_ac, is_dc, is_resistance, is_capacity, is_temperature;
        gboolean is_diode, is_frequency, is_ampere, is_volt, is_farad;
-       gboolean is_hertz, is_ohm, is_celsius, is_nano, is_micro, is_milli;
-       gboolean is_kilo, is_mega, is_gain, is_decibel, is_hfe, is_unitless;
+       gboolean is_hertz, is_ohm, is_celsius, is_pico, is_nano, is_micro;
+       gboolean is_milli, is_kilo, is_mega, is_gain, is_decibel, is_hfe;
+       gboolean is_unitless;
 };
 
 SR_PRIV int sr_metex14_packet_request(struct sr_serial_dev_inst *serial);