mbgtools-lx  4.2.8
mbgirigcfg.c
Go to the documentation of this file.
1 
2 /**************************************************************************
3  *
4  * $Id: mbgirigcfg.c 1.14 2018/11/15 12:12:34 martin TRASH $
5  *
6  * Description:
7  * Main file for the mbgirigcfg program which can be used to configure
8  * the IRIG code frame and the UTC offset of the time contained in the
9  * IRIG code.
10  *
11  * -----------------------------------------------------------------------
12  * $Log: mbgirigcfg.c $
13  * Revision 1.14 2018/11/15 12:12:34 martin
14  * Individual MBG_MICRO_VERSION codes are now obsolete.
15  * Revision 1.13 2018/01/15 15:16:00 martin
16  * Let snprint_hours_mins() return an int value.
17  * Revision 1.12 2017/08/18 08:15:44 martin
18  * Fixed error handling.
19  * Revision 1.11 2017/07/05 19:05:27 martin
20  * New way to maintain version information.
21  * Support build under Windows.
22  * New parameter -i to let incoming TFOM flag be ignored.
23  * Accept parameter -? to print usage.
24  * Use getopt() for option processing.
25  * Support multiple devices.
26  * New parameter -X which set ref offs to 'unconfigured'.
27  * Support specification of minutes for ref offset.
28  * Use safe string functions.
29  * Use more functions from common library modules.
30  * Use codes and inline functions from mbgerror.h.
31  * Proper return codes and exit codes.
32  * Revision 1.10 2009/09/29 15:02:15 martin
33  * Updated version number to 3.4.0.
34  * Revision 1.9 2009/07/24 09:50:08 martin
35  * Updated version number to 3.3.0.
36  * Revision 1.8 2009/06/19 12:38:51 martin
37  * Updated version number to 3.2.0.
38  * Revision 1.7 2009/03/19 17:07:16 martin
39  * Updated version number to 3.1.0.
40  * Updated copyright year to include 2009.
41  * Include mbgtime.h for some symbolic constants.
42  * Revision 1.6 2008/12/22 12:42:58 martin
43  * Updated description, copyright, revision number and string.
44  * Use unified functions from toolutil module.
45  * Accept device name(s) on the command line.
46  * Don't use printf() without format, which migth produce warnings
47  * with newer gcc versions.
48  * Revision 1.5 2007/07/24 09:34:46 martin
49  * Changes due to renamed library symbols.
50  * Updated copyright to include 2007.
51  * Revision 1.4 2006/08/28 10:08:17 martin
52  * Display TFOM settings only it the selected IRIG code format supports TFOM.
53  * Revision 1.3 2006/07/03 13:27:31 martin
54  * Source code cleanup and fixed a typo.
55  * Revision 1.2 2004/11/08 15:59:10 martin
56  * Support separate config of IRIG RX and TX.
57  * Changes due to renamed symbols.
58  * Revision 1.1 2003/04/25 10:42:10 martin
59  *
60  **************************************************************************/
61 
62 // include Meinberg headers
63 #include <mbgdevio.h>
64 #include <mbgutil.h>
65 #include <mbgtime.h>
66 #include <pcpsmktm.h>
67 #include <pcpslstr.h>
68 #include <myutil.h>
69 #include <toolutil.h>
70 
71 // include system headers
72 #include <stdio.h>
73 #include <stdlib.h>
74 #include <string.h>
75 #include <time.h>
76 
77 
78 #define MBG_FIRST_COPYRIGHT_YEAR 2003
79 #define MBG_LAST_COPYRIGHT_YEAR 0 // use default
80 
81 static const char pname[] = "mbgirigcfg";
82 
83 
84 static int glb_argc;
85 static char **glb_argv;
86 
87 static const char str_yes[] = "YES";
88 static const char str_no[] = "NO";
89 static const char str_not_supp[] = " (not supp. by this frame type)";
90 
91 static const char info_curr[] = "Current";
92 static const char info_new[] = "New";
93 static const char msg_rx[] = DEFAULT_OPT_NAME_IRIG_RX_EN;
94 static const char msg_tx[] = DEFAULT_OPT_NAME_IRIG_TX_EN;
95 
100 
101 static int cfg_err_rx;
102 static int cfg_err_tx;
103 static int changed_cfg_rx;
104 static int changed_cfg_tx;
105 static int warned_no_rx;
106 static int warned_no_tx;
107 
109 
112 
115 
116 static char str_ref_offs_min[16]; // need to be snprint_hours_mins'ed with -MBG_REF_OFFS_MAX
117 static char str_ref_offs_max[16]; // need to be snprint_hours_mins'ed with +MBG_REF_OFFS_MAX
118 
119 
120 
121 static /*HDR*/
122 int snprint_hours_mins( char *s, size_t max_len, long num_minutes )
123 {
124  ldiv_t ldt = ldiv( labs( num_minutes ), MINS_PER_HOUR );
125 
126  size_t n = mbg_snprintf( s, max_len, "%c%li",
127  ( num_minutes < 0 ) ? '-' : '+', ldt.quot );
128 
129  if ( ldt.rem )
130  n += mbg_snprintf( &s[n], max_len - n, ":%02li", ldt.rem );
131 
132  n += mbg_snprintf( &s[n], max_len - n, "h" );
133 
134  return _int_from_size_t( n );
135 
136 } // snprint_hours_mins
137 
138 
139 
140 static /*HDR*/
141 void print_cfg_rx( const char *info, const char *msg )
142 {
143  int idx = irig_rx_info.settings.icode;
144  char ws[16];
145  const char *cp = NULL;
146 
147  printf( "%s %s configuration:\n", info, msg );
148 
149  printf( " " DEFAULT_STR_IRIG_FMT_EN ": %s, %s\n",
150  icode_rx_names[idx],
151  icode_rx_descr[idx]
152  );
153 
154  printf( " " DEFAULT_IGNORE_RX_TFOM_EN ": %s%s\n",
155  ( irig_rx_info.settings.flags & IFLAGS_DISABLE_TFOM ) ? str_yes : str_no,
156  ( _idx_bit( idx ) & MSK_ICODE_RX_HAS_TFOM ) ? "" : str_not_supp );
157 
158  printf( " " DEFAULT_STR_IRIG_OFFS_EN ": " );
159 
160  if ( labs( ref_offs ) > MBG_REF_OFFS_MAX )
161  cp = "** not configured **";
162  else
163  {
164  snprint_hours_mins( ws, sizeof( ws ), ref_offs );
165  cp = ws;
166  }
167 
168  printf( "%s", cp );
169 
170  if ( ( 1UL << idx ) & MSK_ICODE_RX_HAS_TZI )
171  printf( " (ignored with code %s)", icode_rx_names[idx] );
172 
173  printf( "\n" );
174 
175  if ( opt_info.supp_flags & MBG_OPT_FLAG_STR_UTC )
176  printf( " " DEFAULT_STR_IRIG_TIMESTR_UTC_EN ": %s\n",
177  ( opt_info.settings.flags & MBG_OPT_FLAG_STR_UTC ) ?
178  str_yes : str_no );
179 
180 } // print_cfg_rx
181 
182 
183 
184 static /*HDR*/
185 void print_cfg_tx( const char *info, const char *msg )
186 {
187  int idx = irig_tx_info.settings.icode;
188 
189  printf( "%s %s configuration:\n", info, msg );
190 
191  printf( " " DEFAULT_STR_IRIG_FMT_EN ": %s, %s\n",
192  icode_tx_names[idx],
193  icode_tx_descr[idx]
194  );
195 
196  printf( " " DEFAULT_STR_TFOM_ALWAYS_SYNC_EN ": %s%s\n",
197  ( irig_tx_info.settings.flags & IFLAGS_DISABLE_TFOM ) ? str_yes : str_no,
198  ( _idx_bit( idx ) & MSK_ICODE_TX_HAS_TFOM ) ? "" : str_not_supp );
199 
200  printf( " " DEFAULT_STR_IRIG_OUTPUT_LOC_TM_EN ": %s\n",
201  ( irig_tx_info.settings.flags & IFLAGS_TX_GEN_LOCAL_TIME ) ?
202  str_yes : str_no
203  );
204 
205 } // print_cfg_tx
206 
207 
208 
209 static /*HDR*/
210 void set_new_icode_rx( char *s )
211 {
212  int idx = atoi( s );
213 
214  if ( idx >= N_ICODE_RX )
215  {
216  fprintf( stderr, "** IRIG RX code index %i is out of range (0..%i).\n",
217  idx, N_ICODE_RX - 1 );
218  cfg_err_rx = 1;
219  return;
220  }
221 
222  if ( _is_supported( idx, irig_rx_info.supp_codes ) )
223  {
224  irig_rx_info.settings.icode = idx;
225  changed_cfg_rx = 1;
226  }
227  else
228  {
229  fprintf( stderr, "** IRIG RX code \"%s\" not supported by this device.\n",
230  icode_rx_names[idx] );
231  cfg_err_rx = 1;
232  }
233 
234 } // set_new_icode_rx
235 
236 
237 
238 static /*HDR*/
239 void set_new_ref_offs( char *s )
240 {
241  long new_ref_offs;
242  char *cp = s;
243  int is_negative = 0;
244 
245  // expected format: [-]hh[:mm]
246 
247  // In case of e.g. "-0:30" conversion of the first part "-0" would yield
248  // 0 and thus the sign would get lost, so we check the sign explicitly.
249  if ( *cp == '-' )
250  is_negative = 1;
251 
252  new_ref_offs = strtol( cp, &cp, 10 );
253 
254  if ( cp == s ) // no number found at beginning
255  goto invalid;
256 
257  new_ref_offs *= MINS_PER_HOUR;
258 
259  if ( *cp++ == ':' ) // offset minutes seem to follow
260  {
261  long tmp = strtol( cp, &cp, 10 );
262 
263  // the value behind the colon should always be positive
264  if ( tmp < 0 || tmp >= MINS_PER_HOUR )
265  goto invalid;
266 
267  // apply the minutes offset according to the sign
268  new_ref_offs += is_negative ? -tmp : tmp;
269  }
270 
271  if ( labs( new_ref_offs ) > MBG_REF_OFFS_MAX )
272  {
273  char ws[16];
274  snprint_hours_mins( ws, sizeof( ws ), new_ref_offs );
275  fprintf( stderr, "** New IRIG time offset %s exceeds range (%s..%s).\n",
277  goto invalid;
278  }
279 
280  ref_offs = (MBG_REF_OFFS) new_ref_offs;
281  changed_cfg_rx = 1;
282 
283  return;
284 
285 
286 invalid:
287  cfg_err_rx = 1;
288 
289 } // set_new_ref_offs
290 
291 
292 
293 static /*HDR*/
295 {
297  changed_cfg_rx = 1;
298 
299 } // set_ref_offs_not_cfgd
300 
301 
302 
303 static /*HDR*/
304 void set_new_str_utc( char *s )
305 {
306  int this_cfg_err;
307 
308  if ( !( opt_info.supp_flags & MBG_OPT_FLAG_STR_UTC ) )
309  return; // not supported
310 
311 
312  this_cfg_err = 0;
313 
314  if ( strcmp( s, "1" ) == 0 )
315  opt_info.settings.flags |= MBG_OPT_FLAG_STR_UTC;
316  else
317  if ( strcmp( s, "0" ) == 0 )
318  opt_info.settings.flags &= ~MBG_OPT_FLAG_STR_UTC;
319  else
320  this_cfg_err = 1;
321 
322  if ( this_cfg_err )
323  cfg_err_rx = 1;
324  else
325  changed_cfg_rx = 1;
326 
327 } // set_new_str_utc
328 
329 
330 
331 static /*HDR*/
332 void set_new_icode_tx( char *s )
333 {
334  int idx = atoi( s );
335 
336  if ( idx >= N_ICODE_TX )
337  {
338  fprintf( stderr, "** IRIG TX code index %i is out of range (0..%i).\n",
339  idx, N_ICODE_TX - 1 );
340  cfg_err_tx = 1;
341  return;
342  }
343 
344  if ( _is_supported( idx, irig_tx_info.supp_codes ) )
345  {
346  irig_tx_info.settings.icode = idx;
347  changed_cfg_tx = 1;
348  }
349  else
350  {
351  fprintf( stderr, "** IRIG TX code \"%s\" not supported by this device.\n",
352  icode_tx_names[idx] );
353  cfg_err_tx = 1;
354  }
355 
356 } // set_new_icode_tx
357 
358 
359 
360 static /*HDR*/
361 void set_new_irig_tx_local( char *s )
362 {
363  int this_cfg_err = 0;
364 
365  if ( strcmp( s, "1" ) == 0 )
366  irig_tx_info.settings.flags |= IFLAGS_TX_GEN_LOCAL_TIME;
367  else
368  if ( strcmp( s, "0" ) == 0 )
369  irig_tx_info.settings.flags &= ~IFLAGS_TX_GEN_LOCAL_TIME;
370  else
371  this_cfg_err = 1;
372 
373  if ( this_cfg_err )
374  cfg_err_tx = 1;
375  else
376  changed_cfg_tx = 1;
377 
378 } // set_new_irig_tx_local
379 
380 
381 
382 static /*HDR*/
383 void set_new_tfom_flag( char *s, IRIG_SETTINGS *p, int *changed_flag, int *err_flag )
384 {
385  if ( !(_idx_bit( p->icode ) & MSK_ICODE_TX_HAS_TFOM ) )
386  return; // not supported
387 
388 
389  if ( strcmp( s, "1" ) == 0 )
391  else
392  if ( strcmp( s, "0" ) == 0 )
393  p->flags &= ~IFLAGS_DISABLE_TFOM;
394  else
395  {
396  *err_flag = 1;
397  return;
398  }
399 
400  *changed_flag = 1;
401 
402 } // set_new_tfom_flag
403 
404 
405 
406 static /*HDR*/
407 int chk_dev_rx( const PCPS_DEV *p_dev )
408 {
409  if ( p_dev )
410  {
411  if ( _pcps_is_irig_rx( p_dev ) )
412  return 1;
413 
414  if ( !warned_no_rx )
415  {
416  fprintf( stderr, "** This device does not provide an IRIG input.\n" );
417  warned_no_rx = 1;
418  }
419 
420  cfg_err_rx = 1;
421  }
422 
423  return 0;
424 
425 } // chk_dev_rx
426 
427 
428 
429 static /*HDR*/
430 int chk_dev_tx( const PCPS_DEV *p_dev )
431 {
432  if ( p_dev )
433  {
434  if ( _pcps_has_irig_tx( p_dev ) )
435  return 1;
436 
437  if ( !warned_no_tx )
438  {
439  fprintf( stderr, "** This device does not provide an IRIG output.\n" );
440  warned_no_tx = 1;
441  }
442 
443  cfg_err_tx = 1;
444  }
445 
446  return 0;
447 
448 } // chk_dev_tx
449 
450 
451 
452 static /*HDR*/
453 void check_cmd_line( int argc, char *argv[], const PCPS_DEV *p_dev )
454 {
455  int c;
456 
457  // force checking all parameters since this may be called several times
458  optind = 1;
459 
460  while ( ( c = getopt( argc, argv, "h?" "r:o:u:i:X" "t:l:s:" ) ) != -1 )
461  {
462  switch ( c )
463  {
464  case '?':
465  case 'h':
466  must_print_usage = 1;
467  break;
468 
469 
470  // IRIG receiver options
471 
472  case 'r': // IRIG RX code frame
473  if ( chk_dev_rx( p_dev ) )
474  set_new_icode_rx( optarg );
475  break;
476 
477  case 'o': // incoming time offset from UTC
478  if ( chk_dev_rx( p_dev ) )
479  set_new_ref_offs( optarg );
480  break;
481 
482  case 'u': // option flag: serial output is always UTC
483  if ( chk_dev_rx( p_dev ) )
484  set_new_str_utc( optarg );
485  break;
486 
487  case 'i': // option flag: ignore incoming TFOM flag, alway sync
488  if ( chk_dev_rx( p_dev ) )
489  set_new_tfom_flag( optarg, &irig_rx_info.settings, &changed_cfg_rx, &cfg_err_rx );
490  break;
491 
492  case 'X': // set UTC ref_offs to "not configured"
493  if ( chk_dev_rx( p_dev ) )
495  break;
496 
497 
498  // IRIG output options
499 
500  case 't': // IRIG TX code frame
501  if ( chk_dev_tx( p_dev ) )
502  set_new_icode_tx( optarg );
503  break;
504 
505  case 'l': // option flag: transmit local time, not UTC
506  if ( chk_dev_tx( p_dev ) )
507  set_new_irig_tx_local( optarg );
508  break;
509 
510  case 's': // option flag: send TFOM as always "sync"
511  if ( chk_dev_tx( p_dev ) )
512  set_new_tfom_flag( optarg, &irig_tx_info.settings, &changed_cfg_tx, &cfg_err_tx );
513  break;
514 
515  } // switch
516 
517  }
518 
519 } // check_cmd_line
520 
521 
522 
523 static /*HDR*/
524 void usage( void )
525 {
526  const char *frame_fmt = " %4i %s, %s\n";
527  int i;
528 
529  printf(
530  "Usage: %s [-h]|[option] [option] ...\n"
531  "\n",
532  pname
533  );
534 
535  printf(
536  " -h or -? prints this info\n"
537  "\n"
538  );
539 
540 
541  printf(
542  "Options supported by IRIG receivers:\n"
543  "\n"
544  );
545 
546  printf(
547  " -r code specifies the IRIG receiver code format, where \"code\" \n"
548  " can be one a number according to the table below:\n"
549  );
550 
551  for ( i = 0; i < N_ICODE_RX; i++ )
552  printf( frame_fmt, i, icode_rx_names[i], icode_rx_descr[i] );
553 
554  printf( "\n" );
555 
556  printf(
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"
563  "\n",
565  );
566 
567  printf(
568  " -X set the IRIG input time offset from UTC to \"not configured\".\n"
569  " See also the -o option.\n"
570  "\n"
571  );
572 
573  printf(
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"
579  "\n"
580  );
581 
582  printf(
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"
587  "\n"
588  );
589 
590 
591  printf(
592  "Options supported by IRIG transmitters:\n"
593  "\n"
594  );
595 
596  printf(
597  " -t code specifies the IRIG transmitter code format, where \"code\" \n"
598  " can be one a number according to the table below:\n"
599  );
600 
601  for ( i = 0; i < N_ICODE_TX; i++ )
602  printf( frame_fmt, i, icode_tx_names[i], icode_tx_descr[i] );
603 
604  printf( "\n" );
605 
606  printf(
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"
610  "\n"
611  );
612 
613  printf(
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"
618  "\n"
619  );
620 
621 
622  printf(
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"
625  );
626 
627 } // usage
628 
629 
630 
631 static /*HDR*/
632 int do_mbgirigcfg( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev )
633 {
634  int rc = MBG_SUCCESS;
635 
636  cfg_err_rx = 0;
637  cfg_err_tx = 0;
638  changed_cfg_rx = 0;
639  changed_cfg_tx = 0;
640  warned_no_rx = 0;
641  warned_no_tx = 0;
642 
643 
644  if ( !_pcps_has_irig( p_dev ) )
645  {
646  fprintf( stderr, "** This device does not provide an IRIG input or output.\n" );
649  goto done;
650  }
651 
652  if ( _pcps_is_irig_rx( p_dev ) )
653  {
654  rc = mbg_get_all_irig_rx_info( dh, p_dev, &irig_rx_info,
655  &ref_offs, &opt_info );
656  if ( mbg_cond_err_msg( rc, "read IRIG input configuration" ) )
657  goto done;
658  }
659 
660  if ( _pcps_has_irig_tx( p_dev ) )
661  {
662  rc = mbg_get_irig_tx_info( dh, &irig_tx_info );
663 
664  if ( mbg_cond_err_msg( rc, "read IRIG output configuration" ) )
665  goto done;
666  }
667 
668  check_cmd_line( glb_argc, glb_argv, p_dev );
669 
670  if ( cfg_err_rx || cfg_err_tx )
671  {
672  printf( "** Invalid configuration options specified.\n" );
674  rc = MBG_ERR_CFG;
675  goto done;
676  }
677 
678  if ( changed_cfg_rx )
679  {
680  if ( chk_dev_rx( p_dev ) )
681  {
683 
684  rc = mbg_save_all_irig_rx_settings( dh, p_dev, &irig_rx_info.settings,
685  &ref_offs, &opt_info.settings );
686  if ( mbg_cond_err_msg( rc, "write IRIG input configuration" ) )
687  goto done;
688  }
689  }
690  else // RX cfg not changed
691  if ( _pcps_is_irig_rx( p_dev ) )
693 
694 
695  if ( changed_cfg_tx )
696  {
697  if ( chk_dev_tx( p_dev ) )
698  {
700 
701  rc = mbg_set_irig_tx_settings( dh, &irig_tx_info.settings );
702 
703  if ( mbg_cond_err_msg( rc, "write IRIG output configuration" ) )
704  goto done;
705  }
706  }
707  else
708  if ( _pcps_has_irig_tx( p_dev ) )
710 
711 done:
712  return rc;
713 
714 } // do_mbgirigcfg
715 
717 
718 
719 
720 int main( int argc, char *argv[] )
721 {
722  int rc;
723 
725 
728 
729  check_cmd_line( argc, argv, NULL );
730 
731  if ( must_print_usage )
732  {
733  usage();
734  return MBG_EXIT_CODE_USAGE;
735  }
736 
737 
738  // We work with copies of the arguments here since the arguments
739  // are evaluated once more for each device.
740  glb_argc = argc;
741  glb_argv = argv;
742 
743  // Handle each of the specified devices.
744  rc = mbg_handle_devices( glb_argc, glb_argv, optind, do_mbgirigcfg, 0 );
745 
746  if ( must_print_help_info )
747  printf( "For help type \"%s -h\"\n\n", pname );
748 
750 }
MBG_OPT_SETTINGS settings
current settings
Definition: gpsdefs.h:5344
see IFLAGS_BIT_DISABLE_TFOM
Definition: gpsdefs.h:5041
static int cfg_err_tx
Definition: mbgirigcfg.c:102
static char str_ref_offs_max[16]
Definition: mbgirigcfg.c:117
_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.
Definition: mbgdevio.c:5146
_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.
Definition: mbgdevio.c:6787
static int glb_argc
Definition: mbgirigcfg.c:84
int mbg_handle_devices(int argc, char *argv[], int optind, MBG_DEV_HANDLER_FNC *fnc, int chk_dev_flags)
Main action handler that can be called by utility programs.
Definition: toolutil.c:655
int must_print_usage
static int must_print_help_info
Definition: mbgirigcfg.c:108
#define DEFAULT_STR_IRIG_OFFS_EN
Definition: pcpslstr.h:589
uint32_t flags
Definition: gpsdefs.h:5325
static void set_new_tfom_flag(char *s, IRIG_SETTINGS *p, int *changed_flag, int *err_flag)
Definition: mbgirigcfg.c:383
Requested action completed successfully.
Definition: mbgerror.h:631
int mbg_snprintf(char *s, size_t max_len, const char *fmt,...)
A portable, safer implementation of snprintf().
Definition: mbgutil.c:157
static MBG_OPT_INFO opt_info
Definition: mbgirigcfg.c:99
Current IRIG settings and supported codes.
Definition: gpsdefs.h:5054
#define MBG_REF_OFFS_MAX
The maximum allowed positive / negative ref offset.
Definition: gpsdefs.h:5305
bool mbg_cond_err_msg(int rc, const char *what)
Check if a value is an error code and print an associated error message.
Definition: mbgerror.c:714
A structure used to configure optional settings.
Definition: gpsdefs.h:5342
static void set_ref_offs_not_cfgd(void)
Definition: mbgirigcfg.c:294
_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.
Definition: mbgdevio.c:5099
#define _int_from_size_t(_n)
Definition: words.h:662
#define DEFAULT_STR_IRIG_FMT_EN
Definition: pcpslstr.h:579
Unable to handle requested action, usage printed.
Definition: mbgerror.h:632
static void set_new_icode_tx(char *s)
Definition: mbgirigcfg.c:332
#define mbg_rc_is_success(_rc)
Definition: mbgerror.h:618
static IRIG_INFO irig_rx_info
Definition: mbgirigcfg.c:96
static int cfg_err_rx
Definition: mbgirigcfg.c:101
static const char * icode_rx_descr[N_ICODE_RX]
Definition: mbgirigcfg.c:111
static const char str_no[]
Definition: mbgirigcfg.c:88
static void set_new_str_utc(char *s)
Definition: mbgirigcfg.c:304
#define _pcps_has_irig_tx(_d)
Definition: pcpsdev.h:1163
#define DEFAULT_STR_TFOM_ALWAYS_SYNC_EN
Definition: pcpslstr.h:627
#define DEFAULT_ICODE_TX_NAMES
Initializers for TX timecode format name strings.
Definition: gpsdefs.h:4137
see MBG_OPT_BIT_STR_UTC
Definition: gpsdefs.h:5375
static MBG_DEV_HANDLER_FNC do_mbgirigcfg
Definition: mbgirigcfg.c:716
#define DEFAULT_OPT_NAME_IRIG_TX_EN
Definition: pcpslstr.h:559
static char str_ref_offs_min[16]
Definition: mbgirigcfg.c:116
static void usage(void)
Definition: mbgirigcfg.c:524
static void set_new_irig_tx_local(char *s)
Definition: mbgirigcfg.c:361
number of known codes
Definition: gpsdefs.h:4128
int main(int argc, char *argv[])
Definition: mbgirigcfg.c:720
static void print_cfg_tx(const char *info, const char *msg)
Definition: mbgirigcfg.c:185
static int chk_dev_rx(const PCPS_DEV *p_dev)
Definition: mbgirigcfg.c:407
#define MBG_ERR_CFG
Tried to write invalid configuration parameters to device, has to match PCPS_ERR_CFG (see also MBG_ER...
Definition: mbgerror.h:265
IRIG_SETTINGS settings
current settings
Definition: gpsdefs.h:5056
static void print_cfg_rx(const char *info, const char *msg)
Definition: mbgirigcfg.c:141
#define DEFAULT_ICODE_RX_NAMES
Initializers for RX timecode format name strings.
Definition: gpsdefs.h:4564
static char ** glb_argv
Definition: mbgirigcfg.c:85
static int changed_cfg_rx
Definition: mbgirigcfg.c:103
#define DEFAULT_STR_IRIG_TIMESTR_UTC_EN
Definition: pcpslstr.h:599
#define DEFAULT_OPT_NAME_IRIG_RX_EN
Definition: pcpslstr.h:569
static const char msg_tx[]
Definition: mbgirigcfg.c:94
static const char str_not_supp[]
Definition: mbgirigcfg.c:89
int16_t MBG_REF_OFFS
A data type used to configure the ref offset.
Definition: gpsdefs.h:5297
#define MINS_PER_HOUR
Definition: mbgtime.h:236
#define MSK_ICODE_RX_HAS_TZI
A mask of IRIG RX formats supporting time zone information.
Definition: gpsdefs.h:4919
see IFLAGS_BIT_TX_GEN_LOCAL_TIME
Definition: gpsdefs.h:5042
#define DEFAULT_ICODE_RX_DESCRIPTIONS_ENG
Initializers for English RX format description strings.
Definition: gpsdefs.h:4633
#define _is_supported(_i, _msk)
Definition: myutil.h:163
#define MSK_ICODE_TX_HAS_TFOM
A mask of IRIG TX formats supporting TFOM.
Definition: gpsdefs.h:4430
int MBG_DEV_HANDLER_FNC(MBG_DEV_HANDLE, const PCPS_DEV *)
The type of functions to called to handle a device in a specific way.
Definition: toolutil.h:144
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
Definition: mbgerror.h:259
#define DEFAULT_ICODE_TX_DESCRIPTIONS_ENG
Initializers for English TX format description strings.
Definition: gpsdefs.h:4196
Definition: myutil.h:117
#define DEFAULT_IGNORE_RX_TFOM_EN
Definition: pcpslstr.h:618
Action failed for specified device.
Definition: mbgerror.h:634
static const char * icode_tx_descr[N_ICODE_TX]
Definition: mbgirigcfg.c:114
static IRIG_INFO irig_tx_info
Definition: mbgirigcfg.c:97
static const char * icode_rx_names[N_ICODE_RX]
Definition: mbgirigcfg.c:110
static int snprint_hours_mins(char *s, size_t max_len, long num_minutes)
Definition: mbgirigcfg.c:122
static int warned_no_rx
Definition: mbgirigcfg.c:105
#define MBG_REF_OFFS_NOT_CFGD
A flag indicating that the ref offset has not yet been configured.
Definition: gpsdefs.h:5314
static const char * icode_tx_names[N_ICODE_TX]
Definition: mbgirigcfg.c:113
#define MBG_LAST_COPYRIGHT_YEAR
Definition: mbgirigcfg.c:79
static const char pname[]
Definition: mbgirigcfg.c:81
uint16_t icode
IRIG signal code, see ICODE_RX_CODES and ICODE_TX_CODES.
Definition: gpsdefs.h:5001
#define MSK_ICODE_RX_HAS_TFOM
A mask of IRIG RX formats supporting TFOM time quality indicator.
Definition: gpsdefs.h:4895
uint32_t supp_flags
bit mask of supported flags, see MBG_OPT_FLAGS
Definition: gpsdefs.h:5345
#define MBG_FIRST_COPYRIGHT_YEAR
Definition: mbgirigcfg.c:78
static MBG_REF_OFFS ref_offs
Definition: mbgirigcfg.c:98
uint32_t supp_codes
see ICODE_TX_MASKS and ICODE_RX_MASKS
Definition: gpsdefs.h:5057
_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.
Definition: mbgdevio.c:6833
Configuration settings of an IRIG input or output.
Definition: gpsdefs.h:4999
#define MBG_ERR_NOT_SUPP_BY_DEV
Command or feature not supported by device.
Definition: mbgerror.h:286
static const char msg_rx[]
Definition: mbgirigcfg.c:93
the number of known codes
Definition: gpsdefs.h:4556
#define DEFAULT_STR_IRIG_OUTPUT_LOC_TM_EN
Definition: pcpslstr.h:609
static void check_cmd_line(int argc, char *argv[], const PCPS_DEV *p_dev)
Definition: mbgirigcfg.c:453
void mbg_print_program_info(const char *pname, int first_year, int last_year)
Print program info to console.
Definition: toolutil.c:193
static int changed_cfg_tx
Definition: mbgirigcfg.c:104
static void set_new_icode_rx(char *s)
Definition: mbgirigcfg.c:210
#define _pcps_is_irig_rx(_d)
Definition: pcpsdev.h:1078
#define _idx_bit(_i)
Definition: myutil.h:159
static const char str_yes[]
Definition: mbgirigcfg.c:87
uint16_t flags
see IFLAGS_BIT_MASKS
Definition: gpsdefs.h:5002
static int warned_no_tx
Definition: mbgirigcfg.c:106
#define _pcps_has_irig(_d)
Definition: pcpsdev.h:1184
Device info structure.
Definition: pcpsdev.h:1043
static const char info_new[]
Definition: mbgirigcfg.c:92
static const char info_curr[]
Definition: mbgirigcfg.c:91
static int chk_dev_tx(const PCPS_DEV *p_dev)
Definition: mbgirigcfg.c:430
static void set_new_ref_offs(char *s)
Definition: mbgirigcfg.c:239