summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2023-08-02 12:09:19 +0200
committerMartin Burnicki <martin.burnicki@meinberg.de>2023-08-02 12:09:19 +0200
commit225d810eaa61f459a2aaa66158b90597a16f0d46 (patch)
treeca8ee2b2ead857024f79ad68a6f8270cc1712e37
parent48c5e6d0e96d28f3d2ba0262882ed58ab36c7b8f (diff)
downloadmbgtools-lx-225d810eaa61f459a2aaa66158b90597a16f0d46.tar.gz
mbgtools-lx-225d810eaa61f459a2aaa66158b90597a16f0d46.zip
Improve and fix SYN1588 debug code
-rw-r--r--makefile-supp-syn1588.mk14
-rw-r--r--mbglib/common/mbg_syn1588_io.c10
-rw-r--r--mbglib/common/mbg_syn1588_util.h10
3 files changed, 25 insertions, 9 deletions
diff --git a/makefile-supp-syn1588.mk b/makefile-supp-syn1588.mk
index 264568a..9a9d62d 100644
--- a/makefile-supp-syn1588.mk
+++ b/makefile-supp-syn1588.mk
@@ -1,14 +1,16 @@
#########################################################################
#
-# $Id: makefile-supp-syn1588.mk 1.5 2022/09/07 17:26:43 martin.burnicki REL_M $
+# $Id: makefile-supp-syn1588.mk 1.6 2023/08/02 10:06:56 martin.burnicki REL_M $
#
# Makefile to be included in the top-level makefile
# of projects with SYN1588 support.
#
# -----------------------------------------------------------------------
# $Log: makefile-supp-syn1588.mk $
-# Revision 1.5 2022/09/07 17:26:43 martin.burnicki
+# Revision 1.6 2023/08/02 10:06:56 martin.burnicki
+# Improved support for SYN1588 debugging.
+# Revision 1.5 2022/09/07 17:26:43 martin.burnicki
# Cleanup.
# Revision 1.4 2022/07/06 14:39:27 martin.burnicki
# Updated syn1588 module list.
@@ -51,6 +53,8 @@ SUPP_SYN1588_USR_SPC ?= $(SUPP_SYN1588)
SUPP_SYN1588_USR_SPC_CPP ?= $(SUPP_SYN1588_USR_SPC)
SUPP_SYN1588_SHM ?= 0
DEBUG_SYN1588_C_API ?= 0
+DEBUG_SYN1588_DETECTION ?= 0
+DEBUG_SYN1588_OPEN_CLOSE ?= 0
# The default subdirectory within the mbglib directory
@@ -200,6 +204,8 @@ endif
export SUPP_SYN1588_USR_SPC
export SUPP_SYN1588_USR_SPC_CPP
export DEBUG_SYN1588_C_API
+export DEBUG_SYN1588_DETECTION
+export DEBUG_SYN1588_OPEN_CLOSE
export SYN1588_OBJS
@@ -218,6 +224,8 @@ $(call debug_msg,$(INFO) SUPP_SYN1588_USR_SPC: $(SUPP_SYN1588_USR_SPC))
$(call debug_msg,$(INFO) SUPP_SYN1588_USR_SPC_CPP: $(SUPP_SYN1588_USR_SPC_CPP))
$(call debug_msg,$(INFO) SUPP_SYN1588_USR_SPC_DEBUG: $(SUPP_SYN1588_USR_SPC_DEBUG))
$(call debug_msg,$(INFO) DEBUG_SYN1588_C_API: $(DEBUG_SYN1588_C_API))
+$(call debug_msg,$(INFO) DEBUG_SYN1588_DETECTION: $(DEBUG_SYN1588_DETECTION))
+$(call debug_msg,$(INFO) DEBUG_SYN1588_OPEN_CLOSE: $(DEBUG_SYN1588_OPEN_CLOSE))
CPPFLAGS_SYN1588 += -DSUPP_SYN1588=$(SUPP_SYN1588)
@@ -226,6 +234,8 @@ CPPFLAGS_SYN1588 += -DSUPP_SYN1588_USR_SPC_CPP=$(SUPP_SYN1588_USR_SPC_CPP)
CPPFLAGS_SYN1588 += -DSUPP_SYN1588_SHM=$(SUPP_SYN1588_SHM)
CPPFLAGS_SYN1588 += -DSUPP_SYN1588_USR_SPC_DEBUG=$(SUPP_SYN1588_USR_SPC_DEBUG)
CPPFLAGS_SYN1588 += -DDEBUG_SYN1588_C_API=$(DEBUG_SYN1588_C_API)
+CPPFLAGS_SYN1588 += -DDEBUG_SYN1588_DETECTION=$(DEBUG_SYN1588_DETECTION)
+CPPFLAGS_SYN1588 += -DDEBUG_SYN1588_OPEN_CLOSE=$(DEBUG_SYN1588_OPEN_CLOSE)
CPPFLAGS_SYN1588 += -DNO_LOGGING=1
CPPFLAGS_SYN1588 += -DLOG_LEVEL=-1
diff --git a/mbglib/common/mbg_syn1588_io.c b/mbglib/common/mbg_syn1588_io.c
index 7390e4e..f9fe086 100644
--- a/mbglib/common/mbg_syn1588_io.c
+++ b/mbglib/common/mbg_syn1588_io.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_syn1588_io.c 1.13 2023/05/03 16:49:27 martin.burnicki REL_M $
+ * $Id: mbg_syn1588_io.c 1.14 2023/08/02 10:07:41 martin.burnicki TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_syn1588_io.c $
+ * Revision 1.14 2023/08/02 10:07:41 martin.burnicki
+ * Fixes in SYN1588 debug code.
* Revision 1.13 2023/05/03 16:49:27 martin.burnicki
* Fixed some format string compiler warnings.
* Revision 1.12 2023/02/21 10:15:34 martin.burnicki
@@ -363,7 +365,7 @@ void mbg_syn1588_close_device( MBG_DEV_HANDLE *p_dh )
}
#if DEBUG_SYN1588_OPEN_CLOSE
- fprintf( stderr, "%s: decreased use count is %i, not closing device with idx %i, handle 0x%" PRIx64 "\n",
+ fprintf( stderr, "%s: decreased use count is %lu, not closing device with idx %i, handle 0x%" PRIx64 "\n",
__func__, p->use_count, p->dev_idx, (uint64_t) p->dh );
#endif
}
@@ -547,13 +549,13 @@ int mbg_syn1588_find_devices( int max_devs, MBG_DEV_FN dev_fn_array[] )
// TODO Maybe we should print an error message here,
// at least in debug mode, or "permission denied".
#if DEBUG_SYN1588_DETECTION
- printf( "SYN1588 device #%i not found: %s\n", i, mbg_strerror( rc ) );
+ printf( "SYN1588 device #%i not found: %s\n", dev_idx, mbg_strerror( rc ) );
#endif
break;
}
#if DEBUG_SYN1588_DETECTION
- printf( "SYN1588 device #%i found!\n", i );
+ printf( "SYN1588 device #%i found!\n", dev_idx );
#endif
if ( ++n_devs >= max_devs )
diff --git a/mbglib/common/mbg_syn1588_util.h b/mbglib/common/mbg_syn1588_util.h
index 96868e3..52ed08c 100644
--- a/mbglib/common/mbg_syn1588_util.h
+++ b/mbglib/common/mbg_syn1588_util.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_syn1588_util.h 1.4 2022/12/21 15:22:49 martin.burnicki REL_M $
+ * $Id: mbg_syn1588_util.h 1.5 2023/08/02 10:07:50 martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -9,6 +9,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_syn1588_util.h $
+ * Revision 1.5 2023/08/02 10:07:50 martin.burnicki
+ * Fixes in SYN1588 debug code.
* Revision 1.4 2022/12/21 15:22:49 martin.burnicki
* Quieted some potential compiler warnings.
* Revision 1.3 2022/07/19 16:05:17 martin.burnicki
@@ -446,6 +448,7 @@ void syn1588_decode_sync_status( SYN1588_PTP_SYNC_STATUS ptp_sync_status, PCPS_H
#if DEBUG_SYN1588_C_API
{
+ char s[128];
bool ptp_sync_status_valid = syn1588_ptp_sync_status_valid( ptp_sync_status );
int utc_tai_offs = syn1588_utc_offs_from_sync_status( ptp_sync_status );
@@ -463,6 +466,8 @@ void syn1588_decode_sync_status( SYN1588_PTP_SYNC_STATUS ptp_sync_status, PCPS_H
bool lsync_running = syn1588_lsync_running( ptp_sync_status );
+ mbg_syn1588_snprint_insync_boundary_code( s, sizeof( s ), insync_boundary_code, true );
+
fprintf( stderr, " PTP sync status: %svalid (0x%08lX)\n", ptp_sync_status_valid ? "" : "NOT ",
(ulong) ptp_sync_status );
fprintf( stderr, " Time scale: %s\n", timescale_is_ptp ? "PTP/TAI" : "arbitrary" );
@@ -471,8 +476,7 @@ void syn1588_decode_sync_status( SYN1588_PTP_SYNC_STATUS ptp_sync_status, PCPS_H
fprintf( stderr, " Leap 59: %i, Leap 61: %i\n", leap_59, leap_61 );
fprintf( stderr, " PTP State: 0x%08X (%s), in sync: %i, boundary: %u (%s)\n", ptp_state,
mbg_syn1588_chk_get_ptp_state_str( ptp_state ),
- ptp_in_sync, insync_boundary_code,
- mbg_syn1588_get_boundary_str( insync_boundary_code ) );
+ ptp_in_sync, insync_boundary_code, s );
fprintf( stderr, " lSync running: %s\n\n", lsync_running ? "Yes" : "No" );
}
#endif