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.
This commit is contained in:
Gerhard Sittig 2018-06-03 06:34:27 +02:00 committed by Uwe Hermann
parent a7b8692ed0
commit 1df81f4b06
10 changed files with 39 additions and 19 deletions

View File

@ -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

View File

@ -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

View File

@ -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. */

View File

@ -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.
*

View File

@ -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';

View File

@ -20,8 +20,9 @@
#include <config.h>
#include <glib.h>
#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
#ifndef HAVE_LIBSERIALPORT
#ifndef HAVE_SERIAL_COMM
SR_API GSList *sr_serial_list(const struct sr_dev_driver *driver)
{

View File

@ -26,6 +26,8 @@
#ifndef LIBSIGROK_LIBSIGROK_INTERNAL_H
#define LIBSIGROK_LIBSIGROK_INTERNAL_H
#include "config.h"
#include <glib.h>
#ifdef HAVE_LIBSERIALPORT
#include <libserialport.h>
@ -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);

View File

@ -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
};

View File

@ -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
};

View File

@ -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