81 #define USLEEP_INTV 10000 // [microseconds] 84 #define MBG_FIRST_COPYRIGHT_YEAR 2001 85 #define MBG_LAST_COPYRIGHT_YEAR 0 // use default 87 static const char *
pname =
"mbggpscap";
144 if ( abs_delta < 0.0 )
145 abs_delta = -abs_delta;
177 FILE *fp = fopen(
log_fn,
"at" );
181 fprintf( fp,
"%s\n", s );
186 fprintf( stderr,
"** Failed to open file %s for writing: %s\n",
187 log_fn, strerror( errno ) );
216 printf(
"New capture: CH%i: %04i-%02i-%02i %2i:%02i:%02i.%07li",
295 "ATTENTION: At least one of the device's serial ports has been\n" 296 "configured to send time strings automatically, which can remove\n" 297 "capture events from the on-board FIFO, so they are unavailable\n" 298 "to this application\n" 300 "Please change the configuration of the serial port(s) in a way that\n" 301 "none of the serial ports sends a capture event string automatically.\n" 303 "For example, use the \"mbgctrl\" program to let the serial ports\n" 304 "transmit the Meinberg standard time string once per second.\n" 306 "See \"mbgctrl -?\" for details.\n" 326 printf(
"This device type does not provide time capture inputs.\n" );
332 printf(
"Be sure the card has been properly configured to enable capture inputs.\n" );
360 if ( ucap_entries.
max )
363 printf(
"\nOn-board FIFO: %u of %u entries used\n\n",
364 ucap_entries.
used, ucap_entries.
max );
367 if ( this_clear_buffer )
369 printf(
"Clearing on-board FIFO buffer\n" );
371 this_clear_buffer = 0;
380 printf( ( ucap_entries.
used == 0 ) ?
381 "Waiting for capture events:\n" :
382 "Reading capture events:\n" 415 printf(
"Checking for capture events using the old API:\n" );
437 printf(
"No capture event available!\n" );
457 "This example program reads time capture events from a card.\n" 458 "This works only with cards which provide time capture inputs." 475 int main(
int argc,
char *argv[] )
483 while ( ( c = getopt( argc, argv,
"cCi:j:l:oqrh?" ) ) != -1 )
534 printf(
"Nominal capture interval: %f s\n",
nom_cap_intv );
535 printf(
"Maximum allowed capture jitter: %f s\n",
max_cap_jitter );
events read too slow (capture events only)
_MBG_API_ATTR int _MBG_API mbg_get_ucap_event(MBG_DEV_HANDLE dh, PCPS_HR_TIME *p)
Retrieve a single time capture event from the on-board FIFO buffer.
TM_GPS tm
time converted to UTC and/or local time according to TZDL settings
uint32_t used
the number of saved capture events
#define _pcps_time_is_read(_t)
_MBG_API_ATTR int _MBG_API mbg_get_gps_ucap(MBG_DEV_HANDLE dh, TTM *p)
Read a time capture event from the on-board FIFO buffer using a TTM structure.
int32_t frac
fractions of a second, 1/RECEIVER_INFO::ticks_per_sec units
static double nom_cap_intv
Requested action completed successfully.
#define _pcps_has_ucap(_d)
int16_t channel
-1: the current on-board time; >= 0 the capture channel number
Configuration settings of a serial port.
bool mbg_cond_err_msg(int rc, const char *what)
Check if a value is an error code and print an associated error message.
PCPS_SECONDS sec
seconds since 1970, usually UTC scale
int8_t sec
seconds, 0..59, or 60 in case of inserted leap second
_MBG_API_ATTR int _MBG_API mbg_clr_ucap_buff(MBG_DEV_HANDLE dh)
Clear a device's on-board time capture FIFO buffer.
static const char * log_fn
Unable to handle requested action, usage printed.
#define mbg_rc_is_success(_rc)
int mbg_get_serial_settings(MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, RECEIVER_PORT_CFG *p_rpcfg, const RECEIVER_INFO *p_ri)
Read all serial port settings and supported configuration parameters.
int8_t mday
day of month, 1..31
uint8_t n_com_ports
number of on-board serial ports
int16_t year
year number, 0..9999
static PCPS_HR_TIME prv_ucap
Status of the time capture FIFO buffer.
PCPS_TIME_STATUS_X status
status bits, see PCPS_TIME_STATUS_FLAGS
static MBG_DEV_HANDLER_FNC do_mbggpscap
int main(int argc, char *argv[])
uint32_t max
capture buffer size
uint16_t status
status flags, see TM_GPS_STATUS_BIT_MASKS
A structure used to transmit information on date and time.
transmission automatically if required, e.g. on capture event
PCPS_FRAC_32 frac
binary fractions of second, see PCPS_FRAC_32
#define MBG_LAST_COPYRIGHT_YEAR
static const char * pname
PCPS_TIME_STAMP tstamp
High resolution time stamp (UTC)
static int must_check_intv
#define MBG_FRAC32_UNITS_PER_SEC
Constant used to convert e.g. PCPS_TIME_STAMP::frac values.
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
_MBG_API_ATTR int _MBG_API mbg_setup_receiver_info(MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, RECEIVER_INFO *p)
Set up a RECEIVER_INFO structure for a device.
static void show_gps_ucap(const TTM *ucap)
Show a user capture event in TTM format read from device.
Action failed for specified device.
uint8_t mode
string mode, see STR_MODES
High resolution time including status and local time offset.
static void check_serial_mode(MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev)
Check the modes of a device's serial ports.
_MBG_API_ATTR int _MBG_API mbg_get_ucap_entries(MBG_DEV_HANDLE dh, PCPS_UCAP_ENTRIES *p)
Read information on a device's event capture buffer.
static int has_been_called
PCPS_SIG_VAL signal
signal strength, see PCPS_SIG_VAL_DEFS, or capture input channel number
#define MBG_FIRST_COPYRIGHT_YEAR
ALL_PORT_INFO_IDX pii
all serial port configuration settings
int snprintf_safe(char *s, size_t max_len, const char *fmt,...)
A portable, safe implementation of snprintf()
A structure used to identify a device type and supported features.
static void show_ucap_event(const PCPS_HR_TIME *ucap)
Show a user capture event in PCPS_HR_TIME format.
static double max_cap_jitter
events interval too short (capture events only)
All configuration parameters for all serial ports.