mbgtools-lx  4.2.8
chk_time_info.c File Reference
#include <chk_time_info.h>
#include <str_util.h>
#include <toolutil.h>
#include <stdio.h>

Go to the source code of this file.

Macros

#define _CHK_TIME_INFO
 

Functions

static MBG_PC_CYCLES do_filter (CYCLES_FILTER_DATA *p, MBG_PC_CYCLES cyc)
 Compute the mean value of a number of cycles. More...
 
int mbg_chk_time_info (MBG_DEV_HANDLE dh, MBG_CHK_TIME_INFO *p, CYCLES_FILTER_DATA *p_filter, int fast_ts_only)
 Read and evaluate a system timestamp / reference timestamp pair. More...
 
int snprint_chk_time_info (char *s, size_t max_len, const MBG_CHK_TIME_INFO *p, const PCPS_DEV *p_dev, int frac_digits, int print_raw)
 Print info from a MBG_CHK_TIME_INFO structure into a string buffer. More...
 

Variables

MBG_PC_CYCLES_FREQUENCY cyc_freq
 

Macro Definition Documentation

◆ _CHK_TIME_INFO

#define _CHK_TIME_INFO

Definition at line 31 of file chk_time_info.c.

Function Documentation

◆ do_filter()

static MBG_PC_CYCLES do_filter ( CYCLES_FILTER_DATA p,
MBG_PC_CYCLES  cyc 
)
static

Compute the mean value of a number of cycles.

Parameters
[in,out]pAddress of a CYCLES_FILTER_DATA structure that needs to be updated.
[in]cycThe last recent cycles value to be taken into account.
Returns
The mean cycles value computed from the values in the filter structure p.

Definition at line 60 of file chk_time_info.c.

References CYCLES_FILTER_DATA::cyc, CYCLES_FILTER_DATA::entries, CYCLES_FILTER_DATA::index, MAX_CYCLES_FILTER_ENTRIES, and CYCLES_FILTER_DATA::sum.

Referenced by mbg_chk_time_info().

◆ mbg_chk_time_info()

int mbg_chk_time_info ( MBG_DEV_HANDLE  dh,
MBG_CHK_TIME_INFO p,
CYCLES_FILTER_DATA p_filter,
int  fast_ts_only 
)

Read and evaluate a system timestamp / reference timestamp pair.

The device timestamp is considered as reference timestamp.

Usually the fast_ts_only flag should be 0, in which case a PCPS_HR_TIME is read from the device in conjunction with the system timestamp.

If the fast_ts_only flag is not 0 then only a PCPS_TIME_STAMP instead of a PCPS_HR_TIME is read in conjunction with the system timestamp. In this case the call executes faster, but this is only supported if the device supports memory mapped timestamps (see chk_fast_tstamp_supp). Also, the returned data doesn't include the device status information in this case.

Once the device system timestamp / reference timestamp pair has been read successfully, the associated cycles values are evaluated to simplify further processing by the calling application.

Parameters
[in]dhValid MBG_DEV_HANDLE handle to a Meinberg device.
[out]pPointer to a POUT_SETTINGS_IDX structure to be written.
[in,out]p_filterOptional address of a CYCLES_FILTER_DATA instance associated with the device that is referenced by dh. If this parameter is not NULL then
[in]fast_ts_onlyA flag indicating that only a PCPS_TIME_STAMP instead of a PCPS_HR_TIME is to be read in conjunction with the system timestamp, usually 0.
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES
See also
snprint_chk_time_info
mbg_get_time_info_hrt
mbg_get_time_info_tstamp

Definition at line 115 of file chk_time_info.c.

References MBG_SYS_TIME_CYCLES::cyc_after, MBG_SYS_TIME_CYCLES::cyc_before, cyc_freq, PCPS_HR_TIME_CYCLES::cycles, MBG_CHK_TIME_INFO::d_ref, MBG_CHK_TIME_INFO::d_ref_comp, MBG_CHK_TIME_INFO::d_sys, do_filter(), MBG_CHK_TIME_INFO::exec_cyc, MBG_CHK_TIME_INFO::exec_cyc_limit, MBG_CHK_TIME_INFO::exec_sec, MBG_CHK_TIME_INFO::exec_sec_limit, PCPS_TIME_STAMP::frac, MBG_CHK_TIME_INFO::hrti, MBG_CHK_TIME_INFO::ltcy_cyc, MBG_CHK_TIME_INFO::ltcy_sec, mbg_delta_pc_cycles(), MBG_FRAC32_UNITS_PER_SEC, mbg_get_time_info_hrt(), mbg_get_time_info_tstamp(), mbg_rc_is_error, MBG_SUCCESS, NANO_TIME_64::nano_secs, NSEC_PER_SEC, MBG_TIME_INFO_HRT::ref_hr_time_cycles, MBG_TIME_INFO_TSTAMP::ref_tstamp_cycles, PCPS_TIME_STAMP::sec, NANO_TIME_64::secs, setup_hr_time_cycles_from_timestamp_cycles(), MBG_SYS_TIME_CYCLES::sys_time, MBG_TIME_INFO_HRT::sys_time_cycles, MBG_TIME_INFO_TSTAMP::sys_time_cycles, PCPS_HR_TIME_CYCLES::t, and PCPS_HR_TIME::tstamp.

Referenced by do_mbgsvctasks().

◆ snprint_chk_time_info()

int snprint_chk_time_info ( char *  s,
size_t  max_len,
const MBG_CHK_TIME_INFO p,
const PCPS_DEV p_dev,
int  frac_digits,
int  print_raw 
)

Print info from a MBG_CHK_TIME_INFO structure into a string buffer.

Parameters
[out]sThe string buffer to be filled.
[in]max_lenSize of the output buffer for 0-terminated string.
[in]pPointer to a MBG_CHK_TIME_INFO to be evaluated.
[in]p_dev
[in]frac_digits
[in]print_raw
Returns
Length of the string in the buffer
See also
mbg_chk_time_info

Definition at line 206 of file chk_time_info.c.

References _int_from_size_t, _pcps_type_name, cyc_freq, MBG_CHK_TIME_INFO::d_ref, MBG_CHK_TIME_INFO::d_ref_comp, MBG_CHK_TIME_INFO::d_sys, MBG_CHK_TIME_INFO::exec_cyc, MBG_CHK_TIME_INFO::exec_cyc_limit, MBG_CHK_TIME_INFO::exec_sec, MBG_CHK_TIME_INFO::exec_sec_limit, MBG_CHK_TIME_INFO::hrti, MBG_CHK_TIME_INFO::ltcy_cyc, MBG_CHK_TIME_INFO::ltcy_sec, mbg_snprint_hr_tstamp(), MBG_TIME_INFO_HRT::ref_hr_time_cycles, snprintf_safe(), PCPS_HR_TIME_CYCLES::t, and PCPS_HR_TIME::tstamp.

Referenced by do_mbgsvctasks().

Variable Documentation

◆ cyc_freq

Definition at line 72 of file mbgcmptime.c.

Referenced by mbg_chk_time_info(), and snprint_chk_time_info().