mbgtools-lx  4.2.8
deviohlp.c
Go to the documentation of this file.
1 
2 /**************************************************************************
3  *
4  * $Id: deviohlp.c 1.7 2018/09/19 16:54:12 martin REL_M $
5  *
6  * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
7  *
8  * Description:
9  * Device configuration helper functions. This is an extension to
10  * mbgdevio.c providing useful functions to simplify reading/writing
11  * complex device configuration structure sets.
12  *
13  * Warning:
14  * These functions should not be implemented in a DLL / shared library
15  * since the parameter sizes might vary with different versions
16  * of the API calls, which which would make different versions of
17  * precompiled libraries incompatible to each other.
18  *
19  * -----------------------------------------------------------------------
20  * $Log: deviohlp.c $
21  * Revision 1.7 2018/09/19 16:54:12 martin
22  * Account for renamed global variables.
23  * Revision 1.6 2018/07/05 08:23:51Z martin
24  * Account for a renamed function in cfg_hlp.c.
25  * Added some comments.
26  * Revision 1.5 2018/04/24 16:10:46 martin
27  * Use predefined symbols to print ASIC version.
28  * Revision 1.4 2018/01/10 11:49:17 martin
29  * Removed usage of obsolete symbol MBGDEVIO_SIMPLE.
30  * Revision 1.3 2017/07/05 13:47:44 martin
31  * Many configuration functions provided by thomas-b,
32  * philipp, and martin.
33  * Revision 1.2 2012/10/15 13:48:35Z martin
34  * Added functions mbg_get_all_ptp_cfg_info(), mbg_save_all_ptp_cfg_info().
35  * Account for renamed structure.
36  * Updated doxygen comments.
37  * Revision 1.1 2011/08/03 15:37:00Z martin
38  * Initial revision with functions moved here from mbgdevio.
39  *
40  **************************************************************************/
41 
42 #define _DEVIOHLP
43  #include <deviohlp.h>
44 #undef _DEVIOHLP
45 
46 #include <str_util.h>
47 #include <lan_util.h>
48 #include <stdio.h>
49 
50 
51 #define DEFAULT_BAUD_RATES_DCF \
52 ( \
53  MBG_PORT_HAS_300 | \
54  MBG_PORT_HAS_600 | \
55  MBG_PORT_HAS_1200 | \
56  MBG_PORT_HAS_2400 | \
57  MBG_PORT_HAS_4800 | \
58  MBG_PORT_HAS_9600 \
59 )
60 
61 #define DEFAULT_BAUD_RATES_DCF_HS \
62 ( \
63  MBG_PORT_HAS_300 | \
64  MBG_PORT_HAS_600 | \
65  MBG_PORT_HAS_1200 | \
66  MBG_PORT_HAS_2400 | \
67  MBG_PORT_HAS_4800 | \
68  MBG_PORT_HAS_9600 | \
69  MBG_PORT_HAS_19200 | \
70  MBG_PORT_HAS_38400 \
71 )
72 
73 
74 #define DEFAULT_FRAMINGS_DCF \
75 ( \
76  MBG_PORT_HAS_7E2 | \
77  MBG_PORT_HAS_8N1 | \
78  MBG_PORT_HAS_8N2 | \
79  MBG_PORT_HAS_8E1 \
80 )
81 
82 
83 /*HDR*/
84 int chk_feat_supp( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, MBG_CHK_SUPP_FNC *chk_supp_fnc,
85  MBG_ERR_MSG_FNC *err_msg_fnc, const char *not_supp_msg )
86 {
87  const char *cp = NULL;
88  int rc = MBG_SUCCESS; // assume option is supported
89 
90  if ( chk_supp_fnc == NULL ) // no check function specified
91  goto out;
92 
93 
94  // A check function has been specified, so we must call it to check if
95  // the specific parameter/command is supported by this particular device.
96 
97  if ( dh == MBG_INVALID_DEV_HANDLE )
98  {
99  cp = "Tried checking feature support with invalid device handle.";
100  rc = MBG_ERR_INV_HANDLE;
101  goto out;
102  }
103 
104  rc = chk_supp_fnc( dh );
105 
106  if ( mbg_rc_is_success( rc ) )
107  goto out; // return with success
108 
109 
110  if ( rc == MBG_ERR_NOT_SUPP_BY_DEV )
111  {
112  cp = not_supp_msg;
113  goto fail;
114  }
115 
116 
117  cp = "Failed to check if supported"; //##++++ TODO:proper error msg
118 
119 fail:
120  if ( err_msg_fnc && cp )
121  err_msg_fnc( p_dev, cp );
122 
123 out:
124  return rc;
125 
126 } // chk_feat_supp
127 
128 
129 
130 /*HDR*/
160 {
161  int rc = MBG_ERR_UNSPEC;
162 
163  memset( p_agi, 0, sizeof( *p_agi ) );
164 
165  // First we check if the device is a GPS receiver,
166  // which includes GNSS receivers.
167  rc = mbg_chk_dev_is_gps( dh );
168 
169  if ( mbg_rc_is_error( rc ) )
170  goto out;
171 
172 
173  // Read the STAT_INFO structure which is supported by all GPS
174  // and GNSS receivers.
175  rc = mbg_get_gps_stat_info( dh, &p_agi->stat_info );
176 
177  if ( mbg_rc_is_error( rc ) )
178  goto out;
179 
180 
181  // Check if the device is a GNSS receiver, i.e. can track satellites
182  // from different systems (GPS, GLONASS, Beidou, ...).
183  rc = mbg_chk_dev_is_gnss( dh );
184 
185  if ( mbg_rc_is_success( rc ) )
186  {
187  // The device is a GNSS receiver, i.e. it can track satellites
188  // from different systems (GPS, GLONASS, Beidou, ...).
189  // Read some specific GNSS information.
190  rc = mbg_get_gps_gnss_mode_info( dh, &p_agi->gnss_mode_info );
191 
192  if ( mbg_rc_is_error( rc ) )
193  goto out;
194 
195 
196  rc = chk_set_n_gnss_supp( p_agi );
197 
198  if ( mbg_rc_is_error( rc ) )
199  goto out;
200 
201 
202  // If the the device supports the current API we can simply
203  // retrieve status information for each individual GNSS system.
205  goto out;
206  }
207 
208 
209  // If we get here then the device is a pure GPS receiver
210  // which neither supports additional GNSS systems nor the
211  // associated data structures, so we set up all GNSS
212  // data structures for GPS only.
214 
215 out:
216  return rc;
217 
218 } // mbg_chk_get_all_gnss_info
219 
220 
221 
222 /*HDR*/
245  const PCPS_DEV *p_dev,
246  RECEIVER_PORT_CFG *p_rpcfg,
247  const RECEIVER_INFO *p_ri )
248 {
249  int rc;
250 
251  memset( p_rpcfg, 0, sizeof( *p_rpcfg ) );
252 
253  if ( _pcps_has_receiver_info( p_dev ) )
254  {
255  // The device provides a RECEIVER_INFO, so we can simply read all
256  // serial port configuration and supported string types directly.
257 
258  rc = mbg_get_gps_all_port_info( dh, p_rpcfg->pii, p_ri );
259 
260  if ( mbg_rc_is_error( rc ) )
261  goto out;
262 
263  rc = mbg_get_gps_all_str_type_info( dh, p_rpcfg->stii, p_ri );
264 
265  if ( mbg_rc_is_error( rc ) )
266  goto out;
267  }
268  else
269  {
270  // The device doesn't support a RECEIVER_INFO, so this is
271  // an old GPS or non-GPS device.
272 
273  if ( _pcps_is_gps( p_dev ) )
274  {
275  // Read the serial port configuration from an old GPS device using
276  // a legacy API call and set up current structures accordingly.
277 
278  rc = mbg_get_gps_port_parm( dh, &p_rpcfg->tmp_pp );
279 
280  if ( mbg_rc_is_error( rc ) )
281  goto out;
282 
283  rc = setup_port_info_from_port_parm( p_rpcfg->pii, &p_rpcfg->tmp_pp, p_ri );
284 
285  if ( mbg_rc_is_error( rc ) )
286  goto out;
287 
288  // Also set up default string type information.
289  rc = setup_default_str_type_info_idx( p_rpcfg->stii, p_ri );
290  }
291  else
292  {
293  // Not all legacy non-GPS clocks have a serial port.
294  if ( _pcps_has_serial( p_dev ) )
295  {
296  // Read the serial port configuration from an old non-GPS device using
297  // a legacy API call and set up current structures accordingly.
298 
299  PCPS_SERIAL ser_code;
300 
301  rc = mbg_get_serial( dh, &ser_code );
302 
303  if ( mbg_rc_is_error( rc ) )
304  goto out;
305 
306  port_info_from_pcps_serial( p_rpcfg->pii, ser_code,
307  _pcps_has_serial_hs( p_dev ) ?
310  );
311  // Also set up default string type information.
312  rc = setup_default_str_type_info_idx( p_rpcfg->stii, p_ri );
313  }
314  }
315 
316  }
317 
318  rc = MBG_SUCCESS;
319 
320 out:
321  return rc;
322 
323 } // mbg_get_serial_settings
324 
325 
326 
327 /*HDR*/
354  RECEIVER_PORT_CFG *p_rpcfg, int port_num )
355 {
356  int rc;
357 
358  if ( _pcps_has_receiver_info( p_dev ) )
359  {
360  // The device provides a ::RECEIVER_INFO, so we can simply write
361  // the configuration for the specified serial port directly.
362  rc = mbg_set_gps_port_settings( dh, &p_rpcfg->pii[port_num].port_info.port_settings, port_num );
363  }
364  else
365  {
366  // This is a legacy device which doesn't provide a ::RECEIVER_INFO.
367  if ( _pcps_is_gps( p_dev ) )
368  {
369  // If the legacy device is a GPS receiver we have to set up
370  // an appropriate ::PORT_PARM structure and write that one
371  // to the device.
372  port_parm_from_port_settings( &p_rpcfg->tmp_pp, port_num,
373  &p_rpcfg->pii[port_num].port_info.port_settings, 1 );
374 
375  rc = mbg_set_gps_port_parm( dh, &p_rpcfg->tmp_pp );
376  }
377  else
378  {
379  // If the legacy device is not a GPS receiver we have
380  // to set up a ::PCPS_SERIAL configuration byte and write
381  // that one to the device.
382  PCPS_SERIAL ser_code;
383 
384  pcps_serial_from_port_info( &ser_code, p_rpcfg->pii );
385 
386  rc = mbg_set_serial( dh, &ser_code );
387  }
388  }
389 
390  return rc;
391 
392 } // mbg_save_serial_settings
393 
394 
395 
396 /*HDR*/
421 {
422  ALL_NET_CFG_INFO *net_cfg_info = *p;
423  int rc;
424 
425  if ( net_cfg_info == NULL )
426  {
427  net_cfg_info = ( ALL_NET_CFG_INFO * )calloc( 1, sizeof( *net_cfg_info ) );
428  if ( net_cfg_info == NULL )
429  {
430  rc = MBG_ERR_NO_MEM;
431  goto out;
432  }
433  }
434 
435  // TODO Use NET_CFG API as soon as its available for PCI/PCIe devices
436  rc = mbg_chk_dev_has_lan_intf( dh );
437 
438  if ( mbg_rc_is_success( rc ) )
439  {
440  LAN_IF_INFO lan_if_info;
441  IP4_SETTINGS ip4_settings;
442 
443  if ( net_cfg_info->glb_cfg_info.n_supp_intf_link != 0 )
444  goto out;
445 
446  rc = mbg_get_lan_if_info( dh, &lan_if_info );
447 
448  if ( mbg_rc_is_error( rc ) )
449  goto out;
450 
451  if ( net_cfg_info->link_infos == NULL )
452  {
453  net_cfg_info->link_infos = ( MBG_NET_INTF_LINK_INFO_IDX * )calloc( 1, sizeof( *net_cfg_info->link_infos ) );
454  if ( net_cfg_info->link_infos == NULL )
455  {
456  rc = MBG_ERR_NO_MEM;
457  goto out;
458  }
459  }
460 
461  net_cfg_info->glb_cfg_info.glb_settings.num_intf_link = 1;
462 
463  memset( &net_cfg_info->link_infos[0], 0, sizeof( net_cfg_info->link_infos[0] ) );
464 
469 
470  snprintf_safe( net_cfg_info->link_infos[0].info.link_settings.name, sizeof( net_cfg_info->link_infos[0].info.link_settings.name ), "lan0" );
471  net_cfg_info->link_infos[0].info.link_settings.mac_addr = lan_if_info.mac_addr;
472  net_cfg_info->link_infos[0].info.link_settings.if_index = 0;
475 
476  if ( net_cfg_info->glb_cfg_info.n_supp_intf_addr != 0 )
477  goto out;
478 
479  rc = mbg_get_ip4_settings( dh, &ip4_settings );
480 
481  if ( mbg_rc_is_error( rc ) )
482  goto out;
483 
484  if( ip4_settings.flags & IP4_MSK_LINK )
485  {
488  }
489 
490  if ( net_cfg_info->addr_infos == NULL )
491  {
492  net_cfg_info->addr_infos = ( MBG_NET_INTF_ADDR_INFO_IDX * )calloc( 1, sizeof( *net_cfg_info->addr_infos ) );
493  if ( net_cfg_info->addr_infos == NULL )
494  {
495  rc = MBG_ERR_NO_MEM;
496  goto out;
497  }
498  }
499 
500  net_cfg_info->glb_cfg_info.glb_settings.num_intf_addr = 1;
501 
502  memset( &net_cfg_info->addr_infos[0], 0, sizeof( net_cfg_info->addr_infos[0] ) );
503 
505 
506  snprintf_safe( net_cfg_info->addr_infos[0].info.addr_settings.label, sizeof( net_cfg_info->addr_infos[0].info.addr_settings.label ), "lan0:0" );
507 
508  if ( ip4_settings.flags & IP4_MSK_VLAN )
509  {
510  net_cfg_info->link_infos = ( MBG_NET_INTF_LINK_INFO_IDX * )realloc( net_cfg_info->link_infos, 2 * sizeof( *net_cfg_info->link_infos ) );
511  if ( net_cfg_info->link_infos == NULL )
512  {
513  rc = MBG_ERR_NO_MEM;
514  goto out;
515  }
516 
517  net_cfg_info->glb_cfg_info.glb_settings.num_intf_link = 2;
518 
519  memset(&net_cfg_info->link_infos[1], 0, sizeof(net_cfg_info->link_infos[1]));
520 
521  net_cfg_info->link_infos[1].idx = 1;
526 
527  snprintf_safe( net_cfg_info->link_infos[1].info.link_settings.name, sizeof( net_cfg_info->link_infos[1].info.link_settings.name ), "vlan0" );
528  net_cfg_info->link_infos[1].info.link_settings.mac_addr = net_cfg_info->link_infos[0].info.link_settings.mac_addr;
529  net_cfg_info->link_infos[1].info.link_settings.if_index = 1;
530  net_cfg_info->link_infos[1].info.link_settings.ass_if_index = 0;
531  net_cfg_info->link_infos[1].info.link_settings.states = net_cfg_info->link_infos[0].info.link_settings.states;
533  net_cfg_info->link_infos[1].info.link_settings.vlan_cfg = ip4_settings.vlan_cfg;
534 
535  net_cfg_info->addr_infos[0].info.addr_settings.ass_if_index = 1;
536  }
537 
538  if ( ip4_settings.flags & IP4_MSK_DHCP )
540 
542  net_cfg_info->addr_infos[0].info.addr_settings.ip.u_addr.ip4_addr = ip4_settings.ip_addr;
543 
545  net_cfg_info->addr_infos[0].info.addr_settings.broadcast.u_addr.ip4_addr = ip4_settings.broad_addr;
546 
547  net_cfg_info->addr_infos[0].info.addr_settings.prefix_bits = get_ip4_net_mask_bits(&ip4_settings.netmask);
548 
549  if ( net_cfg_info->glb_cfg_info.n_supp_intf_route == 0 )
550  {
551  if ( net_cfg_info->route_infos == NULL )
552  {
553  net_cfg_info->route_infos = ( MBG_NET_INTF_ROUTE_INFO_IDX * )calloc( 1, sizeof( *net_cfg_info->route_infos ) );
554  if ( net_cfg_info->route_infos == NULL )
555  {
556  rc = MBG_ERR_NO_MEM;
557  goto out;
558  }
559  }
560 
561  net_cfg_info->glb_cfg_info.glb_settings.num_intf_route = 1;
562 
563  memset( &net_cfg_info->route_infos[0], 0, sizeof( net_cfg_info->route_infos[0] ) );
564 
567  net_cfg_info->route_infos[0].info.route_settings.gateway.u_addr.ip4_addr = ip4_settings.gateway;
568  if ( ip4_settings.gateway != 0 )
569  {
570  if(net_cfg_info->glb_cfg_info.glb_settings.num_intf_link == 2)
571  net_cfg_info->route_infos[0].info.route_settings.ass_if_index = 1;
572  }
573  else net_cfg_info->route_infos[0].info.route_settings.ass_if_index = (uint32_t)-1;
574 
575  }
576 
577  }
578 
579 out:
580  if ( mbg_rc_is_error( rc ) )
581  {
582  free_all_net_cfg_info( net_cfg_info );
583  net_cfg_info = NULL;
584  }
585 
586  *p = net_cfg_info;
587 
588  return rc;
589 
590 } // mbg_get_all_net_cfg_info
591 
592 
593 
594 /*HDR*/
616 {
617  // TODO: Use NET_CFG API as soon as its available for PCI/PCIe devices
618  int rc = mbg_chk_dev_has_lan_intf( dh );
619 
620  if ( mbg_rc_is_success( rc ) )
621  {
622  IP4_SETTINGS ip4_settings;
623  memset( &ip4_settings, 0, sizeof( ip4_settings ) );
624 
626  ip4_settings.ip_addr = p->addr_infos[0].info.addr_settings.ip.u_addr.ip4_addr;
627 
629  ip4_settings.broad_addr = ip4_broad_addr_from_addr( &ip4_settings.ip_addr, &ip4_settings.netmask );
630 
633 
635  {
636  ip4_settings.flags |= IP4_MSK_VLAN;
637  ip4_settings.vlan_cfg = p->link_infos[1].info.link_settings.vlan_cfg;
638  }
639 
641  ip4_settings.flags |= IP4_MSK_DHCP;
642 
643  rc = mbg_set_ip4_settings( dh, &ip4_settings );
644  }
645 
646  return rc;
647 
648 } // mbg_save_all_net_cfg_info
649 
650 
651 
652 /*HDR*/
677 {
678  ALL_NET_STATUS_INFO *net_status_info = *p;
679  int rc;
680 
681  if ( net_status_info == NULL )
682  {
683  net_status_info = ( ALL_NET_STATUS_INFO * )calloc( 1, sizeof( *net_status_info ) );
684  if ( net_status_info == NULL )
685  {
686  rc = MBG_ERR_NO_MEM;
687  goto out;
688  }
689  }
690 
691  // TODO Use NET_CFG API as soon as its available for PCI/PCIe devices
692  rc = mbg_chk_dev_has_lan_intf( dh );
693 
694  if ( mbg_rc_is_success( rc ) )
695  {
696  LAN_IF_INFO lan_if_info;
697  IP4_SETTINGS ip4_state;
698 
699  if ( net_status_info->glb_cfg_info.n_supp_intf_link != 0 )
700  goto out;
701 
702  rc = mbg_get_lan_if_info( dh, &lan_if_info );
703 
704  if ( mbg_rc_is_error( rc ) )
705  goto out;
706 
707  if ( net_status_info->link_infos == NULL )
708  {
709  net_status_info->link_infos = ( MBG_NET_INTF_LINK_INFO_IDX * )calloc( 1, sizeof( *net_status_info->link_infos ) );
710  if ( net_status_info->link_infos == NULL )
711  {
712  rc = MBG_ERR_NO_MEM;
713  goto out;
714  }
715  }
716 
717  net_status_info->glb_cfg_info.glb_settings.num_intf_addr = 1;
718 
719  memset( &net_status_info->link_infos[0], 0, sizeof( net_status_info->link_infos[0] ) );
720 
725 
726  snprintf_safe( net_status_info->link_infos[0].info.link_settings.name, sizeof( net_status_info->link_infos[0].info.link_settings.name ), "lan0" );
727  net_status_info->link_infos[0].info.link_settings.mac_addr = lan_if_info.mac_addr;
728  net_status_info->link_infos[0].info.link_settings.if_index = 0;
731 
732  if ( net_status_info->glb_cfg_info.n_supp_intf_addr != 0 )
733  goto out;
734 
735  rc = mbg_get_ip4_state( dh, &ip4_state );
736 
737  if ( mbg_rc_is_error( rc ) )
738  goto out;
739 
740  if( ip4_state.flags & IP4_MSK_LINK )
741  {
744  }
745 
746  if ( net_status_info->addr_infos == NULL )
747  {
748  net_status_info->addr_infos = ( MBG_NET_INTF_ADDR_INFO_IDX * )realloc( net_status_info->addr_infos, sizeof( *net_status_info->addr_infos ) );
749  if ( net_status_info->addr_infos == NULL )
750  {
751  rc = MBG_ERR_NO_MEM;
752  goto out;
753  }
754  }
755 
756  net_status_info->glb_cfg_info.glb_settings.num_intf_addr = 1;
757 
758  memset( &net_status_info->addr_infos[0], 0, sizeof( net_status_info->addr_infos[0] ) );
759 
761 
762  snprintf_safe( net_status_info->addr_infos[0].info.addr_settings.label, sizeof( net_status_info->addr_infos[0].info.addr_settings.label ), "lan0:0" );
763 
764  if ( ip4_state.flags & IP4_MSK_VLAN )
765  {
766  net_status_info->link_infos = ( MBG_NET_INTF_LINK_INFO_IDX * )realloc( net_status_info->link_infos, 2 * sizeof( *net_status_info->link_infos ) );
767  if ( net_status_info->link_infos == NULL )
768  {
769  rc = MBG_ERR_NO_MEM;
770  goto out;
771  }
772 
773  net_status_info->glb_cfg_info.glb_settings.num_intf_link = 2;
774 
775  memset(&net_status_info->link_infos[1], 0, sizeof(net_status_info->link_infos[1]));
776 
777  net_status_info->link_infos[1].idx = 1;
782 
783  snprintf_safe( net_status_info->link_infos[1].info.link_settings.name, sizeof( net_status_info->link_infos[1].info.link_settings.name ), "vlan0" );
784  net_status_info->link_infos[1].info.link_settings.mac_addr = net_status_info->link_infos[0].info.link_settings.mac_addr;
785  net_status_info->link_infos[1].info.link_settings.if_index = 1;
786  net_status_info->link_infos[1].info.link_settings.ass_if_index = 0;
787  net_status_info->link_infos[1].info.link_settings.states = net_status_info->link_infos[0].info.link_settings.states;
789  net_status_info->link_infos[1].info.link_settings.vlan_cfg = ip4_state.vlan_cfg;
790 
791  net_status_info->addr_infos[0].info.addr_settings.ass_if_index = 1;
792  }
793 
794  if ( ip4_state.flags & IP4_MSK_DHCP )
796 
798  net_status_info->addr_infos[0].info.addr_settings.ip.u_addr.ip4_addr = ip4_state.ip_addr;
799 
801  net_status_info->addr_infos[0].info.addr_settings.broadcast.u_addr.ip4_addr = ip4_state.broad_addr;
802 
803  net_status_info->addr_infos[0].info.addr_settings.prefix_bits = get_ip4_net_mask_bits(&ip4_state.netmask);
804 
805  if ( net_status_info->glb_cfg_info.n_supp_intf_route == 0 )
806  {
807  if ( net_status_info->route_infos == NULL )
808  {
809  net_status_info->route_infos = ( MBG_NET_INTF_ROUTE_INFO_IDX * )calloc( 1, sizeof( *net_status_info->route_infos ) );
810  if ( net_status_info->route_infos == NULL )
811  {
812  rc = MBG_ERR_NO_MEM;
813  goto out;
814  }
815  }
816 
817  net_status_info->glb_cfg_info.glb_settings.num_intf_route = 1;
818 
819  memset( &net_status_info->route_infos[0], 0, sizeof( net_status_info->route_infos[0] ) );
820 
823  net_status_info->route_infos[0].info.route_settings.gateway.u_addr.ip4_addr = ip4_state.gateway;
824  if ( ip4_state.gateway != 0 )
825  {
826  if(net_status_info->glb_cfg_info.glb_settings.num_intf_link == 2)
827  net_status_info->route_infos[0].info.route_settings.ass_if_index = 1;
828  }
829  else net_status_info->route_infos[0].info.route_settings.ass_if_index = (uint32_t)-1;
830 
831  }
832 
833  }
834 
835 out:
836  if ( mbg_rc_is_error( rc ) )
837  {
838  free_all_net_status_info( net_status_info );
839  net_status_info = NULL;
840  }
841 
842  *p = net_status_info;
843 
844  return rc;
845 
846 } // mbg_get_all_net_status_info
847 
848 
849 
850 /*HDR*/
870 {
871  int rc = MBG_SUCCESS;
872 
873  memset( p, 0, sizeof( *p ) );
874 
875  rc = mbg_get_ptp_cfg_info( dh, &p->ptp_cfg_info );
876 
877  if ( rc < 0 )
878  return rc;
879 
881  {
883 
884  if ( rc < 0 )
885  return rc;
886 
888  {
889  // The number of PTP unicast masters supported by this device
890  // exceeds the number of unicast masters supporterd by this driver.
892  }
893 
896  if ( rc < 0 )
897  return rc;
898  }
899 
900  return MBG_SUCCESS;
901 
902 } // mbg_get_all_ptp_cfg_info
903 
904 
905 
906 /*HDR*/
926 {
927  int rc = MBG_SUCCESS;
928 
930 
931  if ( rc < 0 )
932  return rc;
933 
934 
936  {
937  int i;
938 
939  for ( i = 0; i < p->ptp_uc_master_cfg_limits.n_supp_master; i++ )
940  {
942 
943  memset( &s, 0, sizeof( s ) );
944 
945  s.idx = i;
946  s.settings = p->all_ptp_uc_master_info_idx[i].info.settings;
947 
948  rc = mbg_set_ptp_uc_master_settings_idx( dh, &s );
949 
950  if ( rc < 0 )
951  return rc;
952  }
953  }
954 
955  return MBG_SUCCESS;
956 
957 } // mbg_save_all_ptp_cfg_info
958 
959 
960 
961 /*HDR*/
979 {
980  ALL_XMULTI_REF_INFO *xmr_info = *p;
981  int rc;
982 
983  if ( xmr_info == NULL )
984  {
985  xmr_info = ( ALL_XMULTI_REF_INFO * )calloc( 1, sizeof( *xmr_info ) );
986  if ( xmr_info == NULL )
987  {
988  rc = MBG_ERR_NO_MEM;
989  goto out;
990  }
991  }
992 
993  // First, get the XMULTI_REF_INSTANCES to check how many sources are supported
994  rc = mbg_get_xmr_instances( dh, &xmr_info->instances );
995 
996  if ( mbg_rc_is_error( rc ) )
997  goto out;
998 
999  if ( xmr_info->infos == NULL )
1000  {
1001  xmr_info->infos = ( XMULTI_REF_INFO_IDX * )calloc( xmr_info->instances.n_xmr_settings, sizeof( *xmr_info->infos ) );
1002  if ( xmr_info->infos == NULL )
1003  {
1004  rc = MBG_ERR_NO_MEM;
1005  goto out;
1006  }
1007  }
1008 
1009  rc = mbg_get_gps_all_xmr_info( dh, xmr_info->infos, &xmr_info->instances );
1010 
1011  if ( mbg_rc_is_error( rc ) )
1012  goto out;
1013 
1015  {
1016  // TODO!!!
1017  // XMR_EXT_SRC_INFO_IDX can not be read out from bus devices, yet
1018  // Therefore, remove the feature bit from this card
1019  // Has to be changed as soon as low level functions are ready
1020  // TODO!!!
1022  }
1023 
1024 out:
1025  if ( mbg_rc_is_error( rc ) )
1026  {
1027  free_all_xmulti_ref_info( xmr_info );
1028  xmr_info = NULL;
1029  }
1030 
1031  *p = xmr_info;
1032 
1033  return rc;
1034 
1035 } // mbg_get_all_xmulti_ref_info
1036 
1037 
1038 /*HDR*/
1053 {
1054  int rc = MBG_SUCCESS, i;
1055  XMULTI_REF_SETTINGS_IDX settings;
1056 
1057  for (i = 0; ( i < p->instances.n_xmr_settings ) && mbg_rc_is_success( rc ); i++ )
1058  {
1059  settings.idx = i;
1060  memcpy( &settings.settings, &p->infos[i].info.settings, sizeof( settings.settings ) );
1061  rc = mbg_set_gps_xmr_settings_idx( dh, &settings );
1062  }
1063 
1064  // if all settings have been successully set, send dummy structure with index -1 to apply settings
1065  if( mbg_rc_is_success( rc ) )
1066  {
1067  memset( &settings, 0, sizeof( settings ) );
1068  settings.idx = -1;
1069  settings.settings.id.type = MULTI_REF_NONE;
1070  rc = mbg_set_gps_xmr_settings_idx( dh, &settings );
1071  }
1072 
1073  return rc;
1074 
1075 } // mbg_save_all_xmulti_ref_info
1076 
1077 
1078 /*HDR*/
1097 {
1098  ALL_XMULTI_REF_STATUS *xmr_status = *p;
1099  int rc;
1100 
1101  if ( info == NULL )
1102  return MBG_ERR_INV_PARM;
1103 
1104  if ( xmr_status == NULL )
1105  {
1106  xmr_status = ( ALL_XMULTI_REF_STATUS * )calloc( 1, sizeof( *xmr_status ) );
1107  if ( xmr_status == NULL )
1108  {
1109  rc = MBG_ERR_NO_MEM;
1110  goto out;
1111  }
1112  }
1113 
1114  if ( xmr_status->status == NULL )
1115  {
1116  xmr_status->status = ( XMULTI_REF_STATUS_IDX* )calloc( info->instances.n_xmr_settings, sizeof( *xmr_status->status ) );
1117 
1118  if ( xmr_status->status == NULL )
1119  {
1120  rc = MBG_ERR_NO_MEM;
1121  goto out;
1122  }
1123  }
1124 
1125  rc = mbg_get_gps_all_xmr_status( dh, xmr_status->status, &info->instances );
1126 
1127  if ( mbg_rc_is_error( rc ) )
1128  goto out;
1129 
1131  {
1132  // TODO
1133  // XMR_EXT_SRC_INFO_IDX can not be read out from bus devices, yet
1134  }
1135 
1136 out:
1137  if ( mbg_rc_is_error( rc ) )
1138  {
1139  free_all_xmulti_ref_status( xmr_status );
1140  xmr_status = NULL;
1141  }
1142 
1143  *p = xmr_status;
1144 
1145  return rc;
1146 
1147 } // mbg_get_all_xmulti_ref_status
1148 
1149 
1150 
1151 /*HDR*/
1170 {
1171  int rc;
1172  ALL_UCAP_INFO *ucap_info = *p;
1173  UCAP_ENTRY *new_entry, *old_entry;
1174 
1175  // if this function is called for the first time, allocate a new ::ALL_UCAP_INFO structure
1176  if ( ucap_info == NULL )
1177  {
1178  ucap_info = ( ALL_UCAP_INFO* )calloc( 1, sizeof( *ucap_info ) );
1179  if ( ucap_info == NULL )
1180  {
1181  *p = NULL;
1182  return MBG_ERR_NO_MEM;
1183  }
1184  mbg_klist_init(&ucap_info->list);
1185  }
1186 
1187  do
1188  {
1189  new_entry = calloc_ucap_entry();
1190  if ( !new_entry )
1191  {
1192  rc = MBG_ERR_NO_MEM;
1193  goto err_out;
1194  }
1195 
1196  rc = mbg_get_gps_ucap( dh, &new_entry->ttm );
1197  if ( mbg_rc_is_error( rc ) )
1198  goto err_out;
1199 
1200  if ( ( (uint8_t)new_entry->ttm.tm.sec == (uint8_t) 0xFF ) )
1201  {
1202  free ( new_entry );
1203  new_entry = NULL;
1204  break;
1205  }
1206 
1207  if ( ucap_info->num_ucaps < MAX_UCAP_ENTRIES )
1208  {
1209  mbg_klist_append_item(&ucap_info->list, &new_entry->head);
1210  ++ucap_info->num_ucaps;
1211  }
1212  else
1213  {
1214  old_entry = mbg_klist_first_entry(&ucap_info->list, UCAP_ENTRY, head);
1215  mbg_klist_delete_item(&old_entry->head);
1216  free(old_entry);
1217  mbg_klist_append_item(&ucap_info->list, &new_entry->head);
1218  }
1219 
1220  } while (1);
1221 
1222  rc = MBG_SUCCESS;
1223 
1224  goto success_out;
1225 
1226 err_out:
1227  free_all_ucap_info( ucap_info );
1228  ucap_info = NULL;
1229  if ( new_entry )
1230  free( new_entry );
1231 
1232 success_out:
1233  *p = ucap_info;
1234 
1235  return rc;
1236 
1237 } // mbg_get_all_ucap_info
1238 
1239 
1240 
1241 #if 0 && defined( DEBUG ) // ### TODO
1242 
1243 /*HDR*/
1244 void test_gpio( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, int verbose )
1245 {
1246  int b;
1247  int rc;
1248  unsigned int i;
1249  MBG_GPIO_CFG_LIMITS gpio_cfg_limits = { 0 };
1250  ALL_GPIO_INFO_IDX all_gpio_info_idx = { { 0 } };
1251  ALL_GPIO_STATUS_IDX all_gpio_status_idx = { { 0 } };
1252 
1253  rc = mbg_chk_dev_has_gpio( dh );
1254 
1255  printf( "\nGPIO chk supp: %i\n", rc );
1256 
1257  rc = mbg_dev_has_gpio( dh, &b );
1258 
1259  if ( rc != MBG_SUCCESS || !b )
1260  {
1261  printf( "GPIO not supported, rc: %i, b: %i\n", rc, b );
1262  return;
1263  }
1264 
1265  printf( "GPIO supported, rc: %i, b: %i\n", rc, b );
1266 
1267  printf( "\nChecking GPIO:\n" );
1268 
1269  rc = mbg_get_gpio_cfg_limits( dh, &gpio_cfg_limits );
1270 
1271  if ( rc != MBG_SUCCESS )
1272  {
1273  printf( "Failed to read GPIO limits, rc: %i\n", rc );
1274  return;
1275  }
1276 
1277  printf( "Number of GPIO ports: %i\n", gpio_cfg_limits.num_io );
1278 
1279  rc = mbg_get_gps_all_gpio_info( dh, all_gpio_info_idx, &gpio_cfg_limits );
1280 
1281  if ( rc != MBG_SUCCESS )
1282  printf( "Failed to read all GPIO info, rc: %i\n", rc );
1283 
1284  if ( !( gpio_cfg_limits.flags & MBG_GPIO_CFG_LIMIT_FLAG_MASK_STATUS_SUPP ) )
1285  printf( "GPIO status not supported (flag not set).\n" );
1286  else
1287  {
1288  rc = mbg_get_gps_all_gpio_status( dh, all_gpio_status_idx, &gpio_cfg_limits );
1289 
1290  if ( rc != MBG_SUCCESS )
1291  printf( "Failed to read all GPIO status, rc: %i\n", rc );
1292  }
1293 
1294 
1295  for ( i = 0; i < gpio_cfg_limits.num_io; i++ )
1296  {
1297  MBG_GPIO_INFO *p_i = &all_gpio_info_idx[i].info;
1298  MBG_GPIO_STATUS *p_st = &all_gpio_status_idx[i].status;
1299  int gpio_type = p_i->settings.type;
1300 
1301  printf( "GPIO %i: type 0x%02X (%s)", i,
1302  gpio_type, _get_gpio_type_name( gpio_type ) );
1303 
1304  switch ( gpio_type )
1305  {
1306  case MBG_GPIO_TYPE_FREQ_IN: // variable frequency input, freq == 0 if input not used
1307  {
1309 #if 0
1310  MBG_GPIO_FREQ freq;
1311  uint32_t csc_limit;
1312  uint32_t shape;
1313  uint32_t reserved;
1314  uint32_t flags;
1315 #endif
1316 
1317  } break;
1318 
1319  case MBG_GPIO_TYPE_FREQ_OUT: // variable frequency output
1320  {
1322 
1323  printf( " %lu.%lu Hz %s, phase %li.%03li deg",
1324  (ulong) p->freq.hz, (ulong) p->freq.frac,
1326  (long) p->milli_phase / 1000,
1327  labs( (long) p->milli_phase % 1000 ) );
1328 
1329  } break;
1330 
1331  case MBG_GPIO_TYPE_FIXED_FREQ_OUT: // fixed frequency output
1332  {
1334 
1335 #if 0
1336 typedef struct
1337 {
1338  uint32_t freq_idx;
1339  uint32_t shape;
1340  uint32_t reserved;
1341  uint32_t flags;
1342 
1344 #endif
1345 
1346  printf( " %s %s", _get_gpio_fixed_freq_str( p->freq_idx ),
1348 
1349  } break;
1350 
1351  case MBG_GPIO_TYPE_BITS_IN: // framed data stream input
1352  break;
1353 
1354  case MBG_GPIO_TYPE_BITS_OUT: // framed data stream output
1355  break;
1356  }
1357 
1358  printf( ", status 0x%02X (%s)",
1360 
1361  printf( "\n" );
1362  }
1363 
1364 #if 0
1366 #endif
1367 
1368 } // test_gpio
1369 
1370 
1371 
1372 /*HDR*/
1373 void test_xmr( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, int verbose )
1374 {
1375  static const char *multi_ref_names[N_MULTI_REF] = DEFAULT_MULTI_REF_NAMES;
1376 
1377  XMULTI_REF_INSTANCES xmr_instances = { 0 };
1378  ALL_XMULTI_REF_INFO_IDX all_xmulti_ref_info_idx = { { 0 } };
1379  ALL_XMULTI_REF_STATUS_IDX all_xmulti_ref_status_idx = { { 0 } };
1380  XMR_HOLDOVER_STATUS xmr_holdover_status;
1381 
1382  int b;
1383  int rc;
1384  int i;
1385 
1386  rc = mbg_chk_dev_has_xmr( dh );
1387 
1388  printf( "\nXMR chk supp: %i\n", rc );
1389 
1390  rc = mbg_dev_has_xmr( dh, &b );
1391 
1392  if ( rc != MBG_SUCCESS || !b )
1393  {
1394  printf( "XMR not supported, rc: %i, b: %i\n", rc, b );
1395  return;
1396  }
1397 
1398  printf( "XMR supported, rc: %i, b: %i\n", rc, b );
1399 
1400  printf( "\nChecking XMR:\n" );
1401 
1402  rc = mbg_get_xmr_instances( dh, &xmr_instances );
1403 
1404  if ( rc != MBG_SUCCESS )
1405  {
1406  printf( "*** Failed to read XMR instances, rc: %i\n", rc );
1407  return;
1408  }
1409 
1410  printf( "Slot %u, supp. XMR instances/priority levels: %u, flags: 0x%08lX\n",
1411  xmr_instances.slot_id, xmr_instances.n_xmr_settings,
1412  (ulong) xmr_instances.flags );
1413 
1414  if ( verbose )
1415  {
1416 // XMRIF_MSK_MRF_NONE_SUPP = ( 1UL << XMRIF_BIT_MRF_NONE_SUPP ), ///< see ::XMRIF_BIT_MRF_NONE_SUPP
1417 //##++++++++++++++++++++ XMRIF_MSK_HOLDOVER_STATUS_SUPP = ( 1UL << XMRIF_BIT_HOLDOVER_STATUS_SUPP ) ///< see ::XMRIF_BIT_HOLDOVER_STATUS_SUPP
1418  }
1419 
1420 
1421  for ( i = 0; i < MAX_N_MULTI_REF_TYPES; i++ )
1422  {
1423  int n_inst = xmr_instances.n_inst[i];
1424 
1425  if ( i < N_MULTI_REF ) // a known signal type
1426  {
1427  if ( verbose )
1428  {
1429  if ( n_inst )
1430  printf( "%u %s input%s supported\n", n_inst,
1431  multi_ref_names[i], ( n_inst == 1 ) ? "" : "s" );
1432  else
1433  if ( verbose > 1 )
1434  printf( "No %s input supported\n", multi_ref_names[i] );
1435  }
1436 
1437  continue;
1438  }
1439 
1440  // If execution gets here then the signal type is unknown.
1441  // Print a warning if the device supports instances of this signal type.
1442  if ( n_inst )
1443  printf( "*** Warning: %u instances of unknown signal type idx %u supported!\n",
1444  n_inst, i );
1445  }
1446 
1447  rc = mbg_get_gps_all_xmr_info( dh, all_xmulti_ref_info_idx, &xmr_instances );
1448 
1449  if ( rc != MBG_SUCCESS )
1450  printf( "*** Failed to read all XMR info, rc: %i\n", rc );
1451 
1452  rc = mbg_get_gps_all_xmr_status( dh, all_xmulti_ref_status_idx, &xmr_instances );
1453 
1454  if ( rc != MBG_SUCCESS )
1455  printf( "*** Failed to read all XMR status, rc: %i\n", rc );
1456 
1457  for ( i = 0; i < xmr_instances.n_xmr_settings; i++ )
1458  {
1459  XMULTI_REF_INFO *p = &all_xmulti_ref_info_idx[i].info;
1460 
1461  printf( "XMR %i: %li\n", i,
1462  (long) p->settings.bias.secs );
1463 
1464 #if 0
1466  xmrsi.settings = p->settings;
1467  xmrsi.settings.precision.nano_secs = i + 40;
1468  xmrsi.settings.bias.secs = 0xA55ACDEF;
1469  xmrsi.settings.bias.nano_secs = 0x12345678;
1470  xmrsi.idx = i;
1471 
1472  rc = mbg_set_gps_xmr_settings_idx( dh, &xmrsi );
1473 
1474  if ( rc != MBG_SUCCESS )
1475  printf( "Failed to write XMR settings %i, rc: %i\n", i, rc );
1476 #endif
1477  }
1478 
1479  if ( !( xmr_instances.flags & XMRIF_MSK_HOLDOVER_STATUS_SUPP ) )
1480  printf( "*** Warning: XMR holdover status not supported!\n" );
1481  else
1482  {
1483  rc = mbg_get_xmr_holdover_status( dh, &xmr_holdover_status, &xmr_instances );
1484 
1485  if ( rc != MBG_SUCCESS )
1486  printf( "*** Failed to read XMR holdover status, rc: %i\n", rc );
1487  else
1488  {
1489  printf( "XMR mode: %s, %s%s, %s%s, %s%s\n",
1490  _get_xmr_holdover_status_mode_name( xmr_holdover_status.mode ),
1491  ( xmr_holdover_status.flags & XMR_HLDOVR_MSK_IN_HOLDOVER ) ? "" : str_not_spc, "in holdover",
1492  ( xmr_holdover_status.flags & XMR_HLDOVR_MSK_TRANSITION_ENBD ) ? "" : str_not_spc, "transition enabled",
1493  ( xmr_holdover_status.flags & XMR_HLDOVR_MSK_IN_TRANSITION ) ? "" : str_not_spc, "in transition"
1494  );
1495 
1496 //##+++++ print_xmr_prio( xmr_holdover_status.curr_prio, "Current",
1497 #if 0
1498 typedef struct
1499 {
1500  uint8_t mode;
1501  int8_t curr_prio;
1502  int8_t nxt_prio;
1503  uint8_t remote_watchdog;
1504  uint32_t reserved;
1505  XMR_HOLDOVER_INTV elapsed;
1506  XMR_HOLDOVER_INTV interval;
1507  uint32_t flags;
1508 
1510 #endif
1511 
1512  }
1513  }
1514 
1515 } // test_xmr
1516 
1517 #endif // defined DEBUG
1518 
1519 
1520 
1522 {
1527 };
1528 
1529 
1530 
1531 /*HDR*/
1533  PORT_INFO_IDX *p_pii,
1534  PCPS_SERIAL pcps_serial,
1535  uint32_t supp_baud_rates
1536 )
1537 {
1538  PCPS_SER_PACK ser_pack;
1539  PORT_INFO *p_pi;
1540  PORT_SETTINGS *p_ps;
1541 
1542  ser_pack.pack = pcps_serial;
1543  pcps_unpack_serial( &ser_pack );
1544 
1545  p_pi = &p_pii[0].port_info;
1546  p_ps = &p_pi->port_settings;
1547 
1548  p_ps->parm.baud_rate = mbg_baud_rates[ser_pack.baud];
1549 
1550  strncpy_safe( p_ps->parm.framing, //### TODO
1552  sizeof( p_ps->parm.framing ) );
1553 
1554  p_ps->parm.handshake = HS_NONE;
1555 
1556  p_ps->str_type = 0;
1557  p_ps->mode = ser_pack.mode;
1558 
1559  p_pi->supp_baud_rates = supp_baud_rates;
1562 
1563 } // port_info_from_pcps_serial
1564 
1565 
1566 /*HDR*/
1568  PCPS_SERIAL *p,
1569  const PORT_INFO_IDX *p_pii
1570 )
1571 {
1572  PCPS_SER_PACK ser_pack;
1573  const PORT_INFO *p_pi = &p_pii[0].port_info;
1574  const PORT_SETTINGS *p_ps = &p_pi->port_settings;
1575  int framing_idx = get_framing_idx( p_ps->parm.framing );
1576  int i;
1577 
1578 
1579  ser_pack.baud = get_baud_rate_idx( p_ps->parm.baud_rate );
1580 
1581  // Translate the common framing index to the corresponding
1582  // number used with the old PCPS_SERIAL parameter.
1583  // This should always return a valid result since the
1584  // framing index is expected to be selected from
1585  // supported framings.
1586  for ( i = 0; i < N_PCPS_FR_DCF; i++ )
1587  if ( pcps_to_mbg_framing_tbl[i] == framing_idx )
1588  break;
1589 
1590  ser_pack.frame = i;
1591 
1592  ser_pack.mode = p_ps->mode;
1593 
1594  pcps_pack_serial( &ser_pack );
1595 
1596  *p = ser_pack.pack;
1597 
1598 } // pcps_serial_from_port_info
1599 
1600 
1601 
1602 /*--------------------------------------------------------------
1603  * Name: pcps_unpack_serial()
1604  *
1605  * Purpose: Unpack a structure with serial port parameters
1606  *
1607  * Input/Output: p address of a structure holding both the
1608  * packed and unpacked information
1609  *
1610  * Ret value: --
1611  *-------------------------------------------------------------*/
1612 
1613 /*HDR*/
1615 {
1616  uint8_t pack = p->pack;
1617 
1618  p->baud = (uint8_t) ( pack & BITMASK( PCPS_BD_BITS ) );
1619  p->frame = (uint8_t) ( ( pack >> PCPS_FR_SHIFT ) & BITMASK( PCPS_FR_BITS ) );
1620  p->mode = (uint8_t) ( ( pack >> PCPS_MOD_SHIFT ) & BITMASK( PCPS_MOD_BITS ) );
1621 
1622 } // pcps_unpack_serial
1623 
1624 
1625 
1626 /*--------------------------------------------------------------
1627  * Name: pcps_pack_serial()
1628  *
1629  * Purpose: Pack a structure with serial port parameters
1630  *
1631  * Input/Output: p address of a structure holding both the
1632  * packed and unpacked information
1633  *
1634  * Ret value: --
1635  *-------------------------------------------------------------*/
1636 
1637 /*HDR*/
1639 {
1640  p->pack = (uint8_t) ( ( p->baud & BITMASK( PCPS_BD_BITS ) )
1641  | ( ( p->frame & BITMASK( PCPS_FR_BITS ) ) << PCPS_FR_SHIFT )
1642  | ( ( p->mode & BITMASK( PCPS_MOD_BITS ) ) << PCPS_MOD_SHIFT ) );
1643 
1644 } /* pcps_pack_serial */
1645 
1646 
1647 
1648 /*--------------------------------------------------------------
1649  * Name: pcps_str_to_port()
1650  *
1651  * Purpose: Try to convert a string to a valid port
1652  * address.
1653  *
1654  * Input: s the string
1655  *
1656  * Output: --
1657  *
1658  * Ret value: a valid port number or 0
1659  *+-------------------------------------------------------------*/
1660 
1661 /*HDR*/
1662 void pcps_setup_isa_ports( char *s,
1663  int *port_vals,
1664  int n_vals )
1665 {
1666  ushort i;
1667 
1668 
1669  for ( i = 0; i < n_vals; i++ )
1670  {
1671  if ( *s == 0 )
1672  break;
1673 
1674  *port_vals++ = (uint16_t) strtoul( s, &s, 16 );
1675 
1676  if ( *s == ',' )
1677  s++;
1678  }
1679 
1680 } // pcps_setup_isa_ports
1681 
1682 
1683 
1684 /*HDR*/
1685 const char *setup_device_type_name( char *s, size_t max_len, MBG_DEV_HANDLE dh,
1686  const RECEIVER_INFO *p_ri )
1687 {
1688  size_t n = sn_cpy_str_safe( s, max_len, p_ri->model_name );
1689 
1691  {
1692  PCI_ASIC_VERSION asic_version;
1693 
1694  if ( mbg_rc_is_success( mbg_get_asic_version( dh, &asic_version ) ) )
1695  {
1696  asic_version = _convert_asic_version_number( asic_version ); // TODO Do we need this?
1697 
1698  n += snprintf_safe( &s[n], max_len - n, " (PCI ASIC v" PCPS_ASIC_STR_FMT ")",
1699  _pcps_asic_version_major( asic_version ),
1700  _pcps_asic_version_minor( asic_version ) );
1701  }
1702  }
1703 
1704  return s;
1705 
1706 } // setup_device_type_name
1707 
1708 
1709 
1710 /*HDR*/
1711 const char *setup_asic_features( char *s, size_t max_len, MBG_DEV_HANDLE dh )
1712 {
1713  size_t n = 0;
1714 
1716  {
1717  PCI_ASIC_FEATURES asic_features;
1718 
1719  if ( mbg_rc_is_success( mbg_get_asic_features( dh, &asic_features ) ) )
1720  {
1721  if ( asic_features & PCI_ASIC_HAS_MM_IO )
1722  n += sn_cpy_str_safe( &s[n], max_len - n, "Memory Mapped I/O" );
1723 
1724  //### if ( asic_features & PCI_ASIC_HAS_PGMB_IRQ )
1725  // (implement this as loop)
1726  }
1727  }
1728 
1729  if ( n == 0 ) // nothing else printed
1730  sn_cpy_str_safe( s, max_len, str_not_avail );
1731 
1732  return s;
1733 
1734 } // setup_asic_features
1735 
1736 
#define PCPS_MOD_BITS
field with in the cfg byte
Definition: pcpsdefs.h:1416
MBG_IP_ADDR broadcast
Broadcast address associated with this interface.
Definition: gpsdefs.h:12174
_MBG_API_ATTR int _MBG_API mbg_get_gps_all_xmr_status(MBG_DEV_HANDLE dh, XMULTI_REF_STATUS_IDX xmrsi[], const XMULTI_REF_INSTANCES *p_xmri)
Read the status of all XMR sources.
Definition: mbgdevio.c:8290
MBG_DATABASE_INFO info
Definition: cfg_hlp.h:736
_NO_MBG_API_ATTR int _MBG_API chk_dev_xmulti_ref_supp_ext_src_info(const ALL_XMULTI_REF_INFO *info)
Definition: cfg_hlp.c:821
_MBG_API_ATTR int _MBG_API mbg_get_gps_all_str_type_info(MBG_DEV_HANDLE dh, STR_TYPE_INFO_IDX stii[], const RECEIVER_INFO *p_ri)
Read a STR_TYPE_INFO_IDX array of supported string types.
Definition: mbgdevio.c:6125
uint8_t type
see MULTI_REF_TYPES, and note for XMRIF_BIT_MRF_NONE_SUPP
Definition: gpsdefs.h:6703
Configuration settings for a specific PTP unicast master.
Definition: gpsdefs.h:14329
PTP_CFG_INFO ptp_cfg_info
Definition: cfg_hlp.h:371
Variable frequency input, freq == 0 if input not used.
Definition: gpsdefs.h:7665
uint32_t num_io
number of supported GPIO ports
Definition: gpsdefs.h:7610
uint8_t type
see MBG_IP_ADDR_TYPES
Definition: gpsdefs.h:11908
TM_GPS tm
time converted to UTC and/or local time according to TZDL settings
Definition: gpsdefs.h:2717
_MBG_API_ATTR int _MBG_API mbg_get_xmr_holdover_status(MBG_DEV_HANDLE dh, XMR_HOLDOVER_STATUS *p, const XMULTI_REF_INSTANCES *p_xmri)
Read the current XMR holdover interval from a device.
Definition: mbgdevio.c:8436
COM_PARM parm
transmission speed, framing, etc.
Definition: gpsdefs.h:3509
void pcps_pack_serial(PCPS_SER_PACK *p)
Definition: deviohlp.c:1638
MBG_GPIO_SETTINGS settings
current settings
Definition: gpsdefs.h:9256
Configuration of a GPIO variable frequency input.
Definition: gpsdefs.h:7774
struct mbg_klist_head list
User capture counter, see MAX_UCAP_ENTRIES.
Definition: cfg_hlp.h:611
_MBG_API_ATTR int _MBG_API mbg_get_gps_all_gnss_sat_info(MBG_DEV_HANDLE dh, GNSS_SAT_INFO_IDX gsii[], const MBG_GNSS_MODE_INFO *p_mi)
Read a GNSS_SAT_INFO_IDX array of satellite status information.
Definition: mbgdevio.c:8028
_MBG_API_ATTR int _MBG_API mbg_set_ptp_uc_master_settings_idx(MBG_DEV_HANDLE dh, const PTP_UC_MASTER_SETTINGS_IDX *p)
Write PTP/IEEE1588 unicast configuration settings to a device.
Definition: mbgdevio.c:7582
void free_all_net_status_info(ALL_NET_STATUS_INFO *p)
Free an ALL_NET_STATUS_INFO structure.
Definition: cfg_hlp.c:1052
uint32_t num_ucaps
Definition: cfg_hlp.h:610
_MBG_API_ATTR int _MBG_API mbg_get_gps_ucap(MBG_DEV_HANDLE dh, TTM *p)
Read a time capture event from the on-board FIFO buffer using a TTM structure.
Definition: mbgdevio.c:5741
Settings of an IPv4-only network interface.
Definition: gpsdefs.h:11239
char * strncpy_safe(char *dst, const char *src, size_t max_len)
A portable, safe implementation of strncpy()
Definition: str_util.c:247
XMULTI_REF_INFO_IDX * infos
Definition: cfg_hlp.h:523
int setup_default_str_type_info_idx(STR_TYPE_INFO_IDX stii[], const RECEIVER_INFO *p_ri)
Definition: cfg_hlp.c:422
uint16_t n_supp_master
number of unicast masters which can be specified
Definition: gpsdefs.h:14233
uint8_t prefix_bits
Number of subnet mask bits for CIDR notation, e.g. 24 for /24.
Definition: gpsdefs.h:12176
#define _pcps_asic_version_major(_v)
Extract the major part of an ASIC version number.
Definition: pci_asic.h:339
MBG_MAC_ADDR mac_addr
MAC address.
Definition: gpsdefs.h:11277
_MBG_API_ATTR int _MBG_API mbg_get_lan_if_info(MBG_DEV_HANDLE dh, LAN_IF_INFO *p)
Read LAN interface information from a device.
Definition: mbgdevio.c:7271
uint8_t n_inst[32]
the number of supported instances of each input signal type
Definition: gpsdefs.h:7060
void test_xmr(MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, int verbose)
void port_info_from_pcps_serial(PORT_INFO_IDX *p_pii, PCPS_SERIAL pcps_serial, uint32_t supp_baud_rates)
Definition: deviohlp.c:1532
MBG_NET_INTF_ADDR_INFO_IDX * addr_infos
Definition: cfg_hlp.h:240
uint8_t num_intf_link
number of detected/configured physical network interfaces (links), see MBG_NET_INTF_LINK_INFO_IDX ...
Definition: gpsdefs.h:11848
static int verbose
Definition: mbghrtime.c:80
void free_all_xmulti_ref_info(ALL_XMULTI_REF_INFO *p)
Free an ALL_XMULTI_REF_INFO structure.
Definition: cfg_hlp.c:1210
#define DEFAULT_BAUD_RATES_DCF
Definition: deviohlp.c:51
void free_all_ucap_info(ALL_UCAP_INFO *p)
Free memory allocated by mbgextio_get_all_ucap_info.
Definition: cfg_hlp.c:1556
Definition: cfg_hlp.h:602
PTP_UC_MASTER_CFG_LIMITS ptp_uc_master_cfg_limits
Definition: cfg_hlp.h:372
#define DEFAULT_SUPP_STR_TYPES_DCF
Bit mask of string types supported by legacy DCF77 receivers.
Definition: gpsdefs.h:3877
#define _get_gpio_port_state_name(_i)
Definition: cfg_hlp.h:897
Status information on a ref time source at a specific priority level.
Definition: gpsdefs.h:6885
_MBG_API_ATTR int _MBG_API mbg_set_serial(MBG_DEV_HANDLE dh, const PCPS_SERIAL *p)
Write the serial port configuration to an old type of device.
Definition: mbgdevio.c:4716
#define MBG_ERR_INV_PARM
Invalid parameter.
Definition: mbgerror.h:329
uint32_t type
GPIO type, see MBG_GPIO_TYPES.
Definition: gpsdefs.h:9129
int mbg_get_all_ucap_info(MBG_DEV_HANDLE dh, ALL_UCAP_INFO **p)
Read all user capture information and store it into a newly allocated or reused ALL_UCAP_INFO.
Definition: deviohlp.c:1169
see MBG_NET_INTF_LINK_PORT_TYPE_TP
Definition: gpsdefs.h:11534
number of valid codes
Definition: pcpsdefs.h:1389
Configuration settings of a serial port.
Definition: gpsdefs.h:3507
static __mbg_inline void mbg_klist_append_item(struct mbg_klist_head *head, struct mbg_klist_head *item)
Definition: mbgklist.h:156
unsigned short uint16_t
Definition: words.h:213
XMR holdover status.
Definition: gpsdefs.h:7157
int8_t sec
seconds, 0..59, or 60 in case of inserted leap second
Definition: gpsdefs.h:2602
struct mbg_klist_head head
Definition: cfg_hlp.h:604
#define _get_gpio_fixed_freq_str(_i)
Definition: cfg_hlp.h:919
MBG_GNSS_MODE_INFO gnss_mode_info
Definition: cfg_hlp.h:451
int mbg_save_all_net_cfg_info(MBG_DEV_HANDLE dh, ALL_NET_CFG_INFO *p)
Write all network settings to a device.
Definition: deviohlp.c:615
XMULTI_REF_SETTINGS settings
current settings
Definition: gpsdefs.h:6802
#define _pcps_has_serial(_d)
Definition: pcpsdev.h:1145
#define DEFAULT_BAUD_RATES_DCF_HS
Definition: deviohlp.c:61
uint32_t idx
index, 0..PTP_UC_MASTER_CFG_LIMITS::n_supp_master-1
Definition: gpsdefs.h:14331
union MBG_IP_ADDR::u_addr u_addr
void port_parm_from_port_settings(PORT_PARM *p_pp, int port_idx, const PORT_SETTINGS *p_ps, int cap_str_idx)
Set up a a legacy PORT_PARM structure from a PORT_SETTINGS structure.
Definition: cfg_hlp.c:272
#define MBG_ERR_N_UC_MSTR_EXCEEDS_SUPP
Num. PTP unicast masters of the device exceeds max. supp. by driver.
Definition: mbgerror.h:307
#define _pcps_is_gps(_d)
Definition: pcpsdev.h:1074
Real physical network interface.
Definition: gpsdefs.h:11768
Query MBG_NET_INTF_ROUTE_INFO by its index.
Definition: gpsdefs.h:12344
int sn_cpy_str_safe(char *dst, size_t max_len, const char *src)
A function to copy a string safely, returning the number of characters copied.
Definition: str_util.c:276
uint32_t flags
see XMR_INST_FLAG_BIT_MASKS
Definition: gpsdefs.h:7056
#define _NO_MBG_API_ATTR
Definition: mbg_tgt.h:1032
MBG_CHK_SUPP_FNC mbg_chk_dev_has_asic_features
Check if a device supports the mbg_get_asic_features call.
Definition: mbgdevio.c:793
uint8_t frame
The unpacked framing code, see PCPS_FR_CODES.
Definition: deviohlp.h:68
#define mbg_rc_is_success(_rc)
Definition: mbgerror.h:618
MBG_CHK_SUPP_FNC mbg_chk_dev_has_gpio
Check if a device provides GPIO signal inputs and/or outputs.
Definition: mbgdevio.c:1883
uint16_t n_supp_intf_addr
max. number of supported interface addresses, see MBG_NET_INTF_ADDR_SETTINGS_IDX, MBG_NET_INTF_ADDR_I...
Definition: gpsdefs.h:11873
uint8_t PCPS_SERIAL
Legacy definitions used to configure a device&#39;s serial port.
Definition: pcpsdefs.h:1342
A GPIO port&#39;s current settings and limits.
Definition: gpsdefs.h:9254
MBG_CHK_SUPP_FNC mbg_chk_dev_is_gps
Check if a device is a GPS receiver.
Definition: mbgdevio.c:1029
int mbg_get_serial_settings(MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, RECEIVER_PORT_CFG *p_rpcfg, const RECEIVER_INFO *p_ri)
Read all serial port settings and supported configuration parameters.
Definition: deviohlp.c:244
uint16_t n_supp_intf_link
max. number of supported physical network interfaces (links), see MBG_NET_INTF_LINK_SETTINGS_IDX, MBG_NET_INTF_LINK_INFO_IDX
Definition: gpsdefs.h:11872
MBG_GPIO_FREQ_IN_SETTINGS freq_in
if MBG_GPIO_SETTINGS::type is MBG_GPIO_TYPE_FREQ_IN
Definition: gpsdefs.h:9140
_MBG_API_ATTR int _MBG_API mbg_get_gps_all_gpio_info(MBG_DEV_HANDLE dh, MBG_GPIO_INFO_IDX gii[], const MBG_GPIO_CFG_LIMITS *p_gcl)
Get all GPIO settings and capabilities.
Definition: mbgdevio.c:8115
_MBG_API_ATTR int _MBG_API mbg_get_ip4_settings(MBG_DEV_HANDLE dh, IP4_SETTINGS *p)
Read LAN IPv4 settings from a device.
Definition: mbgdevio.c:7331
char int8_t
Definition: words.h:209
int get_baud_rate_idx(BAUD_RATE baud_rate)
Definition: cfg_hlp.c:130
General GPIO config info to be read from a device.
Definition: gpsdefs.h:7608
#define DEFAULT_MULTI_REF_NAMES
Names of known ref time sources.
Definition: gpsdefs.h:6457
see IP4_BIT_LINK
Definition: gpsdefs.h:11342
#define _get_xmr_holdover_status_mode_name(_i)
Definition: cfg_hlp.h:930
const char * setup_device_type_name(char *s, size_t max_len, MBG_DEV_HANDLE dh, const RECEIVER_INFO *p_ri)
Definition: deviohlp.c:1685
uint8_t baud
The unpacked baud rate code, see PCPS_BD_CODES.
Definition: deviohlp.h:67
#define PCPS_ASIC_STR_FMT
Definition: pci_asic.h:334
_MBG_API_ATTR int _MBG_API mbg_set_ptp_cfg_settings(MBG_DEV_HANDLE dh, const PTP_CFG_SETTINGS *p)
Write PTP/IEEE1588 configuration settings to a device.
Definition: mbgdevio.c:7458
uint32_t supp_flags
see MBG_NET_INTF_ADDR_MASKS
Definition: gpsdefs.h:12225
uint32_t ass_if_index
Index of the associated interface link, see MBG_NET_INTF_LINK_SETTINGS::if_index. ...
Definition: gpsdefs.h:12169
static __mbg_inline void mbg_klist_init(struct mbg_klist_head *head)
Definition: mbgklist.h:131
_MBG_API_ATTR int _MBG_API mbg_get_asic_features(MBG_DEV_HANDLE dh, PCI_ASIC_FEATURES *p)
Read the features of the on-board PCI/PCIe interface ASIC.
Definition: mbgdevio.c:6420
_MBG_API_ATTR int _MBG_API mbg_set_gps_xmr_settings_idx(MBG_DEV_HANDLE dh, const XMULTI_REF_SETTINGS_IDX *p)
Write a single XMR setting to a device.
Definition: mbgdevio.c:8399
int32_t milli_phase
phase [1/1000 degree units], see MBG_GPIO_FREQ_OUT_SUPP::milli_phase_max
Definition: gpsdefs.h:7839
see IP4_BIT_DHCP
Definition: gpsdefs.h:11341
unsigned short ushort
Definition: words.h:282
MBG_CHK_SUPP_FNC mbg_chk_dev_is_gnss
Check if a device supports GNSS configuration.
Definition: mbgdevio.c:1002
see XMRIF_BIT_HOLDOVER_STATUS_SUPP
Definition: gpsdefs.h:7106
IP4_ADDR ip_addr
the IP address
Definition: gpsdefs.h:11241
uint32_t supp_flags
a bit mask of supported features, see PTP_CFG_FLAG_MASKS
Definition: gpsdefs.h:13357
uint32_t frac
fractional part, binary (0x80000000 –> 0.5, 0xFFFFFFFF –> 0.9999999...)
Definition: gpsdefs.h:7753
#define _pcps_has_receiver_info(_d)
Definition: pcpsdev.h:1160
static __mbg_inline IP4_ADDR ip4_net_mask_from_cidr(int netmask_bits)
Compute an IP4 net mask according to the number of CIDR netmask bits.
Definition: lan_util.h:130
_MBG_API_ATTR int _MBG_API mbg_dev_has_xmr(MBG_DEV_HANDLE dh, int *p)
Check if a device provides extended multi ref (XMR) inputs.
Definition: mbgdevio.c:2276
Status information on a single GPIO port.
Definition: gpsdefs.h:9292
#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10_T_HALF
see MBG_NET_INTF_LINK_SPEED_MODE_10_T_HALF
Definition: gpsdefs.h:11458
void pcps_setup_isa_ports(char *s, int *port_vals, int n_vals)
Definition: deviohlp.c:1662
char label[16]
Interface label.
Definition: gpsdefs.h:12166
Fixed frequency output.
Definition: gpsdefs.h:7667
MBG_IP_ADDR ip
IP address associated with this interface.
Definition: gpsdefs.h:12173
see IP4_BIT_VLAN
Definition: gpsdefs.h:11343
Summary information on all supported GNSS systems.
Definition: cfg_hlp.h:447
uint16_t n_xmr_settings
number of XMULTI_REF_INFO_IDX or XMULTI_REF_STATUS_IDX which can be retrieved
Definition: gpsdefs.h:7057
_MBG_API_ATTR int _MBG_API mbg_dev_has_gpio(MBG_DEV_HANDLE dh, int *p)
Check if a device provides GPIO signal inputs and/or outputs.
Definition: mbgdevio.c:2993
_MBG_API_ATTR int _MBG_API mbg_get_ptp_cfg_info(MBG_DEV_HANDLE dh, PTP_CFG_INFO *p)
Read PTP/IEEE1588 config info and current settings from a device.
Definition: mbgdevio.c:7427
#define _get_gpio_signal_shape_name(_i)
Definition: cfg_hlp.h:908
Variable frequency output.
Definition: gpsdefs.h:7666
int mbg_get_all_xmulti_ref_status(MBG_DEV_HANDLE dh, const ALL_XMULTI_REF_INFO *info, ALL_XMULTI_REF_STATUS **p)
Read all XMR status info into a newly or re-allocated ALL_XMULTI_REF_STATUS.
Definition: deviohlp.c:1096
A structure used to specify a variable frequency.
Definition: gpsdefs.h:7750
uint32_t ass_if_index
Index of the associated interface link, see MBG_NET_INTF_LINK_SETTINGS::if_index. ...
Definition: gpsdefs.h:12276
#define MAX_PARM_PTP_UC_MASTER
The max number of PTP unicast masters supported by configuration programs.
Definition: cfg_hlp.h:149
#define MBG_ERR_INV_HANDLE
invalid file/device handle specified
Definition: mbgerror.h:339
Reference source configuration for a specific priority level.
Definition: gpsdefs.h:6749
A helper structure used with configuration of old DCF77 clocks.
Definition: deviohlp.h:63
char framing[4]
ASCIIZ framing string, e.g. "8N1" or "7E2", see MBG_FRAMING_STRS.
Definition: gpsdefs.h:3205
the number of defined sources, must not exceed MAX_N_MULTI_REF_TYPES
Definition: gpsdefs.h:6440
uint8_t str_type
index of the supported time string formats, see STR_TYPE_INFO_IDX
Definition: gpsdefs.h:3511
#define PCPS_FR_SHIFT
num of bits to shift left
Definition: pcpsdefs.h:1393
#define _get_gpio_type_name(_i)
Definition: cfg_hlp.h:886
_NO_MBG_API_ATTR int _MBG_API mbg_save_all_xmulti_ref_info(MBG_DEV_HANDLE dh, ALL_XMULTI_REF_INFO *p)
Set all extended multi ref settings to a device.
Definition: deviohlp.c:1052
ALL_PTP_UC_MASTER_INFO_IDX all_ptp_uc_master_info_idx
Definition: cfg_hlp.h:373
_MBG_API_ATTR int _MBG_API mbg_get_gps_port_parm(MBG_DEV_HANDLE dh, PORT_PARM *p)
Read a PORT_PARM structure with a device&#39;s serial port configuration.
Definition: mbgdevio.c:5644
uint8_t mode
XMR/holdover mode, see XMR_HOLDOVER_STATUS_MODES.
Definition: gpsdefs.h:7159
#define MBG_NET_INTF_LINK_STATE_MASK_LOWER_UP
see MBG_NET_INTF_LINK_STATE_BIT_LOWER_UP
Definition: gpsdefs.h:11628
#define PCPS_FR_BITS
field with in the cfg byte
Definition: pcpsdefs.h:1392
PTP_UC_MASTER_SETTINGS settings
specification for the unicast master with that index
Definition: gpsdefs.h:14332
#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10_T_FULL
see MBG_NET_INTF_LINK_SPEED_MODE_10_T_FULL
Definition: gpsdefs.h:11459
uint16_t n_supp_intf_route
max. number of supported interface routes, see MBG_NET_INTF_ROUTE_SETTINGS_IDX, MBG_NET_INTF_ROUTE_IN...
Definition: gpsdefs.h:11876
MBG_VLAN_CFG vlan_cfg
VLAN configuration.
Definition: gpsdefs.h:11246
Framed data stream output.
Definition: gpsdefs.h:7669
_MBG_API_ATTR int _MBG_API mbg_get_serial(MBG_DEV_HANDLE dh, PCPS_SERIAL *p)
Read the serial port configuration from an old type of device.
Definition: mbgdevio.c:4687
uint8_t num_intf_route
number of configured interface routes, see MBG_NET_INTF_ROUTE_INFO_IDX
Definition: gpsdefs.h:11852
MBG_NET_INTF_LINK_INFO_IDX * link_infos
Definition: cfg_hlp.h:239
_MBG_API_ATTR int _MBG_API mbg_get_gps_all_port_info(MBG_DEV_HANDLE dh, PORT_INFO_IDX pii[], const RECEIVER_INFO *p_ri)
Read a PORT_INFO_IDX array of supported serial port configurations.
Definition: mbgdevio.c:6185
int setup_gps_only_gnss_info_from_statinfo(ALL_GNSS_INFO *p_agi)
Setup GNSS info from stat_info so we can use the same printing routine.
Definition: cfg_hlp.c:482
uint16_t flags
see MBG_IP4_FLAG_MASKS
Definition: gpsdefs.h:11245
All network configuration parameters.
Definition: cfg_hlp.h:236
Reference source capabilities and current configuration.
Definition: gpsdefs.h:6800
MBG_CHK_SUPP_FNC mbg_chk_dev_has_lan_intf
Check if a device supports simple LAN interface API calls.
Definition: mbgdevio.c:1271
A GPIO port&#39;s current settings, plus port index.
Definition: gpsdefs.h:9184
uint32_t XMR_HOLDOVER_INTV
XMR holdover interval, or elapsed holdover time, in [s].
Definition: gpsdefs.h:7116
XMULTI_REF_INSTANCES instances
Definition: cfg_hlp.h:522
MBG_NET_GLB_CFG_INFO glb_cfg_info
Definition: cfg_hlp.h:238
void pcps_serial_from_port_info(PCPS_SERIAL *p, const PORT_INFO_IDX *p_pii)
Definition: deviohlp.c:1567
see MBG_NET_INTF_LINK_TYPE_VLAN
Definition: gpsdefs.h:11785
void pcps_unpack_serial(PCPS_SER_PACK *p)
Definition: deviohlp.c:1614
uint32_t flags
see MBG_NET_INTF_ADDR_MASKS
Definition: gpsdefs.h:12171
uint32_t PCI_ASIC_FEATURES
A data type to hold the PCI ASIC feature flags mask.
Definition: pci_asic.h:162
see MBG_NET_INTF_ADDR_BIT_DHCP4
Definition: gpsdefs.h:11814
_MBG_API_ATTR int _MBG_API mbg_get_gps_stat_info(MBG_DEV_HANDLE dh, STAT_INFO *p)
Read the extended GPS receiver status from a device.
Definition: mbgdevio.c:5846
int MBG_CHK_SUPP_FNC(MBG_DEV_HANDLE dh)
The type of functions to check if a feature is supported.
Definition: mbgdevio.h:845
const char * setup_asic_features(char *s, size_t max_len, MBG_DEV_HANDLE dh)
Definition: deviohlp.c:1711
_MBG_API_ATTR int _MBG_API mbg_get_ptp_uc_master_cfg_limits(MBG_DEV_HANDLE dh, PTP_UC_MASTER_CFG_LIMITS *p)
Read PTP/IEEE1588 unicast master configuration limits from a device.
Definition: mbgdevio.c:7494
#define MBG_ERR_UNSPEC
Unspecified error.
Definition: mbgerror.h:312
All PTP configuration parameters.
Definition: cfg_hlp.h:369
int get_ip4_net_mask_bits(const IP4_ADDR *p_mask)
Count the number of sequential bits in an IPv4 net mask.
Definition: lan_util.c:183
MBG_GPIO_STATUS_IDX ALL_GPIO_STATUS_IDX[10]
Status information on all GPIO ports.
Definition: cfg_hlp.h:507
#define MAX_UCAP_ENTRIES
Definition: cfg_hlp.h:599
const char * str_not_avail
XMULTI_REF_SETTINGS settings
the settings configured for this level
Definition: gpsdefs.h:6752
uint32_t flags
holdover status flags, see XMR_HOLDOVER_STATUS_FLAG_MASKS
Definition: gpsdefs.h:7166
uint32_t flags
see MBG_GPIO_CFG_LIMIT_FLAG_MASKS
Definition: gpsdefs.h:7612
_MBG_API_ATTR int _MBG_API mbg_get_gps_gnss_mode_info(MBG_DEV_HANDLE dh, MBG_GNSS_MODE_INFO *p_mi)
Read the current GNSS mode info including current settings.
Definition: mbgdevio.c:7956
static const int pcps_to_mbg_framing_tbl[N_PCPS_FR_DCF]
Definition: deviohlp.c:1521
Twisted Pair (TP) copper cable.
Definition: gpsdefs.h:11515
see XMR_HLDOVR_BIT_IN_HOLDOVER
Definition: gpsdefs.h:7238
uint16_t idx
the priority level index (highest == 0), 0..XMULTI_REF_INSTANCES::n_xmr_settings-1 ...
Definition: gpsdefs.h:6751
unsigned char uint8_t
Definition: words.h:210
STAT_INFO stat_info
Definition: cfg_hlp.h:449
MBG_GPIO_FREQ_OUT_SETTINGS freq_out
if MBG_GPIO_SETTINGS::type is MBG_GPIO_TYPE_FREQ_OUT
Definition: gpsdefs.h:9141
Configuration of a GPIO fixed frequency output.
Definition: gpsdefs.h:7959
XMULTI_REF_STATUS_IDX ALL_XMULTI_REF_STATUS_IDX[10]
Status of all XMR inputs.
Definition: cfg_hlp.h:513
General info on supported XMR sources and instances.
Definition: gpsdefs.h:7054
_MBG_API_ATTR int _MBG_API mbg_get_gps_all_gpio_status(MBG_DEV_HANDLE dh, MBG_GPIO_STATUS_IDX gsi[], const MBG_GPIO_CFG_LIMITS *p_gcl)
Read the status of all GPIO signal ports.
Definition: mbgdevio.c:8205
ALL_GNSS_SAT_INFO_IDX gnss_sat_info_idx
Definition: cfg_hlp.h:452
PORT_INFO port_info
Definition: gpsdefs.h:3680
#define BITMASK(b)
Definition: pcpsdefs.h:903
Current settings and general capabilities of a serial port.
Definition: gpsdefs.h:3618
#define PTP_CFG_MSK_SUPPORT_PTP_UNICAST
A bit mask of the unicast role bits within the flag bits.
Definition: gpsdefs.h:13554
const char * str_not_spc
MBG_NET_INTF_ADDR_INFO info
see MBG_NET_INTF_ADDR_INFO
Definition: gpsdefs.h:12247
#define MBG_ERR_NO_MEM
Failed to allocate memory.
Definition: mbgerror.h:282
PORT_PARM tmp_pp
used internally only, for compatibility
Definition: cfg_hlp.h:194
int32_t secs
[seconds], usually since 1970-01-01 00:00:00
Definition: words.h:582
int mbg_save_all_ptp_cfg_info(MBG_DEV_HANDLE dh, const ALL_PTP_CFG_INFO *p)
Write all PTP settings to a device.
Definition: deviohlp.c:925
TTM ttm
Definition: cfg_hlp.h:605
int32_t nano_secs
[nanoseconds]
Definition: words.h:581
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
Definition: mbgerror.h:259
#define mbg_klist_first_entry(ptr, type, member)
Definition: mbgklist.h:80
see XMR_HLDOVR_BIT_TRANSITION_ENBD
Definition: gpsdefs.h:7239
XMULTI_REF_INFO_IDX ALL_XMULTI_REF_INFO_IDX[10]
Configuration settings for all XMR inputs.
Definition: cfg_hlp.h:516
Reference source capabilities and current configuration for a specific priority level.
Definition: gpsdefs.h:6839
uint32_t shape
selected signal shape, see MBG_GPIO_SIGNAL_SHAPES
Definition: gpsdefs.h:7962
_MBG_API_ATTR int _MBG_API mbg_get_gpio_cfg_limits(MBG_DEV_HANDLE dh, MBG_GPIO_CFG_LIMITS *p)
Read common GPIO configuration limits.
Definition: mbgdevio.c:8082
#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_100_T_HALF
see MBG_NET_INTF_LINK_SPEED_MODE_100_T_HALF
Definition: gpsdefs.h:11460
NANO_TIME bias
time bias, e.g. path delay
Definition: gpsdefs.h:6724
MBG_CHK_SUPP_FNC mbg_chk_dev_has_xmr
Check if a device provides eXtended Multi Ref (XMR) inputs.
Definition: mbgdevio.c:825
uint32_t hz
integral number [Hz]
Definition: gpsdefs.h:7752
see XMR_HLDOVR_BIT_IN_TRANSITION
Definition: gpsdefs.h:7240
uint8_t type
Type of the route entry, see MBG_NET_INTF_ROUTE_TYPES.
Definition: gpsdefs.h:12266
MBG_NET_INTF_ROUTE_INFO info
see MBG_NET_INTF_ROUTE_INFO
Definition: gpsdefs.h:12347
_MBG_API_ATTR int _MBG_API mbg_set_ip4_settings(MBG_DEV_HANDLE dh, const IP4_SETTINGS *p)
Write LAN IPv4 settings to a device.
Definition: mbgdevio.c:7360
const char * mbg_framing_strs[N_MBG_FRAMINGS]
IP4_ADDR netmask
the network mask
Definition: gpsdefs.h:11242
uint32_t freq_idx
fixed frequency index, see MBG_GPIO_FIXED_FREQS
Definition: gpsdefs.h:7961
XMULTI_REF_ID id
reference time source identifier
Definition: gpsdefs.h:6722
see XMRIF_BIT_EXT_SRC_INFO_SUPP
Definition: gpsdefs.h:7107
uint8_t mode
string mode, see STR_MODES
Definition: gpsdefs.h:3510
#define MBG_NET_INTF_LINK_STATE_MASK_UP
Network interface link state masks.
Definition: gpsdefs.h:11626
PTP_CFG_SETTINGS settings
the current configuration
Definition: gpsdefs.h:13344
uint32_t supp_str_types
bit mask of string types supp. by this port, i.e. bit 0 set if str_type[0] is supp.
Definition: gpsdefs.h:3623
PCPS_SERIAL pack
This packed byte is read from or written to the board.
Definition: deviohlp.h:65
NANO_TIME precision
precision of the time source
Definition: gpsdefs.h:6725
union MBG_GPIO_SETTINGS::@4 u
settings depending on the GPIO type, see MBG_GPIO_TYPES
VLAN interface, assigned to physical interface.
Definition: gpsdefs.h:11769
#define MBG_INVALID_DEV_HANDLE
Definition: mbgdevio.h:358
uint32_t shape
selected signal shape, see MBG_GPIO_SIGNAL_SHAPES
Definition: gpsdefs.h:7840
MBG_GPIO_INFO_IDX ALL_GPIO_INFO_IDX[10]
Configuration settings for all GPIO ports.
Definition: cfg_hlp.h:504
int mbg_save_serial_settings(MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, RECEIVER_PORT_CFG *p_rpcfg, int port_num)
Write the configuration settings for a single serial port to a device.
Definition: deviohlp.c:353
MBG_NET_INTF_ROUTE_INFO_IDX * route_infos
Definition: cfg_hlp.h:243
MBG_CHK_SUPP_FNC mbg_chk_dev_has_asic_version
Check if a device supports the mbg_get_asic_version API call.
Definition: mbgdevio.c:764
Current settings and general capabilities of a specific serial port.
Definition: gpsdefs.h:3677
uint32_t PCI_ASIC_VERSION
A data type to hold the PCI ASIC version code.
Definition: pci_asic.h:151
uint32_t supp_framings
bit mask of framings supp. by this port, see MBG_FRAMING_MASKS
Definition: gpsdefs.h:3622
_MBG_API_ATTR int _MBG_API mbg_set_gps_port_parm(MBG_DEV_HANDLE dh, const PORT_PARM *p)
Write a PORT_PARM structure to configure the on-board serial ports.
Definition: mbgdevio.c:5676
void free_all_xmulti_ref_status(ALL_XMULTI_REF_STATUS *p)
Free an ALL_XMULTI_REF_STATUS structure.
Definition: cfg_hlp.c:1236
see MBG_GPIO_CFG_LIMIT_FLAG_BIT_STATUS_SUPP
Definition: gpsdefs.h:7648
int mbg_chk_get_all_gnss_info(MBG_DEV_HANDLE dh, ALL_GNSS_INFO *p_agi)
Read or setup all GNSS status information.
Definition: deviohlp.c:159
#define DEFAULT_FRAMINGS_DCF
Definition: deviohlp.c:74
ALL_PORT_INFO_IDX pii
all serial port configuration settings
Definition: cfg_hlp.h:192
#define PCPS_MOD_SHIFT
num of bits to shift left
Definition: pcpsdefs.h:1417
MBG_NET_GLB_CFG_SETTINGS glb_settings
Definition: gpsdefs.h:11871
int snprintf_safe(char *s, size_t max_len, const char *fmt,...)
A portable, safe implementation of snprintf()
Definition: str_util.c:156
#define _MBG_API
Definition: mbg_tgt.h:1020
int mbg_get_all_net_status_info(MBG_DEV_HANDLE dh, ALL_NET_STATUS_INFO **p)
Read current network status into an ALL_NET_STATUS_INFO structure.
Definition: deviohlp.c:676
#define _pcps_asic_version_minor(_v)
Extract the minor part of an ASIC version number.
Definition: pci_asic.h:346
Query MBG_NET_INTF_ADDR_INFO by its index.
Definition: gpsdefs.h:12244
XMULTI_REF_INFO info
ref source configuration and capabilities
Definition: gpsdefs.h:6842
#define MBG_ERR_NOT_SUPP_BY_DEV
Command or feature not supported by device.
Definition: mbgerror.h:286
IP4_ADDR gateway
the default gateway
Definition: gpsdefs.h:11244
int16_t handshake
handshake mode, yet only HS_NONE supported
Definition: gpsdefs.h:3206
int mbg_get_all_ptp_cfg_info(MBG_DEV_HANDLE dh, ALL_PTP_CFG_INFO *p)
Read all PTP settings and supported configuration parameters.
Definition: deviohlp.c:869
uint8_t port_state
see MBG_GPIO_PORT_STATES
Definition: gpsdefs.h:9294
int chk_feat_supp(MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, MBG_CHK_SUPP_FNC *chk_supp_fnc, MBG_ERR_MSG_FNC *err_msg_fnc, const char *not_supp_msg)
Definition: deviohlp.c:84
char model_name[(16+1)]
ASCIIZ, name of receiver model.
Definition: gpsdefs.h:877
void free_all_net_cfg_info(ALL_NET_CFG_INFO *p)
Free an ALL_NET_CFG_INFO structure.
Definition: cfg_hlp.c:1018
_MBG_API_ATTR int _MBG_API mbg_set_gps_gpio_settings_idx(MBG_DEV_HANDLE dh, const MBG_GPIO_SETTINGS_IDX *p)
Write the configuration for a single GPIO port to a device.
Definition: mbgdevio.c:8172
int mbg_get_all_net_cfg_info(MBG_DEV_HANDLE dh, ALL_NET_CFG_INFO **p)
Read all network configuration into an ALL_NET_CFG_INFO structure.
Definition: deviohlp.c:420
MBG_GPIO_FIXED_FREQ_OUT_SETTINGS ff_out
if MBG_GPIO_SETTINGS::type is MBG_GPIO_TYPE_FIXED_FREQ_OUT
Definition: gpsdefs.h:9142
BAUD_RATE mbg_baud_rates[N_MBG_BAUD_RATES]
void test_gpio(MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, int verbose)
_MBG_API_ATTR int _MBG_API mbg_get_asic_version(MBG_DEV_HANDLE dh, PCI_ASIC_VERSION *p)
Read the version code of the on-board PCI/PCIe interface ASIC.
Definition: mbgdevio.c:6385
#define mbg_rc_is_error(_rc)
Definition: mbgerror.h:617
PORT_SETTINGS port_settings
current configuration of the port
Definition: gpsdefs.h:3620
#define _convert_asic_version_number(_n)
Version number conversion macro.
Definition: pci_asic.h:329
int MBG_ERR_MSG_FNC(const PCPS_DEV *p_dev, const char *s)
Definition: deviohlp.h:75
MBG_GPIO_FREQ freq
frequency, see MBG_GPIO_FREQ_OUT_SUPP::freq_min and MBG_GPIO_FREQ_OUT_SUPP::freq_max ...
Definition: gpsdefs.h:7838
#define MAX_N_MULTI_REF_TYPES
Theoretical maximum number of multi ref input signal types.
Definition: gpsdefs.h:6449
uint8_t mode
The unpacked mode code, see PCPS_MOD_CODES.
Definition: deviohlp.h:69
_MBG_API_ATTR int _MBG_API mbg_get_xmr_instances(MBG_DEV_HANDLE dh, XMULTI_REF_INSTANCES *p)
Read XMULTI_REF_INSTANCES.
Definition: mbgdevio.c:8261
UCAP_ENTRY * calloc_ucap_entry(void)
Definition: cfg_hlp.c:1531
Configuration of a GPIO variable frequency output.
Definition: gpsdefs.h:7836
#define _pcps_has_serial_hs(_d)
Definition: pcpsdev.h:1167
_MBG_API_ATTR int _MBG_API mbg_get_ip4_state(MBG_DEV_HANDLE dh, IP4_SETTINGS *p)
Read LAN IPv4 state from a device.
Definition: mbgdevio.c:7301
#define PCPS_BD_BITS
field with in the cfg byte
Definition: pcpsdefs.h:1367
int setup_port_info_from_port_parm(PORT_INFO_IDX pii[], const PORT_PARM *p_pp, const RECEIVER_INFO *p_ri)
Setup an array of PORT_INFO_IDX structures from a PORT_PARM.
Definition: cfg_hlp.c:397
_MBG_API_ATTR int _MBG_API mbg_set_gps_port_settings(MBG_DEV_HANDLE dh, const PORT_SETTINGS *p, int idx)
Write the configuration for a single serial port to a device.
Definition: mbgdevio.c:6290
IP4_ADDR broad_addr
the broadcast address
Definition: gpsdefs.h:11243
static __mbg_inline void mbg_klist_delete_item(struct mbg_klist_head *item)
Definition: mbgklist.h:171
MBG_NET_INTF_ADDR_SETTINGS addr_settings
see MBG_NET_INTF_ADDR_SETTINGS
Definition: gpsdefs.h:12224
unsigned long ulong
Definition: words.h:292
uint8_t slot_id
ID of the slot in which this device is installed, 0 or up to 15, if multiple slots not supported...
Definition: gpsdefs.h:7058
IP4_ADDR ip4_addr
IPv4 address if MBG_IP_ADDR::type == MBG_IP_ADDR_TYPE_IP4.
Definition: gpsdefs.h:11914
uint32_t supp_baud_rates
bit mask of baud rates supp. by this port, see MBG_BAUD_RATE_MASKS
Definition: gpsdefs.h:3621
BAUD_RATE baud_rate
transmission speed, e.g. 19200L, see MBG_BAUD_RATES
Definition: gpsdefs.h:3204
A structure used to identify a device type and supported features.
Definition: gpsdefs.h:873
#define PCI_ASIC_HAS_MM_IO
Bit masks used with PCI_ASIC_FEATURES.
Definition: pci_asic.h:175
int mbg_get_all_xmulti_ref_info(MBG_DEV_HANDLE dh, ALL_XMULTI_REF_INFO **p)
Read all XMR info into a newly or re-allocated ALL_XMULTI_REF_INFO.
Definition: deviohlp.c:978
uint8_t num_intf_addr
number of configured interface addresses, see MBG_NET_INTF_ADDR_INFO_IDX
Definition: gpsdefs.h:11849
see MBG_NET_INTF_LINK_TYPE_PHYS
Definition: gpsdefs.h:11784
_MBG_API_ATTR int _MBG_API mbg_get_all_ptp_uc_master_info(MBG_DEV_HANDLE dh, PTP_UC_MASTER_INFO_IDX pii[], const PTP_UC_MASTER_CFG_LIMITS *p_umsl)
Read PTP Unicast master settings and configuration options.
Definition: mbgdevio.c:7527
Framed data stream input.
Definition: gpsdefs.h:7668
MBG_NET_INTF_ROUTE_SETTINGS route_settings
see MBG_NET_INTF_ROUTE_SETTINGS
Definition: gpsdefs.h:12323
#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_100_T_FULL
see MBG_NET_INTF_LINK_SPEED_MODE_100_T_FULL
Definition: gpsdefs.h:11461
Simple LAN interface information.
Definition: gpsdefs.h:11274
static __mbg_inline IP4_ADDR ip4_broad_addr_from_addr(const IP4_ADDR *p_addr, const IP4_ADDR *p_mask)
Determine the broadcast address for an IP4 address plus net mask.
Definition: lan_util.h:151
Device info structure.
Definition: pcpsdev.h:1043
int get_framing_idx(const char *framing)
Definition: cfg_hlp.c:145
int chk_set_n_gnss_supp(ALL_GNSS_INFO *p_agi)
Definition: cfg_hlp.c:440
ALL_STR_TYPE_INFO_IDX stii
all supported serial string types
Definition: cfg_hlp.h:193
XMULTI_REF_STATUS_IDX * status
Definition: cfg_hlp.h:530
All configuration parameters for all serial ports.
Definition: cfg_hlp.h:190
_MBG_API_ATTR int _MBG_API mbg_get_gps_all_xmr_info(MBG_DEV_HANDLE dh, XMULTI_REF_INFO_IDX xmrii[], const XMULTI_REF_INSTANCES *p_xmri)
Read all XMR settings and capabilities.
Definition: mbgdevio.c:8342