54 #define MBG_FIRST_COPYRIGHT_YEAR 2012 55 #define MBG_LAST_COPYRIGHT_YEAR 0 // use default 58 static const char *
pname =
"mbgtcrcal";
74 div_t dt = div( comp_data, 10 );
76 snprintf_safe( s, max_len,
"%i.%i", dt.quot, abs ( dt.rem ) );
90 for ( idx = 0; idx < num_rec; idx++ )
95 printf(
" Signal group %i (%s)%-*c %s", idx,
irig_comp_names[idx], l,
':',
130 printf(
"This device does not provide an IRIG input.\n" );
140 printf(
"** Failed to read IRIG RX configuration, rc: %i\n", rc );
148 printf(
"IRIG code %i configured on this device exceeds the maximum code supported by this program (%i)!\n",
156 if ( curr_group_idx < 0 )
157 printf(
"Warning: Unable to assign IRIG RX code %s to a know compensation code group.\n",
166 printf(
"This device does not support IRIG calibration\n" );
175 printf(
"mbg_get_cal_rec_irig_rx_num_rec() returned %i", rc );
178 printf(
", irig_rx_num_rec: %i", num_rec );
185 printf(
"** Failed to read number of IRIG RX calibration records, rc: %i\n", rc );
192 if ( curr_group_idx >= num_rec )
194 printf(
"** Warning: the compensation group index for the current IRIG code (%i)\n" 195 "exceeds the number of records supported by the card (%i).\n",
196 curr_group_idx, num_rec - 1 );
202 printf(
"** The number of calibration records actually supported by the card (%i)\n" 203 "exceeds the number of records supported by this program (%i).\n",
211 printf(
"** This card does not support any IRIG RX calibration records\n" );
217 for ( idx = 0; idx < num_rec; idx++ )
226 for ( idx = 0; idx < num_rec; idx++ )
228 p = &cal_rec_comp[idx];
234 printf(
"** Failed to read IRIG RX calibration record #%i. rc = %i\n", idx, rc );
240 printf(
"** Calibration record header type is %i, no %i as expected.\n",
246 printf(
"\nCurrent compensation settings:\n" );
250 printf(
"\nCurrent IRIG code: %s --> group %i compensation effective\n",
257 if ( curr_group_idx < 0 )
260 if ( curr_group_idx >= num_rec )
267 p = &cal_rec_comp[curr_group_idx];
276 printf(
"** Failed to save new IRIG calibration setting for group %s.\n",
282 printf(
"IRIG calibration setting for code group %s has been set to %s us.\n",
301 "Show or set IRIG RX calibration parameters of devices which support this." );
309 printf(
"Example usage:\n" 311 "%s print current settings of the default device\n" 312 "%s [dev] print current settings of specific device [dev]\n" 313 "%s -c 10 compensate +10.0 us on default device\n" 314 "%s -c -12.1 [dev] compensate -12.1 us on specific device [dev]\n" 316 printf(
"New settings become effective for a group of IRIG codes with similar characteristics\n" 317 "to which the currently configured IRIG RX code belongs. Calibration values are\n" 318 "in microseconds, with 0.1 us resolution, in the range +/-%s us.\n",
327 int main(
int argc,
char *argv[] )
335 while ( ( c = getopt( argc, argv,
"c:vh?" ) ) != -1 )
355 #if defined( MBG_TGT_POSIX ) 356 if ( geteuid() != 0 )
365 printf(
"(Built with DEBUG, so resuming anyway)\n" );
static void print_cal_recs(int num_rec, int curr_group_idx, CAL_REC_IRIG_RX_COMP cal_rec_comp[])
static int must_set_cal_val
uint16_t type
record type, see CAL_REC_TYPES
int16_t c[4]
Delay compensation values [100 ns units].
#define DEFAULT_IRIG_RX_COMP_NAMES
Initializers for format name strings.
int main(int argc, char *argv[])
static __mbg_inline int mbg_get_cal_rec_irig_rx_comp(MBG_DEV_HANDLE dh, uint16_t idx, CAL_REC_IRIG_RX_COMP *p)
Retrieve IRIG RX calibration record with specific index.
Requested action completed successfully.
static char * str_comp_data(char *s, int max_len, int comp_data)
static __mbg_inline int mbg_get_cal_rec_irig_rx_num_rec(MBG_DEV_HANDLE dh, int *p_num_rec)
Get supported number of IRIG RX calibration records.
Structure used to transfer calibration records.
_MBG_API_ATTR int _MBG_API mbg_get_irig_rx_info(MBG_DEV_HANDLE dh, IRIG_INFO *p)
Read the current IRIG input settings plus capabilities.
IRIG_RX_COMP comp_data
IRIG receiver delay compensation.
Current IRIG settings and supported codes.
Unable to handle requested action, usage printed.
#define mbg_rc_is_success(_rc)
static IRIG_INFO irig_rx_info
static size_t max_label_len
#define MBG_LAST_COPYRIGHT_YEAR
static int do_mbgtcrcal(MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev)
static const char * irig_comp_names[N_IRIG_RX_COMP]
number of compensation values
static const char * pname
static const char * icode_rx_names[N_ICODE_RX]
#define MBG_FIRST_COPYRIGHT_YEAR
CAL_REC_HDR hdr
data header
IRIG_SETTINGS settings
current settings
#define DEFAULT_ICODE_RX_NAMES
Initializers for RX timecode format name strings.
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
_MBG_API_ATTR void _MBG_API mbg_close_device(MBG_DEV_HANDLE *dev_handle)
Close a device handle and set the handle value to MBG_INVALID_DEV_HANDLE.
IRIG receiver delay compensation.
Action failed for specified device.
uint16_t icode
IRIG signal code, see ICODE_RX_CODES and ICODE_TX_CODES.
#define _pcps_has_generic_io(_d)
int snprintf_safe(char *s, size_t max_len, const char *fmt,...)
A portable, safe implementation of snprintf()
the number of known codes
static __mbg_inline int mbg_set_cal_rec_irig_rx_comp(MBG_DEV_HANDLE dh, const CAL_REC_IRIG_RX_COMP *p)
Write an IRIG RX calibration record to a device.
#define mbg_rc_is_error(_rc)
#define _pcps_is_irig_rx(_d)
static __mbg_inline int mbg_icode_rx_to_group_idx(int icode_rx)
Get the IRIG calibration group index for a given IRIG RX code.
#define N_IRIG_RX_COMP_VAL