diff options
author | Martin Burnicki <martin.burnicki@meinberg.de> | 2009-01-21 12:31:00 +0100 |
---|---|---|
committer | Martin Burnicki <martin.burnicki@meinberg.de> | 2009-01-21 12:31:00 +0100 |
commit | 13364f3c64b13c8bac5dabcbf3a8d7448569bdc2 (patch) | |
tree | 651c85fd3100436c5d213e967bdfac2b22116aca | |
parent | f3a47fcf8ad7a41cec8eb6e7128dab3a419ebec4 (diff) | |
parent | 8de4b2ab69a2b6c3a36ddaf7e7f1f68dfbc43855 (diff) | |
download | mbgsdk-win-13364f3c64b13c8bac5dabcbf3a8d7448569bdc2.tar.gz mbgsdk-win-13364f3c64b13c8bac5dabcbf3a8d7448569bdc2.zip |
Merge branch 'mbgdmpst'
-rw-r--r-- | c/demo/mbgsvcio/mbgdmpst.cpp | 149 | ||||
-rw-r--r-- | c/demo/mbgsvcio/vc6/mbgdmpst.dsp | 150 | ||||
-rw-r--r-- | c/demo/mbgsvcio/vc6/mbgdmpst.dsw | 29 | ||||
-rw-r--r-- | c/demo/mbgsvcio/vc6/mbgdmpst.rc | 109 | ||||
-rw-r--r-- | c/demo/mbgsvcio/vc6/resource.h | 15 | ||||
-rw-r--r-- | c/demo/mbgsvcio/vc6/stdafx.cpp | 8 | ||||
-rw-r--r-- | c/demo/mbgsvcio/vc6/stdafx.h | 23 | ||||
-rw-r--r-- | c/mbglib/include/mbg_tgt.h | 154 | ||||
-rw-r--r-- | c/mbglib/include/mbgsvcio.h | 77 | ||||
-rw-r--r-- | c/mbglib/include/pcpsdefs.h | 826 | ||||
-rw-r--r-- | c/mbglib/include/use_pack.h | 29 | ||||
-rw-r--r-- | c/mbglib/include/words.h | 131 | ||||
-rw-r--r-- | c/mbglib/lib/bc/mbgsvcio.lib | bin | 0 -> 1024 bytes | |||
-rw-r--r-- | c/mbglib/lib/msc/mbgsvcio.lib | bin | 0 -> 4248 bytes |
14 files changed, 1700 insertions, 0 deletions
diff --git a/c/demo/mbgsvcio/mbgdmpst.cpp b/c/demo/mbgsvcio/mbgdmpst.cpp new file mode 100644 index 0000000..fe81bcc --- /dev/null +++ b/c/demo/mbgsvcio/mbgdmpst.cpp @@ -0,0 +1,149 @@ +// mbgdmpst.cpp : Defines the entry point for the application. +// + +#include "stdafx.h" + +#include <mbgsvcio.h> +#include <pcpsdefs.h> + +#include <stdio.h> + + + + +static const char *prog_info = "Meinberg Time Adjustment Status Dumper"; +static const char *prog_version = "v1.1"; + +#define SECTION_INFO "[Info]" +#define SECTION_OUTPUT "[Output]" + +#define KEY_SVC_ACTIVE "SvcTimeAdjustmentActive" +#define KEY_SVC_REF_ACCESSIBLE "SvcRefTimeAccessible" + + +#define KEY_FREER "RefTimeNotSynchronized" +#define KEY_DL_ENB "RefDaylightSavingEnabled" +#define KEY_SYNC_AFTER_RESET "RefSyncAfterReset" +#define KEY_DL_ANN "RefDaylightChangeAnnounced" +#define KEY_UTC "RefIsUtc" +#define KEY_LS_ANN "RefLeapSecondAnnounced" +#define KEY_SET_MANUALLY "RefTimeSetManually" +#define KEY_INV_TIME "RefTimeInvalid" + + + +static /*HDR*/ +void dump_status_item( FILE *fp, const char *name, int val, int cond ) +{ + fprintf( fp, "%s=", name ); + + if ( cond ) + fprintf( fp, "%i", val ); + + fprintf( fp, "\n" ); + +} // dump_status_item + + + +static /*HDR*/ +void dump_status( FILE *fp, int st, int cond ) +{ + #define N_STATUS 8 + + typedef struct + { + int mask; + const char *key_name; + } ST_INFO; + + static const ST_INFO st_info[N_STATUS] = + { + { PCPS_FREER, KEY_FREER }, + { PCPS_DL_ENB, KEY_DL_ENB }, + { PCPS_SYNCD, KEY_SYNC_AFTER_RESET }, + { PCPS_DL_ANN, KEY_DL_ANN }, + { PCPS_UTC, KEY_UTC }, + { PCPS_LS_ANN, KEY_LS_ANN }, + { PCPS_IFTM, KEY_SET_MANUALLY }, + { PCPS_INVT, KEY_INV_TIME } + }; + + int i; + + + for ( i = 0; i < N_STATUS; i++ ) + { + const ST_INFO *p = &st_info[i]; + int val = ( st & p->mask ) != 0; + dump_status_item( fp, p->key_name, val, cond ); + } + +} // dump_status + + + +/*HDR*/ +void mbg_dump_time_adjustment_status( FILE *fp ) +{ + static const char *key_svc_active = KEY_SVC_ACTIVE; + static const char *key_ref_accessible = KEY_SVC_REF_ACCESSIBLE; + + int svc_active; + int ref_accessible; + int ref_time_status; + + fprintf( fp, + "%s\n" + "About=%s %s\n" + "\n", + SECTION_INFO, + prog_info, + prog_version + ); + + fprintf( fp, "%s\n", SECTION_OUTPUT ); + + svc_active = mbg_time_adjustment_active(); + dump_status_item( fp, key_svc_active, svc_active, 1 ); + + svc_active = svc_active > 0; + + ref_accessible = svc_active && mbg_ref_time_accessible(); + dump_status_item( fp, key_ref_accessible, ref_accessible, svc_active ); + + ref_accessible = ref_accessible > 0; + + ref_time_status = mbg_get_ref_time_status(); + dump_status( fp, ref_time_status, ref_accessible ); + + fprintf( fp, "\n" ); + +} // mbg_dump_time_adjustment_status + + + + +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) +{ +#if 1 + if ( nCmdShow ) + { + FILE *fp = fopen( lpCmdLine, "wt" ); + + if ( fp ) + { + mbg_dump_time_adjustment_status( fp ); + fclose( fp ); + } + } +#endif + + return 0; +} + + + diff --git a/c/demo/mbgsvcio/vc6/mbgdmpst.dsp b/c/demo/mbgsvcio/vc6/mbgdmpst.dsp new file mode 100644 index 0000000..d8ca388 --- /dev/null +++ b/c/demo/mbgsvcio/vc6/mbgdmpst.dsp @@ -0,0 +1,150 @@ +# Microsoft Developer Studio Project File - Name="mbgdmpst" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=mbgdmpst - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "mbgdmpst.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "mbgdmpst.mak" CFG="mbgdmpst - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mbgdmpst - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "mbgdmpst - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "mbgdmpst - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "." /I "common" /I "win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "mbgdmpst - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "common" /I "win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "mbgdmpst - Win32 Release" +# Name "mbgdmpst - Win32 Debug" +# Begin Group "common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\common\mbg_tgt.h +# End Source File +# Begin Source File + +SOURCE=.\common\pcpsdefs.h +# End Source File +# Begin Source File + +SOURCE=.\common\use_pack.h +# End Source File +# Begin Source File + +SOURCE=.\common\words.h +# End Source File +# End Group +# Begin Group "win32" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\win32\mbgsvcio.h +# End Source File +# End Group +# Begin Group "lib" + +# PROP Default_Filter "" +# Begin Group "msc" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\lib\msc\mbgsvcio.lib +# End Source File +# End Group +# End Group +# Begin Source File + +SOURCE=.\mbgdmpst.cpp +# End Source File +# Begin Source File + +SOURCE=.\mbgdmpst.rc +# End Source File +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Target +# End Project diff --git a/c/demo/mbgsvcio/vc6/mbgdmpst.dsw b/c/demo/mbgsvcio/vc6/mbgdmpst.dsw new file mode 100644 index 0000000..5c76f67 --- /dev/null +++ b/c/demo/mbgsvcio/vc6/mbgdmpst.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "mbgdmpst"=.\mbgdmpst.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/c/demo/mbgsvcio/vc6/mbgdmpst.rc b/c/demo/mbgsvcio/vc6/mbgdmpst.rc new file mode 100644 index 0000000..232311e --- /dev/null +++ b/c/demo/mbgsvcio/vc6/mbgdmpst.rc @@ -0,0 +1,109 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// German (Germany) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,1,0,0 + PRODUCTVERSION 1,1,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "Comments", "\0" + VALUE "CompanyName", "Meinberg Funkuhren, Bad Pyrmont, Germany\0" + VALUE "FileDescription", "Meinberg Service Status Dumper\0" + VALUE "FileVersion", "1, 1, 0, 0\0" + VALUE "InternalName", "mbgdmpst\0" + VALUE "LegalCopyright", "Copyright © Meinberg 2004\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "mbgdmpst.exe\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "Meinberg Service Status Dumper\0" + VALUE "ProductVersion", "1, 1, 0, 0\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END + +#endif // !_MAC + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // German (Germany) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/c/demo/mbgsvcio/vc6/resource.h b/c/demo/mbgsvcio/vc6/resource.h new file mode 100644 index 0000000..7c77e12 --- /dev/null +++ b/c/demo/mbgsvcio/vc6/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by mbgdmpst.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/c/demo/mbgsvcio/vc6/stdafx.cpp b/c/demo/mbgsvcio/vc6/stdafx.cpp new file mode 100644 index 0000000..da3801b --- /dev/null +++ b/c/demo/mbgsvcio/vc6/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// mbgdmpst.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/c/demo/mbgsvcio/vc6/stdafx.h b/c/demo/mbgsvcio/vc6/stdafx.h new file mode 100644 index 0000000..8baa7c7 --- /dev/null +++ b/c/demo/mbgsvcio/vc6/stdafx.h @@ -0,0 +1,23 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) +#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include <windows.h> + + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) diff --git a/c/mbglib/include/mbg_tgt.h b/c/mbglib/include/mbg_tgt.h new file mode 100644 index 0000000..2bca823 --- /dev/null +++ b/c/mbglib/include/mbg_tgt.h @@ -0,0 +1,154 @@ + +/************************************************************************** + * + * $Id: mbg_tgt.h 1.5 2003/12/17 16:11:41Z martin TEST $ + * + * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany + * + * Description: + * Check the build environment and setup control definitions + * for the Meinberg library modules. + * + * ----------------------------------------------------------------------- + * $Log: mbg_tgt.h $ + * Revision 1.5 2003/12/17 16:11:41Z martin + * Split API modifiers into _MBG_API and _MBG_API_ATTR. + * Revision 1.4 2003/06/19 08:20:22Z martin + * Added WINAPI attribute for DLL exported functions. + * Revision 1.3 2003/04/09 13:37:20Z martin + * Added definition for _MBG_API. + * Revision 1.2 2003/02/24 16:08:45Z martin + * Don't setup for Win32 PNP if explicitely configured non-PNP. + * Revision 1.1 2002/02/19 13:46:20Z MARTIN + * Initial revision + * + **************************************************************************/ + +#ifndef _MBG_TGT_H +#define _MBG_TGT_H + + +/* Other headers to be included */ + +#ifdef _MBG_TGT + #define _ext +#else + #define _ext extern +#endif + + +/* Start of header body */ + +#if defined( _WIN32_WINNT ) + + // MS platform SDK + // WinNT 4.0 and above + #define MBG_TGT_WIN32 + + #if ( _WIN32_WINNT >= 0x0500 ) + // Win2k and above + #if !defined( MBG_TGT_WIN32_NON_PNP ) + // only if not explicitely disabled + #define MBG_TGT_WIN32_PNP + #endif + #endif + +#elif defined( WINVER ) + + // MS platform SDK + // Win95, WinNT 4.0 and above + #define MBG_TGT_WIN32 + + #if ( WINVER >= 0x0500 ) + // Win98, Win2k and above + // #define ... + #endif + +#elif defined( __WIN32__ ) + + // Borland C++ Builder + #define MBG_TGT_WIN32 + +#elif defined( _WIN32 ) + + // MS Visual C++ + #define MBG_TGT_WIN32 + +#elif defined( __NETWARE_386__ ) + + // Watcom C/C++ for target NetWare + #define MBG_TGT_NETWARE + +#elif defined( __OS2__ ) + + // Watcom C/C++ for target OS/2 + #define MBG_TGT_OS2 + +#elif defined( __linux ) + + // GCC for target Linux + #define MBG_TGT_LINUX + +#elif defined( __QNX__ ) + + // any compiler for target QNX + #define MBG_TGT_QNX + + #if defined( __QNXNTO__ ) + // target QNX Neutrino + #define MBG_TGT_QNX_NTO + #endif + +#elif defined( __MSDOS__ ) + + // any compiler for target DOS + #define MBG_TGT_DOS + +#endif + + + +#if defined MBG_TGT_WIN32 + + #define _MBG_API WINAPI + + #if defined MBG_LIB_EXPORT + #define _MBG_API_ATTR __declspec( dllexport ) + #else + #define _MBG_API_ATTR __declspec( dllimport ) + #endif + +#else + + #define _MBG_API + #define _MBG_API_ATTR + +#endif + + +/* End of header body */ + +#undef _ext + + +/* function prototypes: */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----- function prototypes begin ----- */ + +/* This section was generated automatically */ +/* by MAKEHDR, do not remove the comments. */ + +/* (no header definitions found) */ + +/* ----- function prototypes end ----- */ + +#ifdef __cplusplus +} +#endif + + +#endif /* _MBG_TGT_H */ diff --git a/c/mbglib/include/mbgsvcio.h b/c/mbglib/include/mbgsvcio.h new file mode 100644 index 0000000..e489c48 --- /dev/null +++ b/c/mbglib/include/mbgsvcio.h @@ -0,0 +1,77 @@ + +/************************************************************************** + * + * $Id: mbgsvcio.h 1.1 2004/07/01 10:00:51Z martin TEST $ + * + * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany + * + * Description: + * Definitions and prototypes for mbgsvcio.c. + * + * ----------------------------------------------------------------------- + * $Log: mbgsvcio.h $ + * Revision 1.1 2004/07/01 10:00:51Z martin + * + **************************************************************************/ + +#ifndef _MBGSVCIO_H +#define _MBGSVCIO_H + + +/* Other headers to be included */ + +#include <mbg_tgt.h> + +#include <windows.h> +#include <stdio.h> //##++ + + +#ifdef _MBGSVCIO + #define _ext +#else + #define _ext extern +#endif + + +/* Start of header body */ + +#if defined( _USE_PACK ) // set byte alignment + #pragma pack( 1 ) +#endif + +#define MBGSVCIO_VERSION 0x0200 + +#define MBGSVCIO_COMPAT_VERSION 0x0200 + + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----- function prototypes begin ----- */ + +/* This section was generated automatically */ +/* by MAKEHDR, do not remove the comments. */ + + _MBG_API_ATTR int _MBG_API mbgsvcio_get_version( void ) ; + _MBG_API_ATTR int _MBG_API mbgsvcio_check_version( int header_version ) ; + _MBG_API_ATTR int _MBG_API mbg_time_adjustment_active( void ) ; + _MBG_API_ATTR int _MBG_API mbg_ref_time_accessible( void ) ; + _MBG_API_ATTR int _MBG_API mbg_get_ref_time_status( void ) ; + +/* ----- function prototypes end ----- */ + +#ifdef __cplusplus +} +#endif + +#if defined( _USE_PACK ) // set default alignment + #pragma pack() +#endif + +/* End of header body */ + +#undef _ext + +#endif // _MBGSVCIO_H + diff --git a/c/mbglib/include/pcpsdefs.h b/c/mbglib/include/pcpsdefs.h new file mode 100644 index 0000000..10d8320 --- /dev/null +++ b/c/mbglib/include/pcpsdefs.h @@ -0,0 +1,826 @@ + +/************************************************************************** + * + * $Id: pcpsdefs.h 1.19 2004/06/16 12:46:33Z martin REL_M $ + * + * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany + * + * Description: + * General definitions for Meinberg plug-in radio clocks + * + * ----------------------------------------------------------------------- + * $Log: pcpsdefs.h $ + * Revision 1.19 2004/06/16 12:46:33Z martin + * Moved OPT_SETTINGS related definitions to gpsdefs.h, + * and renamed symbols from PCPS_.. to to MBG_... + * Revision 1.18 2004/04/26 14:27:08Z martin + * Added union PCPS_TIME_UNION. + * Revision 1.17 2003/05/27 08:50:35Z MARTIN + * New commands PCPS_GIVE_UCAP_ENTRIES, PCPS_GIVE_UCAP_EVENT + * and associated definitions which allow faster reading of + * user capture events and monitoring of the capture buffer + * fill level. + * Revision 1.16 2003/04/03 10:48:53 martin + * Support for PCI510, GPS169PCI, and TCR510PCI. + * New codes PCPS_GET_REF_OFFS, PCPS_SET_REF_OFFS + * and related structures. + * New codes PCPS_GET_OPT_INFO, PCPS_SET_OPT_SETTINGS + * and related structures. + * New codes PCPS_GET_IRIG_INFO, PCPS_SET_IRIG_SETTINGS. + * Preliminary PCPS_TZDL structure and cmd codes + * to read/write that structure. + * Revision 1.15 2002/08/08 13:24:03 MARTIN + * Moved definition of ref time sources here. + * Added new ref time source IRIG. + * Added new cmd to clear time capture buffer. + * Fixed some comments. + * Revision 1.14 2002/01/31 13:39:38 MARTIN + * Added new GPS data type codes for RECEIVER_INFO, etc. + * New PCPS_HR_TIME status flag PCPS_IO_BLOCKED. + * Moved REV_NUMs defining special features to pcpsdev.h. + * Removed obsolete initializer for framing string table. + * Updated some comments. + * Removed obsolete code. + * Revision 1.13 2001/12/03 16:15:14 martin + * Introduced PCPS_TIME_STAMP which allows to handle high precision + * time stamps. + * Replaced the sec/frac fields in PCPS_HR_TIME by PCPS_TIME_STAMP. + * This is compatible on byte level but may require source code + * modifications. + * Introduced new command PCPS_SET_EVENT_TIME which is used + * EXCLUSIVELY with a custom GPS firmware. + * Revision 1.12 2001/10/16 10:07:42 MARTIN + * Defined PCI509 firmware revision number which supports + * baud rate higher than standard. + * Revision 1.11 2001/03/30 13:02:39 MARTIN + * Control alignment of structures from new file use_pack.h. + * Defined initializers with valid framing parameters. + * Revision 1.10 2001/02/28 15:39:25 MARTIN + * Modified preprocessor syntax. + * Revision 1.9 2001/02/16 11:32:05 MARTIN + * Renamed "PROM" or "EPROM" in comments or and names to + * "FW" or firmware. + * This includes the cmd codes PCPS_GIVE_PROM_ID_... which have + * been renamed to PCPS_GIVE_FW_ID_... + * Renamed structure PCPS_TIME_SET to PCPS_STIME. + * Renamed return code PCPS_ERR_NONE to PCPS_SUCCESS. + * Modified some comments. + * Revision 1.8 2000/10/11 09:17:09 MARTIN + * Cleaned up comment syntax. + * Revision 1.7 2000/07/21 14:16:30 MARTIN + * Modified some comments. + * Added PCI definitions. + * Renamed PCPS_GET_GPS_DATA to PCPS_READ_GPS_DATA. + * Renamed PCPS_SET_GPS_DATA to PCPS_WRITE_GPS_DATA. + * New types PCPS_SERIAL and PCPS_TZCODE. + * Removed PCPS_SERIAL_BYTES and PCPS_TZCODE_BYTES, may use sizeof() + * the types instead. + * New type PCPS_TIME_SET which can be used to write date and time + * to the clock. + * Revision 1.6 2000/06/07 12:09:31 MARTIN + * renamed PCPS_SERIAL_GROUP to PCPS_CFG_GROUP + * renamed PCPS_ERR_SERIAL to PCPS_ERR_CFG + * modified definitions for baud rate, framing, and mode + * added PCPS_SN_... definitions + * added PCPS_GET_TZCODE and PCPS_SET_TZCODE definitions + * added PC_GPS_ANT_CABLE_LEN definition + * added RCS keywords + * updated some comments + * + * ----------------------------------------------------------------------- + * Changes before put under RCS control: + * + * Revision 1.5 2000/03/24 + * Introduced PCPS_GIVE_SERNUM + * Cleaned up for definitions for serial parameter byte + * Reviewed and updated comments. + * + * 1998/07/22 + * Introduced PCPS_HR_TIME. + * Rearranged order of definitions. + * Reviewed and updated comments. + * + * 1997/06/12 + * GPS definitions added. + * + * 1996/01/25 + * PCPS_TIME redefined from an array of bytes to a structure. + * + **************************************************************************/ + +#ifndef _PCPSDEFS_H +#define _PCPSDEFS_H + + +/* Other headers to be included */ + +#include <words.h> +#include <use_pack.h> + + +/* Start of header body */ + +#if defined( _USE_PACK ) // set byte alignment + #pragma pack( 1 ) +#endif + + +/* + * The following codes enumerate the ref time sources + * from which the clocks receive the reference time. + */ +enum +{ + PCPS_REF_NONE, // (unknown or not defined) + PCPS_REF_DCF, // see http://www.meinberg.de/english/info/dcf77.htm + PCPS_REF_GPS, // see http://www.meinberg.de/english/info/gps.htm + PCPS_REF_IRIG, // see http://www.meinberg.de/english/info/irig.htm + N_PCPS_REF // number of valid ref time sources +}; + + +/* PCI vendor ID number (assigned by PCI SIG) */ +#define PCI_VENDOR_MEINBERG 0x1360 + +/* PCI device ID numbers (assigned by Meinberg) * + * High byte: type of ref time source + * Low Byte: enumeration of device types + */ +#define PCI_DEV_PCI32 ( ( PCPS_REF_DCF << 8 ) | 0x01 ) +#define PCI_DEV_PCI509 ( ( PCPS_REF_DCF << 8 ) | 0x02 ) +#define PCI_DEV_PCI510 ( ( PCPS_REF_DCF << 8 ) | 0x03 ) + +#define PCI_DEV_GPS167PCI ( ( PCPS_REF_GPS << 8 ) | 0x01 ) +#define PCI_DEV_GPS168PCI ( ( PCPS_REF_GPS << 8 ) | 0x02 ) +#define PCI_DEV_GPS169PCI ( ( PCPS_REF_GPS << 8 ) | 0x03 ) + +#define PCI_DEV_TCR510PCI ( ( PCPS_REF_IRIG << 8 ) | 0x01 ) + + +/* + * Command bytes used to access the board + * + * The commands described below can be used to access the Meinberg + * plug-in radio clocks. However, some of the commands have not been + * implemented with older clock models, or firmware versions. + * + * The device driver library contains functions which detect the clocks + * and check which features are supported by a given clock model/firmware + * The header files pcpsdev.h and pcpsdrvr.h contain macros which can be + * used to query whether a detected clock supports a feature. + * If checking is required, the name of the macro is given in the + * comments below. + * + * Some commands expect parameters to be passed to the board. In that + * case, the board returns the number of parameter bytes expected when + * the command code is passed. Every parameter byte has to be supplied + * to the board exactly like a command byte. + * Refer to function pcps_write_data() and the macro _pcps_write_var() + * for details. + * + * PCPS_GIVE_TIME Return a PCPS_TIME structure with current date, + * time and status. Supported by all clocks. + * + * PCPS_GIVE_TIME_NOCLEAR Same as PCPS_GIVE_TIME but the bits PCPS_ST_SEC + * and PCPS_ST_MIN (see pcpsdev.h) of the status + * port are not cleared. + * Supported by all clocks except PC31/PS31 with + * firmware version older than v3.0. + * This is mainly used by the DOS TSR and should + * not be used in other environments. + * + * PCPS_GIVE_SYNC_TIME Return a PCPS_TIME structure with date and time + * of last synchronization of the clock or + * the last time set via the interface. + * _pcps_has_sync_time() checks whether supported. + * + * PCPS_GIVE_HR_TIME Return a PCPS_HR_TIME structure with current + * date, time and status. This command should be + * used to read the clock with higher resolution. + * _pcps_has_hr_time() checks whether supported. + * + * PCPS_SET_TIME Set the board date, time and status. This + * command expects sizeof( PCPS_TIME_SET ) parameter + * bytes. + * _pcps_can_set_time() checks whether supported. + * + * PCPS_SET_EVENT_TIME Send a high resolution time stamp to the clock to + * configure a UTC time when the clock shall generate + * some event. This command expects a PCPS_TIME_STAMP + * parameter. + * _pcps_has_event_time() checks whether supported. + * (requires custom GPS CERN firmware) + * + * PCPS_IRQ_NONE Disable the board's hardware IRQ + * PCPS_IRQ_1_SEC Enable hardware IRQs once per second + * PCPS_IRQ_1_MIN Enable hardware IRQs once per minute + * PCPS_IRQ_10_MIN Enable hardware IRQs once per 10 minutes + * PCPS_IRQ_30_MIN Enable hardware IRQs once per 30 minutes + * + * PCPS_GET_SERIAL These commands read or set the configuration + * PCPS_SET_SERIAL of a clock's serial port COM0. The commands + * expect PCPS_SERIAL_BYTES parameter bytes and + * should be used preferably with the DCF77 + * clocks which have only one COM port. + * _pcps_has_serial() checks whether supported. + * Recent GPS clocks' COM ports should be cfg'd + * using the structures RECEIVER_INFO, PORT_INFO, + * and STR_TYPE_INFO. + * _pcps_has_receiver_info() checks whether + * these are supported. If they are not, then + * the code PC_GPS_PORT_PARM together with the + * PCPS_READ_GPS_DATA and PCPS_WRITE_GPS_DATA + * commands should be used. + * + * PCPS_GET_TZCODE These commands read or set a DCF77 clock's + * PCPS_SET_TZCODE time zone code and should be used preferably + * with the newer DCF77 clocks which have limited + * support of different time zones. + * _pcps_has_tzcode() checks whether supported. + * A GPS clock's time zone must be cfg'd using + * the code PC_GPS_TZDL together with the + * PCPS_READ_GPS_DATA and PCPS_WRITE_GPS_DATA + * commands. + * + * PCPS_GET_PCPS_TZDL These commands read or set a DCF77 clock's + * PCPS_SET_PCPS_TZDL time zone / daylight saving configuration. + * _pcps_has_pcps_tzdl() checks whether supported. + * A GPS clock's time zone must be cfg'd using + * the code PC_GPS_TZDL together with the + * PCPS_READ_GPS_DATA and PCPS_WRITE_GPS_DATA + * commands. + * + * PCPS_GET_REF_OFFS These commands can be used to configure the + * PCPS_SET_REF_OFFS reference time offset from UTC for clocks + * which can't determine the offset automatically, + * e.g. from an IRIG input signal. + * _pcps_has_ref_offs() checks whether supported. + * + * PCPS_GET_OPT_INFO These commands can be used to configure some + * PCPS_SET_OPT_SETTINGS optional settings, controlled by flags. + * When reading, the clock returns a MBG_OPT_INFO + * structure which contains the supported values, + * plus the current settings. + * When writing, clocks accepts a MBG_OPT_SETTINGS + * structure only which contain the desired settings + * of the supported flags only. + * _pcps_has_opt_flags() checks whether supported. + * + * PCPS_GET_IRIG_INFO These commands can be used to configure IRIG + * PCPS_SET_IRIG_SETTINGS formats. When reading, the clock returns an + * IRIG_INFO structure which contains the supported + * values, plus the current settings. When writing, + * clocks accepts an IRIG_SETTINGS structure only + * which contain the desired settings only. + * _pcps_is_irig_rx() checks whether supported. + * + * PCPS_GIVE_FW_ID_1 Returns the first/second block of PCPS_FIFO_SIZE + * PCPS_GIVE_FW_ID_2 characters of the firmware ID string. These + * commands can be used to check if the board + * responds properly. This is done by the clock + * detection functions. + * + * PCPS_GIVE_SERNUM Returns PCPS_FIFO_SIZE characters of the + * clock's serial number. + * _pcps_has_sernum() checks whether supported. + * + * PCPS_READ_GPS_DATA These commands are used by the functions + * PCPS_WRITE_GPS_DATA pcps_read_gps_data() and pcps_write_gps_data() + * to read or write large data structures to + * Meinberg GPS plug-in clocks. + * _pcps_is_gps() checks whether supported. + * + * PCPS_CLR_UCAP_BUFF Clear a clock's time capture buffer. + * _pcps_can_clr_ucap_buff() checks whether + * supported. + * + * PCPS_GIVE_UCAP_ENTRIES Read a PCPS_UCAP_ENTRIES structure which + * reports the max number of entries and the + * currently used number of entries in the + * user capture buffer. + * _pcps_has_ucap() checks whether supported. + * + * PCPS_GIVE_UCAP_EVENT Read capture events using a PCPS_HR_TIME + * structure. This is faster than reading using the + * GPS command PC_GPS_UCAP. If no capture event is + * available then the structure is filled with 0s. + * _pcps_has_ucap() checks whether supported. + * + * PCPS_FORCE_RESET Resets the microprocessor on the radio clock + * board. This is for debug purposes only and + * should not be used by standard applications. + * + * The command codes listed above are defined below. The commands are + * grouped for bytes having the same high nibble: + */ +#define PCPS_GIVE_TIME_GROUP 0x00 +#define PCPS_SET_TIME_GROUP 0x10 +#define PCPS_IRQ_GROUP 0x20 +#define PCPS_CFG_GROUP 0x30 +#define PCPS_GIVE_DATA_GROUP 0x40 +#define PCPS_GPS_DATA_GROUP 0x50 +#define PCPS_CTRL_GROUP 0x60 + + +/* PCPS_GIVE_TIME_GROUP */ +#define PCPS_GIVE_TIME ( PCPS_GIVE_TIME_GROUP | 0x0 ) +#define PCPS_GIVE_TIME_NOCLEAR ( PCPS_GIVE_TIME_GROUP | 0x1 ) +#define PCPS_GIVE_SYNC_TIME ( PCPS_GIVE_TIME_GROUP | 0x2 ) +#define PCPS_GIVE_HR_TIME ( PCPS_GIVE_TIME_GROUP | 0x3 ) + + +/* PCPS_SET_TIME_GROUP */ +#define PCPS_SET_TIME ( PCPS_SET_TIME_GROUP | 0x0 ) +/* on error, return PCPS_ERR_STIME */ + +/* Attention: The code below can be used EXCLUSIVELY */ +/* with a GPS167PCI with customized CERN firmware !! */ +/* _pcps_has_event_time() checks whether supported. */ +#define PCPS_SET_EVENT_TIME ( PCPS_SET_TIME_GROUP | 0x4 ) + + +/* PCPS_IRQ_GROUP */ +#define PCPS_IRQ_NONE ( PCPS_IRQ_GROUP | 0x0 ) +#define PCPS_IRQ_1_SEC ( PCPS_IRQ_GROUP | 0x1 ) +#define PCPS_IRQ_1_MIN ( PCPS_IRQ_GROUP | 0x2 ) +#define PCPS_IRQ_10_MIN ( PCPS_IRQ_GROUP | 0x4 ) +#define PCPS_IRQ_30_MIN ( PCPS_IRQ_GROUP | 0x8 ) + + +/* PCPS_CFG_GROUP */ + +#define PCPS_GET_SERIAL ( PCPS_CFG_GROUP | 0x0 ) +#define PCPS_SET_SERIAL ( PCPS_CFG_GROUP | 0x1 ) +/* on error, return PCPS_ERR_CFG */ + +typedef uchar PCPS_SERIAL; + + +#define PCPS_GET_TZCODE ( PCPS_CFG_GROUP | 0x2 ) +#define PCPS_SET_TZCODE ( PCPS_CFG_GROUP | 0x3 ) +/* on error, return PCPS_ERR_CFG */ + +typedef uchar PCPS_TZCODE; + +/* the following codes are used with the PCPS_TZCODE parameter: */ +enum +{ + PCPS_TZCODE_MEZMESZ, /* default as broadcasted by DCF77 (UTC+1h/UTC+2h) */ + PCPS_TZCODE_MEZ, /* always MEZ (UTC+1h), discard DST */ + PCPS_TZCODE_UTC, /* always UTC */ + PCPS_TZCODE_OEZ, /* Eastern European Time, MEZ/MESZ + 1h */ + N_PCPS_TZCODE /* the number of valid codes */ +}; + + +#define PCPS_GET_PCPS_TZDL ( PCPS_CFG_GROUP | 0x4 ) +#define PCPS_SET_PCPS_TZDL ( PCPS_CFG_GROUP | 0x5 ) +/* on error, return PCPS_ERR_CFG */ + +/* + * The structures below can be used to configure a clock's + * time zone/daylight saving setting. This structure is shorter + * than the TZDL structure used with GPS clocks. + */ +typedef struct +{ + ushort year_or_wday; // contents depends on MSB flag; see below + uchar month; + uchar mday; + uchar hour; + uchar min; +} PCPS_DL_ONOFF; + +// char wday; /* 0..6 == Sun..Sat */ +// char wday; /* 1..7 == Mon..Sun */ + +/* + * If the field year_or_wday is or'ed with the constant DL_AUTO_FLAG + * defined below then this means that start and end of daylight saving + * time shall be computed automatically for each year. In this case + * the remaining bits represent the day-of-week after the specified + * mday/month at which the change shall occur. If that flag is not set + * then the field contains the full four-digit year number and the + * mday/month values specify the exact date of that year. + */ +#define DL_AUTO_FLAG 0x8000 // also defined in gpsdefs.h + +typedef struct +{ + short offs; // offset from UTC to local time [min] + short offs_dl; // additional offset if DST enabled [min] + PCPS_DL_ONOFF tm_on; // date/time when daylight saving starts + PCPS_DL_ONOFF tm_off; // date/time when daylight saving ends +} PCPS_TZDL; + + + +#define PCPS_GET_REF_OFFS ( PCPS_CFG_GROUP | 0x6 ) +#define PCPS_SET_REF_OFFS ( PCPS_CFG_GROUP | 0x7 ) +/* on error, return PCPS_ERR_CFG */ + +typedef short PCPS_REF_OFFS; // -PCPS_REF_OFFS_MAX..PCPS_REF_OFFS_MAX + +/* the maximum allowed positive / negative offset */ +#define PCPS_REF_OFFS_MAX ( ( 12L * 60 ) + 30 ) // [minutes] + + + +#define PCPS_GET_OPT_INFO ( PCPS_CFG_GROUP | 0x8 ) +#define PCPS_SET_OPT_SETTINGS ( PCPS_CFG_GROUP | 0x9 ) +/* on error, return PCPS_ERR_CFG */ + +/* The associated structures MBG_OPT_INFO and MBG_OPT_SETTINGS + are defined in gpsdefs.h. */ + + +#define PCPS_GET_IRIG_INFO ( PCPS_CFG_GROUP | 0xA ) +#define PCPS_SET_IRIG_SETTINGS ( PCPS_CFG_GROUP | 0xB ) +/* on error, return PCPS_ERR_CFG */ + +/* The associated structures IRIG_INFO and IRIG_SETTINGS + are defined in gpsdefs.h. */ + + +/* PCPS_GIVE_DATA_GROUP */ +#define PCPS_GIVE_FW_ID_1 ( PCPS_GIVE_DATA_GROUP | 0x0 ) +#define PCPS_GIVE_FW_ID_2 ( PCPS_GIVE_DATA_GROUP | 0x1 ) +#define PCPS_GIVE_SERNUM ( PCPS_GIVE_DATA_GROUP | 0x2 ) + + +/* PCPS_GPS_DATA_GROUP */ +#define PCPS_READ_GPS_DATA ( PCPS_GPS_DATA_GROUP | 0x0 ) +#define PCPS_WRITE_GPS_DATA ( PCPS_GPS_DATA_GROUP | 0x1 ) + + +/* PCPS_CTRL_GROUP */ +#define PCPS_CLR_UCAP_BUFF ( PCPS_CTRL_GROUP | 0x0 ) +#define PCPS_GIVE_UCAP_ENTRIES ( PCPS_CTRL_GROUP | 0x1 ) +#define PCPS_GIVE_UCAP_EVENT ( PCPS_CTRL_GROUP | 0x2 ) + +typedef struct +{ + ulong used; /* the number of saved capture events */ + ulong max; /* capture buffer size */ +} PCPS_UCAP_ENTRIES; + + +/* special -- use with care */ +#define PCPS_FORCE_RESET 0x80 + + +/* Codes returned when commands with parameters have been passed */ +/* to the board */ +#define PCPS_SUCCESS 0 /* OK, no error */ +#define PCPS_ERR_STIME -1 /* invalid date/time/status passed */ +#define PCPS_ERR_CFG -2 /* invalid parms with a PCPS_CFG_GROUP cmd */ + + + +#ifndef BITMASK + #define BITMASK( b ) ( ( 1 << b ) - 1 ) +#endif + + +/* the size of the plug-in radio clock's on-board FIFO: */ +#define PCPS_FIFO_SIZE 16 + +typedef char PCPS_BUFF[PCPS_FIFO_SIZE]; + + +#define PCPS_ID_SIZE ( 2 * PCPS_FIFO_SIZE + 1 ) /* ASCIIZ string */ +typedef char PCPS_ID_STR[PCPS_ID_SIZE]; + + +#define PCPS_SN_SIZE ( PCPS_FIFO_SIZE + 1 ) /* ASCIIZ string */ +typedef char PCPS_SN_STR[PCPS_SN_SIZE]; + + +/* + * The structure below has been introduced to be able to handle + * high resolution time stamps. + */ +typedef struct +{ + ulong sec; /* seconds since 1970 (UTC) */ + ulong frac; /* fractions of second ( 0xFFFFFFFF == 0.9999.. sec) */ +} PCPS_TIME_STAMP; + + +/* + * The structure below has been introduced to be able to read the + * current time with higher resolution of fractions of seconds and + * more detailed information on the time zone and status. + * The structure is returned if the new command PCPS_GIVE_HR_TIME + * is written to the board. + * _pcps_has_hr_time() checks whether supported. + * + * Newer GPS boards also accept the PCPS_GIVE_UCAP_EVENT command + * to return user capture event times using this format. In this + * case, the "signal" field contains the number of the capture + * input line, e.g. 0 or 1. + * _pcps_has_ucap() checks whether supported. + */ +typedef struct +{ + PCPS_TIME_STAMP tstamp; + long utc_offs; /* UTC offs [sec] (loc_time = UTC + utc_offs) */ + ushort status; /* status flags as defined below */ + uchar signal; /* for normal time, the relative RF signal level */ + /* for ucap, the channel number */ +} PCPS_HR_TIME; /* "high resolution time" */ + + +/* the standard structure used to read times from the board */ +typedef struct PCPS_TIME_s +{ + uchar sec100; + uchar sec; + uchar min; + uchar hour; + + uchar mday; + uchar wday; + uchar month; + uchar year; + + uchar status; + uchar signal; + char offs_utc; /* [hours], 0 if !_pcps_has_utc_offs() */ +} PCPS_TIME; + + +/* the structure below is passed as parameter with the PCPS_SET_TIME cmd */ +typedef struct PCPS_STIME_s +{ + uchar sec100; + uchar sec; + uchar min; + uchar hour; + + uchar mday; + uchar wday; + uchar month; + uchar year; + + uchar status; +} PCPS_STIME; + + +typedef union +{ + PCPS_TIME t; + PCPS_STIME stime; +} PCPS_TIME_UNION; + + +/* + * The enumeration below is useful if a PCPS_TIME structure + * must be accessed as an array of bytes. Be sure the order of + * fields matches: + */ +enum +{ + PCPS_SEC100, + PCPS_SEC, + PCPS_MIN, + PCPS_HOUR, + PCPS_MDAY, + PCPS_WDAY, + PCPS_MONTH, + PCPS_YEAR, + PCPS_STATUS, + PCPS_SIGNAL, + PCPS_OFFS_UTC +}; + + + +/* Bit masks used with both PCPS_TIME.status and PCPS_HR_TIME.status */ + +#define PCPS_FREER 0x01 /* DCF77 clock running on xtal */ + /* GPS receiver has not verified its position */ + +#define PCPS_DL_ENB 0x02 /* daylight saving enabled */ + +#define PCPS_SYNCD 0x04 /* clock has sync'ed at least once after pwr up */ + +#define PCPS_DL_ANN 0x08 /* a change in daylight saving is announced */ + +#define PCPS_UTC 0x10 /* a special UTC firmware is installed */ + +#define PCPS_LS_ANN 0x20 /* leap second announced */ + /* (requires firmware rev. REV_PCPS_LS_ANN_...) */ + +#define PCPS_IFTM 0x40 /* the current time was set via PC */ + /* (requires firmware rev. REV_PCPS_IFTM_...) */ + +#define PCPS_INVT 0x80 /* invalid time because battery was disconn'd */ + + +/* Bit masks used only with PCPS_HR_TIME.status */ + +#define PCPS_LS_ENB 0x0100 /* current second is leap second */ +#define PCPS_ANT_FAIL 0x0200 /* antenna failure */ + +/* The next two bits are used only if the structure */ +/* PCPS_HR_TIME contains a user capture event */ +#define PCPS_UCAP_OVERRUN 0x2000 /* events interval too short */ +#define PCPS_UCAP_BUFFER_FULL 0x4000 /* events read too slow */ + +/* + * Immediately after a clock has been accessed, subsequent accesses + * are blocked for up to 1.5 msec to give the clock's microprocessor + * some time to decode the incoming time signal. + * The flag below is set if a program tries to read the PCPS_HR_TIME + * during this interval. In this case the read function returns the + * proper time stamp which is taken if the command byte is written, + * however, the read function returns with delay. + * This flag is not supported by all clocks. + */ +#define PCPS_IO_BLOCKED 0x8000 + +/* + * Some DCF77 clocks have a serial interface that can be controlled + * using the commands PCPS_SET_SERIAL and PCPS_GET_SERIAL. Both commands + * use a parameter byte describing transmission speed, framing and mode + * of operation. The parameter byte can be build using the constants + * defined below, by or'ing one of the constants of each group, shifted + * to the right position. PCPS_GET_SERIAL expects that parameter byte + * and PCPS_GET_SERIAL returns the current configuration from the board. + * _pcps_has_serial() checks whether supported. + * For GPS clocks, please refer to the comments for the PCPS_GET_SERIAL + * command. + */ + +/* + * Baud rate indices. The values below are obsolete and should + * be replaced by the codes named MBG_BAUD_RATE_... which are + * defined in gpsdefs.h. The resulting index numbers, however, + * have not changed. + */ +enum +{ + PCPS_BD_300, + PCPS_BD_600, + PCPS_BD_1200, + PCPS_BD_2400, + PCPS_BD_4800, + PCPS_BD_9600, + PCPS_BD_19200, + N_PCPS_BD /* number of codes */ +}; + +#define PCPS_BD_BITS 4 /* field with in the cfg byte */ +#define PCPS_BD_SHIFT 0 /* num of bits to shift left */ + +/* + * Initializers for a table of all baud rate strings + * and values can be found in gpsdefs.h. + */ + + +/* + * Unfortunately, the framing codes below can not simply be + * replaced by the newer MBG_FRAMING_... definitions since + * the order of indices does not match. + */ +enum +{ + PCPS_FR_8N1, + PCPS_FR_7E2, + PCPS_FR_8N2, + PCPS_FR_8E1, + N_PCPS_FR_DCF /* number of valid codes */ +}; + +#define PCPS_FR_BITS 2 /* field with in the cfg byte */ +#define PCPS_FR_SHIFT PCPS_BD_BITS /* num of bits to shift left */ + +/* + * An initializer for a table of framing strings is only defined for + * the new MBG_FRAMING_... definitions. For editing the serial port + * configuration, the old codes above should be translated to the new + * codes to unify handling inside the edit functions. + */ + +/* modes of operation */ +/* + * Indices for modes of operation. The values below are obsolete + * and should be replaced by the codes named STR_... which are + * defined in gpsdefs.h. The resulting index numbers, however, + * have not changed. + */ +enum +{ + PCPS_MOD_REQ, /* time string on request '?' only */ + PCPS_MOD_SEC, /* time string once per second */ + PCPS_MOD_MIN, /* time string once per minute */ + PCPS_MOD_RSVD, /* reserved */ + N_PCPS_MOD_DCF /* number of possible codes */ +}; + +#define PCPS_MOD_BITS 2 /* field with in the cfg byte */ +#define PCPS_MOD_SHIFT ( PCPS_BD_BITS + PCPS_FR_BITS ) + /* num of bits to shift left */ + +/* + * The fixed-length standard time string being sent on the serial + * output is described below: + * + * <STX>D:dd.mm.yy;T:d;U:hh.mm.ss;uvwx<ETX> + * + * where <STX> and <ETX> represent the ASCII codes 0x02 and 0x03, + * 'dd.mm.yy' is the format of the current date, 'd' is the current + * day of week (1..7, 1 == Monday ) and 'hh.mm.ss' is the format of + * the current time. The characters 'uvwx' reflect the clock's status: + * + * u clock status character: + * '#' clock has not synchronized after reset + * ' ' (space, 20h) clock has synchronized after reset + * + * v clock status character, different for DCF77 or GPS receivers: + * '*' DCF77 clock currently runs on XTAL + * GPS receiver has not checked its position + * ' ' (space, 20h): + * DCF77 clock is syncronized with transmitter + * GPS receiver has determined its position + * + * x time zone indicator: + * 'U' UTC Universal Time, Coordinated + * ' ' MEZ European Standard Time, daylight saving disabled + * 'S' MESZ European Summertime, daylight saving enabled + * + * y anouncement of discontinuity of time, enabled during last hour + * before discontinuity comes in effect: + * '!' announcement of start or end of daylight saving + * 'A' announcement of leap second insertion + * ' ' (space, 20h): nothing announced + */ + + +/* The enumeration below defines the various types of data that can be + * read from or written to a Meinberg GPS plug-in clock. Access should be + * done using the functions pcps_read_gps_data() and pcps_write_gps_data() + * in file pcpsio.c because the size of some of the structures exceeds + * the size of the clock's on-board FIFO and must therefore be accessed + * in several portions. + * + * The structures to be used are defined in gpsdefs.h. Not all structures + * are supportet, yet. Check the R/W indicators for details. + */ + +enum +{ // R/W data type description + // system data ----------------------------------------------- + PC_GPS_TZDL = 0, // R/W TZDL time zone / daylight saving + PC_GPS_SW_REV, // R/- SW_REV software revision + PC_GPS_STAT, // R/- ushort status of buffered variables + PC_GPS_TIME, // R/W TTM curr. time + PC_GPS_POS_XYZ, // -/W XYZ curr. pos. in ECEF coords + PC_GPS_POS_LLA, // -/W LLA curr. pos. in geogr. coords + PC_GPS_PORT_PARM, // R/W PORT_PARM param. of the serial ports + PC_GPS_ANT_INFO, // R/- ANT_INFO time diff after ant. disconn. + PC_GPS_UCAP, // R/- TTM user capture + PC_GPS_ENABLE_FLAGS, // R/W ENABLE_FLAGS controls when to enable outp. + PC_GPS_STAT_INFO, // R/- GPS_STAT_INFO + PC_GPS_CMD, // -/W ushort commands as described below + PC_GPS_IDENT, // R/- GPS_IDENT serial number + PC_GPS_POS, // R/- POS position XYZ, LLA, and DMS + PC_GPS_ANT_CABLE_LEN, // R/W ushort used to compensate delay + // The codes below are supported by new GPS receiver boards: + PC_GPS_RECEIVER_INFO, // R/- RECEIVER_INFO rcvr model info + PC_GPS_ALL_STR_TYPE_INFO, // R/- n*STR_TYPE_INFO_IDX all string types + PC_GPS_ALL_PORT_INFO, // R/- n*PORT_INFO_IDX all port info + PC_GPS_PORT_SETTINGS_IDX, // -/W PORT_SETTINGS_IDX port settings only + + // GPS data + PC_GPS_CFGH = 0x80, // -/- CFGH SVs' config. and health codes + PC_GPS_ALM, // -/- SV_ALM one SV's num and almanac + PC_GPS_EPH, // -/- SV_EPH one SV's num and ephemeris + PC_GPS_UTC, // -/- UTC UTC corr. param. + PC_GPS_IONO, // -/- IONO ionospheric corr. param. + PC_GPS_ASCII_MSG // -/- ASCII_MSG the GPS ASCII message +}; + + +/* codes used with PC_GPS_CMD: */ + +enum +{ + PC_GPS_CMD_BOOT = 1, /* force the clock to boot mode */ + PC_GPS_CMD_INIT_SYS, /* let the clock clear its system variables */ + PC_GPS_CMD_INIT_USER, /* reset the clock's user parameters to defaults */ + PC_GPS_CMD_INIT_DAC, /* initialize the oscillator disciplining values */ + N_PC_GPS_CMD /* no command, just the number of known commands */ +}; + + +#if defined( _USE_PACK ) // set default alignment + #pragma pack() +#endif + +/* End of header body */ + +#endif /* _PCPSDEFS_H */ + diff --git a/c/mbglib/include/use_pack.h b/c/mbglib/include/use_pack.h new file mode 100644 index 0000000..b48ecd6 --- /dev/null +++ b/c/mbglib/include/use_pack.h @@ -0,0 +1,29 @@ + +/************************************************************************** + * + * $Id: use_pack.h 1.2 2002/02/25 08:50:33Z Andre TRASH $ + * + * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany + * + * Description: + * Check the current compiler type to decide if pragma pack() is + * required to pack cross-platform data structures. + * + * ----------------------------------------------------------------------- + * $Log: use_pack.h $ + * Revision 1.2 2002/02/25 08:50:33Z Andre + * query __ARM added, __SH2 removed + * Revision 1.1 2001/03/30 08:54:33Z MARTIN + * Initial revision + * + **************************************************************************/ + +#ifndef _USE_PACK_H +#define _USE_PACK_H + +#if ( !defined( _C166 ) && !defined( _CC51 ) && !defined( __ARM ) ) + #define _USE_PACK +#endif + +#endif /* _USE_PACK_H */ + diff --git a/c/mbglib/include/words.h b/c/mbglib/include/words.h new file mode 100644 index 0000000..9597b8a --- /dev/null +++ b/c/mbglib/include/words.h @@ -0,0 +1,131 @@ + +/************************************************************************** + * + * $Id: words.h 1.9 2003/02/07 11:36:54Z MARTIN TRASH $ + * + * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany + * + * Description: + * Definitions of commonly used data types. + * + * ----------------------------------------------------------------------- + * $Log: words.h $ + * Revision 1.9 2003/02/07 11:36:54Z MARTIN + * New macros _hilo_16() and _hilo_32() for endian conversion. + * Revision 1.8 2002/05/28 10:09:54 MARTIN + * Added new macros _var_bswap16() and _var_bswap32(). + * Revision 1.7 2001/03/14 11:30:48 MARTIN + * Removed definitions for UINT8, UINT16, UINT32. + * Redefined preprocessor control for Win32. + * Revision 1.6 2001/02/28 15:43:20 MARTIN + * Modified preprocessor syntax. + * Revision 1.5 2001/02/05 10:20:53 MARTIN + * Include different Linux types for user space and kernel space programs. + * Source code cleanup. + * Revision 1.4 2000/09/15 08:34:11 MARTIN + * Exclude some definitions if compiling under Win NT. + * Revision 1.3 2000/08/22 15:04:28 MARTIN + * Added new file header. + * Added macros to revert endianess of 16 and 32 bit values. + * + **************************************************************************/ + +#ifndef _WORDS_H +#define _WORDS_H + + +/* Other headers to be included */ + +#ifdef _WORDS + #define _ext +#else + #define _ext extern +#endif + + +/* Start of header body */ + +typedef unsigned char uchar; + +#if defined( __linux ) + #ifdef __KERNEL__ + #include <linux/types.h> + #else + #include <sys/types.h> + #endif +#else + typedef unsigned short ushort; + typedef unsigned int uint; + typedef unsigned long ulong; +#endif + +typedef double udouble; + +typedef unsigned char byte; +typedef unsigned short word; +typedef unsigned long longword; +typedef unsigned long dword; + + +#if !defined( __OS2__ ) && !defined( _Windows ) && \ + !defined( _WIN32 ) && !defined( __WIN32__ ) + + #ifndef BYTE + #define BYTE unsigned char + #endif + + #ifndef WORD + #define WORD unsigned short + #endif + + #ifndef LONG + #define LONG unsigned long + #endif + + #ifndef LONGWORD + #define LONGWORD longword + #endif +#endif + + +// a macro to swap the byte order of a 16 bit value +#define _bswap16( _x ) \ +( \ + ( ( ( (ushort) (_x) ) & 0x00FF ) << 8 ) | \ + ( ( ( (ushort) (_x) ) & 0xFF00 ) >> 8 ) \ +) + +// a macro to swap the byte order of a 32 bit value +#define _bswap32( _x ) \ +( \ + ( ( ( (ulong) (_x) ) & 0x000000FFUL ) << 24 ) | \ + ( ( ( (ulong) (_x) ) & 0x0000FF00UL ) << 8 ) | \ + ( ( ( (ulong) (_x) ) & 0x00FF0000UL ) >> 8 ) | \ + ( ( ( (ulong) (_x) ) & 0xFF000000UL ) >> 24 ) \ +) + +#define _var_bswap16( _v ) (_v) = _bswap16( _v ) +#define _var_bswap32( _v ) (_v) = _bswap32( _v ) + + +// The C51 compiler is big-endian, that means the most +// significant byte of a 16 or 32 bit value is stored in +// the lowest memory location. Most other systems are +// little-endian, so we must use macros to adjust the +// byte order if the C51 is used. + +#if defined _CC51 + #define _hilo_16( _x ) _bswap16( _x ) + #define _hilo_32( _x ) _bswap32( _x ) +#else + #define _hilo_16( _x ) (_x) + #define _hilo_32( _x ) (_x) +#endif + + + +/* End of header body */ + +#undef _ext + +#endif /* _WORDS_H */ diff --git a/c/mbglib/lib/bc/mbgsvcio.lib b/c/mbglib/lib/bc/mbgsvcio.lib Binary files differnew file mode 100644 index 0000000..2c3097b --- /dev/null +++ b/c/mbglib/lib/bc/mbgsvcio.lib diff --git a/c/mbglib/lib/msc/mbgsvcio.lib b/c/mbglib/lib/msc/mbgsvcio.lib Binary files differnew file mode 100644 index 0000000..f60f960 --- /dev/null +++ b/c/mbglib/lib/msc/mbgsvcio.lib |