From: Gerhard Sittig Date: Sun, 3 Jun 2018 04:34:27 +0000 (+0200) Subject: serial: introduce more general "have serial comm" feature flag X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1df81f4b062fcfe8c6de4d2e5edf9743030ae0fc;p=libsigrok.git serial: introduce more general "have serial comm" feature flag Introduce the HAVE_SERIAL_COMM identifier, which gets derived from, but need not be identical to the HAVE_LIBSERIALPORT condition. Derive the NEED_SERIAL automake condition from the general availability of serial communication not the specific libserialport library. Adjust source code references. Stick with HAVE_LIBSERIALPORT where the specific library is meant, but switch to HAVE_SERIAL_COMM where the availability of serial communication in general is meant. --- diff --git a/configure.ac b/configure.ac index 50787cde..b4757c97 100644 --- a/configure.ac +++ b/configure.ac @@ -96,7 +96,7 @@ SR_PKGLIBS_RUBY= SR_EXTRA_LIBS= SR_EXTRA_CXX_LIBS= -SR_ARG_OPT_PKG([libserialport], [LIBSERIALPORT], [NEED_SERIAL], +SR_ARG_OPT_PKG([libserialport], [LIBSERIALPORT], , [libserialport >= 0.1.1]) SR_ARG_OPT_PKG([libftdi], [LIBFTDI], , [libftdi1 >= 1.0]) @@ -130,6 +130,14 @@ SR_ARG_OPT_CHECK([libieee1284], [LIBIEEE1284],, [ AS_IF([test "x$sr_have_libieee1284" = xyes], [SR_PREPEND([SR_EXTRA_LIBS], [-lieee1284])]) +AS_IF([test "x$sr_have_libserialport" = xyes], + sr_have_serial_comm=yes, sr_have_serial_comm=no) +AS_IF([test "x$sr_have_serial_comm" = xyes], + [AC_DEFINE([HAVE_SERIAL_COMM], [1], [Specifies whether serial communication is supported.])]) +AS_IF([test "x$sr_have_serial_comm" = xyes], + [SR_APPEND([sr_deps_avail], [serial_comm])]) +AM_CONDITIONAL([NEED_SERIAL], [test "x$sr_have_serial_comm" = xyes]) + ###################### ## Feature checks ## ###################### @@ -218,6 +226,11 @@ m4_define([_SR_DRIVER], [ m4_define([SR_DRIVER], [_SR_DRIVER([$1], [$2], m4_expand([AS_TR_CPP([HW_$2])]), [$3])]) +# TODO +# Make device drivers depend on the more generic HAVE_SERIAL_COMM +# feature flag instead of the specific libserialport, which no longer +# is the exclusive provider of serial communication support. + SR_DRIVER([Agilent DMM], [agilent-dmm], [libserialport]) SR_DRIVER([Appa 55II], [appa-55ii], [libserialport]) SR_DRIVER([Arachnid Labs Re:load Pro], [arachnid-labs-re-load-pro], [libserialport]) @@ -601,10 +614,14 @@ Detected libraries (optional): $sr_pkglibs_summary Enabled hardware drivers: $sr_driver_summary +Enabled serial communication transports: + - serial comm ................... $sr_have_serial_comm + - libserialport ................. $sr_have_libserialport + Enabled SCPI backends: - TCP............................. yes - RPC............................. $sr_cv_have_rpc - - serial.......................... $sr_have_libserialport + - serial.......................... $sr_have_serial_comm - VISA............................ $sr_have_librevisa - GPIB............................ $sr_have_libgpib - USBTMC.......................... $sr_have_libusb diff --git a/src/backend.c b/src/backend.c index 1fbba5c1..a5d5749b 100644 --- a/src/backend.c +++ b/src/backend.c @@ -205,7 +205,7 @@ SR_API char *sr_buildinfo_scpi_backends_get(void) #if HAVE_RPC g_string_append_printf(s, "RPC, "); #endif -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM g_string_append_printf(s, "serial, "); #endif #ifdef HAVE_LIBREVISA diff --git a/src/device.c b/src/device.c index 20ab882b..4642e5f0 100644 --- a/src/device.c +++ b/src/device.c @@ -518,7 +518,7 @@ SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_dev_inst *usb) #endif -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM /** * Allocate and init a struct for a serial device instance. @@ -814,7 +814,7 @@ SR_API const char *sr_dev_inst_connid_get(const struct sr_dev_inst *sdi) struct libusb_device **devlist; #endif -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM struct sr_serial_dev_inst *serial; #endif @@ -824,7 +824,7 @@ SR_API const char *sr_dev_inst_connid_get(const struct sr_dev_inst *sdi) if (!sdi) return NULL; -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM if ((!sdi->connection_id) && (sdi->inst_type == SR_INST_SERIAL)) { /* connection_id isn't populated, let's do that for serial devices. */ diff --git a/src/dmm/asycii.c b/src/dmm/asycii.c index f32cbfef..b34ec70b 100644 --- a/src/dmm/asycii.c +++ b/src/dmm/asycii.c @@ -446,7 +446,7 @@ static gboolean flags_valid(const struct asycii_info *info) return TRUE; } -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM /** * Arrange for the reception of another measurement from the DMM. * diff --git a/src/dmm/metex14.c b/src/dmm/metex14.c index b610aba9..d363c550 100644 --- a/src/dmm/metex14.c +++ b/src/dmm/metex14.c @@ -329,7 +329,7 @@ static gboolean flags_valid(const struct metex14_info *info) return TRUE; } -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM SR_PRIV int sr_metex14_packet_request(struct sr_serial_dev_inst *serial) { const uint8_t wbuf = 'D'; diff --git a/src/fallback.c b/src/fallback.c index 9a4a536b..ef70d509 100644 --- a/src/fallback.c +++ b/src/fallback.c @@ -20,8 +20,9 @@ #include #include #include +#include "libsigrok-internal.h" -#ifndef HAVE_LIBSERIALPORT +#ifndef HAVE_SERIAL_COMM SR_API GSList *sr_serial_list(const struct sr_dev_driver *driver) { diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index 9384bbb6..3ea3590a 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -26,6 +26,8 @@ #ifndef LIBSIGROK_LIBSIGROK_INTERNAL_H #define LIBSIGROK_LIBSIGROK_INTERNAL_H +#include "config.h" + #include #ifdef HAVE_LIBSERIALPORT #include @@ -721,7 +723,7 @@ struct sr_usb_dev_inst { }; #endif -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM struct ser_lib_functions; struct sr_serial_dev_inst { /** Port name, e.g. '/dev/tty42'. */ @@ -840,7 +842,7 @@ SR_PRIV struct sr_usb_dev_inst *sr_usb_dev_inst_new(uint8_t bus, SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_dev_inst *usb); #endif -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM /* Serial-specific instances */ SR_PRIV struct sr_serial_dev_inst *sr_serial_dev_inst_new(const char *port, const char *serialcomm); @@ -957,7 +959,7 @@ SR_PRIV int std_dummy_dev_open(struct sr_dev_inst *sdi); SR_PRIV int std_dummy_dev_close(struct sr_dev_inst *sdi); SR_PRIV int std_dummy_dev_acquisition_start(const struct sr_dev_inst *sdi); SR_PRIV int std_dummy_dev_acquisition_stop(struct sr_dev_inst *sdi); -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM SR_PRIV int std_serial_dev_open(struct sr_dev_inst *sdi); SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi); #endif @@ -1067,7 +1069,7 @@ SR_PRIV int soft_trigger_logic_check(struct soft_trigger_logic *st, uint8_t *buf /*--- serial.c --------------------------------------------------------------*/ -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM enum { SERIAL_RDWR = 1, SERIAL_RDONLY = 2, @@ -1385,7 +1387,7 @@ struct metex14_info { gboolean is_hfe, is_unitless, is_logic, is_min, is_max, is_avg; }; -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM SR_PRIV int sr_metex14_packet_request(struct sr_serial_dev_inst *serial); #endif SR_PRIV gboolean sr_metex14_packet_valid(const uint8_t *buf); @@ -1516,7 +1518,7 @@ struct asycii_info { gboolean is_invalid; }; -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM SR_PRIV int sr_asycii_packet_request(struct sr_serial_dev_inst *serial); #endif SR_PRIV gboolean sr_asycii_packet_valid(const uint8_t *buf); diff --git a/src/modbus/modbus.c b/src/modbus/modbus.c index 3c660a18..88be136c 100644 --- a/src/modbus/modbus.c +++ b/src/modbus/modbus.c @@ -28,7 +28,7 @@ SR_PRIV extern const struct sr_modbus_dev_inst modbus_serial_rtu_dev; static const struct sr_modbus_dev_inst *modbus_devs[] = { -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM &modbus_serial_rtu_dev, /* Must be last as it matches any resource. */ #endif }; diff --git a/src/scpi/scpi.c b/src/scpi/scpi.c index 4f72d6e6..31f82a3f 100644 --- a/src/scpi/scpi.c +++ b/src/scpi/scpi.c @@ -100,7 +100,7 @@ static const struct sr_scpi_dev_inst *scpi_devs[] = { #ifdef HAVE_LIBGPIB &scpi_libgpib_dev, #endif -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM &scpi_serial_dev, /* Must be last as it matches any resource. */ #endif }; diff --git a/src/std.c b/src/std.c index 6a6c80ad..b6a0fc9c 100644 --- a/src/std.c +++ b/src/std.c @@ -305,7 +305,7 @@ SR_PRIV int std_session_send_frame_end(const struct sr_dev_inst *sdi) return SR_OK; } -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM /** * Standard serial driver dev_open() callback API helper. @@ -454,7 +454,7 @@ SR_PRIV int std_dev_clear_with_callback(const struct sr_dev_driver *driver, driver->dev_close(sdi); if (sdi->conn) { -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM if (sdi->inst_type == SR_INST_SERIAL) sr_serial_dev_inst_free(sdi->conn); #endif