mbgtools-lx  4.2.8
mbggpscap.c File Reference
#include <mbgdevio.h>
#include <deviohlp.h>
#include <toolutil.h>
#include <str_util.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

Go to the source code of this file.

Macros

#define USLEEP_INTV   10000
 
#define MBG_FIRST_COPYRIGHT_YEAR   2001
 
#define MBG_LAST_COPYRIGHT_YEAR   0
 

Functions

static void show_ucap_event (const PCPS_HR_TIME *ucap)
 Show a user capture event in PCPS_HR_TIME format. More...
 
static void show_gps_ucap (const TTM *ucap)
 Show a user capture event in TTM format read from device. More...
 
static void check_serial_mode (MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev)
 Check the modes of a device's serial ports. More...
 
static int do_mbggpscap (MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev)
 
static void usage (void)
 
int main (int argc, char *argv[])
 

Variables

static const char * pname = "mbggpscap"
 
static int continuous
 
static double nom_cap_intv
 
static double max_cap_jitter
 
static int raw
 
static int force_old_api
 
static int clear_buffer
 
static const char * log_fn
 
static int has_been_called
 
static int must_check_intv
 
static int query_only
 
static ulong err_cnt
 
static PCPS_HR_TIME prv_ucap
 
static MBG_DEV_HANDLER_FNC do_mbggpscap
 

Macro Definition Documentation

◆ MBG_FIRST_COPYRIGHT_YEAR

#define MBG_FIRST_COPYRIGHT_YEAR   2001

Definition at line 84 of file mbggpscap.c.

Referenced by main().

◆ MBG_LAST_COPYRIGHT_YEAR

#define MBG_LAST_COPYRIGHT_YEAR   0

Definition at line 85 of file mbggpscap.c.

Referenced by main().

◆ USLEEP_INTV

#define USLEEP_INTV   10000

Definition at line 81 of file mbggpscap.c.

Referenced by do_mbggpscap().

Function Documentation

◆ check_serial_mode()

static void check_serial_mode ( MBG_DEV_HANDLE  dh,
const PCPS_DEV p_dev 
)
static

Check the modes of a device's serial ports.

If one of the device's serial ports has been configured to send a serial string automatically then this is usually to send a capture event string automatically as soon as an event has occurred.

As a consequence, those events are removed from the on-board FIFO and aren't available anymore when an application tries to read capture events via the PCI bus, using the API functions mbg_get_ucap_event or mbg_get_gps_ucap.

So we check and print a warning, if this may be the case.

Parameters
[in]dhValid MBG_DEV_HANDLE handle to a Meinberg device.
[in]p_devPointer do a device info structure for the device.
See also
mbg_get_ucap_event
mbg_get_gps_ucap

Definition at line 259 of file mbggpscap.c.

References mbg_cond_err_msg(), mbg_get_serial_settings(), mbg_setup_receiver_info(), PORT_SETTINGS::mode, RECEIVER_INFO::n_com_ports, RECEIVER_PORT_CFG::pii, and STR_AUTO.

Referenced by do_mbggpscap().

◆ do_mbggpscap()

◆ main()

◆ show_gps_ucap()

static void show_gps_ucap ( const TTM ucap)
static

Show a user capture event in TTM format read from device.

This function is actually obsolete since it shows user capture events provided as TTM structure, as returned by the obsolete API call mbg_get_gps_ucap.

The current API call mbg_get_ucap_event is faster and provides capture events as PCPS_HR_TIME structure, but some very old devices may not support the newer API.

Parameters
[in]ucapThe capture event read from a device.
See also
mbg_get_ucap_event
mbg_get_gps_ucap
show_ucap_event

Definition at line 214 of file mbggpscap.c.

References TTM::channel, TM_GPS::frac, TM_GPS::hour, TM_GPS::mday, TM_GPS::min, TM_GPS::month, raw, TM_GPS::sec, TM_GPS::status, TTM::tm, and TM_GPS::year.

Referenced by do_mbggpscap().

◆ show_ucap_event()

static void show_ucap_event ( const PCPS_HR_TIME ucap)
static

Show a user capture event in PCPS_HR_TIME format.

The current API call mbg_get_ucap_event provides capture events as PCPS_HR_TIME structure, but there may be older devices which only support the obsolete API call mbg_get_gps_ucap.

Parameters
[in]ucapThe capture event read from a device.
See also
mbg_get_ucap_event
mbg_get_gps_ucap
show_gps_ucap

Definition at line 121 of file mbggpscap.c.

References err_cnt, PCPS_TIME_STAMP::frac, has_been_called, log_fn, max_cap_jitter, MBG_FRAC32_UNITS_PER_SEC, mbg_snprint_hr_time(), must_check_intv, nom_cap_intv, PCPS_UCAP_BUFFER_FULL, PCPS_UCAP_OVERRUN, raw, PCPS_TIME_STAMP::sec, PCPS_HR_TIME::signal, snprintf_safe(), PCPS_HR_TIME::status, and PCPS_HR_TIME::tstamp.

Referenced by do_mbggpscap().

◆ usage()

static void usage ( void  )
static

Variable Documentation

◆ clear_buffer

int clear_buffer
static

Definition at line 95 of file mbggpscap.c.

Referenced by do_mbggpscap(), and main().

◆ continuous

int continuous
static

Definition at line 90 of file mbggpscap.c.

Referenced by do_mbggpscap(), and main().

◆ do_mbggpscap

MBG_DEV_HANDLER_FNC do_mbggpscap
static

Definition at line 449 of file mbggpscap.c.

Referenced by main().

◆ err_cnt

ulong err_cnt
static

Definition at line 101 of file mbggpscap.c.

Referenced by do_mbggpscap(), and show_ucap_event().

◆ force_old_api

int force_old_api
static

Definition at line 94 of file mbggpscap.c.

Referenced by do_mbggpscap(), and main().

◆ has_been_called

int has_been_called
static

Definition at line 98 of file mbggpscap.c.

Referenced by do_mbggpscap(), and show_ucap_event().

◆ log_fn

const char* log_fn
static

Definition at line 96 of file mbggpscap.c.

Referenced by main(), and show_ucap_event().

◆ max_cap_jitter

double max_cap_jitter
static

Definition at line 92 of file mbggpscap.c.

Referenced by do_mbggpscap(), main(), and show_ucap_event().

◆ must_check_intv

int must_check_intv
static

Definition at line 99 of file mbggpscap.c.

Referenced by do_mbggpscap(), and show_ucap_event().

◆ nom_cap_intv

double nom_cap_intv
static

Definition at line 91 of file mbggpscap.c.

Referenced by do_mbggpscap(), main(), and show_ucap_event().

◆ pname

const char* pname = "mbggpscap"
static

Definition at line 87 of file mbggpscap.c.

Referenced by main(), and usage().

◆ prv_ucap

PCPS_HR_TIME prv_ucap
static

Definition at line 102 of file mbggpscap.c.

◆ query_only

int query_only
static

Definition at line 100 of file mbggpscap.c.

Referenced by do_mbggpscap(), and main().

◆ raw

int raw
static

Definition at line 93 of file mbggpscap.c.

Referenced by main(), show_gps_ucap(), and show_ucap_event().