mbgtools-lx  4.2.8
cmp_time_util.h File Reference
#include <mbgdevio.h>
#include <deviohlp.h>

Go to the source code of this file.

Macros

#define _ext   extern
 

Functions

int chk_fast_tstamp_supp (MBG_DEV_HANDLE dh1, const PCPS_DEV *p_dev_1, MBG_DEV_HANDLE dh2, const PCPS_DEV *p_dev_2, MBG_ERR_MSG_FNC err_msg_fnc)
 Check if both devices support fast HR timestamps. More...
 
int get_htc_timestamps (MBG_DEV_HANDLE dh1, PCPS_HR_TIME_CYCLES *p_htc1, MBG_DEV_HANDLE dh2, PCPS_HR_TIME_CYCLES *p_htc2, int read_fast)
 Read timestamps and cycles from both devices. More...
 
double get_htc_delta (const PCPS_HR_TIME_CYCLES *p_htc, const PCPS_HR_TIME_CYCLES *p_htc_ref, double *p_delta_ts, double *p_delta_cyc)
 Compute the delta cycles and time difference. More...
 
int mbg_snprint_hr_tstamp_ext (char *s, int max_len, const PCPS_TIME_STAMP *p, int print_raw)
 Print UTC date and time from a PCPS_TIME_STAMP structure to a string. More...
 
int mbg_snprint_hr_time_loc (char *s, size_t max_len, const PCPS_HR_TIME *p)
 Print local date and time from a PCPS_TIME_STAMP structure to a string. More...
 

Variables

MBG_PC_CYCLES_FREQUENCY cyc_freq
 Must be set up tby the application. More...
 

Macro Definition Documentation

◆ _ext

#define _ext   extern

Definition at line 35 of file cmp_time_util.h.

Function Documentation

◆ chk_fast_tstamp_supp()

int chk_fast_tstamp_supp ( MBG_DEV_HANDLE  dh1,
const PCPS_DEV p_dev_1,
MBG_DEV_HANDLE  dh2,
const PCPS_DEV p_dev_2,
MBG_ERR_MSG_FNC  err_msg_fnc 
)

Check if both devices support fast HR timestamps.

Parameters
[in]dh1Handle of the first device
[in]p_dev_1Device info of the first device
[in]dh2Handle of the second device
[in]p_dev_2Device info of the second device
[in]err_msg_fncPointer to a function to be called in case of error
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES

Definition at line 54 of file cmp_time_util.c.

References chk_feat_supp(), mbg_chk_dev_has_fast_hr_timestamp, and mbg_rc_is_success.

Referenced by do_mbgcmptime().

◆ get_htc_delta()

double get_htc_delta ( const PCPS_HR_TIME_CYCLES p_htc,
const PCPS_HR_TIME_CYCLES p_htc_ref,
double *  p_delta_ts,
double *  p_delta_cyc 
)

Compute the delta cycles and time difference.

Parameters
[in]p_htcTimestamp/cycles t from device under test.
[in]p_htc_refTimestamp/cycles t_ref from reference device.
[out]p_delta_tsPointer to save time difference (t - tref), can be NULL.
[out]p_delta_cycPointer to save delta cycles (t - tref), can be NULL.
Returns
The difference between delta_t and delta_cycles.

Definition at line 140 of file cmp_time_util.c.

References cyc_freq, PCPS_HR_TIME_CYCLES::cycles, dfrac_sec_from_bin(), PCPS_TIME_STAMP::frac, PCPS_TIME_STAMP::sec, PCPS_HR_TIME_CYCLES::t, and PCPS_HR_TIME::tstamp.

Referenced by do_mbgcmptime().

◆ get_htc_timestamps()

int get_htc_timestamps ( MBG_DEV_HANDLE  dh1,
PCPS_HR_TIME_CYCLES p_htc1,
MBG_DEV_HANDLE  dh2,
PCPS_HR_TIME_CYCLES p_htc2,
int  read_fast 
)

Read timestamps and cycles from both devices.

Parameters
[in]dh1Handle of the first device
[out]p_htc1Timestamp and cycles read from the first device
[in]dh2Handle of the second device
[out]p_htc2Timestamp and cycles read from the first device
[in]read_fastFlag indicating that fast timestamps should be read
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES

Definition at line 85 of file cmp_time_util.c.

References mbg_cond_err_msg(), mbg_get_fast_hr_timestamp_cycles(), mbg_get_hr_time_cycles(), and setup_hr_time_cycles_from_timestamp_cycles().

Referenced by do_mbgcmptime().

◆ mbg_snprint_hr_time_loc()

int mbg_snprint_hr_time_loc ( char *  s,
size_t  max_len,
const PCPS_HR_TIME p 
)

Print local date and time from a PCPS_TIME_STAMP structure to a string.

This function is mostly similar to mbg_snprint_hr_tstamp, but optionally appends the raw timestamp instead of inserting it at the beginning.

Parameters
[out]sAddress of a string buffer to be filled.
[in]max_lenSize of the string buffer.
[in]pPointer to a PCPS_TIME_STAMP structure to be evaluated.
Returns
The number of characters printed to the buffer.
See also
mbg_snprint_hr_tstamp
mbg_snprint_hr_tstamp_ext

Definition at line 220 of file cmp_time_util.c.

References _int_from_size_t, mbg_snprint_hr_tstamp(), mbg_snprintf(), mbg_str_pcps_hr_time_offs(), PCPS_UTC, snprintf_safe(), PCPS_HR_TIME::status, PCPS_HR_TIME::tstamp, and PCPS_HR_TIME::utc_offs.

◆ mbg_snprint_hr_tstamp_ext()

int mbg_snprint_hr_tstamp_ext ( char *  s,
int  max_len,
const PCPS_TIME_STAMP p,
int  print_raw 
)

Print UTC date and time from a PCPS_TIME_STAMP structure to a string.

This function is mostly similar to mbg_snprint_hr_tstamp, but optionally appends the raw timestamp instead of inserting it at the beginning.

Parameters
[out]sAddress of a string buffer to be filled.
[in]max_lenSize of the string buffer.
[in]pPointer to a PCPS_TIME_STAMP structure to be evaluated.
[in]print_rawFlag indicating if a raw timestamp (hex) is to be appended.
Returns
The number of characters printed to the buffer.
See also
mbg_snprint_hr_tstamp
mbg_snprint_hr_time_loc

Definition at line 188 of file cmp_time_util.c.

References PCPS_TIME_STAMP::frac, mbg_snprint_hr_tstamp(), and PCPS_TIME_STAMP::sec.

Referenced by do_mbgcmptime().

Variable Documentation

◆ cyc_freq

Must be set up tby the application.

Definition at line 72 of file mbgcmptime.c.

Referenced by do_mbgcmptime(), and do_mbgsvctasks().