mbgtools-lx  4.2.8
Legacy API functions to read the time

Functions

_MBG_API_ATTR int _MBG_API mbg_get_time (MBG_DEV_HANDLE dh, PCPS_TIME *p)
 Read a PCPS_TIME structure returning the current date/time/status. More...
 
_MBG_API_ATTR int _MBG_API mbg_get_time_sec_change (MBG_DEV_HANDLE dh, PCPS_TIME *p)
 Wait until the next second change, then return current time. More...
 
_MBG_API_ATTR int _MBG_API mbg_get_time_cycles (MBG_DEV_HANDLE dh, PCPS_TIME_CYCLES *p)
 Read the current time plus the associated PC cycles from a device. More...
 

Detailed Description

These functions are supported by all devices, but return time only as a PCPS_TIME structure, which provides local time according to the local time zone configured on the device, and with 10 ms resolution only.

Note: The API functions reading high resolution time, plus status or Fast API functions reading high resolution timestamps, but no status should be used preferably, if the device supports these.

See also
mbg_get_time
mbg_get_time_cycles
API functions reading high resolution time, plus status
Fast API functions reading high resolution timestamps, but no status

Function Documentation

◆ mbg_get_time()

int mbg_get_time ( MBG_DEV_HANDLE  dh,
PCPS_TIME p 
)

Read a PCPS_TIME structure returning the current date/time/status.

The returned time is local time according to the card's time zone setting, with a resolution of 10 ms (i.e. 10ths of seconds) only.

This call is supported by any device manufactured by Meinberg. However, for higher accuracy and resolution the API functions reading high resolution time, plus status or the Fast API functions reading high resolution timestamps, but no status group of calls should be used preferably, if supported by the device.

Parameters
[in]dhValid MBG_DEV_HANDLE handle to a Meinberg device.
[out]pPointer to a PCPS_TIME structure to be filled up
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES
See also
mbg_get_hr_time
mbg_set_time
mbg_get_sync_time

Definition at line 4491 of file mbgdevio.c.

References _mbgdevio_cnv_ret_val, _mbgdevio_read_var, IOCTL_GET_PCPS_TIME, MBGDEVIO_RET_VAL, and PCPS_GIVE_TIME.

Referenced by do_set_system_time_from_pcps_time(), set_date_time(), show_modulation(), and show_time_and_status().

◆ mbg_get_time_cycles()

int mbg_get_time_cycles ( MBG_DEV_HANDLE  dh,
PCPS_TIME_CYCLES p 
)

Read the current time plus the associated PC cycles from a device.

The PCPS_TIME_CYCLES structure contains a PCPS_TIME structure and a PC cycles counter value which can be used to compensate the latency of the call, i.e. the program execution time until the time stamp has actually been read from the board.

This call is supported for any card, similar to mbg_get_time. However, the mbg_get_hr_time_cycles call should be used preferably if supported by the device since that call provides much better accuracy than this one.

The cycles counter value corresponds to a value returned by QueryPerformanceCounter() under Windows, and get_cycles() under Linux. On operating systems or targets which don't provide a cycles counter the returned cycles value is always 0.

Applications should first pick up their own cycles counter value and then call this function. The difference of the cycles counter values corresponds to the latency of the call in units of the cycles counter clock frequency, e.g as reported by QueryPerformanceFrequency() under Windows.

Parameters
[in]dhValid MBG_DEV_HANDLE handle to a Meinberg device.
[out]pPointer to a PCPS_TIME_CYCLES structure to be filled up.
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES
See also
mbg_get_hr_time_cycles
mbg_get_hr_time_comp
mbg_get_hr_time
mbg_get_time

Definition at line 6629 of file mbgdevio.c.

References _mbgdevio_cnv_ret_val, _mbgdevio_read_var, PCPS_TIME_CYCLES::cycles, IOCTL_GET_PCPS_TIME_CYCLES, MBGDEVIO_RET_VAL, and PCPS_GIVE_TIME.

◆ mbg_get_time_sec_change()

int mbg_get_time_sec_change ( MBG_DEV_HANDLE  dh,
PCPS_TIME p 
)

Wait until the next second change, then return current time.

Returns time in a PCPS_TIME structure similar to mbg_get_time.

Note: This API call is supported under Windows only. The call blocks until the kernel driver detects a second change reported by the device. The accuracy of this call is limited to a few milliseconds.

Parameters
[in]dhValid MBG_DEV_HANDLE handle to a Meinberg device.
[out]pPointer to a PCPS_TIME structure to be filled up
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES
See also
mbg_get_time

Definition at line 4586 of file mbgdevio.c.

References _mbgdevio_cnv_ret_val, _mbgdevio_read_var, IOCTL_GET_PCPS_TIME_SEC_CHANGE, MBG_ERR_NOT_SUPP_ON_OS, and MBGDEVIO_RET_VAL.

Referenced by mbg_get_raw_irig_data_on_sec_change().