summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2019-02-11 12:00:00 +0100
committerMartin Burnicki <martin.burnicki@meinberg.de>2019-02-11 12:00:00 +0100
commita7b8404dbfa620de4b5aca578746ee33eed3f447 (patch)
tree11691dfd5f47a73349ba2536db1aa905c026f7d8
parent020a5fe7ba02488bf6c90a62fdd40d168b00ee25 (diff)
downloadmbgtools-win-a7b8404dbfa620de4b5aca578746ee33eed3f447.tar.gz
mbgtools-win-a7b8404dbfa620de4b5aca578746ee33eed3f447.zip
'mbgstatus' also prints the device's EPLD version in verbose mode
Also update some mbglib files according to mbgtools-lx-4.2.2. Requires dkwin-3.08 or newer.
-rw-r--r--mbglib/common/mbg_tgt.h95
-rw-r--r--mbglib/common/mbgerror.h72
-rw-r--r--mbglib/common/mbgioctl.c113
-rw-r--r--mbglib/common/mbgioctl.h24
-rw-r--r--mbglib/common/mbgsystm.h40
-rw-r--r--mbglib/common/mbgtime.h13
-rw-r--r--mbglib/common/timeutil.c16
-rw-r--r--mbglib/common/timeutil.h40
-rw-r--r--mbglib/common/toolutil.c10
-rw-r--r--mbglib/common/usbdefs.h43
-rw-r--r--mbglib/common/words.h10
-rw-r--r--mbgstatus/mbgstatus.c11
-rw-r--r--mbgversion.h11
13 files changed, 329 insertions, 169 deletions
diff --git a/mbglib/common/mbg_tgt.h b/mbglib/common/mbg_tgt.h
index fa72dbb..d9f84f5 100644
--- a/mbglib/common/mbg_tgt.h
+++ b/mbglib/common/mbg_tgt.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_tgt.h 1.44 2018/12/11 15:34:15Z martin REL_M $
+ * $Id: mbg_tgt.h 1.45 2019/02/11 09:53:02Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,7 +11,11 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_tgt.h $
- * Revision 1.44 2018/12/11 15:34:15Z martin
+ * Revision 1.45 2019/02/11 09:53:02Z martin
+ * Support the mingw build environment.
+ * Changed inclusion of winsock2.h/windows.h on Windows.
+ * Removed obsolete RCS log entries.
+ * Revision 1.44 2018/12/11 15:34:15 martin
* Older Visual Studio versions don't support _strtoi64().
* Revision 1.43 2018/11/22 11:28:01Z martin
* New preprocessor symbol MBG_TGT_USE_IOCTL.
@@ -70,54 +74,6 @@
* Fixed some spelling.
* Tmp workaround for 2.6.32-5-sparc64.
* Proper fix required.
- * Revision 1.34.1.26 2016/08/05 10:38:10 martin
- * Revision 1.34.1.25 2016/08/04 14:51:25Z martin
- * Moved some compatibility definitions from gpsserio.h to mbg_tgt.h.
- * Revision 1.34.1.24 2016/08/02 13:10:58 martin
- * Define ssize_t for Windows, if required.
- * Revision 1.34.1.23 2016/07/18 14:41:27Z martin
- * New symbol MBG_TGT_HAS_ABS64.
- * Revision 1.34.1.22 2016/07/14 09:00:58Z martin
- * Conditionally provided struct timespec for Windows.
- * Revision 1.34.1.21 2016/07/07 10:01:28Z martin
- * Modified inclusion of Windows header files.
- * Revision 1.34.1.20 2016/06/06 12:59:03 thomas-b
- * Include all necessary Windows headers in the needed sequence
- * Revision 1.34.1.19 2016/04/26 14:53:06 martin
- * Revision 1.34.1.18 2016/04/26 13:31:08Z martin
- * Added compatible 64 bit type print format specifiers.
- * Revision 1.34.1.17 2016/04/25 14:46:20Z martin
- * Include inttypes.h for all targets providing also stdint.h.
- * Revision 1.34.1.16 2016/03/02 12:26:15 martin
- * *** empty log message ***
- * Revision 1.34.1.15 2016/02/26 09:12:11 paul
- * Revision 1.34.1.14 2015/12/10 12:34:14Z martin
- * *** empty log message ***
- * Revision 1.34.1.13 2015/12/01 14:55:52 martin
- * Revision 1.34.1.12 2015/12/01 14:54:08Z martin
- * *** empty log message ***
- * Revision 1.34.1.11 2015/12/01 14:52:20 martin
- * *** empty log message ***
- * Revision 1.34.1.10 2015/12/01 14:43:44 martin
- * *** empty log message ***
- * Revision 1.34.1.9 2015/12/01 13:55:09 martin
- * Conditionally define a macro _DEPRECATED_BY which can be used to
- * tag functions as deprecated, so compilers can emit appropriate warnings.
- * Revision 1.34.1.8 2015/10/28 13:45:25 martin
- * Added some MSVC version code information.
- * Revision 1.34.1.7 2015/10/19 09:34:56 martin
- * Fixed some spelling.
- * Revision 1.34.1.6 2015/10/15 12:49:10 marvin
- * Revision 1.34.1.5 2015/10/08 08:55:16Z martin
- * Revision 1.34.1.4 2015/10/05 15:07:23Z marvin
- * Unicode support.
- * Revision 1.34.1.3 2015/09/21 08:58:27Z martin
- * *** empty log message ***
- * Revision 1.34.1.2 2015/09/18 14:53:25 martin
- * Fixes for FreeBSD.
- * Revision 1.34.1.1 2015/04/07 15:40:59 martin
- * Tmp workaround for 2.6.32-5-sparc64.
- * Proper fix required.
* Revision 1.34 2015/03/03 13:32:49 martin
* Provide __func__ for MS Visual Studio.
* Revision 1.33 2015/03/02 11:27:59Z martin
@@ -436,6 +392,23 @@ extern "C" {
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__ )
+ #if defined( __MINGW32__ )
+ #define MBG_TGT_MINGW
+ #endif
+
+ #if defined( __MINGW64__ )
+ #define MBG_TGT_MINGW
+ #endif
+
+ #if defined( MBG_TGT_MINGW ) && defined( __MINGW_EXTENSION )
+ // MSYS2 / MinGW defines __MINGW_EXTENSION
+ // and provides _abs64() and some other stuff,
+ // but the standard MinGW environment does not.
+ #if !defined( MBG_TGT_HAS_ABS64 )
+ #define MBG_TGT_HAS_ABS64 1
+ #endif
+ #endif
+
#if defined( __i386__ )
#define MBG_ARCH_I386
@@ -708,7 +681,10 @@ extern "C" {
#if ( _MSC_VER >= 1310 )
// This is supported at least since Visual Studio 2008
// and Windows Server 2003 SP1 DDK.
- #define MBG_TGT_HAS_ABS64 1
+
+ #if !defined( MBG_TGT_HAS_ABS64 )
+ #define MBG_TGT_HAS_ABS64 1
+ #endif
#endif
#if !defined ( HAVE_SSIZE_T )
@@ -938,12 +914,9 @@ extern "C" {
#if !defined( WIN32_LEAN_AND_MEAN )
#define WIN32_LEAN_AND_MEAN 1
#endif
- #if !defined( _WINSOCKAPI_ )
- #define _WINSOCKAPI_
- #endif
- #include <windows.h>
#include <winsock2.h>
+ #include <windows.h>
#include <ws2tcpip.h>
typedef HANDLE MBG_HANDLE;
@@ -976,10 +949,12 @@ extern "C" {
#endif
- #if defined( MBG_LIB_EXPORT )
- #define _MBG_API_ATTR __declspec( dllexport )
- #else
- #define _MBG_API_ATTR __declspec( dllimport )
+ #if !defined( MBG_TGT_MINGW ) // not required for MinGW
+ #if defined( MBG_LIB_EXPORT )
+ #define _MBG_API_ATTR __declspec( dllexport )
+ #else
+ #define _MBG_API_ATTR __declspec( dllimport )
+ #endif
#endif
#elif defined( MBG_TGT_POSIX )
@@ -1006,7 +981,7 @@ extern "C" {
/**
* @brief A socket file descriptor type
*/
-#if defined( MBG_TGT_WIN32 )
+#if defined( MBG_TGT_WIN32 ) && !defined( MBG_TGT_MINGW )
#if !defined( MBG_TGT_KERNEL ) // we don't need this in kernel space
// usually evaluates to UINT_PTR, which in turn evaluates
// to (unsigned int), or (unsigned __int64).
diff --git a/mbglib/common/mbgerror.h b/mbglib/common/mbgerror.h
index d839fb2..2aa07c4 100644
--- a/mbglib/common/mbgerror.h
+++ b/mbglib/common/mbgerror.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgerror.h 1.18 2018/11/22 11:25:56Z martin REL_M $
+ * $Id: mbgerror.h 1.19 2019/02/08 10:42:56Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,7 +11,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbgerror.h $
- * Revision 1.18 2018/11/22 11:25:56Z martin
+ * Revision 1.19 2019/02/08 10:42:56Z martin
+ * Distinguish more detailed if an NTSTATUS replacement
+ * is required for a particular build environment.
+ * Revision 1.18 2018/11/22 11:25:56 martin
* New error code MBG_ERR_STR_SUBSTR merged from 1.15.1.x branch.
* Refactored surrogate definitions.
* Updated function prototypes.
@@ -89,6 +92,51 @@
#include <mbg_tgt.h>
#include <words.h>
+// We may need surrogate declarations for target-specific
+// types that are used in common function prototypes.
+// Without such declarations we'd get compiler errors
+// on targets that don't have them.
+
+#if defined( MBG_TGT_WIN32 )
+
+ #if defined( MBG_TGT_KERNEL )
+
+ #define MBG_TGT_MISSING_DWORD 1 // missing even in kernel space.
+ #define MBG_TGT_MISSING_NTSTATUS 0 // available in kernel space
+
+ #else // Windows user space
+
+ #define MBG_TGT_MISSING_DWORD 0 // available in user space
+
+ // Some (but not all) Windows build environments provide a
+ // bcrypt.h file which has a definition for NTSTATUS, so we
+ // use.that if available to avoid duplicate / mismatching
+ // definitions in case an application uses bcrypt.h anyway.
+ #if !defined( MBG_TGT_HAS_BCRYPT_H ) // unless already defined elsewhere
+ #if defined( _MSC_VER ) && ( _MSC_VER >= 1500 ) // at least VS2008 has it
+ #define MBG_TGT_HAS_BCRYPT_H 1
+ #else // older MSVC versions or other build environments may not have it
+ #define MBG_TGT_HAS_BCRYPT_H 0
+ #endif
+ #endif
+
+ #if MBG_TGT_HAS_BCRYPT_H
+ #include <bcrypt.h>
+ #define MBG_TGT_MISSING_NTSTATUS 0
+ #else
+ #define MBG_TGT_MISSING_NTSTATUS 1
+ #endif
+
+ #endif
+
+#else // non-Windows targets
+
+ #define MBG_TGT_MISSING_DWORD 1
+ #define MBG_TGT_MISSING_NTSTATUS 1
+
+#endif
+
+
#ifdef _MBGERROR
#define _ext
#define _DO_INIT
@@ -158,7 +206,6 @@ extern "C" {
#define _win_msg_is_custom( _st ) ( _get_win_msg_custom_flag( _st ) != 0 )
-
#define _mbg_msg_id_inf( num ) ((DWORD) ( STATUS_SEVERITY_INFORMATIONAL_MASK | STATUS_CUSTOM_FLAG_MASK | num ) )
#define _mbg_msg_id_wrn( num ) ((DWORD) ( STATUS_SEVERITY_WARNING_MASK | STATUS_CUSTOM_FLAG_MASK | num ) )
#define _mbg_msg_id_err( num ) ((DWORD) ( STATUS_SEVERITY_ERROR_MASK | STATUS_CUSTOM_FLAG_MASK | num ) )
@@ -167,26 +214,21 @@ extern "C" {
-// Surrogate declarations for target-specific types
-// that are used in common function prototypes.
-// Without these declarations we'd get compiler errors
-// on targets that don't have them.
-
-#if !defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_KERNEL )
- // Even required in Windows kernel space.
+#if MBG_TGT_MISSING_DWORD
typedef uint32_t DWORD;
#define DWORD DWORD
#endif
-#if !( defined( MBG_TGT_WIN32 ) && defined( MBG_TGT_KERNEL ) )
- // Always required, except in Windows kernel space.
- typedef void *NTSTATUS;
- #define NTSTATUS NTSTATUS
+#if MBG_TGT_MISSING_NTSTATUS
+ // We intentionally define an uncommon type to
+ // enforce build errors in case NTSTATUS is really
+ // used on targets that should not use it.
+ typedef int *NTSTATUS;
+ #define NTSTATUS NTSTATUS
#endif
-
/**
* @brief Error codes used with Meinberg devices and drivers
*
diff --git a/mbglib/common/mbgioctl.c b/mbglib/common/mbgioctl.c
new file mode 100644
index 0000000..4a38f03
--- /dev/null
+++ b/mbglib/common/mbgioctl.c
@@ -0,0 +1,113 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgioctl.c 1.5 2018/11/22 14:57:43Z martin REL_M $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Utility functions to be used with IOCTLs.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgioctl.c $
+ * Revision 1.5 2018/11/22 14:57:43Z martin
+ * Check new preprocessor symbol MBG_TGT_USE_IOCTL to exclude
+ * code from build on targets that don't use IOCTL calls.
+ * Revision 1.4 2018/11/05 13:33:26 martin
+ * Avoid signed/unsigned mismatch by using appropriate function parameter.
+ * Revision 1.3 2018/07/05 08:57:05Z martin
+ * New function mbgioctl_rc_to_mbg_errno().
+ * New function mbgioctl_get_name().
+ * Updated file header comment.
+ * Revision 1.2 2003/03/18 09:30:05 martin
+ * Changed names from ioctlw32 to mbgioctl.
+ * Revision 1.1 2002/02/19 13:51:08Z MARTIN
+ * Initial revision
+ *
+ **************************************************************************/
+
+#include <mbg_tgt.h>
+
+// The code below is only required for target systems
+// where IOCTLs are used to access a kernel driver, so
+// we exclude it from build on systems where the physical
+// devices are accessed directly from user space.
+
+#if MBG_TGT_USE_IOCTL
+
+#define _MBGIOCTL
+ #include <mbgioctl.h>
+#undef _MBGIOCTL
+
+#include <mbgerror.h>
+
+
+#if defined( MBG_TGT_WINDOWS ) && !defined( MBG_TGT_KERNEL )
+
+/*HDR*/
+int mbgioctl_rc_to_mbg_errno( int sys_errno )
+{
+ // FIXME: This is a hack: Under Linux the IOCTL_RC_ERR_...
+ // code definitions are all negative, but the sys_errno
+ // number we expect here is positive. So just revert the
+ // sign to be able to uses the original IOCTL_RC_ERR_...
+ // definitions for the switch cases.
+ #if defined( MBG_TGT_LINUX )
+ int cmp_rc_code = -sys_errno;
+ #else
+ int cmp_rc_code = sys_errno;
+ #endif
+
+ switch ( cmp_rc_code )
+ {
+ case IOCTL_RC_ERR_PERM: return MBG_ERR_PERM;
+ case IOCTL_RC_ERR_UNSUPP_IOCTL: return MBG_ERR_INV_DEV_REQUEST;
+ case IOCTL_RC_ERR_INVAL_PARAM: return MBG_ERR_INV_PARM;
+ case IOCTL_RC_ERR_NOT_SUPP_BY_DEV: return MBG_ERR_NOT_SUPP_BY_DEV;
+ case IOCTL_RC_ERR_NO_MEM: return MBG_ERR_NO_MEM;
+ case IOCTL_RC_ERR_BUSY_IRQ_UNSAFE: return MBG_ERR_IRQ_UNSAFE; // or MBG_ERR_BUSY ?
+ case IOCTL_RC_ERR_DEV_ACCESS: return MBG_ERR_IO;
+
+ #if defined( MBG_TGT_LINUX ) // Linux-specific codes
+ case IOCTL_RC_ERR_COPY_TO_USER: return MBG_ERR_COPY_TO_USER; // FIXME
+ // case IOCTL_RC_ERR_COPY_FROM_USER: return MBG_ERR_COPY_FROM_USER;
+
+ #endif // defined( MBG_TGT_LINUX )
+ }
+
+ // FIXME: This is another hack: Eventually the error code returned
+ // in kernel space is remapped to some other code by the kernel,
+ // so this is is not covered by the switch above, and the error
+ // code used in kernel may not even be defined in user space.
+ // E.g. ENOIOCTL for *BSD is only defined in kernel space.
+ return mbg_posix_errno_to_mbg( sys_errno, NULL );
+
+} // mbgioctl_rc_to_mbg_errno
+
+#endif // defined( MBG_TGT_WINDOWS ) && !defined( MBG_TGT_KERNEL )
+
+
+
+#if defined( DEBUG ) || defined( MBG_DEBUG )
+
+/*HDR*/
+const char *mbgioctl_get_name( long code )
+{
+ static const MBG_CODE_NAME_TABLE_ENTRY tbl[] = IOCTL_CODES_TABLE;
+
+ const MBG_CODE_NAME_TABLE_ENTRY *p = tbl;
+
+ for ( p = tbl; p->name; p++ )
+ {
+ if ( p->code == code )
+ return p->name;
+ }
+
+ return "UNKNOWN_IOCTL";
+
+} // mbgioctl_get_name
+
+#endif // defined( DEBUG ) || defined( MBG_DEBUG )
+
+#endif // MBG_TGT_USE_IOCTL
+
diff --git a/mbglib/common/mbgioctl.h b/mbglib/common/mbgioctl.h
index b99cacc..41253d3 100644
--- a/mbglib/common/mbgioctl.h
+++ b/mbglib/common/mbgioctl.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgioctl.h 1.32 2018/11/22 15:01:44Z martin REL_M $
+ * $Id: mbgioctl.h 1.33 2019/02/08 16:06:52Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbgioctl.h $
- * Revision 1.32 2018/11/22 15:01:44Z martin
+ * Revision 1.33 2019/02/08 16:06:52Z martin
+ * Moved the Windows GUID stuff elsewhere.
+ * Revision 1.32 2018/11/22 15:01:44 martin
* Refactored structure IOCTL_GENERIC_REQ using fixed size integer
* types only to avoid pointer size problems in a mixed 32/64 bit
* Linux environment.
@@ -170,14 +172,6 @@
#include <winioctl.h>
#endif
- #if !defined( MBG_TGT_WIN32_NON_PNP )
- #ifdef _MBGIOCTL
- #include <initguid.h> // instance the GUID
- #else
- #include <guiddef.h> // just define the GUID
- #endif
- #endif
-
#endif
@@ -352,16 +346,6 @@ extern "C" {
#define _MBG_SUPP_VAR_ACC_SIZE 1
#endif
- #ifdef DEFINE_GUID // don't break compiles of drivers that
- // include this header but don't want the
- // GUIDs
-
- // ClassGuid = { 78A1C341-4539-11d3-B88D-00C04FAD5171 }
- DEFINE_GUID( GUID_MEINBERG_DEVICE,
- 0x78A1C341L, 0x4539, 0x11D3,
- 0xB8, 0x8D, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71 );
- #endif
-
// Device type in the "User Defined" range."
#define PCPS_TYPE 40000
diff --git a/mbglib/common/mbgsystm.h b/mbglib/common/mbgsystm.h
index 7d3fe54..44ece8e 100644
--- a/mbglib/common/mbgsystm.h
+++ b/mbglib/common/mbgsystm.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgsystm.h 1.4 2018/07/16 12:32:58Z martin REL_M $
+ * $Id: mbgsystm.h 1.5 2019/02/08 11:05:48Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,7 +11,13 @@
*
* -----------------------------------------------------------------------
* $Log: mbgsystm.h $
- * Revision 1.4 2018/07/16 12:32:58Z martin
+ * Revision 1.5 2019/02/08 11:05:48Z martin
+ * Commonly use int64_t for MBG_SYS_TIME on Windows, rather than
+ * FILETIME in user space and LARGE_INTEGER in kernel space.
+ * Also use a function pointer to read the Windows system time
+ * depending on whether the precise time API calls are supported
+ * by the running Windows system, or not.
+ * Revision 1.4 2018/07/16 12:32:58 martin
* Fixed do_div() for 32 bit ARM Linux kernel.
* Include another header file on NetBSD.
* Revision 1.3 2017/07/26 14:26:17 martin
@@ -94,7 +100,9 @@
#elif defined( MBG_TGT_WIN32 )
#if defined( MBG_TGT_KERNEL )
- #include <mbg_w32.h>
+ #include <mbg_w32.h> // ke_query_system_time_fnc
+ #else
+ #include <timeutil.h> // gstaft_fnc
#endif
#include <mbgtime.h>
@@ -120,14 +128,10 @@
extern "C" {
#endif
-/**
- Define generic types to hold PC cycle counter values and system timestamps.
- The generic types are defined using native types used by the target operating
- systems.
- The cycle counter value is usually derived from the PC CPU's TSC or some other
- timer hardware on the mainboard.
- */
+/*
+ * Generic types to hold system timestamps and values for the system uptime..
+ */
#if defined( MBG_TGT_POSIX )
typedef NANO_TIME_64 MBG_SYS_TIME;
@@ -135,7 +139,7 @@ extern "C" {
#elif defined( MBG_TGT_WIN32 )
- typedef LARGE_INTEGER MBG_SYS_TIME;
+ typedef int64_t MBG_SYS_TIME; // Number of 100ns units
typedef int64_t MBG_SYS_UPTIME; // [s]
#elif defined( MBG_TGT_OS2 )
@@ -223,18 +227,10 @@ void mbg_get_sys_time( MBG_SYS_TIME *p )
#elif defined( MBG_TGT_WIN32 )
#if defined( MBG_TGT_KERNEL ) // Windows kernel space
- #if defined( MBG_TGT_WIN32_PNP ) && !defined( MBG_TGT_WIN32_PNP_X64 )
- extern KE_QUERY_SYSTEM_TIME_FNC ke_query_system_time_fnc;
- ke_query_system_time_fnc( p );
- #else
- KeQuerySystemTime( p );
- #endif
+ ke_query_system_time_fnc( (LARGE_INTEGER *) p );
#else // Windows user space
{
- FILETIME ft;
- GetSystemTimeAsFileTime( &ft );
- p->LowPart = ft.dwLowDateTime;
- p->HighPart = ft.dwHighDateTime;
+ gstaft_fnc( (FILETIME *) p );
}
#endif
@@ -378,7 +374,7 @@ long mbg_delta_sys_time_ms( const MBG_SYS_TIME *t2, const MBG_SYS_TIME *t1 )
#endif
return dt;
#elif defined( MBG_TGT_WIN32 )
- return (long) ( ( t2->QuadPart - t1->QuadPart ) / HNS_PER_MS );
+ return (long) ( ( *t2 - *t1 ) / HNS_PER_MS );
#else
return 0;
#endif
diff --git a/mbglib/common/mbgtime.h b/mbglib/common/mbgtime.h
index f8f7a62..0c08da3 100644
--- a/mbglib/common/mbgtime.h
+++ b/mbglib/common/mbgtime.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgtime.h 1.30 2018/11/26 12:04:44Z martin REL_M $
+ * $Id: mbgtime.h 1.31 2019/02/06 10:08:09Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,17 +10,19 @@
*
* -----------------------------------------------------------------------
* $Log: mbgtime.h $
+ * Revision 1.31 2019/02/06 10:08:09Z martin
+ * Added symbol HNS_PER_MIN.
* Revision 1.30 2018/11/26 12:04:44Z martin
* Moved definition NTP_FRAC_PER_SEC here.
* Revision 1.29 2018/02/28 16:58:10 martin
* Removed reference to frac_sec_from_bin().
* Revision 1.28 2018/01/15 18:18:49 martin
- * Renamed symbol NSECS_PER_SEC to NSEC_PER_SEC
+ * Renamed symbol NSECS_PER_SEC to NSEC_PER_SEC.
* according to namings of similar symbols.
* Revision 1.27 2017/11/29 11:14:57 gregoire
- * Added Multiplier MSEC_TO_NSEC_MULTIPLIER, MSEC_TO_USEC_MULTIPLIER
+ * Added Multiplier MSEC_TO_NSEC_MULTIPLIER, MSEC_TO_USEC_MULTIPLIER.
* Revision 1.26 2017/11/16 13:33:46 philipp
- * Added USEC_PER_SEC define
+ * Added USEC_PER_SEC define.
* Revision 1.25 2017/08/15 15:48:59 martin
* Define NSECS_PER_SEC only if it hasn't been defined before.
* Revision 1.24 2017/07/04 14:02:25 martin
@@ -270,6 +272,9 @@ typedef struct
#define HNS_PER_MS 10000L
#endif
+#if !defined( HNS_PER_MIN )
+ #define HNS_PER_MIN ( HNS_PER_SEC * SECS_PER_MIN )
+#endif
#define MSEC_TO_NSEC_MULTIPLIER ( NSEC_PER_SEC / MSEC_PER_SEC )
#define MSEC_TO_USEC_MULTIPLIER ( USEC_PER_SEC / MSEC_PER_SEC )
diff --git a/mbglib/common/timeutil.c b/mbglib/common/timeutil.c
index 4d13f4f..672b188 100644
--- a/mbglib/common/timeutil.c
+++ b/mbglib/common/timeutil.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: timeutil.c 1.9 2018/12/18 11:00:48Z martin REL_M $
+ * $Id: timeutil.c 1.10 2019/02/08 10:51:44Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: timeutil.c $
- * Revision 1.9 2018/12/18 11:00:48Z martin
+ * Revision 1.10 2019/02/08 10:51:44Z martin
+ * Removed some definitions that are also in the header file.
+ * Fixed a compiler warning.
+ * Revision 1.9 2018/12/18 11:00:48 martin
* Implemented setting time on Windows.
* Revision 1.8 2018/12/11 15:02:57Z martin
* Cast to avoid build error on Windows.
@@ -73,11 +76,6 @@ int snprint_gmtime_error( char *s, size_t max_len, int mbg_errno, time_t t, cons
#if defined( MBG_TGT_WIN32 )
-typedef int clockid_t;
-#define clockid_t clockid_t
-
-#define CLOCK_REALTIME ( (clockid_t) 0 )
-
/*HDR*/
int mbg_clock_gettime( clockid_t clock_id, struct timespec *tp )
{
@@ -165,7 +163,7 @@ void check_precise_time_api( void )
GSTAFT_FNC tmp_fnc;
HINSTANCE h = LoadLibrary( "kernel32.dll" );
- if ( h == NULL )
+ if ( h == NULL ) // TODO error msg
{
info = "Precise system time may not be supported; failed to get handle for kernel32.dll.";
goto out;
@@ -215,7 +213,7 @@ int snprint_utc_offs( char *s, size_t max_len, const char *info, long utc_offs )
size_t n = 0;
// utc_offs is in [s]
- char utc_offs_sign = ( utc_offs < 0 ) ? '-' : '+';
+ char utc_offs_sign = (char) ( ( utc_offs < 0 ) ? '-' : '+' );
ulong abs_utc_offs = labs( utc_offs );
ulong utc_offs_hours = abs_utc_offs / SECS_PER_HOUR;
ulong tmp = abs_utc_offs % SECS_PER_HOUR;
diff --git a/mbglib/common/timeutil.h b/mbglib/common/timeutil.h
index 92a38d2..ed87e9f 100644
--- a/mbglib/common/timeutil.h
+++ b/mbglib/common/timeutil.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: timeutil.h 1.9 2018/12/11 15:36:40Z martin REL_M $
+ * $Id: timeutil.h 1.10 2019/02/11 09:49:46Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,8 +10,11 @@
*
* -----------------------------------------------------------------------
* $Log: timeutil.h $
- * Revision 1.9 2018/12/11 15:36:40Z martin
- * _cvt_to_time_t() now expects an int64_t type parameter.
+ * Revision 1.10 2019/02/11 09:49:46Z martin
+ * Support the mingw build environment.
+ * Fixed build for targets that don't support 64 bit types.
+ * Revision 1.9 2018/12/11 15:36:40 martin
+ * cvt_to_time_t() now expects an int64_t type parameter.
* Revision 1.8 2018/11/29 15:32:04Z martin
* Moved some inline functions here.
* Include mbgtime.h.
@@ -60,13 +63,14 @@ extern "C" {
#endif
+// exclude for MinGW
#if defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_DOS )
+ #if !defined( MBG_TGT_MINGW )
+ typedef int clockid_t;
+ #define clockid_t clockid_t
-typedef int clockid_t;
-#define clockid_t clockid_t
-
-#define CLOCK_REALTIME ( (clockid_t) 0 )
-
+ #define CLOCK_REALTIME ( (clockid_t) 0 )
+ #endif
#endif
@@ -92,10 +96,18 @@ _ext GSTAFT_FNC gstaft_fnc
#endif
+
+#if !defined( MBG_TGT_MISSING_64_BIT_TYPES )
+ typedef int64_t mbg_time_t; // we try to always use 64 bit types
+#else
+ typedef time_t mbg_time_t; // fall back to the default
+#endif
+
+
static __mbg_inline
-time_t cvt_to_time_t( int64_t t )
+time_t cvt_to_time_t( mbg_time_t t )
{
- // Eventually we can do some epoch check here.
+ // Eventually we can do some epoch check / conversion here.
return (time_t) t;
} // cvt_to_time_t
@@ -118,6 +130,8 @@ int mbg_gmtime( struct tm *p_tm, const time_t *p_time )
+#if !defined( MBG_TGT_MISSING_64_BIT_TYPES )
+
static __mbg_inline /*HDR*/
double ntp_tstamp_to_double( const NTP_TSTAMP *t )
{
@@ -181,6 +195,8 @@ void ntp_tstamp_to_timespec( struct timespec *t_ts, const NTP_TSTAMP *t_ntp )
} // ntp_tstamp_to_timespec
+#endif // !defined( MBG_TGT_MISSING_64_BIT_TYPES )
+
static __mbg_inline /*HDR*/
@@ -206,6 +222,8 @@ double delta_timespec_d_s( const struct timespec *ts,
+#if !defined( MBG_TGT_MISSING_64_BIT_TYPES )
+
static __mbg_inline /*HDR*/
int64_t delta_timespec_ll_ns( const struct timespec *ts,
const struct timespec *ts_ref )
@@ -217,6 +235,8 @@ int64_t delta_timespec_ll_ns( const struct timespec *ts,
} // delta_timespec_ll_ns
+#endif // !defined( MBG_TGT_MISSING_64_BIT_TYPES )
+
/* ----- function prototypes begin ----- */
diff --git a/mbglib/common/toolutil.c b/mbglib/common/toolutil.c
index e0e05f1..46c8e65 100644
--- a/mbglib/common/toolutil.c
+++ b/mbglib/common/toolutil.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: toolutil.c 1.9 2018/12/14 13:13:46Z martin REL_M $
+ * $Id: toolutil.c 1.10 2019/02/08 10:34:47Z martin REL_M $
*
* Description:
* Common functions which can be used with Meinberg command line
@@ -9,7 +9,9 @@
*
* -----------------------------------------------------------------------
* $Log: toolutil.c $
- * Revision 1.9 2018/12/14 13:13:46Z martin
+ * Revision 1.10 2019/02/08 10:34:47Z martin
+ * Fix for the mingw build environment.
+ * Revision 1.9 2018/12/14 13:13:46 martin
* Cleaned up mbg_open_device_by_param(), removed obsolete
* parameters, and removed all printing by this function.
* New function mbg_open_device_by_param_chk() which actually
@@ -90,7 +92,9 @@
-#if defined( MBG_TGT_WIN32 )
+#if defined( MBG_TGT_WIN32 ) && defined( _MSC_VER )
+ // Required for MSC, but not for e.g. MinGW.
+ // Must be defined *after* stdio has been included.
#define isatty _isatty
#define fileno _fileno
#endif
diff --git a/mbglib/common/usbdefs.h b/mbglib/common/usbdefs.h
index 4ca60ef..1159868 100644
--- a/mbglib/common/usbdefs.h
+++ b/mbglib/common/usbdefs.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: usbdefs.h 1.37 2018/11/01 10:53:29Z martin REL_M $
+ * $Id: usbdefs.h 1.40 2019/01/14 08:37:45Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,15 @@
*
* -----------------------------------------------------------------------
* $Log: usbdefs.h $
+ * Revision 1.40 2019/01/14 08:37:45Z martin
+ * GRC181 and GRC165 were preliminary names, so changed the
+ * associated definitions to GNS181 and GNS165 which are the
+ * final device names.
+ * Removed obsolete USYNCPWR stuff.
+ * Revision 1.39 2019/01/11 11:45:42 martin
+ * Added definitions for CPC200.
+ * Revision 1.38 2018/12/18 13:08:20 gregoire.diehl
+ * Added VSI180
* Revision 1.37 2018/11/01 10:53:29Z martin
* Added some missing device name strings.
* Revision 1.36 2018/10/30 12:22:26 paul.kretz
@@ -164,9 +173,14 @@ enum MBG_USB_CLASS_CODES
MBG_USB_CLASS_GRC, ///< GNSS receivers (GPS, GLONASS, ... )
MBG_USB_CLASS_N2X, ///< NTP/PTP receiver
- MBG_USB_CLASS_USYNC, ///< MicroSync
+ MBG_USB_CLASS_PLACEHOLDER, // TODO formerly this was MBG_USB_CLASS_USYNC, used with USYNCPWR.
+ // This is obsolete, but we need to keep an entry here to preserve
+ // the numeric values of subsequent symbols.
+ // When another new class needs to be defined, the class can be
+ // defined in place here, and MBG_USB_CLASS_PLACEHOLDER can be removed.
MBG_USB_CLASS_FCM, ///< Fake Clock Module
MBG_USB_CLASS_PIO, ///< Programmable Input/Output Module
+ MBG_USB_CLASS_VSI, ///< Video Sync Interface
N_MBG_USB_CLASS ///< number of known Meinberg USB device class codes
};
@@ -190,6 +204,7 @@ enum MBG_USB_CLASS_CODES
#define USB_DEV_CPC_01 ( ( MBG_USB_CLASS_CPC << 8 ) | 0x01 )
#define USB_DEV_CPC180 ( ( MBG_USB_CLASS_CPC << 8 ) | 0x02 )
+#define USB_DEV_CPC200 ( ( MBG_USB_CLASS_CPC << 8 ) | 0x03 )
#define USB_DEV_TSU_01 ( ( MBG_USB_CLASS_TSU << 8 ) | 0x01 )
@@ -259,17 +274,16 @@ enum MBG_USB_CLASS_CODES
#define USB_DEV_VSG180 ( ( MBG_USB_CLASS_VSG << 8 ) | 0x01 )
+#define USB_DEV_VSI180 ( ( MBG_USB_CLASS_VSI << 8 ) | 0x01 )
+
#define USB_DEV_GTS180 ( ( MBG_USB_CLASS_GTS << 8 ) | 0x01 )
-// Eventually these GRC* devices should be named GNS*.
#define USB_DEV_GRC180 ( ( MBG_USB_CLASS_GRC << 8 ) | 0x01 )
-#define USB_DEV_GRC181 ( ( MBG_USB_CLASS_GRC << 8 ) | 0x02 )
-#define USB_DEV_GRC165 ( ( MBG_USB_CLASS_GRC << 8 ) | 0x03 )
+#define USB_DEV_GNS181 ( ( MBG_USB_CLASS_GRC << 8 ) | 0x02 )
+#define USB_DEV_GNS165 ( ( MBG_USB_CLASS_GRC << 8 ) | 0x03 )
#define USB_DEV_N2X180 ( ( MBG_USB_CLASS_N2X << 8 ) | 0x01 )
-#define USB_DEV_USYNCPWR ( ( MBG_USB_CLASS_USYNC << 8 ) | 0x01 ) ///< MicroSync Power Supply Module
-
#define USB_DEV_FCM180 ( ( MBG_USB_CLASS_FCM << 8 ) | 0x01 ) ///< Fake Clock Module
#define USB_DEV_PIO180 ( ( MBG_USB_CLASS_PIO << 8 ) | 0x01 ) ///< Programmable Input/Output Module
@@ -292,6 +306,7 @@ enum MBG_USB_CLASS_CODES
#define USB_DEV_NAME_CPC_01 "CPC_01"
#define USB_DEV_NAME_CPC180 "CPC180"
+#define USB_DEV_NAME_CPC200 "CPC200"
#define USB_DEV_NAME_TSU_01 "TSU_01"
@@ -359,17 +374,16 @@ enum MBG_USB_CLASS_CODES
#define USB_DEV_NAME_SSP100 "SSP100"
#define USB_DEV_NAME_VSG180 "VSG180"
+#define USB_DEV_NAME_VSI180 "VSI180"
#define USB_DEV_NAME_GTS180 "GTS180"
#define USB_DEV_NAME_GRC180 "GRC180"
-#define USB_DEV_NAME_GRC181 "GRC181"
-#define USB_DEV_NAME_GRC165 "GRC165"
+#define USB_DEV_NAME_GNS181 "GNS181"
+#define USB_DEV_NAME_GNS165 "GNS165"
#define USB_DEV_NAME_N2X180 "N2X180"
-#define USB_DEV_NAME_USYNCPWR "MICROSYNC-PWR"
-
#define USB_DEV_NAME_FCM180 "FCM180"
#define USB_DEV_NAME_PIO180 "PIO180"
@@ -425,19 +439,20 @@ enum MBG_USB_CLASS_CODES
{ USB_DEV_LNE180SFP, USB_DEV_NAME_LNE180SFP }, \
{ USB_DEV_GTS180, USB_DEV_NAME_GTS180 }, \
{ USB_DEV_GRC180, USB_DEV_NAME_GRC180 }, \
- { USB_DEV_GRC181, USB_DEV_NAME_GRC181 }, \
+ { USB_DEV_GNS181, USB_DEV_NAME_GNS181 }, \
{ USB_DEV_N2X180, USB_DEV_NAME_N2X180 }, \
{ USB_DEV_MDU312, USB_DEV_NAME_MDU312 }, \
{ USB_DEV_PZF180, USB_DEV_NAME_PZF180 }, \
- { USB_DEV_USYNCPWR, USB_DEV_NAME_USYNCPWR }, \
{ USB_DEV_FDM180M, USB_DEV_NAME_FDM180M }, \
{ USB_DEV_LSG180, USB_DEV_NAME_LSG180 }, \
{ USB_DEV_FCM180, USB_DEV_NAME_FCM180 }, \
{ USB_DEV_PIO180, USB_DEV_NAME_PIO180 }, \
{ USB_DEV_TCR180USB, USB_DEV_NAME_TCR180USB }, \
{ USB_DEV_SSP100, USB_DEV_NAME_SSP100 }, \
- { USB_DEV_GRC165, USB_DEV_NAME_GRC165 }, \
+ { USB_DEV_GNS165, USB_DEV_NAME_GNS165 }, \
{ USB_DEV_BPE_STM, USB_DEV_NAME_BPE_STM }, \
+ { USB_DEV_VSI180, USB_DEV_NAME_VSI180 }, \
+ { USB_DEV_CPC200, USB_DEV_NAME_CPC200 }, \
{ 0, /* end of table */ NULL } \
}
diff --git a/mbglib/common/words.h b/mbglib/common/words.h
index 48812cc..5550bbb 100644
--- a/mbglib/common/words.h
+++ b/mbglib/common/words.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: words.h 1.45 2018/11/22 16:38:15Z martin REL_M $
+ * $Id: words.h 1.46 2019/02/07 14:38:56Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: words.h $
- * Revision 1.45 2018/11/22 16:38:15Z martin
+ * Revision 1.46 2019/02/07 14:38:56Z martin
+ * Removed a duplicate definition.
+ * Revision 1.45 2018/11/22 16:38:15 martin
* Removed inclusion of mbg_no_tgt.h which is obsolete here.
* Revision 1.44 2018/06/25 09:21:02 martin
* Support MBG_TGT_NO_TGT.
@@ -692,10 +694,6 @@ do \
*/
#define STRINGIFY(x) XSTRINGIFY(x)
-// The XSTRINGIFY() macro is just a helper macro to implement STRINGIFY()
-// and should not be used alone.
-#define XSTRINGIFY(x) #x
-
/* End of header body */
diff --git a/mbgstatus/mbgstatus.c b/mbgstatus/mbgstatus.c
index 654367b..fdf1e07 100644
--- a/mbgstatus/mbgstatus.c
+++ b/mbgstatus/mbgstatus.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgstatus.c 1.17 2018/11/15 12:12:37Z martin REL_M $
+ * $Id: mbgstatus.c 1.18 2019/02/08 11:08:47Z martin REL_M $
*
* Description:
* Main file for mbgstatus program which demonstrates how to
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbgstatus.c $
- * Revision 1.17 2018/11/15 12:12:37Z martin
+ * Revision 1.18 2019/02/08 11:08:47Z martin
+ * Also print EPLD name in verbose mode.
+ * Revision 1.17 2018/11/15 12:12:37 martin
* Individual MBG_MICRO_VERSION codes are now obsolete.
* Revision 1.16 2018/07/03 15:28:55 martin
* Use -L rather than -l to display unique names of installed devices
@@ -453,8 +455,13 @@ void show_ext_stat_info( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, const char *t
// now print information
if ( verbose )
+ {
printf( "Feature mask: 0x%08lX\n", (ulong) ri.features );
+ if ( verbose > 2 )
+ printf( "EPLD name: \"%s\"\n", ri.epld_name );
+ }
+
if ( _pcps_has_stat_info( p_dev ) )
{
if ( _pcps_has_stat_info_mode( p_dev ) )
diff --git a/mbgversion.h b/mbgversion.h
index 9a957fb..22fbec1 100644
--- a/mbgversion.h
+++ b/mbgversion.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgversion.h 1.11 2018/12/13 15:39:00Z martin REL_M $
+ * $Id: mbgversion.h 1.12 2019/02/08 10:18:07Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbgversion.h $
- * Revision 1.11 2018/12/13 15:39:00Z martin
+ * Revision 1.12 2019/02/08 10:18:07Z martin
+ * New version code 4.2.2.
+ * Changed current copyright year to 2019.
+ * Revision 1.11 2018/12/13 15:39:00 martin
* New version code 4.2.1.
* Revision 1.10 2018/08/07 13:15:33 martin
* Cleaned up version definitions.
@@ -44,11 +47,11 @@
// copyright year, and the software version numbers.
// --------------------------------------------------------------------
-#define MBG_CURRENT_COPYRIGHT_YEAR 2018
+#define MBG_CURRENT_COPYRIGHT_YEAR 2019
#define MBG_MAJOR_VERSION_CODE 4
#define MBG_MINOR_VERSION_CODE 2
-#define MBG_MICRO_VERSION_CODE 1
+#define MBG_MICRO_VERSION_CODE 2
#if defined( MBG_TGT_WIN32 )
#define MBG_BUILD_VERSION_CODE 1