summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2022-04-01 16:15:49 +0200
committerMartin Burnicki <martin.burnicki@meinberg.de>2022-07-08 17:21:00 +0200
commita5b8957046d2d8d0bfb6e5e1ac7d45b51cce18f6 (patch)
tree600238afa6cb7754af94ad4b6b9edd578d7561a0
parent5db9b6b4bb5fc750b9221f005a7fa0eb1643694b (diff)
downloadmbgtools-win-a5b8957046d2d8d0bfb6e5e1ac7d45b51cce18f6.tar.gz
mbgtools-win-a5b8957046d2d8d0bfb6e5e1ac7d45b51cce18f6.zip
Update some mbglib files
-rw-r--r--mbglib/common/mbg_tgt.h7
-rw-r--r--mbglib/common/mbgdevio.h16
-rw-r--r--mbglib/common/mbgerror.c14
-rw-r--r--mbglib/common/mbgerror.h10
-rw-r--r--mbglib/common/mbgsystm.h43
-rw-r--r--mbglib/common/pcpsdefs.h61
-rw-r--r--mbglib/common/pcpsdev.h105
-rw-r--r--mbglib/common/toolutil.c79
-rw-r--r--mbglib/common/toolutil.h30
-rw-r--r--mbglib/common/words.h27
10 files changed, 291 insertions, 101 deletions
diff --git a/mbglib/common/mbg_tgt.h b/mbglib/common/mbg_tgt.h
index fb8991b..a7a7a92 100644
--- a/mbglib/common/mbg_tgt.h
+++ b/mbglib/common/mbg_tgt.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_tgt.h 1.52 2021/10/05 09:10:44Z martin REL_M $
+ * $Id: mbg_tgt.h 1.53 2022/03/17 16:38:57Z martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,6 +11,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_tgt.h $
+ * Revision 1.53 2022/03/17 16:38:57Z martin.burnicki
+ * Added definitions MBG_DEV_HANDLE_FMT.
* Revision 1.52 2021/10/05 09:10:44Z martin
* Clean up definitions _MBG_API_ATTR_EXPORT and _MBG_API_ATTR_IMPORT.
* Revision 1.51 2021/09/13 08:59:55 martin
@@ -936,6 +938,7 @@ extern "C" {
#include <ws2tcpip.h>
typedef HANDLE MBG_HANDLE;
+ #define MBG_DEV_HANDLE_FMT "%p"
#define MBG_INVALID_HANDLE INVALID_HANDLE_VALUE
@@ -997,6 +1000,7 @@ extern "C" {
typedef int MBG_HANDLE;
typedef int MBG_PORT_HANDLE;
+ #define MBG_DEV_HANDLE_FMT "%i"
#define MBG_INVALID_HANDLE -1
@@ -1004,6 +1008,7 @@ extern "C" {
typedef int MBG_HANDLE;
typedef int MBG_PORT_HANDLE;
+ #define MBG_DEV_HANDLE_FMT "%i"
#define MBG_INVALID_HANDLE -1
diff --git a/mbglib/common/mbgdevio.h b/mbglib/common/mbgdevio.h
index 6b5242b..f17ca2b 100644
--- a/mbglib/common/mbgdevio.h
+++ b/mbglib/common/mbgdevio.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgdevio.h 1.59 2021/11/08 21:31:51Z martin.burnicki REL_M $
+ * $Id: mbgdevio.h 1.60 2022/02/10 13:56:19Z martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbgdevio.h $
- * Revision 1.59 2021/11/08 21:31:51Z martin.burnicki
+ * Revision 1.60 2022/02/10 13:56:19Z martin.burnicki
+ * Fixed some doxygen comments.
+ * Revision 1.59 2021/11/08 21:31:51 martin.burnicki
* Updated function prototypes.
* Revision 1.58 2021/11/08 18:00:06 martin.burnicki
* Changed MBG_DEV_FN to a structure.
@@ -3313,7 +3315,7 @@ typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh );
/**
* @brief Read time zone/daylight saving configuration code from a device.
*
- * The APIs using ::TZCODE are only supported by some simpler devices
+ * The APIs using ::PCPS_TZCODE are only supported by some simpler devices
* and allow just a very basic configuration.
*
* The API call ::mbg_chk_dev_has_tzcode checks whether
@@ -3338,7 +3340,7 @@ typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh );
/**
* @brief Write time zone/daylight saving configuration code to a device.
*
- * The APIs using ::TZCODE are only supported by some simpler devices
+ * The APIs using ::PCPS_TZCODE are only supported by some simpler devices
* and allow only a very basic configuration.
*
* The API call ::mbg_chk_dev_has_tzcode checks whether
@@ -3364,8 +3366,8 @@ typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh );
* @brief Read time zone/daylight saving parameters from a device.
*
* This function fills up a ::PCPS_TZDL structure which supports a more
- * detailed configuration of time zone and daylight saving than the ::TZCODE
- * structure.
+ * detailed configuration of time zone and daylight saving than the ::PCPS_TZCODE
+ * type.
*
* The API call ::mbg_chk_dev_has_pcps_tzdl checks whether
* this call is supported by a device.
@@ -3390,7 +3392,7 @@ typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh );
*
* This function passes a ::PCPS_TZDL structure to a device which supports
* a more detailed configuration of time zone and daylight saving than the
- * ::TZCODE structure.
+ * ::PCPS_TZCODE type.
*
* The API call ::mbg_chk_dev_has_pcps_tzdl checks whether
* this call is supported by a device.
diff --git a/mbglib/common/mbgerror.c b/mbglib/common/mbgerror.c
index 2c4be21..efb2a73 100644
--- a/mbglib/common/mbgerror.c
+++ b/mbglib/common/mbgerror.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgerror.c 1.12 2021/03/16 12:20:57Z martin REL_M $
+ * $Id: mbgerror.c 1.13 2021/12/01 15:51:16Z martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbgerror.c $
- * Revision 1.12 2021/03/16 12:20:57Z martin
+ * Revision 1.13 2021/12/01 15:51:16Z martin.burnicki
+ * New error code MBG_ERR_OP_NOT_SUPP for EOPNOTSUPP and ENOTSUP.
+ * Revision 1.12 2021/03/16 12:20:57 martin
* Updated some comments.
* Revision 1.11 2021/03/12 12:32:15 martin
* Updated some comments.
@@ -228,6 +230,12 @@ static ERRNO_CNV_ENTRY posix_errno_table[] =
#if defined( ENOTSOCK )
{ ENOTSOCK, MBG_ERR_NOT_A_SOCKET }, // 88, Socket operation on non-socket (file descriptor is not a socket).
#endif
+#if defined( EOPNOTSUPP)
+ { EOPNOTSUPP, MBG_ERR_OP_NOT_SUPP }, // 95, Operation not supported.
+#endif
+#if defined( ENOTSUP)
+ { ENOTSUP, MBG_ERR_OP_NOT_SUPP }, // (On some systems same as EOPNOTSUPP, but may be different on other systems)
+#endif
#if defined( ECONNRESET )
{ ECONNRESET, MBG_ERR_CONN_RESET }, // 104, Connection reset by peer.
#endif
@@ -545,7 +553,7 @@ static ERRNO_CNV_ENTRY win32_wsa_err_table[] =
// { WSAENOPROTOOPT // 10042L An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call.
// { WSAEPROTONOSUPPORT // 10043L The requested protocol has not been configured into the system, or no implementation for it exists.
// { WSAESOCKTNOSUPPORT // 10044L The support for the specified socket type does not exist in this address family.
- // { WSAEOPNOTSUPP // 10045L The attempted operation is not supported for the type of object referenced.
+ { WSAEOPNOTSUPP, MBG_ERR_OP_NOT_SUPP }, // 10045L The attempted operation is not supported for the type of object referenced.
// { WSAEPFNOSUPPORT // 10046L The protocol family has not been configured into the system or no implementation for it exists.
// { WSAEAFNOSUPPORT // 10047L An address incompatible with the requested protocol was used.
// { WSAEADDRINUSE // 10048L Only one usage of each socket address (protocol/network address/port) is normally permitted.
diff --git a/mbglib/common/mbgerror.h b/mbglib/common/mbgerror.h
index fada6d3..04d629f 100644
--- a/mbglib/common/mbgerror.h
+++ b/mbglib/common/mbgerror.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgerror.h 1.33 2021/11/03 16:57:02Z martin.burnicki REL_M $
+ * $Id: mbgerror.h 1.34 2021/12/01 15:51:25Z martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,7 +11,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbgerror.h $
- * Revision 1.33 2021/11/03 16:57:02Z martin.burnicki
+ * Revision 1.34 2021/12/01 15:51:25Z martin.burnicki
+ * New error code MBG_ERR_OP_NOT_SUPP for EOPNOTSUPP and ENOTSUP.
+ * Revision 1.33 2021/11/03 16:57:02 martin.burnicki
* Added MBG_ERR_NOT_SUPP_BY_DRVR.
* Revision 1.32 2021/04/13 08:27:01 martin
* Updated some comments.
@@ -430,6 +432,7 @@ extern "C" {
#define MBG_ERR_NAME -123 ///< Invalid name
#define MBG_ERR_NOT_SUPP_BY_DRVR -124 ///< Requested feature is not supported by the driver
+#define MBG_ERR_OP_NOT_SUPP -125 ///< Requested operation is not supported
// NOTE: New codes have to be appended to this list, and the sequence of codes must not
// be changed. Whenever new codes have been defined, appropriate entries have to be added
@@ -538,7 +541,8 @@ extern "C" {
{ MBG_ERR_INV_USER, "Invalid user" }, \
{ MBG_ERR_INV_GROUP, "Invalid group" }, \
{ MBG_ERR_NAME, "Invalid name" }, \
- { MBG_ERR_NOT_SUPP_BY_DRVR, "Not supported by the driver" }
+ { MBG_ERR_NOT_SUPP_BY_DRVR, "Not supported by the driver" }, \
+ { MBG_ERR_OP_NOT_SUPP, "Requested operation is not supported" }
/**
diff --git a/mbglib/common/mbgsystm.h b/mbglib/common/mbgsystm.h
index c16212d..19eee86 100644
--- a/mbglib/common/mbgsystm.h
+++ b/mbglib/common/mbgsystm.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgsystm.h 1.12 2021/05/31 09:51:09Z thomas-b REL_M $
+ * $Id: mbgsystm.h 1.13 2021/11/29 14:32:13Z martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,7 +11,13 @@
*
* -----------------------------------------------------------------------
* $Log: mbgsystm.h $
- * Revision 1.12 2021/05/31 09:51:09Z thomas-b
+ * Revision 1.13 2021/11/29 14:32:13Z martin.burnicki
+ * Commonly use new macros _mbg_sys_time_from_timespec() and
+ * _mbg_sys_time_from_timeval() which are based on the new macros
+ * _nano_time_64_from_timespec() and _nano_time_64_from_timeval()
+ * defined in words.h.
+ * New macro _mbg_sys_timestamp_is_empty().
+ * Revision 1.12 2021/05/31 09:51:09 thomas-b
* Fixed missing include for POSIX systems (we need mbgtime for NSEC_PER_SEC)
* Revision 1.11 2021/05/11 19:04:58 martin
* Changed mbg_sleep_sec() to mbg_sleep_msec(), which expects milliseconds,
@@ -158,6 +164,15 @@ extern "C" {
typedef NANO_TIME_64 MBG_SYS_TIME;
typedef int64_t MBG_SYS_UPTIME; // [s]
+ #define _mbg_sys_timestamp_is_empty( _p ) \
+ _nano_time_64_zero( _p )
+
+ #define _mbg_sys_time_from_timespec( _p, _p_ts ) \
+ _nano_time_64_from_timespec( _p, _p_ts )
+
+ #define _mbg_sys_time_from_timeval( _p, _p_ts ) \
+ _nano_time_64_from_timeval( _p, _p_ts )
+
#elif defined( MBG_TGT_WIN32 )
typedef int64_t MBG_SYS_TIME; // Number of 100ns units.
@@ -180,6 +195,11 @@ extern "C" {
#endif
+#if !defined( _mbg_sys_timestamp_is_empty )
+ #define _mbg_sys_timestamp_is_empty( _p ) \
+ ( *(_p) == 0 )
+#endif
+
// MBG_SYS_TIME is always read in native machine endianess,
// so no need to convert endianess.
#define _mbg_swab_mbg_sys_time( _p ) \
@@ -210,18 +230,14 @@ void mbg_get_sys_time( MBG_SYS_TIME *p )
struct timespec64 ts;
ktime_get_real_ts64( &ts );
-
- p->secs = ts.tv_sec;
- p->nano_secs = ts.tv_nsec;
+ _mbg_sys_time_from_timespec( p, &ts );
}
#elif LINUX_KERNEL_HAS_GETNSTIMEOFDAY
{
struct timespec ts;
getnstimeofday( &ts );
-
- p->secs = ts.tv_sec;
- p->nano_secs = ts.tv_nsec;
+ _mbg_sys_time_from_timespec( p, &ts );
}
#else
{
@@ -229,9 +245,7 @@ void mbg_get_sys_time( MBG_SYS_TIME *p )
struct timeval tv;
do_gettimeofday( &tv );
-
- p->secs = tv.tv_sec;
- p->nano_secs = tv.tv_usec * 1000;
+ _mbg_sys_time_from_timeval( p, &tv );
}
#endif
@@ -240,9 +254,7 @@ void mbg_get_sys_time( MBG_SYS_TIME *p )
struct timespec ts;
nanotime( &ts );
-
- p->secs = ts.tv_sec;
- p->nano_secs = ts.tv_nsec;
+ _mbg_sys_time_from_timespec( p, &ts );
}
#endif
@@ -256,8 +268,7 @@ void mbg_get_sys_time( MBG_SYS_TIME *p )
clock_gettime( CLOCK_REALTIME, &ts );
#endif
- p->secs = ts.tv_sec;
- p->nano_secs = ts.tv_nsec;
+ _mbg_sys_time_from_timespec( p, &ts );
}
#endif
diff --git a/mbglib/common/pcpsdefs.h b/mbglib/common/pcpsdefs.h
index 3e71254..c22e141 100644
--- a/mbglib/common/pcpsdefs.h
+++ b/mbglib/common/pcpsdefs.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdefs.h 1.70 2021/03/21 22:35:01Z martin REL_M $
+ * $Id: pcpsdefs.h 1.73 2022/03/16 16:18:59Z martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,12 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdefs.h $
+ * Revision 1.73 2022/03/16 16:18:59Z martin.burnicki
+ * Reserved PCI ID range 0x0A00 to 0x0AFF for Oregano PCI cards.
+ * Revision 1.72 2022/02/10 12:08:50 martin.burnicki
+ * Fixed a doxygen comment, removed some trailing spaces.
+ * Revision 1.71 2022/01/07 11:19:31 torben.mueller
+ * Added FREE_DELAY_MINUTES type.
* Revision 1.70 2021/03/21 22:35:01Z martin
* Updated a bunch of comments.
* Revision 1.69 2021/03/18 11:08:15 martin
@@ -302,16 +308,18 @@
*/
enum PCPS_REF_TYPES
{
- PCPS_REF_NONE, ///< Unknown, or not defined.
- PCPS_REF_DCF, ///< DCF77 long wave signal (Germany), see http://www.meinberg.de/english/info/dcf77.htm
- PCPS_REF_GPS, ///< GPS satellite system, see http://www.meinberg.de/english/info/gps.htm
- PCPS_REF_IRIG, ///< IRIG or similar time code, see http://www.meinberg.de/english/info/irig.htm
- PCPS_REF_MSF, ///< MSF long wave signal (UK).
- PCPS_REF_PTP, ///< PTP/IEEE1588 network protocol.
- PCPS_REF_FRC, ///< Free Running Clock.
- PCPS_REF_WWVB, ///< WWVB long wave signal (U.S.).
- PCPS_REF_JJY, ///< JJY long wave signal (Japan).
- N_PCPS_REF ///< Number of defined ref time sources.
+ PCPS_REF_NONE, ///< Unknown, or not defined.
+ PCPS_REF_DCF, ///< DCF77 long wave signal (Germany), see http://www.meinberg.de/english/info/dcf77.htm
+ PCPS_REF_GPS, ///< GPS satellite system, see http://www.meinberg.de/english/info/gps.htm
+ PCPS_REF_IRIG, ///< IRIG or similar time code, see http://www.meinberg.de/english/info/irig.htm
+ PCPS_REF_MSF, ///< MSF long wave signal (UK).
+ PCPS_REF_PTP, ///< PTP/IEEE1588 network protocol.
+ PCPS_REF_FRC, ///< Free Running Clock.
+ PCPS_REF_WWVB, ///< WWVB long wave signal (U.S.).
+ PCPS_REF_JJY, ///< JJY long wave signal (Japan).
+ PCPS_REF_RSVD, ///< Reserved, can be assigned later.
+ PCPS_REF_OREGANO, ///< 0x0A00..0x0AFF is reserved for Oregano PCI cards.
+ N_PCPS_REF ///< Number of defined ref time sources.
};
@@ -332,6 +340,8 @@ enum PCPS_REF_TYPES
#define PCPS_REF_NAME_FRC "FRC"
#define PCPS_REF_NAME_WWVB "WWVB"
#define PCPS_REF_NAME_JJY "JJY"
+#define PCPS_REF_NAME_RSVD "(reserved)"
+#define PCPS_REF_NAME_OREGANO "Oregano"
/** @} @defgroup group_pcps_ref_type_names */
@@ -351,7 +361,9 @@ enum PCPS_REF_TYPES
PCPS_REF_NAME_PTP, \
PCPS_REF_NAME_FRC, \
PCPS_REF_NAME_WWVB, \
- PCPS_REF_NAME_JJY \
+ PCPS_REF_NAME_JJY, \
+ PCPS_REF_NAME_RSVD, \
+ PCPS_REF_NAME_OREGANO \
}
@@ -370,7 +382,9 @@ enum PCPS_REF_TYPES
{ PCPS_REF_NAME_PTP, NULL }, \
{ PCPS_REF_NAME_FRC, NULL }, \
{ PCPS_REF_NAME_WWVB, NULL }, \
- { PCPS_REF_NAME_JJY, NULL } \
+ { PCPS_REF_NAME_JJY, NULL }, \
+ { PCPS_REF_NAME_RSVD, NULL }, \
+ { PCPS_REF_NAME_OREGANO, NULL } \
}
@@ -439,7 +453,7 @@ enum PCPS_REF_TYPES
/**
* @brief Type of the status register port.
- *
+ *
* @see @ref PCPS_STATUS_PORT_BIT_MASKS.
*/
typedef uint8_t PCPS_STATUS_PORT;
@@ -476,7 +490,7 @@ typedef uint8_t PCPS_STATUS_PORT;
/**
* @brief A format string to be used with snprintb().
- *
+ *
* The function snprintb() is available on some Unix systems
* to print information held in a bit coded variable.
*/
@@ -1154,7 +1168,7 @@ typedef uint8_t PCPS_SIG_VAL;
*
* These constants are used to draw a signal bar
* depending on the signal value of a DCF77 receiver.
- *
+ *
* @{ */
#define PCPS_SIG_BIAS 55
@@ -1170,7 +1184,7 @@ typedef uint8_t PCPS_SIG_VAL;
*
* These constants are used by devices that are not longwave receivers
* (e.g. GPS, GNSS, TCR) to indicate whether an input signal is available, or not.
- *
+ *
* @{ */
#define PCPS_SIG_LVL_SIG_NOT_AVAIL 0
@@ -1598,6 +1612,17 @@ typedef uint16_t TR_DISTANCE; ///< Range may vary with receiver type.
_mbg_swab16( _p )
+
+/**
+ * @brief Free run delay of the PZF [min].
+ */
+typedef uint16_t FREE_DELAY_MINUTES; ///< Free run delay of the PZF in minutes.
+
+#define _mbg_swab_free_delay( _p ) \
+ _mbg_swab16( _p )
+
+
+
/**
* @brief PZF correlation status info.
*/
@@ -1688,7 +1713,7 @@ enum PC_GPS_CMD_CODES
PC_GPS_UCAP, ///< (r/-) ::TTM, user capture events, deprecated by ::PCPS_GIVE_UCAP_EVENT.
PC_GPS_ENABLE_FLAGS, ///< (r/w) ::ENABLE_FLAGS, when to enable serial, pulses, and synth, only if ::GPS_MODEL_HAS_ENABLE_FLAGS.
- PC_GPS_STAT_INFO, ///< (r/-) ::GPS_STAT_INFO, satellite info, mode of operation, and DAC info, only if ::GPS_MODEL_HAS_STAT_INFO.
+ PC_GPS_STAT_INFO, ///< (r/-) ::STAT_INFO, satellite info, mode of operation, and DAC info, only if ::GPS_MODEL_HAS_STAT_INFO.
PC_GPS_CMD, ///< (-/w) ::GPS_CMD, send one of the ::PC_GPS_COMMANDS.
PC_GPS_IDENT, ///< (r/-) ::IDENT, serial number, deprecated by ::PC_GPS_RECEIVER_INFO.
PC_GPS_POS, ///< (r/-) ::POS, position ::XYZ, ::LLA, and ::DMS combined, only if ::GPS_MODEL_HAS_POS.
diff --git a/mbglib/common/pcpsdev.h b/mbglib/common/pcpsdev.h
index 34cea76..5727b24 100644
--- a/mbglib/common/pcpsdev.h
+++ b/mbglib/common/pcpsdev.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdev.h 1.65 2021/04/29 15:06:04Z martin REL_M $
+ * $Id: pcpsdev.h 1.67 2022/03/30 15:35:49Z martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -17,7 +17,14 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdev.h $
- * Revision 1.65 2021/04/29 15:06:04Z martin
+ * Revision 1.67 2022/03/30 15:35:49Z martin.burnicki
+ * New inline function setup_default_receiver_info() which is used to
+ * set up a RECEIVER_INFO structure for devices that don't provide one,
+ * and also copies the device name into the model_name field.
+ * Revision 1.66 2022/03/21 16:35:45 martin.burnicki
+ * Enable TZDL support for TCR180USB only with firmware v1.18 and newer
+ * because the implementation in earlier FW versions was faulty.
+ * Revision 1.65 2021/04/29 15:06:04 martin
* Support reading device CPU info.
* Revision 1.64 2021/03/22 18:11:17 martin
* Updated a bunch of comments.
@@ -1008,13 +1015,11 @@ enum PCPS_FEATURE_BITS
#define PCPS_FEAT_GNS181PEX ( PCPS_FEAT_GLN180PEX )
#define PCPS_FEAT_TCR180USB ( PCPS_FEAT_TCR600USB \
- | PCPS_HAS_TZDL \
| PCPS_HAS_RECEIVER_INFO \
- | PCPS_HAS_GPS_DATA_16 \
- | PCPS_CAN_CLR_UCAP_BUFF /* TODO ? */ \
- | PCPS_HAS_UCAP /* TODO ? */ \
- | PCPS_HAS_GENERIC_IO /* TODO ? */ )
- ///< IRIG TX only supported if ::GPS_HAS_IRIG_TX.
+ | PCPS_HAS_GPS_DATA_16 )
+ ///< IRIG TX only supported if ::GPS_HAS_IRIG_TX.<br>
+ ///< PCPS_HAS_TZDL is only supported with firmware ::REV_HAS_TZDL_TCR180USB
+ ///< and newer. Implementation is faulty in earlier firmware versions.
/** @} defgroup group_pcps_dev_features */
@@ -1034,7 +1039,7 @@ enum PCPS_FEATURE_BITS
#define REV_HAS_IRQ_FIX_MINOR_PEX511 0x0106
#define REV_HAS_IRQ_FIX_MINOR_TCR511PEX 0x0105
#define REV_HAS_IRQ_FIX_MINOR_GPS170PEX 0x0104
-// Additionally there are certain revisions of the bus interface logic
+// Additionally, there are certain revisions of the bus interface logic
// required. The associated version codes are defined in pci_asic.h.
// The macro below can be used to check whether the required versions are there:
@@ -1044,74 +1049,78 @@ enum PCPS_FEATURE_BITS
(_curr_asic_ver), (_req_asic_ver_major), (_req_asic_ver_minor ) ) \
)
-/* command PCPS_GIVE_RAW_IRIG_DATA: */
+// Command PC_GPS_TZDL:
+#define REV_HAS_TZDL_TCR180USB 0x118 // Also supported by earlier versions, but faulty.
+
+// Command PCPS_GIVE_RAW_IRIG_DATA:
#define REV_HAS_RAW_IRIG_DATA_TCR511PEX 0x0111
#define REV_HAS_RAW_IRIG_DATA_TCR511PCI 0x0111
#define REV_HAS_RAW_IRIG_DATA_TCR51USB 0x0106
-/* command PCPS_GIVE_IRIG_TIME: */
+// Command PCPS_GIVE_IRIG_TIME:
#define REV_HAS_IRIG_TIME_TCR511PEX 0x0109
#define REV_HAS_IRIG_TIME_TCR511PCI 0x0109
#define REV_HAS_IRIG_TIME_TCR51USB 0x0106
-/* command PCPS_GET_IRIG_CTRL_BITS: */
+// Command PCPS_GET_IRIG_CTRL_BITS:
#define REV_HAS_IRIG_CTRL_BITS_TCR511PEX 0x0107
#define REV_HAS_IRIG_CTRL_BITS_TCR511PCI 0x0107
#define REV_HAS_IRIG_CTRL_BITS_TCR51USB 0x0106
-/* This device uses the GPS_DATA interface with 16 bit buffer sizes
- instead of the original 8 bit sizes, thus allowing to transfer
- data blocks that exceed 255 bytes (PCPS_HAS_GPS_DATA_16) */
+// The device uses the GPS_DATA interface where the buffer size
+// is specified as a 16 bit number (PCPS_HAS_GPS_DATA_16), instead
+// of the original approach where size was specified by an 8 bit number
+// which limited the data block size to 255 bytes:
#define REV_HAS_GPS_DATA_16_GPS169PCI 0x0202
-/* the device supports a higher baud rate than N_PCPS_BD_DCF */
+// The device supports a higher baud rate than N_PCPS_BD_DCF:
#define REV_HAS_SERIAL_HS_PCI509 0x0104
-/* commands PCPS_GIVE_UCAP_ENTRIES, PCPS_GIVE_UCAP_EVENT */
+// Commands PCPS_GIVE_UCAP_ENTRIES, PCPS_GIVE_UCAP_EVENT:
#define REV_HAS_UCAP_GPS167PCI 0x0421
#define REV_HAS_UCAP_GPS168PCI 0x0104
-/* command PCPS_CLR_UCAP_BUFF */
+// Command PCPS_CLR_UCAP_BUFF:
#define REV_CAN_CLR_UCAP_BUFF_GPS167PCI 0x0419
#define REV_CAN_CLR_UCAP_BUFF_GPS168PCI 0x0101
-/* commands PCPS_READ_GPS_DATA and PCPS_WRITE_GPS_DATA with */
-/* code PC_GPS_ANT_CABLE_LEN */
+// Commands PCPS_READ_GPS_DATA and PCPS_WRITE_GPS_DATA
+// with code PC_GPS_ANT_CABLE_LEN:
#define REV_HAS_CABLE_LEN_GPS167PCI 0x0411
#define REV_HAS_CABLE_LEN_GPS167PC 0x0411
-/* command PCPS_GIVE_HR_TIME, structure PCPS_HR_TIME: */
+// Command PCPS_GIVE_HR_TIME, structure PCPS_HR_TIME:
#define REV_HAS_HR_TIME_GPS167PC 0x0305
#define REV_HAS_HR_TIME_TCR510PCI 0x0200
#define REV_HAS_HR_TIME_PEX511 0x0105 // This also requires a certain ASIC version.
#define REV_HAS_HR_TIME_PCI511 0x0103
-/* field offs_utc in structure PCPS_TIME: */
+// Field offs_utc in structure PCPS_TIME:
#define REV_HAS_UTC_OFFS_PC31PS31 0x0300
-/* command PCPS_GIVE_SYNC_TIME: */
+// Command PCPS_GIVE_SYNC_TIME:
#define REV_HAS_SYNC_TIME_PC31PS31 0x0300
-/* command PCPS_GET_SERIAL, PCPS_SET_SERIAL: */
+// Commands PCPS_GET_SERIAL, PCPS_SET_SERIAL:
#define REV_HAS_SERIAL_PC31PS31 0x0300
-/* command PCPS_GIVE_TIME_NOCLEAR: */
+// Command PCPS_GIVE_TIME_NOCLEAR:
#define REV_GIVE_TIME_NOCLEAR_PC31PS31 0x0300
-/* status bit PCPS_LS_ANN: */
+// Status bit PCPS_LS_ANN:
#define REV_PCPS_LS_ANN_PC31PS31 0x0300
-/* status bit PCPS_IFTM: */
+// Status bit PCPS_IFTM:
#define REV_PCPS_IFTM_PC31PS31 0x0300
-/* command PCPS_SET_TIME: */
+// Command PCPS_SET_TIME:
#define REV_CAN_SET_TIME_PC31PS31 0x0240
-/* command PCPS_GIVE_TIME_NOCLEAR: */
-// This is supported by all clocks but PC31/PS31 with
-// firmware versions before v3.0. If such a card shall
-// be used, the firmware should be updated to the
-// last recent version.
+// Command PCPS_GIVE_TIME_NOCLEAR:
+// Supported by all devices except PC31/PS31
+// with firmware versions before v3.0.
+// If such a card is to be used, the firmware
+// should be updated to the latest version.
/** @} defgroup group_pcps_features */
@@ -1574,9 +1583,37 @@ typedef uint32_t PCPS_IRQ_STAT_INFO;
#endif
+
+static __mbg_inline /*HDR*/
+/**
+ * @brief Set up a default ::RECEIVER_INFO for a legacy device.
+ *
+ * Some legacy devices don't provide a ::RECEIVER_INFO structure,
+ * so we set one op, depending on whether the device is a GPS receiver
+ * or not, in which case it's a DCF77 receiver.
+ *
+ * @param[out] p_ri Address of a ::RECEIVER_INFO structure to be set up.
+ * @param[in] p_dev Address of a ::PCPS_DEV structure with some device info.
+ * @param[in] is_gps Flag indicating whether the device is a GPS receiver.
+ */
+void setup_default_receiver_info( RECEIVER_INFO *p_ri,
+ const PCPS_DEV *p_dev, bool is_gps )
+{
+ if ( is_gps )
+ _setup_default_receiver_info_gps( p_ri );
+ else
+ _setup_default_receiver_info_dcf( p_ri, p_dev );
+
+ strncpy( p_ri->model_name, _pcps_type_name( p_dev ), sizeof( p_ri->model_name ) );
+ p_ri->model_name[sizeof( p_ri->model_name ) - 1] = 0; // Force terminating 0.
+
+} // setup_default_receiver_info
+
+
+
#if !defined( MBG_TGT_KERNEL )
-static __mbg_inline
+static __mbg_inline /*HDR*/
void setup_hr_time_cycles_from_timestamp_cycles( PCPS_HR_TIME_CYCLES *p_ht_c,
const PCPS_TIME_STAMP_CYCLES *p_ts_c )
{
diff --git a/mbglib/common/toolutil.c b/mbglib/common/toolutil.c
index 9eba445..266d33d 100644
--- a/mbglib/common/toolutil.c
+++ b/mbglib/common/toolutil.c
@@ -1,15 +1,17 @@
/**************************************************************************
*
- * $Id: toolutil.c 1.22 2021/11/08 21:37:29Z martin.burnicki REL_M $
+ * $Id: toolutil.c 1.23 2021/11/15 17:08:30Z martin.burnicki REL_M $
*
* Common functions that can be used with Meinberg command line
* utility programs.
*
* -----------------------------------------------------------------------
* $Log: toolutil.c $
- * Revision 1.22 2021/11/08 21:37:29Z martin.burnicki
- * SYN1588 devices are now enumerated after native Meinberg devices.
+ * Revision 1.23 2021/11/15 17:08:30Z martin.burnicki
+ * Improved printing of usage information.
+ * Revision 1.22 2021/11/08 21:37:29 martin.burnicki
+ * SYN1588 devices are now enumerated after native Meinberg devices.
* Print build number of SYN1588 device instead of firmware version.
* Use new functions from mbgdevio to reduce dependies on conditional
* preprocessor symbols.
@@ -297,12 +299,18 @@ void mbg_print_no_device_found( void )
/**
* @brief Print usage intro to console.
*
- * @param[in] pname The program name.
- * @param[in] info An optional additional info string, may be @a NULL.
+ * @param[in] pname The program name.
+ * @param[in] print_dev Print device parameters, or not.
+ * @param[in] info An optional additional info string, may be @a NULL.
*/
-void mbg_print_usage_intro( const char *pname, const char *info )
+void mbg_print_usage_intro( const char *pname, bool print_dev, const char *info )
{
- printf( "Usage: %s [[opt] [opt] ...] [[dev] [dev] ...]\n\n", pname );
+ printf( "Usage: %s [[opt] [opt] ...]", pname );
+
+ if ( print_dev )
+ printf( " [[dev] [dev] ...]" );
+
+ printf( "\n\n" );
if ( info )
printf( "%s\n\n", info );
@@ -373,9 +381,18 @@ void mbg_print_help_options( void )
*/
void mbg_print_device_options( int mask )
{
- printf( "\n" );
+ #if SUPP_SERIAL
+ int cmp_mask = DEV_OPT_PRINT_BUS_LEVEL | DEV_OPT_PRINT_SERIAL;
+ #else
+ int cmp_mask = DEV_OPT_PRINT_BUS_LEVEL;
+ #endif
+
+ if ( mask & cmp_mask )
+ {
+ printf( "\n" );
- puts( "where \"dev\" can be:" );
+ puts( "where \"dev\" can be:" );
+ }
if ( mask & DEV_OPT_PRINT_BUS_LEVEL )
{
@@ -403,6 +420,45 @@ void mbg_print_device_options( int mask )
/*HDR*/
/**
+ * @brief Print usage info whether SYN1588 support has been compiled in.
+ */
+void mbg_print_usage_syn1588_support( void )
+{
+ bool syn1588_supported = mbg_rc_is_success( mbg_chk_if_syn1588_supported() );
+
+ printf( "This program has been built %s support for SYN1588 cards.\n",
+ syn1588_supported ? "with" : "WITHOUT" );
+ puts( "" );
+
+} // mbg_print_usage_syn1588_support
+
+
+
+/*HDR*/
+/**
+ * @brief Print usage outro, including device options and info on SYN1588 support .
+ *
+ * @param[in] mask Bit mask to control for which kind of devices
+ * information shall be displayed.
+ * See ::DEV_OPT_PRINT_MASKS.
+ *
+ * @param[in] print_syn1588_info Controls whether info on SYN1588 support
+ * is to be printed, or not.
+ */
+void mbg_print_usage_outro( int mask, bool print_syn1588_info )
+{
+ mbg_print_device_options( mask );
+ puts( "" );
+
+ if ( print_syn1588_info )
+ mbg_print_usage_syn1588_support();
+
+} // mbg_print_usage_outro
+
+
+
+/*HDR*/
+/**
* @brief Print program info and default usage information.
*
* @param[in] pname The program name.
@@ -410,10 +466,9 @@ void mbg_print_device_options( int mask )
*/
void mbg_print_default_usage( const char *pname, const char *prog_info )
{
- mbg_print_usage_intro( pname, prog_info );
+ mbg_print_usage_intro( pname, true, prog_info );
mbg_print_help_options();
- mbg_print_device_options( DEV_OPT_PRINT_BUS_LEVEL );
- puts( "" );
+ mbg_print_usage_outro( DEV_OPT_PRINT_BUS_LEVEL, true );
} // mbg_print_default_usage
diff --git a/mbglib/common/toolutil.h b/mbglib/common/toolutil.h
index b520949..5d8773d 100644
--- a/mbglib/common/toolutil.h
+++ b/mbglib/common/toolutil.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: toolutil.h 1.18 2021/11/08 20:26:20Z martin.burnicki REL_M $
+ * $Id: toolutil.h 1.19 2021/11/15 17:09:16Z martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -9,7 +9,9 @@
*
* -----------------------------------------------------------------------
* $Log: toolutil.h $
- * Revision 1.18 2021/11/08 20:26:20Z martin.burnicki
+ * Revision 1.19 2021/11/15 17:09:16Z martin.burnicki
+ * Updated function prototypes.
+ * Revision 1.18 2021/11/08 20:26:20 martin.burnicki
* Updated comment of a function prototype.
* Revision 1.17 2021/05/03 16:14:57 martin
* Provide default definition for SUPP_SERIAL.
@@ -243,10 +245,11 @@ typedef int MBG_DEV_HANDLER_FNC( MBG_DEV_HANDLE, const PCPS_DEV *);
/**
* @brief Print usage intro to console.
*
- * @param[in] pname The program name.
- * @param[in] info An optional additional info string, may be @a NULL.
+ * @param[in] pname The program name.
+ * @param[in] print_dev Print device parameters, or not.
+ * @param[in] info An optional additional info string, may be @a NULL.
*/
- void mbg_print_usage_intro( const char *pname, const char *info ) ;
+ void mbg_print_usage_intro( const char *pname, bool print_dev, const char *info ) ;
/**
* @brief Print info on a single program option / argument.
@@ -277,6 +280,23 @@ typedef int MBG_DEV_HANDLER_FNC( MBG_DEV_HANDLE, const PCPS_DEV *);
void mbg_print_device_options( int mask ) ;
/**
+ * @brief Print usage info whether SYN1588 support has been compiled in.
+ */
+ void mbg_print_usage_syn1588_support( void ) ;
+
+ /**
+ * @brief Print usage outro, including device options and info on SYN1588 support .
+ *
+ * @param[in] mask Bit mask to control for which kind of devices
+ * information shall be displayed.
+ * See ::DEV_OPT_PRINT_MASKS.
+ *
+ * @param[in] print_syn1588_info Controls whether info on SYN1588 support
+ * is to be printed, or not.
+ */
+ void mbg_print_usage_outro( int mask, bool print_syn1588_info ) ;
+
+ /**
* @brief Print program info and default usage information.
*
* @param[in] pname The program name.
diff --git a/mbglib/common/words.h b/mbglib/common/words.h
index b90278c..85200a5 100644
--- a/mbglib/common/words.h
+++ b/mbglib/common/words.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: words.h 1.52 2021/03/18 11:08:31Z martin REL_M $
+ * $Id: words.h 1.53 2021/11/29 14:22:49Z martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: words.h $
- * Revision 1.52 2021/03/18 11:08:31Z martin
+ * Revision 1.53 2021/11/29 14:22:49Z martin.burnicki
+ * New macros _nano_time_64_from_timespec() and
+ * _nano_time_64_from_timeval().
+ * Revision 1.52 2021/03/18 11:08:31 martin
* Updated some comments.
* Revision 1.51 2021/03/16 12:20:31 martin
* Updated some comments.
@@ -663,6 +666,26 @@ do \
( ( (_nt)->secs == 0 ) && ( (_nt)->nano_secs == 0 ) )
+/**
+ * @brief Set up a ::NANO_TIME_64 structure from struct timespec.
+ */
+#define _nano_time_64_from_timespec( _p, _p_ts ) \
+do \
+{ \
+ (_p)->secs = (_p_ts)->tv_sec; \
+ (_p)->nano_secs = (_p_ts)->tv_nsec; \
+} while ( 0 )
+
+/**
+ * @brief Set up a ::NANO_TIME_64 structure from struct timeval.
+ */
+#define _nano_time_64_from_timeval( _p, _p_ts ) \
+do \
+{ \
+ (_p)->secs = (_p_ts)->tv_sec; \
+ (_p)->nano_secs = (_p_ts)->tv_usec * 1000; \
+} while ( 0 )
+
// The size_t type may be larger than an int type.
// However, some snprintf-like functions expect a size_t value