78 #define MBG_FIRST_COPYRIGHT_YEAR 2003 79 #define MBG_LAST_COPYRIGHT_YEAR 0 // use default 81 static const char pname[] =
"mbgirigcfg";
89 static const char str_not_supp[] =
" (not supp. by this frame type)";
127 ( num_minutes < 0 ) ?
'-' :
'+', ldt.quot );
130 n +=
mbg_snprintf( &s[n], max_len - n,
":%02li", ldt.rem );
145 const char *cp = NULL;
147 printf(
"%s %s configuration:\n", info, msg );
161 cp =
"** not configured **";
189 printf(
"%s %s configuration:\n", info, msg );
216 fprintf( stderr,
"** IRIG RX code index %i is out of range (0..%i).\n",
229 fprintf( stderr,
"** IRIG RX code \"%s\" not supported by this device.\n",
252 new_ref_offs = strtol( cp, &cp, 10 );
261 long tmp = strtol( cp, &cp, 10 );
268 new_ref_offs += is_negative ? -tmp : tmp;
275 fprintf( stderr,
"** New IRIG time offset %s exceeds range (%s..%s).\n",
314 if ( strcmp( s,
"1" ) == 0 )
317 if ( strcmp( s,
"0" ) == 0 )
338 fprintf( stderr,
"** IRIG TX code index %i is out of range (0..%i).\n",
351 fprintf( stderr,
"** IRIG TX code \"%s\" not supported by this device.\n",
363 int this_cfg_err = 0;
365 if ( strcmp( s,
"1" ) == 0 )
368 if ( strcmp( s,
"0" ) == 0 )
389 if ( strcmp( s,
"1" ) == 0 )
392 if ( strcmp( s,
"0" ) == 0 )
416 fprintf( stderr,
"** This device does not provide an IRIG input.\n" );
439 fprintf( stderr,
"** This device does not provide an IRIG output.\n" );
460 while ( ( c = getopt( argc, argv,
"h?" "r:o:u:i:X" "t:l:s:" ) ) != -1 )
526 const char *frame_fmt =
" %4i %s, %s\n";
530 "Usage: %s [-h]|[option] [option] ...\n" 536 " -h or -? prints this info\n" 542 "Options supported by IRIG receivers:\n" 547 " -r code specifies the IRIG receiver code format, where \"code\" \n" 548 " can be one a number according to the table below:\n" 557 " -o offs specifies the IRIG input time offset from UTC, in hours and optional minute,\n" 558 " where \"offs\" can be a value in the range %s .. %s.\n" 559 " When the device is shipped this parameter is set to \"not configured\"\n" 560 " to prevent the receiver from synchronizing to an IRIG input signal with\n" 561 " unknown UTC offset immediately after installation, which could cause\n" 562 " the system time to be set wrong by the time synchronization software.\n" 568 " -X set the IRIG input time offset from UTC to \"not configured\".\n" 569 " See also the -o option.\n" 574 " -u flag determines whether the time string sent via the\n" 575 " board's serial output contains always UTC time\n" 576 " or the same time as received from the IRIG input\n" 577 " signal. \"flag\" can be \"1\" for always UTC,\n" 578 " or \"0\" for IRIG time.\n" 583 " -i flag If \"flag\" is set to \"1\" then the TFOM qualifier in the\n" 584 " incoming IRIG signal is ignored, i.e. the receiver even synchronizes\n" 585 " to an input signal if the TFOM codes says the generator is freewheeling.\n" 586 " Please note that most IRIG codes do not support a TFOM qualifier.\n" 592 "Options supported by IRIG transmitters:\n" 597 " -t code specifies the IRIG transmitter code format, where \"code\" \n" 598 " can be one a number according to the table below:\n" 607 " -l flag determines whether IRIG output shall contain local\n" 608 " time, or UTC. \"flag\" must be \"1\" for local time,\n" 609 " or \"0\" for UTC.\n" 614 " -s flag If \"flag\" is set to \"1\" then the TFOM qualifier in the\n" 615 " IRIG output is always set to \"synchronized\". If it is \"0\" \n" 616 " then the qualifier reflects the current status of the input signal.\n" 617 " Please note that most IRIG codes do not support a TFOM qualifier.\n" 623 "If no parameters are given the program reports the current settings.\n" 624 "Please note that not all IRIG codes must be supported by all devices.\n" 646 fprintf( stderr,
"** This device does not provide an IRIG input or output.\n" );
672 printf(
"** Invalid configuration options specified.\n" );
720 int main(
int argc,
char *argv[] )
747 printf(
"For help type \"%s -h\"\n\n",
pname );
MBG_OPT_SETTINGS settings
current settings
see IFLAGS_BIT_DISABLE_TFOM
static char str_ref_offs_max[16]
_MBG_API_ATTR int _MBG_API mbg_save_all_irig_rx_settings(MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, const IRIG_SETTINGS *p_irig_settings, const MBG_REF_OFFS *p_ref_offs, const MBG_OPT_SETTINGS *p_opt_settings)
Write all IRIG input configuration settings to a device.
_MBG_API_ATTR int _MBG_API mbg_get_irig_tx_info(MBG_DEV_HANDLE dh, IRIG_INFO *p)
Read the current IRIG output settings plus the supported settings.
static int must_print_help_info
#define DEFAULT_STR_IRIG_OFFS_EN
static void set_new_tfom_flag(char *s, IRIG_SETTINGS *p, int *changed_flag, int *err_flag)
Requested action completed successfully.
int mbg_snprintf(char *s, size_t max_len, const char *fmt,...)
A portable, safer implementation of snprintf().
static MBG_OPT_INFO opt_info
Current IRIG settings and supported codes.
#define MBG_REF_OFFS_MAX
The maximum allowed positive / negative ref offset.
bool mbg_cond_err_msg(int rc, const char *what)
Check if a value is an error code and print an associated error message.
A structure used to configure optional settings.
static void set_ref_offs_not_cfgd(void)
_MBG_API_ATTR int _MBG_API mbg_get_all_irig_rx_info(MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, IRIG_INFO *p_irig_info, MBG_REF_OFFS *p_ref_offs, MBG_OPT_INFO *p_opt_info)
Read all IRIG input configuration information from a device.
#define _int_from_size_t(_n)
#define DEFAULT_STR_IRIG_FMT_EN
Unable to handle requested action, usage printed.
static void set_new_icode_tx(char *s)
#define mbg_rc_is_success(_rc)
static IRIG_INFO irig_rx_info
static const char * icode_rx_descr[N_ICODE_RX]
static const char str_no[]
static void set_new_str_utc(char *s)
#define _pcps_has_irig_tx(_d)
#define DEFAULT_STR_TFOM_ALWAYS_SYNC_EN
#define DEFAULT_ICODE_TX_NAMES
Initializers for TX timecode format name strings.
static MBG_DEV_HANDLER_FNC do_mbgirigcfg
#define DEFAULT_OPT_NAME_IRIG_TX_EN
static char str_ref_offs_min[16]
static void set_new_irig_tx_local(char *s)
int main(int argc, char *argv[])
static void print_cfg_tx(const char *info, const char *msg)
static int chk_dev_rx(const PCPS_DEV *p_dev)
#define MBG_ERR_CFG
Tried to write invalid configuration parameters to device, has to match PCPS_ERR_CFG (see also MBG_ER...
IRIG_SETTINGS settings
current settings
static void print_cfg_rx(const char *info, const char *msg)
#define DEFAULT_ICODE_RX_NAMES
Initializers for RX timecode format name strings.
static int changed_cfg_rx
#define DEFAULT_STR_IRIG_TIMESTR_UTC_EN
#define DEFAULT_OPT_NAME_IRIG_RX_EN
static const char msg_tx[]
static const char str_not_supp[]
int16_t MBG_REF_OFFS
A data type used to configure the ref offset.
#define MSK_ICODE_RX_HAS_TZI
A mask of IRIG RX formats supporting time zone information.
see IFLAGS_BIT_TX_GEN_LOCAL_TIME
#define DEFAULT_ICODE_RX_DESCRIPTIONS_ENG
Initializers for English RX format description strings.
#define _is_supported(_i, _msk)
#define MSK_ICODE_TX_HAS_TFOM
A mask of IRIG TX formats supporting TFOM.
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
#define DEFAULT_ICODE_TX_DESCRIPTIONS_ENG
Initializers for English TX format description strings.
#define DEFAULT_IGNORE_RX_TFOM_EN
Action failed for specified device.
static const char * icode_tx_descr[N_ICODE_TX]
static IRIG_INFO irig_tx_info
static const char * icode_rx_names[N_ICODE_RX]
static int snprint_hours_mins(char *s, size_t max_len, long num_minutes)
#define MBG_REF_OFFS_NOT_CFGD
A flag indicating that the ref offset has not yet been configured.
static const char * icode_tx_names[N_ICODE_TX]
#define MBG_LAST_COPYRIGHT_YEAR
static const char pname[]
uint16_t icode
IRIG signal code, see ICODE_RX_CODES and ICODE_TX_CODES.
#define MSK_ICODE_RX_HAS_TFOM
A mask of IRIG RX formats supporting TFOM time quality indicator.
uint32_t supp_flags
bit mask of supported flags, see MBG_OPT_FLAGS
#define MBG_FIRST_COPYRIGHT_YEAR
static MBG_REF_OFFS ref_offs
uint32_t supp_codes
see ICODE_TX_MASKS and ICODE_RX_MASKS
_MBG_API_ATTR int _MBG_API mbg_set_irig_tx_settings(MBG_DEV_HANDLE dh, const IRIG_SETTINGS *p)
Write an IRIG_SETTINGS structure to a device to configure the IRIG output.
Configuration settings of an IRIG input or output.
#define MBG_ERR_NOT_SUPP_BY_DEV
Command or feature not supported by device.
static const char msg_rx[]
the number of known codes
#define DEFAULT_STR_IRIG_OUTPUT_LOC_TM_EN
static void check_cmd_line(int argc, char *argv[], const PCPS_DEV *p_dev)
static int changed_cfg_tx
static void set_new_icode_rx(char *s)
#define _pcps_is_irig_rx(_d)
static const char str_yes[]
uint16_t flags
see IFLAGS_BIT_MASKS
#define _pcps_has_irig(_d)
static const char info_new[]
static const char info_curr[]
static int chk_dev_tx(const PCPS_DEV *p_dev)
static void set_new_ref_offs(char *s)