mbgtools-lx  4.2.8
mbgextio.c
Go to the documentation of this file.
1 
2 /**************************************************************************
3  *
4  * $Id: mbgextio.c 1.20.1.33.1.212 2018/06/07 14:16:55 philipp TRASH $
5  *
6  * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
7  *
8  * Description:
9  * Meinberg extended I/O functions for the binary data protocol
10  * via serial communication, network socket I/O, or direct USB I/O.
11  *
12  * These functions can *not* be used to access LANTIME NTP servers,
13  * or the modules assembled within a LANTIME since LANTIMEs are using
14  * this kind of communication only internally.
15  *
16  * Also, standalone USB devices are usually handled by the driver
17  * accessed in the same way as PCI cards, using the API functions
18  * provided by the mbgdevio library.
19  *
20  * These functions can be used, however, with standalone devices
21  * which are accessible either directly via a serial port, or via a
22  * special serial-to-LAN converter like the meinberg LAN_XPT module.
23  *
24  * -----------------------------------------------------------------------
25  * $Log: mbgextio.c $
26  * Revision 1.20.1.33.1.212 2018/06/07 14:16:55 philipp
27  * Added database command structure send function
28  * Revision 1.20.1.33.1.211 2018/06/05 14:09:14 martin
29  * Doxygen fixes.
30  * Revision 1.20.1.33.1.210 2018/06/05 11:27:55 thomas-b
31  * Added function to check for MBG_XFEATURE_GNSS_MODE
32  * Revision 1.20.1.33.1.209 2018/06/05 11:16:41 thomas-b
33  * *** empty log message ***
34  * Revision 1.20.1.33.1.208 2018/06/05 09:41:55 philipp
35  * Added XFeature database
36  * Revision 1.20.1.33.1.207 2018/06/01 12:27:23 martin
37  * Introduced an optional NACK handler callback function.
38  * Removed mbgextio_get_last_nack_err_code() which is
39  * now obsolete.
40  * Added and fixed some doxygen comments.
41  * Revision 1.20.1.33.1.206 2018/05/29 11:15:32 philipp
42  * Added UFU flash command
43  * Revision 1.20.1.33.1.205 2018/05/29 08:17:49 martin
44  * Unified reception of spurious async binary messages and data bytes.
45  * Use common function to handle NACK messages.
46  * Revision 1.20.1.33.1.204 2018/05/09 08:15:24 thomas-b
47  * Fixed error check in mbgextio_setup_xdevfeat
48  * Revision 1.20.1.33.1.203 2018/04/17 13:29:57 martin
49  * Fixed build without socket I/O.
50  * Revision 1.20.1.33.1.202 2018/04/03 05:49:54 thomas-b
51  * User authentication is only supported via encrypted SSH connection, yet
52  * Revision 1.20.1.33.1.201 2018/03/26 08:04:50 thomas-b
53  * Added fw mngmnt API functions
54  * Revision 1.20.1.33.1.200 2018/03/15 14:03:32 philipp
55  * Added syslog option to monitoring feature
56  * Revision 1.20.1.33.1.199 2018/03/15 11:12:05 martin
57  * New function mbgextio_dev_has_up_conv().
58  * Fixed compiler warning if building without SSH support.
59  * Revision 1.20.1.33.1.198 2018/03/13 07:16:38 thomas-b
60  * Use MBG_INVALID_SOCK_FD instead of INVALID_SOCKET
61  * Revision 1.20.1.33.1.197 2018/03/12 09:32:20 thomas-b
62  * Fixed INVALID_SOCKET check and getaddrinfo usage under Windows
63  * Revision 1.20.1.33.1.196 2018/03/08 13:34:33 philipp
64  * Added mutex to protect libssh's read/write functions
65  * Revision 1.20.1.33.1.195 2018/03/01 10:20:33 martin
66  * Fixed Windows build.
67  * Revision 1.20.1.33.1.194 2018/02/28 16:54:25Z martin
68  * Doxygen fixes.
69  * Revision 1.20.1.33.1.193 2018/02/27 06:53:55 gregoire.diehl
70  * Add mbgextio_dev_has_clk_res_info and mbgextio_get_clk_res_info calls
71  * Revision 1.20.1.33.1.192 2018/02/15 08:07:32Z thomas-b
72  * Exchanged gethostbyname call by getaddrinfo to make socket_init thread safe
73  * Revision 1.20.1.33.1.191 2018/02/14 09:11:44 thomas-b
74  * Use XBP_ADDR in mbgextio_xmt_secu_settings
75  * Revision 1.20.1.33.1.190 2018/02/07 10:56:42 thomas-b
76  * fixed deadlock, mutex is acquired in mbgextio_xmt_cmd_u32, already
77  * Revision 1.20.1.33.1.189 2018/02/06 12:39:09 philipp
78  * Added service feature and API
79  * Revision 1.20.1.33.1.188 2018/01/31 16:03:40 daniel
80  * Account for getting SMPTE TLV data from PTP slave module
81  * Revision 1.20.1.33.1.187 2018/01/30 06:38:35 thomas-b
82  * SSH timeout should be long instead of int
83  * Revision 1.20.1.33.1.186 2018/01/26 12:16:53 martin
84  * Moved mbgextio_setup_xdevfeat() out of a conditional code block.
85  * Revision 1.20.1.33.1.185 2018/01/26 09:49:19Z thomas-b
86  * Renamed setup_extended_device_info to mbgextio_setup_xdevfeat,
87  * added parameter XBP_ADDR and made it non-static.
88  * Revision 1.20.1.33.1.184 2018/01/15 12:47:16 thomas-b
89  * Added permission check to mbgextio_get_corr_info
90  * Revision 1.20.1.33.1.183 2018/01/11 08:16:38 thomas-b
91  * Added permission checks to most read/write functions
92  * Revision 1.20.1.33.1.182 2017/12/21 07:46:33 thomas-b
93  * Added function to check if TLV exec cmd is supported by a device
94  * Revision 1.20.1.33.1.181 2017/12/20 13:40:35 thomas-b
95  * Added function to check if TLV file request is supported by a device
96  * Revision 1.20.1.33.1.180 2017/12/14 14:11:11 martin
97  * Fixed _mbg_mutex_init() call.
98  * Revision 1.20.1.33.1.179 2017/11/23 10:33:00Z thomas-b
99  * Removed USB_LOCK feature and appropriate structs and functions
100  * Revision 1.20.1.33.1.178 2017/11/21 06:22:38 thomas-b
101  * Added function to check support of TLV rollback command
102  * Revision 1.20.1.33.1.177 2017/11/16 11:12:20 thomas-b
103  * Implemented SSH encryption and user authentication in binary protocol
104  * Added functions for user management
105  * Removed several checks for _PRELIMINARY_CODE, because appropriate code is productive, anyway
106  * Revision 1.20.1.33.1.176 2017/09/19 14:11:37 thomas-b
107  * Request ACK for unregister push command
108  * Revision 1.20.1.33.1.175 2017/09/19 12:47:12 thomas-b
109  * Request ACK for register push command
110  * Revision 1.20.1.33.1.174 2017/08/15 15:27:06 gregoire.diehl
111  * mbgextio_dev_supp_xhe moved to xtiopriv
112  * Revision 1.20.1.33.1.173 2017/08/15 13:45:10Z gregoire.diehl
113  * Added support for XHE structures
114  * Revision 1.20.1.33.1.172 2017/08/02 10:09:20Z philipp
115  * Added MBG_MSG_CTL server site related functionality
116  * Revision 1.20.1.33.1.171 2017/08/02 06:55:40 philipp
117  * Added new push messages xfeature
118  * Revision 1.20.1.33.1.170 2017/07/20 06:21:41 philipp
119  * Added tainted config swaP macro
120  * Revision 1.20.1.33.1.169 2017/07/20 06:17:18 philipp
121  * - Refactored monitoring events
122  * - Added xfeature tainted config
123  * - Removed obsolete code
124  * - Added mbglib xmt helper function
125  * Revision 1.20.1.33.1.168 2017/06/19 16:01:14 martin
126  * New functions mbg_chk_dev_is_irig_rx(), mbg_chk_dev_is_irig_rx(),
127  * and mbg_chk_dev_is_irig_rx().
128  * Revision 1.20.1.33.1.167 2017/06/07 12:54:16 thomas-b
129  * Added function to check TLV feature for UFU files
130  * Revision 1.20.1.33.1.166 2017/05/22 12:41:53 thomas-b
131  * Added function to read NTP_REFCLK_STATE_IDX from a device
132  * Revision 1.20.1.33.1.165 2017/05/18 09:29:50 martin
133  * Account for MBG_IO_PORT_SETTINGS::type renamed to port_type.
134  * Doxygen fixes.
135  * Revision 1.20.1.33.1.164 2017/05/17 15:41:06 martin
136  * Doxygen fixes.
137  * Revision 1.20.1.33.1.163 2017/04/25 16:05:34 martin
138  * Fixed build under FreeBSD.
139  * Fixed compiler warning from clang.
140  * Revision 1.20.1.33.1.162 2017/04/20 04:59:57 thomas-b
141  * Use correct swab macros in USB lock functions
142  * Revision 1.20.1.33.1.161 2017/04/20 04:57:27 thomas-b
143  * Added functions to get and set USB lock (LCES) and get USB lock status
144  * Revision 1.20.1.33.1.160 2017/04/12 08:34:53 martin
145  * *** empty log message ***
146  * Revision 1.20.1.33.1.159 2017/04/12 07:34:20 martin
147  * Fixed build with VC6.
148  * Revision 1.20.1.33.1.158 2017/04/11 14:28:26Z martin
149  * Revision 1.20.1.33.1.157 2017/04/11 14:12:49Z martin
150  * Fixed DOS build.
151  * Revision 1.20.1.33.1.156 2017/04/11 13:19:41Z martin
152  * Made mbgextio_setup_receiver_info() more fault tolerant.
153  * Use function call to retrieve RECEIVER_INFO address
154  * from message control block.
155  * Revision 1.20.1.33.1.155 2017/04/10 13:41:55Z martin
156  * Fixed some compiler warnings.
157  * Revision 1.20.1.33.1.154 2017/04/10 07:49:07Z martin
158  * Fixed a compiler warning.
159  * Revision 1.20.1.33.1.153 2017/04/05 16:06:38 martin
160  * Added mbgextio_dev_has_bvar_stat().
161  * Revision 1.20.1.33.1.152 2017/03/27 10:38:40 thomas-b
162  * Added functions to read and write PTPv1 common datasets
163  * Revision 1.20.1.33.1.151 2017/03/20 17:11:07 martin
164  * Replaced dummy swab...() macro calls by real macros.
165  * Revision 1.20.1.33.1.150 2017/03/20 10:10:03 martin
166  * Fixed build without _PRELIMINARY_CODE.
167  * Revision 1.20.1.33.1.149 2017/03/07 13:45:55 thomas-b
168  * Added functions to get and set ignore lock
169  * Revision 1.20.1.33.1.148 2017/03/03 06:46:04 thomas-b
170  * Added functions to read/write NTP key, server, refclock and orphan mode settings
171  * Revision 1.20.1.33.1.147 2017/02/23 14:32:08 thomas-b
172  * *** empty log message ***
173  * Revision 1.20.1.33.1.146 2017/02/22 08:31:13 thomas-b
174  * Added functions to read/write event info and read monitoring status and event status
175  * Revision 1.20.1.33.1.145 2017/02/16 13:01:52 thomas-b
176  * Changed get and set functions for PTPv2 port dataset to use idx structure
177  * Revision 1.20.1.33.1.144 2017/02/16 09:27:59 thomas-b
178  * Fixed doxygen docu
179  * Revision 1.20.1.33.1.143 2017/02/16 09:24:32 thomas-b
180  * Added functions to get and set PTPv2 common datasets
181  * Revision 1.20.1.33.1.142 2017/02/15 16:17:37 martin
182  * *** empty log message ***
183  * Revision 1.20.1.33.1.141 2017/02/08 13:12:36 thomas-b
184  * Added functions to get and set SNMP configuration
185  * Revision 1.20.1.33.1.140 2017/02/07 14:24:52 thomas-b
186  * Added function mbgextio_dev_has_monitoring, which checks if the extended feature MBG_XFEATURE_MONITORING is set
187  * Revision 1.20.1.33.1.139 2017/02/07 14:10:19 daniel
188  * Added calls to check for new License TLV feature types
189  * Revision 1.20.1.33.1.138 2016/12/07 09:33:58 martin
190  * Renamed mbgextio_get_utc_param() to mbgextio_get_utc_parm()
191  * and mbgextio_set_utc_param() to mbgextio_set_utc_parm()
192  * for consisten naming with related functions.
193  * Check if index of received data set matches requested index, and
194  * keep receiving if not. Only in mbgextio_get_xmr_status_idx() for now.
195  * Revision 1.20.1.33.1.137 2016/12/01 10:17:27 thomas-b
196  * Temporarily removed ACK request from GPS_SCU_STAT set command
197  * Revision 1.20.1.33.1.136 2016/11/30 16:12:54 thomas-b
198  * Added functions to get/set SCU_STAT_INFO/SCU_STAT_SETTINGS
199  * Revision 1.20.1.33.1.135 2016/11/24 07:06:34 philipp
200  * Honour big endian system when swapping bytes
201  * Revision 1.20.1.33.1.134 2016/11/22 10:33:15 philipp
202  * Implemented I/O ports
203  * Revision 1.20.1.33.1.133 2016/11/22 10:28:04 gregoire.diehl
204  * chk index added in mbgextio_get_xmr_status_idx
205  * Revision 1.20.1.33.1.132 2016/11/15 15:44:12Z martin
206  * Account for modified mbgserio functions.
207  * Revision 1.20.1.33.1.131 2016/11/02 12:15:17 thomas-b
208  * Added function to check if a device has MBG_XFEATURE_REQ_TTM and adapted the documentation for mbgextio_get_time
209  * Revision 1.20.1.33.1.130 2016/11/01 07:39:02 thomas-b
210  * Fixed reception of XBP packets, copy std_msg_data from xbp_msg_data
211  * Revision 1.20.1.33.1.129 2016/10/31 09:28:06 martin
212  * Doxygen fixes.
213  * Revision 1.20.1.33.1.128 2016/10/25 09:11:17 thomas-b
214  * Added functions to get CFGH, ALM and IONO structures from a device
215  * Revision 1.20.1.33.1.127 2016/10/24 13:59:42 thomas-b
216  * Removed needless space from comment
217  * Fixed mbgextio_rcv_msg_unlocked for reception of XBP packets
218  * Revision 1.20.1.33.1.126 2016/10/20 14:46:03 thomas-b
219  * Added function to check if XBP is supported
220  * Revision 1.20.1.33.1.125 2016/10/20 11:29:10 martin
221  * Added missing const qualifier in mbgextio_get_utc_param().
222  * Revision 1.20.1.33.1.124 2016/10/20 10:43:34 thomas-b
223  * Added function to check if a device is a bus level device
224  * Revision 1.20.1.33.1.123 2016/10/19 14:33:43 thomas-b
225  * Added functions to read and write ucap via network configuration
226  * Revision 1.20.1.33.1.122 2016/10/14 11:09:40 thomas-b
227  * Added function to check MBG_XFEATURE_UCAP_NET
228  * Revision 1.20.1.33.1.121 2016/10/14 08:18:54 thomas-b
229  * Decreased poll timeout
230  * Revision 1.20.1.33.1.120 2016/10/12 08:13:27 thomas-b
231  * Fixed check_init_winsock to return MBG_SUCCESS if WSAStartup returns 0
232  * Revision 1.20.1.33.1.119 2016/09/30 05:36:53 thomas-b
233  * Increased serial poll timeout
234  * Revision 1.20.1.33.1.118 2016/09/29 14:35:12 thomas-b
235  * Moved new get and set functions for NET_CFG_API stage 2 to mbgextio
236  * Revision 1.20.1.33.1.117 2016/09/29 12:19:57 thomas-b
237  * Added function to check transactions feature
238  * Revision 1.20.1.33.1.116 2016/09/20 14:18:27 martin
239  * Fixed a compiler warning.
240  * Revision 1.20.1.33.1.115 2016/09/20 13:52:38 martin
241  * Moved GPS_REQACK preprocessor handling to the header file.
242  * Revision 1.20.1.33.1.114 2016/09/16 08:00:20 thomas-b
243  * Always try to use high speed baud in mbgextio_open_serial_force_default
244  * Revision 1.20.1.33.1.113 2016/09/15 10:15:12 philipp
245  * Fixed compiler warning (uninitialized variable may be used)
246  * Revision 1.20.1.33.1.112 2016/09/12 15:26:24 martin
247  * Conditionally try to retrieve serial number from very old devices.
248  * Revision 1.20.1.33.1.111 2016/09/12 13:42:35Z martin
249  * *** empty log message ***
250  * Revision 1.20.1.33.1.110 2016/08/23 15:56:59 martin
251  * Set up default receiver info for very old devices
252  * which don't provide it.
253  * Revision 1.20.1.33.1.109 2016/08/23 11:02:59Z martin
254  * *** empty log message ***
255  * Revision 1.20.1.33.1.108 2016/08/23 09:25:17 martin
256  * *** empty log message ***
257  * Revision 1.20.1.33.1.107 2016/08/23 08:33:25 udo
258  * renamed some Time Mon functions
259  * Revision 1.20.1.33.1.106 2016/08/22 14:14:47 gregoire.diehl
260  * new call: mbgextio_get_corr_info
261  * Revision 1.20.1.33.1.105 2016/08/15 09:36:23Z udo
262  * added mbgextio_time_mon_get_target_ext_data_set_idx()
263  * Revision 1.20.1.33.1.104 2016/08/11 10:25:53 martin
264  * Started to support time_mon.
265  * Revision 1.20.1.33.1.103 2016/08/09 16:00:36 martin
266  * Removed obsolete string variable.
267  * Revision 1.20.1.33.1.102 2016/08/09 07:12:26 martin
268  * *** empty log message ***
269  * Revision 1.20.1.33.1.101 2016/08/01 10:32:53 daniel
270  * Add functions to get ptp statistics
271  * Revision 1.20.1.33.1.100 2016/07/07 15:04:11 martin
272  * Renamed functions due to renamed library symbols.
273  * Revision 1.20.1.33.1.99 2016/06/29 11:59:11 philipp
274  * Extended socket API by TCP client
275  * Revision 1.20.1.33.1.98 2016/06/15 10:15:49 thomas-b
276  * Added functions which check if the user capture feature is supported by a device
277  * Revision 1.20.1.33.1.97 2016/06/14 10:33:21 thomas-b
278  * Added functions which check if the event log feature is supported by a device
279  * Revision 1.20.1.33.1.96 2016/06/08 09:55:12 thomas-b
280  * Added function mbgextio_open_serial_force_default
281  * Revision 1.20.1.33.1.95 2016/06/07 14:50:33 udo
282  * Reset Meinberg USB device in case if the open_usb function return MBG_ERR_BUSY
283  * Revision 1.20.1.33.1.94 2016/06/07 07:43:06 philipp
284  * New function to check for Irig Rx feature
285  * Revision 1.20.1.33.1.93 2016/06/03 11:15:49 thomas-b
286  * Fixed Windows compatibility issues in get_sock_error and mbgextio_find_lan_devices
287  * Revision 1.20.1.33.1.92 2016/06/02 10:15:38 philipp
288  * Renaming all MBG_EXT_REV_INFO related stuff to MBG_EXT_SYS_INFO.
289  * Revision 1.20.1.33.1.91 2016/05/30 08:10:44 thomas-b
290  * Added functions to check several builtin features
291  * Revision 1.20.1.33.1.90 2016/05/27 05:18:17 philipp
292  * New functions mbgextio_get_xmr_ext_source_stats_idx and mbgextio_get_xmr_ext_source_metrics_idx
293  * Revision 1.20.1.33.1.89 2016/05/25 09:22:58 philipp
294  * New function mbgextio_get_xmr_ext_source_stats_idx
295  * Revision 1.20.1.33.1.88 2016/05/20 13:37:53 philipp
296  * New function mbgextio_set_gpio_settings_idx
297  * Revision 1.20.1.33.1.87 2016/05/20 09:41:33 thomas-b
298  * Removed functions which check for a specific IMS card
299  * Revision 1.20.1.33.1.86 2016/05/20 08:51:19 thomas-b
300  * Added functions mbgextio_dev_has_time_scale and mbgextio_dev_has_tzcode
301  * Revision 1.20.1.33.1.85 2016/05/20 07:51:32 thomas-b
302  * Added function mbgextio_dev_has_tzdl
303  * Revision 1.20.1.33.1.84 2016/05/20 06:42:06 thomas-b
304  * Added function mbgextio_dev_has_enable_flags
305  * Revision 1.20.1.33.1.83 2016/05/18 13:15:40 philipp
306  * Fixed wrong GPS command in mbgextio_cmd_save_cfg
307  * Revision 1.20.1.33.1.82 2016/05/17 13:29:35 philipp
308  * New function to check whether device is LNO
309  * Revision 1.20.1.33.1.81 2016/05/17 06:33:07 philipp
310  * New function to check whether a device has serial outputs
311  * Revision 1.20.1.33.1.80 2016/05/12 10:41:35 philipp
312  * New functions to check bpe card and IRIG Tx feature
313  * Revision 1.20.1.33.1.79 2016/05/10 06:15:26 philipp
314  * New function to check whether a device has programmable pulses
315  * Revision 1.20.1.33.1.78 2016/05/04 13:04:55 thomas-b
316  * Fixed double mutex acquisition in dns set functions (NULL pointer)
317  * Revision 1.20.1.33.1.77 2016/04/26 06:55:45 thomas-b
318  * Added functions to check if NET_CFG and LAN_IP4 APIs are supported
319  * Revision 1.20.1.33.1.76 2016/04/25 14:47:13 martin
320  * *** empty log message ***
321  * Revision 1.20.1.33.1.75 2016/04/22 10:53:58 philipp
322  * New function to check whether device is LIU
323  * Revision 1.20.1.33.1.74 2016/04/20 13:20:25 thomas-b
324  * Added function to check if a device supports NTP
325  * Revision 1.20.1.33.1.73 2016/04/20 09:26:11 philipp
326  * Moved all HPS-PTP related structures to gpspriv.h and removed related extended feature bit from gpsdefs.h.
327  * Also removed functions from mbgextio and xdevfeat since HPS-PTP handling needs a redesign concerning structures.
328  * Thus, handle everything explicitly for now!
329  * -> Redesing this A.S.A.P.!!!
330  * Revision 1.20.1.33.1.72 2016/04/15 08:17:25 philipp
331  * New feature MBG_XFEATURE_EXT_PTP
332  * Revision 1.20.1.33.1.71 2016/04/13 07:01:20 philipp
333  * New function to check whether device is HPS
334  * Revision 1.20.1.33.1.70 2016/04/12 13:27:40 philipp
335  * Several new functions to check for device models and device features
336  * Revision 1.20.1.33.1.69 2016/04/11 13:56:47 thomas-b
337  * Added function mbgextio_dev_has_xmulti_ref
338  * Revision 1.20.1.33.1.68 2016/04/07 14:08:33 philipp
339  * Added function mbgextio_get_ext_rev_info
340  * Revision 1.20.1.33.1.67 2016/04/07 12:45:43 martin
341  * New function mbgextio_dev_has_ext_rev_info().
342  * Revision 1.20.1.33.1.66 2016/03/24 14:08:50 martin
343  * *** empty log message ***
344  * Revision 1.20.1.33.1.65 2016/03/23 13:49:44 thomas-b
345  * Added case for overflow error after check_transfer
346  * Revision 1.20.1.33.1.64 2016/03/23 10:12:52 martin
347  * *** empty log message ***
348  * Revision 1.20.1.33.1.63 2016/03/23 09:48:51 thomas-b
349  * Stop mbgextio_rcv_msg_unlocked after poll_timeout expires
350  * Several changes in mbgextio_find_lan_devices
351  * Revision 1.20.1.33.1.62 2016/03/22 14:52:37 thomas-b
352  * Shutdown socket before close in mbgextio_find_lan_devices
353  * Revision 1.20.1.33.1.61 2016/03/22 14:24:26 thomas-b
354  * Several fixes in mbgextio_find_lan_devices
355  * Revision 1.20.1.33.1.60 2016/03/22 12:53:30 thomas-b
356  * Added functions to find and free Meinberg LAN devices
357  * Revision 1.20.1.33.1.59 2016/03/22 08:39:42 thomas-b
358  * Removed debug output
359  * Revision 1.20.1.33.1.58 2016/03/22 08:16:16 martin
360  * *** empty log message ***
361  * Revision 1.20.1.33.1.57 2016/03/21 13:27:33 martin
362  * *** empty log message ***
363  * Revision 1.20.1.33.1.56 2016/03/18 11:21:55 martin
364  * *** empty log message ***
365  * Revision 1.20.1.33.1.55 2016/03/18 10:48:32 martin
366  * *** empty log message ***
367  * Revision 1.20.1.33.1.54 2016/03/17 11:33:10 philipp
368  * Added XMR functions
369  * Revision 1.20.1.33.1.53 2016/03/16 15:08:50 martin
370  * Moved some low level functions to new module xtiocomm.c.
371  * Revision 1.20.1.33.1.52 2016/03/14 11:53:15 martin
372  * Moved some low level feature check functions to new
373  * module xdevfeat.c, and use those functions.
374  * Removed function mbgextio_get_xfeature_buffer().
375  * Revision 1.20.1.33.1.51 2016/03/11 11:48:18 thomas-b
376  * Check MBG_SUCCESS with macro mbg_rc_is_success
377  * Revision 1.20.1.33.1.50 2016/03/11 10:29:03 thomas-b
378  * Decreased default serial message timeout
379  * Read more than one byte in each call to serial read
380  * Increase timeout if header has been completely received
381  * Revision 1.20.1.33.1.49 2016/03/11 08:20:13 marvin
382  * Added function to save PTP unicast master settings.
383  * Revision 1.20.1.33.1.48 2016/03/02 16:31:40Z marvin
384  * Do not close socket if opened successfully.
385  * Revision 1.20.1.33.1.47 2016/02/25 12:02:54Z udo
386  * used mbgextio_req_data_idx instead of mbgextio_req_data for TIME_MON_TARGET_STATUS_IDX
387  * Revision 1.20.1.33.1.46 2016/02/17 15:03:16 udo
388  * used MBG_TIME_MON_TARGET_STATUS_IDX
389  * Revision 1.20.1.33.1.45 2016/02/15 08:28:29 gregoire
390  * typo fixed
391  * Revision 1.20.1.33.1.44 2016/02/15 08:23:51Z gregoire
392  * mbgextio_get_xfeature_buffer_addr added
393  * Revision 1.20.1.33.1.43 2016/02/11 10:18:47Z thomas-b
394  * Added function mbgextio_set_fdm_tdev
395  * Revision 1.20.1.33.1.42 2016/02/03 09:16:48 martin
396  * *** empty log message ***
397  * Revision 1.20.1.33.1.41 2016/02/02 15:58:42 martin
398  * Added mbgextio_get_raw_irig_data().
399  * Revision 1.20.1.33.1.40 2016/01/19 14:13:53 udo
400  * improve time monitor functions
401  * Revision 1.20.1.33.1.39 2016/01/18 08:53:34 udo
402  * added support for PTP Time Monitoring on TSU/HPS100
403  * Revision 1.20.1.33.1.38 2016/01/04 15:55:07 martin
404  * New function mbgextio_open_usb_ldev which takes a libusb_device as parameter.
405  * Revision 1.20.1.33.1.37 2015/12/10 16:30:16 martin
406  * *** empty log message ***
407  * Revision 1.20.1.33.1.36 2015/12/10 11:55:14 martin
408  * *** empty log message ***
409  * Revision 1.20.1.33.1.35 2015/12/10 11:10:39 martin
410  * Don't try to read RECEIVER_INFO etc. from legacy USB devices.
411  * Revision 1.20.1.33.1.34 2015/12/09 17:35:01 martin
412  * *** empty log message ***
413  * Revision 1.20.1.33.1.33 2015/12/09 10:45:34 martin
414  * Revision 1.20.1.33.1.32 2015/12/09 10:21:22Z martin
415  * *** empty log message ***
416  * Revision 1.20.1.33.1.31 2015/12/07 16:34:54 martin
417  * *** empty log message ***
418  * Revision 1.20.1.33.1.30 2015/12/03 16:00:20 martin
419  * Also mbgextio_xmt_cmd() and mbgextio_xmt_cmd() now wait for ACK or NACK
420  * if the transmitted command code has been or'ed with GPS_REQACK.
421  * Doxygen stuff.
422  * Revision 1.20.1.33.1.29 2015/12/01 11:54:49 martin
423  * *** empty log message ***
424  * Revision 1.20.1.33.1.28 2015/12/01 11:36:01 martin
425  * *** empty log message ***
426  * Revision 1.20.1.33.1.27 2015/11/30 17:00:49 martin
427  * *** empty log message ***
428  * Revision 1.20.1.33.1.26 2015/11/30 08:16:14 philipp
429  * Added (wrapper) functions to test for TLV features
430  * Revision 1.20.1.33.1.25 2015/11/26 16:19:26 martin
431  * Reworked check feature API causing some other API calls to be
432  * simplified/changed since receiver info is now stored inside
433  * the message control block.
434  * Revision 1.20.1.33.1.24 2015/11/26 09:57:10 martin
435  * *** empty log message ***
436  * Revision 1.20.1.33.1.23 2015/11/23 12:55:25 philipp
437  * Removed TLV functions
438  * Revision 1.20.1.33.1.21 2015/11/20 10:47:12 daniel
439  * Removed debug messages
440  * Revision 1.20.1.33.1.20 2015/11/20 08:14:36 philipp
441  * Added id member to struct MBG_TLV_ANNOUNCE
442  * Revision 1.20.1.33.1.19 2015/11/20 07:31:19 philipp
443  * Added _mbg_swab_tlv macro in function mbgextio_send_tlv_chunk
444  * Revision 1.20.1.33.1.18 2015/11/20 07:27:37 philipp
445  * Adjusted functions and prototypes to match new TLV structures from gpsdefs.h
446  * Revision 1.20.1.33.1.17 2015/11/19 16:31:14 daniel
447  * Added debug messages
448  * Revision 1.20.1.33.1.16 2015/11/19 13:15:39 philipp
449  * Added TLV functionality
450  * Revision 1.20.1.33.1.15 2015/11/02 10:12:27 martin
451  * *** empty log message ***
452  * Revision 1.20.1.33.1.14 2015/10/19 16:42:20 martin
453  * *** empty log message ***
454  * Revision 1.20.1.33.1.13 2015/10/19 09:35:10 martin
455  * *** empty log message ***
456  * Revision 1.20.1.33.1.12 2015/10/19 09:16:44 martin
457  * Fixed some spelling.
458  * Revision 1.20.1.33.1.11 2015/10/15 14:00:57 martin
459  * Doxygen comments.
460  * Revision 1.20.1.33.1.10 2015/10/09 11:09:16 martin
461  * *** empty log message ***
462  * Revision 1.20.1.33.1.9 2015/10/06 14:19:06 martin
463  * *** empty log message ***
464  * Revision 1.20.1.33.1.8 2015/10/02 08:57:44 thomas-b
465  * Added several functions to retrieve and set parameter structures of the new FDM API
466  * Revision 1.20.1.33.1.7 2015/10/02 08:18:52 martin
467  * *** empty log message ***
468  * Revision 1.20.1.33.1.6 2015/10/01 09:15:56 philipp
469  * _USE_USB_DIRECT_IO: Return MBG_ERR_TIMEOUT and MBG_ERR_DISCONN if poll times out or holds POLLHUP event after reading data returns
470  * Revision 1.20.1.33.1.5 2015/09/15 13:25:55 martin
471  * *** empty log message ***
472  * Revision 1.20.1.33.1.4 2015/09/14 07:23:32 martin
473  * *** empty log message ***
474  * Revision 1.20.1.33.1.3 2015/09/11 12:06:16 martin
475  * *** empty log message ***
476  * Revision 1.20.1.33.1.2 2015/09/10 14:45:16 martin
477  * Unified timeout handling.
478  * If a NACK is received then accept and return an optional
479  * error code which may have been appended by the device.
480  * Revision 1.20.1.33.1.1 2015/09/09 16:00:08 martin
481  * Debug timing.
482  * Revision 1.20.1.33 2015/09/09 15:26:13 martin
483  * Revision 1.20.1.32 2015/09/09 08:41:01 martin
484  * Revision 1.20.1.31 2015/09/09 08:26:27 martin
485  * Revision 1.20.1.30 2015/09/09 06:57:51 daniel
486  * Revision 1.20.1.29 2015/09/08 15:25:48 martin
487  * Copy received data to destination buffer before
488  * device mutex is release.
489  * Revision 1.20.1.28 2015/09/08 14:22:32 martin
490  * Added some some missing mutex code.
491  * Use new inline functions mbg_rc_is_error() and mbg_rc_is_success().
492  * Revision 1.20.1.27 2015/09/08 12:15:02 martin
493  * Changed xmt_mutex to dev_mutex.
494  * Revision 1.20.1.26 2015/09/08 08:38:22 daniel
495  * Use mutex in mbgextio_req_data()
496  * Revision 1.20.1.25 2015/09/04 09:20:17 daniel
497  * Added fuctions to exchange refclock state and tsu version with TSU
498  * Revision 1.20.1.24 2015/09/02 16:42:20 martin
499  * Preliminary code which is only included if a preprocessor symbol
500  * _PRELIMINARY_CODE is defined in the project Makefile.
501  * Revision 1.20.1.23 2015/08/27 16:21:30 martin
502  * Revision 1.20.1.22 2015/08/25 15:33:56 martin
503  * Use safe string copy function from str_util.c.
504  * Revision 1.20.1.21 2015/08/20 14:50:05 martin
505  * Revision 1.20.1.20 2015/08/12 15:53:57 martin
506  * Revision 1.20.1.19 2015/07/22 16:02:07 martin
507  * Started to support variable USB endpoint numbers.
508  * Revision 1.20.1.18 2015/07/14 15:08:43 martin
509  * Unified parameter naming and updated doxygen comments.
510  * Revision 1.20.1.17 2015/07/14 14:05:55 martin
511  * Support XBP addressing.
512  * Added functions to read/send UTC parameters.
513  * Support for USB_DIRECT_IO
514  * Fixed dealloc_msg_ctl() where not all memory was freed.
515  * Reworked mbgextio_force_conn_serial_ftdi().
516  * Revision 1.20.1.16 2014/10/30 16:03:05 martin
517  * Doxygen fixes.
518  * Revision 1.20.1.15 2014/10/30 14:45:55 martin
519  * Generally return Meinberg error codes only.
520  * Do not use GPS_REQACK for secu_settings.
521  * Added FTDI support functions.
522  * Reworked "force connection" functions, also supporting high speed now.
523  * Updated libusb support.
524  * Many new API functions.
525  * Revision 1.20.1.14 2013/11/28 15:51:45Z marvin
526  * Added mbgextio_get_ntp_peer_state_idx.
527  * Revision 1.20.1.13 2013/11/26 16:06:43Z marvin
528  * Added mbgextio_get_ntp_sys_state.
529  * Revision 1.20.1.12 2013/11/21 07:46:44Z marvin
530  * Added mbgextio_xmt_secu_settings.
531  * Cleanup for socket port.
532  * Revision 1.20.1.11 2013/11/15 12:17:30Z marvin
533  * Added error return for TGT_LINUX if socket_opt_error detected.
534  * Revision 1.20.1.10 2013/11/15 11:49:12Z marvin
535  * Fixed: return 0 if non_blocking_socket is OK.
536  * check if received GPS_NACK for encryption mode (socket connection).
537  * Revision 1.20.1.9 2013/11/13 16:30:10Z martin
538  * Revision 1.20.1.8 2013/11/13 16:13:26 martin
539  * Revision 1.20.1.7 2013/11/13 16:05:52 marvin
540  * Revision 1.20.1.6 2013/11/13 15:14:17Z martin
541  * Cleaned up socket connection code.
542  * Revision 1.20.1.5 2013/11/12 12:12:02 marvin
543  * Changed calls for NTP info and settings.
544  * Revision 1.20.1.4 2013/11/11 11:30:27Z marvin
545  * Changed socket connection.
546  * Revision 1.20.1.3 2013/11/05 15:53:11Z marvin
547  * Changed connecting via socket.
548  * Revision 1.20.1.2 2013/10/14 08:54:19Z marvin
549  * Added mbgextio_set_ntp_clnt_mode_cfg.
550  * Revision 1.20.1.1 2013/09/25 11:09:53Z marvin
551  * Added NTP support and new support for PTP.
552  * Revision 1.20 2013/09/10 08:56:35Z marvin
553  * Changed Doxygen comments.
554  * Revision 1.19 2013/09/05 15:10:39Z marvin
555  * Added support for LAN interface setup
556  * Added support for PTP state
557  * Added support for XMR.
558  * Revision 1.18 2013/09/02 15:16:48Z marvin
559  * Added support for XMR (get multi ref info, set multi ref settings)
560  * Revision 1.17 2013/08/28 11:01:41Z marvin
561  * Added read and set tr_distance and gnss_mode.
562  * Revision 1.16.1.1 2013/06/05 09:17:54Z marvin
563  * Changed close_connection for socket.
564  * Revision 1.16 2013/04/11 14:18:33Z Gregoire
565  * new calls for sending havequick rx and tx settings to clock
566  * Revision 1.15 2013/02/14 14:42:13Z martin
567  * Fixed syntax err due to unintentionally pasted word.
568  * Revision 1.14 2013/02/06 15:43:54 martin
569  * Updated doxygen comments.
570  * Revision 1.13 2013/02/01 15:58:43 martin
571  * In mbgextio_force_connection() for Windows wait until all chars
572  * must have been sent since flushing output buffer doesn't work reliably.
573  * Added a number of new functions.
574  * Added doxygen comments.
575  * Revision 1.12 2012/10/30 16:17:30 martin
576  * Started to migrate to opaque stuctures.
577  * Conditionally let xmt routines request for ACK packet,
578  * though this is by default disabled.
579  * Support receiving NACK status.
580  * Support big endian target platforms.
581  * Merged and adapted Daniel's USB support functions.
582  * Support event log entries.
583  * Syntax workaround which is required until this module becomes a DLL.
584  * Added some new functions.
585  * Updated doxygen comments.
586  * Huge cleanup.
587  * Revision 1.11 2011/04/15 13:17:14 martin
588  * Use common mutex support macros from mbgmutex.h.
589  * Revision 1.10 2011/04/08 11:28:24 martin
590  * Modified mbgextio_get_ucap() to account for different device behaviour.
591  * Added missing braces.
592  * Revision 1.9 2009/10/02 14:19:05 martin
593  * Added a bunch of missing functions.
594  * Revision 1.8 2009/10/01 11:10:51 martin
595  * Added functions to set/retrieve char and msg rcv timeout.
596  * Revision 1.7 2009/09/01 10:44:58 martin
597  * Cleanup for CVI.
598  * Use new portable timeout functions from mbg_tmo.h.
599  * Timeouts are now specified in milliseconds.
600  * Distinguish between character timeout and message timeout.
601  * Only fetch one character at a time to prevent received characters
602  * from being discarded after the end of one message.
603  * Revision 1.6 2009/03/10 17:02:08Z martin
604  * Added support for configurable time scales.
605  * Added mbgextio_get_time() call.
606  * Fixed some compiler warnings.
607  * Revision 1.5 2008/09/04 14:35:50Z martin
608  * Fixed opening COM port under CVI.
609  * Moved generic serial I/O stuff to mbgserio.c and mbgserio.h.
610  * Restart reception if received msg does not match expected cmd code.
611  * Fixed timeout value for Windows.
612  * New symbol _MBGEXTIO_DIRECT_RC controls whether the return code of the
613  * mbgextio_set_...() functions is evaluated or returned as-is.
614  * New functions mbgextio_set_time(), mbgextio_set_tzdl().
615  * Added mbgextio_get_ucap(). This may not work with older firmware,
616  * see the comments in mbgextio_get_ucap().
617  * Conditionally support checking of time strings.
618  * Revision 1.4 2007/02/27 10:35:19Z martin
619  * Added mutex for transmit buffer to make transmission thread-safe.
620  * Fixed timeout handling for serial reception.
621  * Renamed mbgextio_get_data() to mbgextio_rcv_msg().
622  * Added some new functions.
623  * Temp. changes for parameter setting functions.
624  * Added comments on POSIX flags used when opening serial port.
625  * Revision 1.3 2006/12/21 10:56:17 martin
626  * Added function mbgextio_set_port_parm.
627  * Revision 1.2 2006/10/25 12:18:31 martin
628  * Support serial I/O under Windows.
629  * Revision 1.1 2006/08/24 12:40:37Z martin
630  * Initial revision.
631  *
632  **************************************************************************/
633 
634 #define _MBGEXTIO
635  #include <mbgextio.h>
636 #undef _MBGEXTIO
637 
638 #include <xtiocomm.h>
639 #include <xdevfeat.h>
640 #include <mbgserio.h>
641 #include <cfg_hlp.h>
642 #include <mbg_arch.h>
643 #include <mbgerror.h>
644 #include <gpsutils.h>
645 #include <str_util.h>
646 
647 #include <stdio.h>
648 #include <stdlib.h>
649 #include <string.h>
650 #include <ctype.h>
651 
652 
653 #if !defined( _TRY_IDENT_DECODE )
654  #define _TRY_IDENT_DECODE 0
655 #endif
656 
657 #if _TRY_IDENT_DECODE
658  #include <identdec.h>
659 #endif
660 
661 #if _USE_SOCKET_IO
662  #if defined( MBG_TGT_POSIX )
663  #include <ifaddrs.h>
664  #include <sys/socket.h>
665  #include <netdb.h> // ### TODO gethostbyname / struct hostent
666  #include <arpa/inet.h>
667  #elif defined( MBG_TGT_WIN32 )
668  #if defined( _MSC_VER ) && ( _MSC_VER <= 1200 ) // at least up to VC6
669  #define VS_MISSING_IPHLPAPI
670  #endif
671 
672  #if !defined( VS_MISSING_IPHLPAPI )
673  #include <IPHlpApi.h>
674  #endif
675  #endif
676 #endif
677 
678 #if defined( MBG_TGT_POSIX )
679  #include <fcntl.h>
680  #include <errno.h>
681 #endif
682 
683 #if defined( MBG_TGT_DOS )
684  #include <dos.h>
685 #endif
686 
687 #if _USE_USB_IO
688  #include <mbgusbio.h>
689 #endif
690 
691 #if _USE_USB_DIRECT_IO
692  #include <poll.h>
693 #endif
694 
695 #if defined( DEBUG )
696  #define DEBUG_SOCK_IO 1
697  #define DEBUG_FORCE_CONN 1
698  #define DEBUG_INIT_CONN 1
699 #else
700  #define DEBUG_SOCK_IO 0
701  #define DEBUG_FORCE_CONN 0
702  #define DEBUG_INIT_CONN 0
703 #endif
704 
705 #if defined( MBG_TGT_WIN32 ) && _USE_SOCKET_IO
706  #define _USE_WIN32_CONSOLE_CONTROL_HANDLER 1
707 #else
708  #define _USE_WIN32_CONSOLE_CONTROL_HANDLER 0
709 #endif
710 
711 // default serial message timeout
712 #if !defined( MBGEXTIO_MSG_TIMEOUT_SERIAL )
713  #define MBGEXTIO_MSG_TIMEOUT_SERIAL 2000 // [ms]
714 #endif
715 
716 // default serial single character timeout
717 #if !defined( MBGEXTIO_POLL_TIMEOUT_SERIAL )
718  #define MBGEXTIO_POLL_TIMEOUT_SERIAL 200 // [ms]
719 #endif
720 
721 
722 // default USB message timeout
723 #if !defined( MBGEXTIO_MSG_TIMEOUT_USB )
724  #define MBGEXTIO_MSG_TIMEOUT_USB 100 // [ms]
725 #endif
726 
727 // default USB character timeout, same as message timeout
728 #if !defined( MBGEXTIO_POLL_TIMEOUT_USB )
729  #define MBGEXTIO_POLL_TIMEOUT_USB MBGEXTIO_MSG_TIMEOUT_USB
730 #endif
731 
732 
733 
736 
737 
738 
747 {
750 };
751 
752 
753 
760 {
762 };
763 
764 
765 
766 //### TODO proper header / prototype
767 /*HDR*/
768 const char *mbgextio_get_cmd_name( GPS_CMD cmd_code )
769 {
770  return xtiocomm_get_cmd_name( cmd_code );
771 
772 } // mbgextio_get_cmd_name
773 
774 
775 
776 #if _USE_WIN32_CONSOLE_CONTROL_HANDLER
777 
778 static /*HDR*/
779 BOOL WINAPI mbgextio_on_console_event( DWORD dwCtrlType )
780 {
781  switch ( dwCtrlType )
782  {
783  case CTRL_BREAK_EVENT:
784  case CTRL_C_EVENT:
785  case CTRL_CLOSE_EVENT:
786  case CTRL_SHUTDOWN_EVENT:
787  exit( 0 );
788 
789  } // switch
790 
791  return FALSE;
792 
793 } // mbgextio_on_console_event
794 
795 
796 
797 static /*HDR*/
798 void mbgextio_set_console_control_handler( void )
799 {
800  static int has_been_set;
801 
802  if ( !has_been_set )
803  {
804  SetConsoleCtrlHandler( mbgextio_on_console_event, TRUE );
805  has_been_set = 1;
806  }
807 
808 } // mbgextio_set_console_control_handler
809 
810 #endif // _USE_WIN32_CONSOLE_CONTROL_HANDLER
811 
812 
813 
814 #if _USE_USB_IO
815 
816 static /*HDR*/
831 int check_setup_legacy_usb_device( const MBG_USB_DEV_INFO *mdev_info, RECEIVER_INFO *p_ri )
832 {
833  int model_code = GPS_MODEL_UNKNOWN;
834  const char *model_name = str_unknown;
835 
836  if ( mdev_info->ven_id == USB_VENDOR_MEINBERG )
837  {
838  switch ( mdev_info->prod_id )
839  {
840  case USB_DEV_CPC_01:
841  model_code = GPS_MODEL_CPC_01;
842  model_name = GPS_MODEL_NAME_CPC_01;
843  break;
844 
845  case USB_DEV_CPC180:
846  model_code = GPS_MODEL_CPC180;
847  model_name = GPS_MODEL_NAME_CPC180;
848  break;
849 
850  case USB_DEV_TSU_01:
851  model_code = GPS_MODEL_TSU_01;
852  model_name = GPS_MODEL_NAME_TSU_01;
853  break;
854 
855  case USB_DEV_CMC:
856  model_code = GPS_MODEL_CMC_01;
857  model_name = GPS_MODEL_NAME_CMC_01;
858  break;
859 
860  case USB_DEV_SCU_USB:
861  model_code = GPS_MODEL_SCU_01;
862  model_name = GPS_MODEL_NAME_SCU_01;
863  break;
864 
865  case USB_DEV_FCU_01:
866  model_code = GPS_MODEL_FCU_01;
867  model_name = GPS_MODEL_NAME_FCU_01;
868  break;
869 
870  #if 0 // //### TODO check these device, they probably do support binary
871  case USB_DEV_SDI_01:
872  model_code = GPS_MODEL_UNKNOWN;
873  model_name = str_unknown;
874  break;
875 
876  case USB_DEV_MDU300:
877  model_code = GPS_MODEL_MDU300;
878  model_name = str_unknown;
879  break;
880  #endif
881  }
882  }
883 
884  #if DEBUG
885  fprintf( stderr, "Checking for legacy USB device %04X:%04X: %s, code %i\n",
886  mdev_info->ven_id, mdev_info->ven_id, model_name, model_code );
887  #endif
888 
889  if ( model_code == GPS_MODEL_UNKNOWN )
890  return MBG_ERR_DEV_NOT_SUPP;
891 
892  if ( p_ri )
893  {
894  memset( p_ri, 0, sizeof( *p_ri ) );
895 
896  p_ri->model_code = model_code;
897  sn_cpy_str_safe( p_ri->model_name, sizeof( p_ri->model_name ), model_name );
899  }
900 
901  return MBG_SUCCESS;
902 
903 } // check_setup_legacy_usb_device
904 
905 #endif // _USE_USB_IO
906 
907 
908 
909 /*HDR*/
923 {
924  MBG_XDEV_FEATURES *p_xdf = &pmctl->xdev_features;
925  int rc;
926 
927  memset( p_xdf, 0, sizeof( *p_xdf ) );
928 
929  // Get the receiver info first.
930  rc = mbgextio_setup_receiver_info( pmctl, addr, &p_xdf->receiver_info );
931 
932  if ( mbg_rc_is_error( rc ) )
933  goto out;
934 
935  // If the device supports extended features then read the
936  // extended feature buffer from the device, else clear extended features.
937  if ( p_xdf->receiver_info.features & GPS_HAS_XFEATURE )
938  {
939  rc = mbgextio_req_data( pmctl, addr, GPS_XFEATURES, &p_xdf->xfeature_buffer, sizeof( p_xdf->xfeature_buffer ) );
940  //### TODO use special API call?
941  }
942 
943  // FIXME TODO
944  // Shouldn't the same rc check be used after every API call?
945  if ( !mbg_rc_is_success_or_err_perm( rc ) )
946  goto out;
947 
948  rc = MBG_SUCCESS;
949 
950  // If the device supports TLVs then read the TLV info and supported TLV
951  // features from the device, else clear the structure.
952  if ( mbg_rc_is_success( xdevfeat_has_tlv_api( p_xdf ) ) )
953  {
954  rc = mbgextio_req_data( pmctl, addr, GPS_TLV_INFO, &p_xdf->tlv_info, sizeof( p_xdf->tlv_info ) );
955  //### TODO use special API call?
956  }
957 
958  if ( !mbg_rc_is_success_or_err_perm( rc ) )
959  goto out;
960 
961  rc = MBG_SUCCESS;
962 
963  // If the device supports user authentification, read the logged in user from the device
965  {
966  rc = mbgextio_req_data( pmctl, addr, GPS_AUTH_USER_INFO, &p_xdf->user_info, sizeof( p_xdf->user_info ) );
967 
968  if ( mbg_rc_is_success( rc ) )
969  rc = mbgextio_req_data( pmctl, addr, GPS_AUTH_USER_STATUS, &p_xdf->user_status, sizeof( p_xdf->user_status ) );
970  }
971 
972 out:
973  return rc;
974 
975 } // mbgextio_setup_xdevfeat
976 
977 
978 
979 static /*HDR*/
980 //### TODO
981 int dev_open_finish_setup( MBG_MSG_CTL **ppmctl, MBG_MSG_CTL **caller_ppmctl )
982 {
983  int rc;
984 
985  #if _USE_WIN32_CONSOLE_CONTROL_HANDLER
986  mbgextio_set_console_control_handler();
987  #endif
988 
989  #if _USE_MUTEX
990  _mbg_mutex_init( &(*ppmctl)->dev_mutex, "dev_mutex" );
991  #endif
992 
993  rc = mbgextio_setup_xdevfeat( *ppmctl, NULL );
994 
995  if ( mbg_rc_is_error( rc ) )
996  return dev_open_fail_close( rc, ppmctl, caller_ppmctl );
997 
998  return dev_open_finish( rc, *ppmctl, caller_ppmctl );
999 
1000 } // dev_open_finish_setup
1001 
1002 
1003 
1004 #if _USE_SOCKET_IO
1005 
1006 static /*HDR*/
1015 int set_socket_blocking_mode( MBG_SOCK_FD sock_fd, int blocking )
1016 {
1017  int rc = MBG_ERR_UNSPEC;
1018 
1019  if ( sock_fd == MBG_INVALID_SOCK_FD )
1020  {
1021  rc = MBG_ERR_INV_SOCK_FD;
1022  goto out;
1023  }
1024 
1025  #if defined( MBG_TGT_WIN32 )
1026  {
1027  u_long mode = blocking ? 0 : 1; // ioctlsocket expects an (u_long *)
1028 
1029  rc = ioctlsocket( sock_fd, FIONBIO, &mode ); // returns 0 on success
1030 
1031  if ( rc != 0 ) // error
1032  {
1033  rc = mbg_get_last_socket_error( "ioctlsocket(FIONBIO) failed in set_socket_blocking_mode" );
1034  goto out;
1035  }
1036  }
1037  #elif defined( MBG_TGT_POSIX )
1038  {
1039  int val = fcntl( sock_fd, F_GETFL, 0 ); // returns -1 on error
1040 
1041  if ( val == -1 )
1042  {
1043  rc = mbg_get_last_socket_error( "fcntl(F_GETFL) failed in set_socket_blocking_mode" );
1044  goto out;
1045  }
1046 
1047  if ( blocking )
1048  val &= ~O_NONBLOCK;
1049  else
1050  val |= O_NONBLOCK;
1051 
1052  rc = fcntl( sock_fd, F_SETFL, val ); // returns -1 on error
1053 
1054  if ( rc == -1 )
1055  {
1056  rc = mbg_get_last_socket_error( "fcntl(F_SETFL) failed in set_socket_blocking_mode" );
1057  goto out;
1058  }
1059  }
1060  #else
1061  {
1063  goto out;
1064  }
1065  #endif
1066 
1067  rc = MBG_SUCCESS;
1068 
1069 out:
1070  return rc;
1071 
1072 } // set_socket_blocking_mode
1073 
1074 
1075 
1076 static /*HDR*/
1084 int get_sock_error( MBG_SOCK_FD sock_fd )
1085 {
1086  int so_err = 0;
1087  socklen_t so_err_sz = sizeof( so_err );
1088  int rc = getsockopt( sock_fd, SOL_SOCKET, SO_ERROR, (char *) &so_err, &so_err_sz ); // returns 0 on success
1089 
1090  if ( rc != 0 ) // error
1091  {
1092  rc = mbg_get_last_socket_error( "getsockopt SO_ERROR failed in get_sock_error" );
1093  goto out;
1094  }
1095 
1096  if ( so_err_sz != sizeof( so_err ) ) // might have been modified by getsockopt()
1097  {
1098  fprintf( stderr, "Warning: getsockopt option size changed in get_sock_error: %li -> %li",
1099  (long) sizeof( so_err ), (long) so_err_sz );
1100  rc = MBG_ERR_UNSPEC;
1101  goto out;
1102  }
1103 
1104  if ( so_err != 0 ) // error
1105  {
1106  #if defined( MBG_TGT_WIN32 )
1107  rc = mbg_win32_wsa_err_to_mbg( so_err, "wait failed in wait_nonblocking_socket_ready" );
1108  #elif defined( MBG_TGT_POSIX )
1109  rc = mbg_posix_errno_to_mbg( so_err, "wait failed in wait_nonblocking_socket_ready" );
1110  #else
1111  #error This function is not supported for this target.
1112  #endif
1113  goto out;
1114  }
1115 
1116  rc = MBG_SUCCESS;
1117 
1118 out:
1119  return rc;
1120 
1121 } // get_sock_error
1122 
1123 
1124 
1125 static /*HDR*/
1140 int wait_nonblocking_socket_ready( MBG_SOCK_FD sock_fd, long timeout_msec )
1141 {
1142  // At least under Windows a select call can set except_fds if
1143  // the non-blocking attempt to connect fails.
1144  // See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740141(v=vs.85).aspx
1145  // Linux and FreeBSD suggest to use write_fds only.
1146  #if ( 1 || defined( MBG_TGT_WIN32 ) ) //### TODO
1147  #define USE_EXCEPT_FDS_WITH_CONNECT 1
1148  #else
1149  #define USE_EXCEPT_FDS_WITH_CONNECT 0
1150  #endif
1151 
1152  fd_set write_fds;
1153  #if USE_EXCEPT_FDS_WITH_CONNECT
1154  fd_set except_fds;
1155  #endif
1156  int max_fd;
1157  struct timeval tv_timeout;
1158  int rc = MBG_ERR_UNSPEC;
1159 
1160  mbg_msec_to_timeval( timeout_msec, &tv_timeout );
1161 
1162  FD_ZERO( &write_fds );
1163  FD_SET( sock_fd, &write_fds );
1164 
1165  #if defined( MBG_TGT_WIN32 )
1166  // Under Windows an fd is a handle which can't simply
1167  // be converted to an int, but the first argument of
1168  // select() is ignored under Windows anyway, so we just
1169  // set max_fd to 0.
1170  max_fd = 0;
1171  #else
1172  max_fd = sock_fd;
1173  #endif
1174 
1175  #if USE_EXCEPT_FDS_WITH_CONNECT
1176  FD_ZERO( &except_fds );
1177  FD_SET( sock_fd, &except_fds );
1178  rc = select( max_fd + 1, NULL, &write_fds, &except_fds, &tv_timeout );
1179  #else
1180  rc = select( max_fd + 1, NULL, &write_fds, NULL, &tv_timeout );
1181  #endif
1182 
1183  if ( rc == MBG_SOCKET_ERR_RETVAL ) // < 0, error
1184  {
1185  rc = mbg_get_last_socket_error( "select failed in wait_nonblocking_socket_ready" );
1186  goto out;
1187  }
1188 
1189  if ( rc == 0 ) // timeout
1190  {
1191  #if DEBUG_SOCK_IO
1192  fprintf( stderr, "select timed out in wait_nonblocking_socket_ready" );
1193  #endif
1195  goto out;
1196  }
1197 
1198  #if USE_EXCEPT_FDS_WITH_CONNECT
1199  // The except_fds might be set if no connection could be
1200  // established if e.g. the target socket is already busy.
1201  if ( FD_ISSET( sock_fd, &except_fds ) )
1202  {
1203  rc = get_sock_error( sock_fd );
1204  goto out;
1205  }
1206  #endif
1207 
1208  // Usually the write_fds are checked to see if the
1209  // non-blocking connect() call completed successfully,
1210  // in which case the associated descriptor is set.
1211  if ( !FD_ISSET( sock_fd, &write_fds ) )
1212  {
1213  #if DEBUG_SOCK_IO
1214  fprintf( stderr, "write_fd is not set after select in wait_nonblocking_socket_ready" );
1215  #endif
1217  goto out;
1218  }
1219 
1220  #if defined( MBG_TGT_LINUX )
1221  // From the connect(2) man page:
1222  // After select(2) indicates writability, use getsockopt(2) to read
1223  // the SO_ERROR option at level SOL_SOCKET to determine whether connect()
1224  // completed successfully (SO_ERROR is zero) or unsuccessfully (SO_ERROR
1225  // is one of the usual error codes, explaining the reason for the failure).
1226  rc = get_sock_error( sock_fd );
1227  goto out;
1228  #endif
1229 
1230  rc = MBG_SUCCESS;
1231 
1232 out:
1233  return rc;
1234 
1235 } // wait_nonblocking_socket_ready
1236 
1237 
1238 #if defined( MBG_TGT_WIN32 )
1239 
1248 void deinit_winsock( void )
1249 {
1250  WSACleanup( );
1251 }
1252 
1253 
1259 int check_init_winsock( void )
1260 {
1261  static bool wsa_init;
1262  int rc = MBG_SUCCESS;
1263 
1264  if( !wsa_init )
1265  {
1266  WORD wVersionRequested = MAKEWORD( 2, 2 );
1267  WSADATA wsaData;
1268 
1269  rc = WSAStartup( wVersionRequested, &wsaData );
1270  if ( rc != 0 )
1271  rc = mbg_win32_wsa_err_to_mbg( rc , NULL );
1272  else rc = MBG_SUCCESS;
1273 
1274  if( mbg_rc_is_success( rc ) )
1275  {
1276  wsa_init = true;
1277  atexit( deinit_winsock );
1278  }
1279 
1280  }
1281 
1282  return rc;
1283 }
1284 
1285 #endif // defined( MBG_TGT_WIN32 )
1286 
1287 
1288 /*HDR*/
1302 {
1303 #if defined( VS_MISSING_IPHLPAPI )
1304  return MBG_ERR_NOT_SUPP_ON_OS;
1305 #else
1306  struct sockaddr_in src_addr = { 0 };
1307  struct sockaddr_in bcast_addr = { 0 };
1308  struct sockaddr_in global_bcast_addr = { 0 };
1309  MBG_LAN_DEV_LIST *list_head = NULL;
1310  MBG_LAN_DEV_LIST *curr_entry = NULL;
1311  MBG_LAN_DEV_LIST *tmp_entry;
1312  const uint32_t query = htonl( MBG_LAN_REQUEST_CONFIG );
1313  socklen_t addr_len = sizeof ( struct sockaddr_in );
1314  struct in_addr src_in_addr = { 0 };
1315  struct in_addr broad_in_addr = { 0 };
1316  struct timeval select_timeout;
1317  int opt = 1;
1318  int rc = MBG_SUCCESS;
1320  MBG_TMO_TIME t_end;
1321  MBG_TMO_TIME t_now;
1322  MBG_LAN_DEV_CFG buf;
1323  fd_set socks;
1324  bool found;
1325 
1326 #if defined( MBG_TGT_POSIX )
1327 
1328  struct ifaddrs *ifaddr = NULL, *ifa;
1329 
1330 #elif defined( MBG_TGT_WIN32 )
1331 
1332  PIP_ADAPTER_ADDRESSES pAdptAddrs, pAdptAddr;
1333  PIP_ADAPTER_UNICAST_ADDRESS pUnicastAddr;
1334  ULONG flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER;
1335  unsigned long adptAddrsBuflen = sizeof( IP_ADAPTER_ADDRESSES );
1336  uint8_t prefix;
1337 
1338 #endif
1339 
1340  global_bcast_addr.sin_family = AF_INET;
1341  global_bcast_addr.sin_addr.s_addr = htonl( INADDR_BROADCAST );
1342  global_bcast_addr.sin_port = htons( MBG_LAN_UDP_BROADCAST_PORT );
1343 
1344  bcast_addr.sin_family = AF_INET;
1345  bcast_addr.sin_port = htons( MBG_LAN_UDP_BROADCAST_PORT );
1346 
1347 #if defined( MBG_TGT_POSIX )
1348 
1349  if ( getifaddrs( &ifaddr ) == 0 )
1350  {
1351  for ( ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next )
1352  {
1353  if ( ifa->ifa_addr && ( ifa->ifa_addr->sa_family == AF_INET ) )
1354  {
1355  src_in_addr.s_addr = ( (struct sockaddr_in *) ifa->ifa_addr )->sin_addr.s_addr;
1356 
1357  if ( ifa->ifa_broadaddr )
1358  broad_in_addr = ( (struct sockaddr_in *) ifa->ifa_broadaddr )->sin_addr;
1359 
1360 #elif defined( MBG_TGT_WIN32 )
1361 
1362  rc = check_init_winsock();
1363  if( mbg_rc_is_error( rc ) )
1364  return rc;
1365 
1366  pAdptAddrs = (PIP_ADAPTER_ADDRESSES) malloc( sizeof( IP_ADAPTER_ADDRESSES ) );
1367 
1368  if ( !pAdptAddrs )
1369  return MBG_ERR_NO_MEM;
1370 
1371  rc = GetAdaptersAddresses( AF_INET, flags, NULL, pAdptAddrs, &adptAddrsBuflen );
1372  if ( rc == ERROR_BUFFER_OVERFLOW )
1373  {
1374  free( pAdptAddrs );
1375  pAdptAddrs = (PIP_ADAPTER_ADDRESSES) malloc( adptAddrsBuflen );
1376  if ( !pAdptAddrs )
1377  return MBG_ERR_NO_MEM;
1378  rc = GetAdaptersAddresses( AF_INET, flags, NULL, pAdptAddrs, &adptAddrsBuflen );
1379  }
1380 
1381  if ( rc == NO_ERROR )
1382  {
1383  for ( pAdptAddr = pAdptAddrs; pAdptAddr != NULL; pAdptAddr = pAdptAddr->Next )
1384  {
1385  if ( pAdptAddr->OperStatus != IfOperStatusUp )
1386  continue;
1387 
1388  for ( pUnicastAddr = pAdptAddr->FirstUnicastAddress; pUnicastAddr != NULL; pUnicastAddr = pUnicastAddr->Next )
1389  {
1390  if ( pUnicastAddr->Address.lpSockaddr->sa_family != AF_INET )
1391  continue;
1392 
1393  src_in_addr.s_addr = ( (struct sockaddr_in *) pUnicastAddr->Address.lpSockaddr )->sin_addr.s_addr;
1394 
1395  broad_in_addr = src_in_addr;
1396  for( prefix = pUnicastAddr->OnLinkPrefixLength; prefix < 32; prefix++ )
1397  broad_in_addr.s_addr |= ( 1UL << prefix );
1398 
1399 #endif
1400 
1401  if ( ntohl( src_in_addr.s_addr ) == INADDR_LOOPBACK )
1402  continue;
1403 
1404  sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
1405 
1406  if ( sock >= 0 )
1407  {
1408  mbg_tmo_get_time( &t_end );
1409  mbg_tmo_add_ms( &t_end, timeout_ms );
1410 
1411  src_addr.sin_family = AF_INET;
1412  src_addr.sin_addr.s_addr = src_in_addr.s_addr;
1413 
1414  bcast_addr.sin_addr.s_addr = broad_in_addr.s_addr;
1415 
1416  if ( ( setsockopt( sock, SOL_SOCKET, SO_BROADCAST, (const char*) &opt, sizeof( opt ) ) == 0 ) &&
1417  ( bind( sock, (const struct sockaddr *) &src_addr, addr_len ) == 0 ) )
1418  {
1419  if ( ( sendto( sock, (char *) &query, sizeof( query ), 0, (struct sockaddr *) &global_bcast_addr, addr_len ) == sizeof( query ) ) &&
1420  ( sendto( sock, (char *) &query, sizeof( query ), 0, (struct sockaddr *) &bcast_addr, addr_len ) == sizeof( query ) ) )
1421  {
1422  while ( 1 )
1423  {
1424  FD_ZERO( &socks );
1425  FD_SET( sock, &socks );
1426 
1427  mbg_tmo_get_time( &t_now );
1428  if ( mbg_tmo_time_is_after( &t_now, &t_end ) )
1429  break;
1430  mbg_msec_to_timeval( mbg_tmo_time_diff_ms( &t_end, &t_now ), &select_timeout );
1431 
1432  addr_len = sizeof( struct sockaddr_in );
1433 
1434  // The first parameter for select() is always an int, but sock
1435  // is not an int in Windows, but always in POSIX. Since the parameter
1436  // is ignored in windows anyway, it's safe to cast it to an int
1437  // to avoid compiler warnings.
1438  if( select( (int) ( sock + 1 ), &socks, NULL, NULL, &select_timeout ) > 0 )
1439  {
1440  if( recvfrom( sock, (char *) &buf, sizeof( buf ), 0, (struct sockaddr *) &src_addr, &addr_len ) >= (ssize_t)sizeof( buf ) )
1441  {
1442  if( ( ntohl( buf.command ) == MBG_LAN_RESPOND_CONFIG ) &&
1443  ( ( ntohs( buf.channel_0.own_tcp_port ) == LAN_XPT_PORT ) ||
1444  ( buf.channel_0.own_tcp_port == LAN_XPT_PORT ) ||
1445  ( ntohs( buf.channel_0.own_tcp_port ) == LAN_SSH_PORT ) ||
1446  ( buf.channel_0.own_tcp_port == LAN_SSH_PORT ) ) )
1447  {
1448  found = false;
1449 
1450  if ( list_head )
1451  {
1452  tmp_entry = list_head;
1453  while( tmp_entry && !found )
1454  {
1455  if( tmp_entry->config.ip_address == ntohl( src_addr.sin_addr.s_addr ) )
1456  found = true;
1457  tmp_entry = tmp_entry->next;
1458  }
1459  }
1460 
1461  if ( !found )
1462  {
1463  if ( curr_entry )
1464  {
1465  curr_entry->next = (MBG_LAN_DEV_LIST *) malloc( sizeof( *curr_entry->next ) );
1466  if ( !curr_entry->next )
1467  {
1468  rc = MBG_ERR_NO_MEM;
1469  goto cleanup_and_return;
1470  }
1471  curr_entry = curr_entry->next;
1472  }
1473  else
1474  {
1475  curr_entry = (MBG_LAN_DEV_LIST *) malloc( sizeof( *curr_entry ) );
1476  if( !curr_entry )
1477  {
1478  rc = MBG_ERR_NO_MEM;
1479  goto cleanup_and_return;
1480  }
1481  list_head = curr_entry;
1482  }
1483 
1484  memset( curr_entry, 0, sizeof( *curr_entry ) );
1485  curr_entry->config = buf;
1486  curr_entry->config.ip_address = ntohl( src_addr.sin_addr.s_addr );
1487  rc++;
1488  }
1489  }
1490  }
1491  }
1492  else
1493  break;
1494  }
1495  }
1496  else
1497  {
1498  rc = MBG_ERR_NBYTES;
1499  goto cleanup_and_return;
1500  }
1501  }
1502  else
1503  {
1504  rc = MBG_ERR_INV_SOCK_FD;
1505  goto cleanup_and_return;
1506  }
1507 
1508 #if defined( MBG_TGT_POSIX )
1509 
1510  shutdown( sock, SHUT_RDWR );
1511  close( sock );
1512 
1513 #elif defined( MBG_TGT_WIN32 )
1514 
1515  shutdown( sock, SD_BOTH );
1516  closesocket( sock );
1517 
1518 #endif
1519  sock = -1;
1520  }
1521  else
1522  {
1523  rc = MBG_ERR_INV_SOCK_FD;
1524  goto cleanup_and_return;
1525  }
1526  }
1527  }
1528  }
1529  else
1530  rc = MBG_ERR_GENERIC;
1531 
1532 cleanup_and_return:
1533 
1534 #if defined( MBG_TGT_POSIX )
1535 
1536  if ( ifaddr )
1537  freeifaddrs( ifaddr );
1538 
1539  if ( sock >= 0 )
1540  {
1541  shutdown( sock, SHUT_RDWR );
1542  close( sock );
1543  }
1544 
1545 #elif defined( MBG_TGT_WIN32 )
1546 
1547  if ( pAdptAddrs )
1548  free( pAdptAddrs );
1549 
1550  if ( sock >= 0 )
1551  {
1552  shutdown( sock, SD_BOTH );
1553  closesocket( sock );
1554  }
1555 
1556 #endif
1557 
1558  if ( rc <= 0 )
1559  {
1560  mbgextio_free_lan_devices( list_head );
1561  list_head = NULL;
1562  }
1563 
1564  *list = list_head;
1565 
1566  return rc;
1567 #endif
1568 }
1569 
1570 
1571 /*HDR*/
1582 {
1583  if( list )
1584  {
1585  MBG_LAN_DEV_LIST *next_entry = list;
1586  while( next_entry )
1587  {
1588  list = next_entry;
1589  next_entry = list->next;
1590  free( list );
1591  }
1592  return MBG_SUCCESS;
1593  }
1594  return MBG_ERR_INV_PARM;
1595 }
1596 
1597 
1598 static /*HDR*/
1607 int socket_init( MBG_MSG_CTL *pmctl, const char *host )
1608 {
1609  int rc = MBG_ERR_UNSPEC;
1610  #if _USE_SSH_ENCRYPTION
1611  int login_rc = MBG_SUCCESS;
1612  #endif
1613  struct addrinfo *pinfo = NULL;
1614 
1615 #if defined( MBG_TGT_WIN32 )
1616  rc = check_init_winsock( );
1617 
1618  if( !mbg_rc_is_success( rc ) )
1619  goto out;
1620 #endif
1621 
1622  if ( pmctl->st.sockio.use_ssh )
1623  {
1624 #if _USE_SSH_ENCRYPTION
1625  long tout = 5000 * 1000;
1626  int state, port = LAN_SSH_PORT;
1627  SSH_DATA *ssh_data = ( SSH_DATA* )pmctl->priv_data;
1628 
1629 retry:
1630  ssh_data->session = ssh_new();
1631  if ( ssh_data->session == NULL )
1632  {
1633  rc = MBG_ERR_SOCK_INIT;
1634  goto out;
1635  }
1636 
1637  ssh_options_set( ssh_data->session, SSH_OPTIONS_HOST, host );
1638  ssh_options_set( ssh_data->session, SSH_OPTIONS_PORT, &port );
1639  ssh_options_set( ssh_data->session, SSH_OPTIONS_TIMEOUT_USEC, &tout );
1640 
1641  if ( ssh_connect( ssh_data->session ) != SSH_OK )
1642  {
1643  if( ssh_get_error_code( ssh_data->session ) == SSH_REQUEST_DENIED )
1644  rc = MBG_ERR_ACCESS;
1645  else rc = MBG_ERR_DISCONN;
1646  goto out_close;
1647  }
1648 
1649  rc = MBG_ERR_ACCESS;
1650  state = ssh_is_server_known( ssh_data->session );
1651  switch ( state )
1652  {
1653  case SSH_SERVER_KNOWN_OK:
1654  {
1655  rc = MBG_SUCCESS;
1656  break;
1657  }
1658  case SSH_SERVER_KNOWN_CHANGED:
1659  case SSH_SERVER_FOUND_OTHER:
1660  case SSH_SERVER_FILE_NOT_FOUND:
1661  case SSH_SERVER_NOT_KNOWN:
1662  {
1663  if ( ssh_data->key_prompt )
1664  rc = ssh_data->key_prompt( ssh_data, state );
1665 
1666  if(mbg_rc_is_error(rc))
1667  goto out_close;
1668  break;
1669  }
1670  default: goto out_close;
1671  }
1672 
1673  if ( ssh_data->login_prompt )
1674  {
1675  rc = ssh_data->login_prompt( ssh_data, login_rc );
1676  if ( mbg_rc_is_success( rc ) )
1677  {
1678  int32_t tmp;
1679 
1680  ssh_data->channel = ssh_channel_new( ssh_data->session );
1681  if ( ssh_data->channel == NULL )
1682  {
1683  rc = MBG_ERR_SOCK_INIT;
1684  goto out_close;
1685  }
1686 
1687  if ( ssh_channel_open_session( ssh_data->channel ) != SSH_OK )
1688  {
1689  rc = MBG_ERR_INV_SOCK_FD;
1690  goto out_close;
1691  }
1692 
1693  rc = ssh_channel_read( ssh_data->channel, &tmp, sizeof( tmp ), 0 );
1694  if ( rc > 0 )
1695  rc = ntohl( tmp );
1696  else rc = MBG_ERR_TIMEOUT;
1697 
1698  if ( mbg_rc_is_error( rc ) )
1699  {
1700  socket_close(pmctl);
1701  login_rc = rc;
1702  goto retry;
1703  }
1704  }
1705  }
1706  else
1707  rc = MBG_ERR_AUTH;
1708 
1709  if ( mbg_rc_is_error( rc ) )
1710  goto out_close;
1711 
1712 #else
1714 #endif
1715  }
1716  else
1717  {
1718  struct sockaddr_in addr;
1719  struct addrinfo hints;
1720  struct sockaddr_in *paddr;
1721  const struct sockaddr *p;
1722  int sz;
1723 
1724  if ( inet_pton( AF_INET, host, &addr.sin_addr ) == 1 )
1725  rc = MBG_SUCCESS;
1726 
1727  if( mbg_rc_is_error( rc ) )
1728  {
1729  memset( &hints, 0, sizeof( hints ) );
1730  hints.ai_family = AF_INET;
1731  hints.ai_socktype = SOCK_STREAM;
1732  hints.ai_protocol = IPPROTO_TCP;
1733 
1734  switch ( getaddrinfo( host, NULL, &hints, &pinfo ) )
1735  {
1736  case 0:
1737  rc = MBG_SUCCESS;
1738  break;
1739 
1740  case EAI_NONAME:
1741  // At least with some versions of Microsoft Visual Studio
1742  // EAI_NODATA evaluates to the same number as EAI_NONAME,
1743  // which caused a "duplicate case" compiler error.
1744  #if defined( EAI_NODATA ) && ( EAI_NODATA != EAI_NONAME )
1745  case EAI_NODATA:
1746  #endif
1747  #if defined( EAI_ADDRFAMILY )
1748  case EAI_ADDRFAMILY:
1749  #endif
1750  #if defined( EAI_FAMILY )
1751  case EAI_FAMILY:
1752  #endif
1753  rc = MBG_ERR_DEV_NOT_SUPP;
1754  break;
1755 
1756  case EAI_AGAIN:
1757  rc = MBG_ERR_BUSY;
1758  break;
1759 
1760  case EAI_MEMORY:
1761  rc = MBG_ERR_NO_MEM;
1762  break;
1763 
1764  default:
1765  rc = MBG_ERR_UNKNOWN;
1766  break;
1767  }
1768 
1769  if ( !pinfo )
1770  {
1771  rc = MBG_ERR_GENERIC;
1772  goto out;
1773  }
1774 
1775  addr.sin_addr = ( ( struct sockaddr_in* )pinfo->ai_addr )->sin_addr;
1776  }
1777 
1778  // Create socket on which to send.
1779  pmctl->st.sockio.sockfd = socket( PF_INET, SOCK_STREAM, 0 );
1780 
1781  if ( pmctl->st.sockio.sockfd == MBG_INVALID_SOCK_FD )
1782  {
1783  rc = mbg_get_last_socket_error( "failed to create socket in socket_init" );
1784  goto out;
1785  }
1786 
1787  // Set the socket to nonblocking mode to be able to
1788  // reduce the timeout when connecting to a socket
1789  // which is offline.
1790  rc = set_socket_blocking_mode( pmctl->st.sockio.sockfd, 0 );
1791 
1792  if ( mbg_rc_is_error( rc ) )
1793  goto out_close;
1794 
1795 
1796  // Now try to connect to the socket.
1797  paddr = &pmctl->st.sockio._addr;
1798  memset( paddr, 0, sizeof( *paddr ) );
1799 
1800  paddr->sin_addr = addr.sin_addr;
1801  paddr->sin_family = AF_INET;
1802  paddr->sin_port = htons( LAN_XPT_PORT );
1803 
1804  p = (const struct sockaddr *) paddr;
1805  sz = sizeof( *paddr );
1806 
1807  rc = connect( pmctl->st.sockio.sockfd, p, sz ); // returns 0 on success on Windows and Linux
1808 
1809  // In nonblocking mode connect() might complete successfully
1810  // if the destination socket is on the same machine (localhost)
1811  // However, for remote connections the call usually returns
1812  // immediately with WSAEWOULDBLOCK on Windows, or EINPROGRESS or
1813  // EALREADY on POSIX systems. In the latter cases we need to wait
1814  // and see if the connection can be established successfully.
1815 
1816  if ( rc != 0 ) // eventually not (yet) completed in non-blocking mode
1817  {
1818  #if defined( MBG_TGT_WIN32 )
1819  DWORD wsa_err = WSAGetLastError();
1820 
1821  // WSAEWOULDBLOCK is actually not an error in non-blocking mode
1822  if ( wsa_err != WSAEWOULDBLOCK )
1823  {
1824  rc = mbg_win32_wsa_err_to_mbg( wsa_err, "connect failed in socket_init" );
1825  goto out_close;
1826  }
1827  #else // POSIX ...
1828  int posix_errno = errno;
1829 
1830  // EINPROGRESS and EALREADY are actually not errors in non-blocking mode
1831  if ( ( posix_errno != EINPROGRESS ) && ( posix_errno != EALREADY ) )
1832  {
1833  rc = mbg_posix_errno_to_mbg( posix_errno, "connect failed in socket_init" );
1834  goto out_close;
1835  }
1836  #endif
1837 
1838  rc = wait_nonblocking_socket_ready( pmctl->st.sockio.sockfd, 1500 ); //##++++++++++++
1839 
1840  if ( mbg_rc_is_error( rc ) )
1841  goto out_close;
1842  }
1843 
1844  // Set the socket back to blocking mode.
1845  rc = set_socket_blocking_mode( pmctl->st.sockio.sockfd, 1 );
1846 
1847  pmctl->st.sockio.p_addr = &pmctl->st.sockio._addr;
1848  pmctl->st.sockio.addrlen = sizeof( pmctl->st.sockio._addr );
1849  }
1850 
1851  if ( mbg_rc_is_success( rc ) )
1852  goto out;
1853 
1854  // error, fall through and close socket
1855 out_close:
1856  socket_close( pmctl );
1857 
1858 out:
1859  if ( pinfo )
1860  freeaddrinfo( pinfo );
1861  return rc;
1862 
1863 } // socket_init
1864 
1865 
1866 
1867 /*HDR*/
1884  const char *old_passwd, const char *new_passwd )
1885 {
1886  MBG_MSG_BUFF *pmb;
1887  SECU_SETTINGS *pss = &pmctl->secu_settings;
1888  GPS_CMD cmd = GPS_SECU_SETTINGS; // GPS_REQACK is not supported by LAN_XPT, so never use it
1889  int rc = MBG_ERR_UNSPEC;
1890 
1891  #if _USE_MUTEX
1892  _mbg_mutex_acquire( &pmctl->dev_mutex );
1893  #endif
1894 
1895  memset( pss, 0, sizeof *pss );
1896  strncpy_safe( pss->password, old_passwd, sizeof( pss->password ) );
1897 
1898  set_encryption_mode( pmctl, MBG_XFER_MODE_ENCRYPTED, pss->password );
1899 
1900  if ( new_passwd )
1901  {
1902  if ( strlen( new_passwd ) > 0 )
1903  strncpy_safe( pss->new_password, new_passwd, sizeof( pss->new_password ) );
1904 
1905  pss->flags |= MSK_FLAG_CHANGE_PASSWORD;
1906  }
1907 
1908  pmb = pmctl->xmt.pmb;
1909  pmb->u.msg_data.secu_settings = *pss;
1910  pmb->hdr.cmd = cmd;
1911  pmb->hdr.len = sizeof( pmb->u.msg_data.secu_settings );
1912 
1913  rc = xmt_tbuff( pmctl, p_addr ); //### TODO Use mbgextio_req_data instead? Is NULL OK?
1914 
1915  if ( mbg_rc_is_error( rc ) )
1916  goto out;
1917 
1918  rc = mbgextio_rcv_msg_unlocked( pmctl, NULL, cmd, NULL, 0 ); //### TODO Is XBP_ADDR NULL OK?
1919 
1920  // With some devices a timeout may also occur
1921  // if a wrong password has been used.
1922  if ( mbg_rc_is_error( rc ) )
1923  goto out;
1924 
1925  cmd = pmctl->rcv.pmb->hdr.cmd;
1926 
1927  // If we either received a reply with GPS_NACK, or
1928  // without GPS_ACK, the password was definitely wrong.
1929  if ( ( cmd & GPS_NACK ) || !( cmd & GPS_ACK ) )
1930  {
1931  rc = MBG_ERR_AUTH;
1932  goto out;
1933  }
1934 
1935  rc = MBG_SUCCESS;
1936 
1937 out:
1938  #if _USE_MUTEX
1939  _mbg_mutex_release( &pmctl->dev_mutex );
1940  #endif
1941 
1942  return rc;
1943 
1944 } // mbgextio_xmt_secu_settings
1945 
1946 
1947 /*HDR*/
1967 _NO_MBG_API_ATTR int mbgextio_socket_write_default(MBG_MSG_CTL* pmctl, const void *buf, size_t len)
1968 {
1969  int rc = sendto( pmctl->st.sockio.sockfd, buf, len, 0,
1970  ( const struct sockaddr *)pmctl->st.sockio.p_addr,
1971  pmctl->st.sockio.addrlen );
1972 
1973  if ( rc >= 0 )
1974  {
1975  if ( (size_t)rc != len )
1976  rc = MBG_ERR_BYTES_WRITTEN;
1977  }
1978  else
1979  rc = mbg_posix_errno_to_mbg( errno, NULL ) ;
1980 
1981  return rc;
1982 }
1983 
1984 
1985 /*HDR*/
2006 _NO_MBG_API_ATTR int mbgextio_socket_read_default(MBG_MSG_CTL* pmctl, void *buf, size_t len)
2007 {
2008  struct timeval tv_timeout;
2009  fd_set fds;
2010  int max_fd;
2011  int rc;
2012 
2013  mbg_msec_to_timeval( pmctl->st.sockio.poll_timeout, &tv_timeout );
2014 
2015  FD_ZERO( &fds );
2016  FD_SET( pmctl->st.sockio.sockfd, &fds );
2017 
2018  #if defined( MBG_TGT_WIN32 )
2019  // Under Windows an fd is a handle which can't simply
2020  // be converted to an int, but the first argument of
2021  // select() is ignored under Windows anyway, so we just
2022  // set max_fd to 0.
2023  max_fd = 0;
2024  #else
2025  max_fd = pmctl->st.sockio.sockfd;
2026  #endif
2027 
2028  rc = select( max_fd + 1, &fds, NULL, NULL, &tv_timeout );
2029 
2030  if ( rc < 0 )
2031  return rc;
2032 
2033  if ( rc == 0 )
2034  return MBG_ERR_TIMEOUT;
2035 
2036  // data is available
2037 
2038  return recv( pmctl->st.sockio.sockfd, buf, len, 0 );
2039 }
2040 
2041 
2042 /*HDR*/
2060 _NO_MBG_API_ATTR int _MBG_API mbgextio_open_socket( const char *host,
2061  MBG_MSG_CTL **ppmctl, const char *passwd )
2062 {
2063  MBG_MSG_CTL *pmctl;
2064  int rc = alloc_msg_ctl( &pmctl );
2065 
2066  if ( mbg_rc_is_error( rc ) )
2067  return dev_open_finish( rc, pmctl, ppmctl );
2068 
2069  pmctl->st.sockio.read = mbgextio_socket_read_default;
2070  pmctl->st.sockio.write = mbgextio_socket_write_default;
2071 
2072  rc = socket_init( pmctl, host );
2073 
2074  if ( mbg_rc_is_error( rc ) )
2075  return dev_open_fail_free( rc, &pmctl, ppmctl );
2076 
2077  dev_open_init( pmctl, MBG_CONN_TYPE_SOCKET, MBGEXTIO_MSG_TIMEOUT_SOCKET,
2078  MBGEXTIO_POLL_TIMEOUT_SOCKET );
2079 
2080  rc = mbgextio_xmt_secu_settings( pmctl, NULL, passwd, NULL );
2081 
2082  if ( mbg_rc_is_error( rc ) )
2083  return dev_open_fail_close( rc, &pmctl, ppmctl );
2084 
2085  return dev_open_finish_setup( &pmctl, ppmctl );
2086 
2087 } // mbgextio_open_socket
2088 
2089 
2090 #if _USE_SSH_ENCRYPTION
2091 
2092 /*HDR*/
2112 _NO_MBG_API_ATTR int mbgextio_socket_write_ssh( MBG_MSG_CTL* pmctl, const void *buf, size_t len )
2113 {
2114  int rc;
2115  SSH_DATA *ssh_data;
2116 
2117  ssh_data = __mbg_get_pmctl_ssh_data( pmctl );
2118 
2119  _mbg_mutex_acquire(&ssh_data->mutex);
2120  rc = ssh_channel_write( ssh_data->channel, buf, len );
2121  _mbg_mutex_release(&ssh_data->mutex);
2122 
2123  if ( rc >= 0 )
2124  {
2125  if ( (size_t)rc != len )
2126  rc = MBG_ERR_BYTES_WRITTEN;
2127  }
2128  else
2129  rc = MBG_ERR_IO;
2130 
2131  return rc;
2132 }
2133 
2134 
2135 /*HDR*/
2157 _NO_MBG_API_ATTR int mbgextio_socket_read_ssh( MBG_MSG_CTL* pmctl, void *buf, size_t len )
2158 {
2159  SSH_DATA *ssh_data = __mbg_get_pmctl_ssh_data( pmctl );
2160  struct timeval tv_timeout;
2161  ssh_channel chans[2];
2162  int ssh_rc;
2163 
2164  mbg_msec_to_timeval( pmctl->st.sockio.poll_timeout, &tv_timeout );
2165 
2166  chans[0] = ssh_data->channel;
2167  chans[1] = NULL;
2168 
2169  /*
2170  * As far as I can tell from libssh's source code there's no need to protect
2171  * "ssh_channel_select" by the session mutex as no session members are
2172  * altered in that function. But hey: No guarantee! ;) (Especially not
2173  * for any future libssh versions!!)
2174  */
2175  ssh_rc = ssh_channel_select( chans, NULL, NULL, &tv_timeout );
2176  if ( ssh_rc == SSH_OK )
2177  {
2178  if ( chans[0] != ssh_data->channel )
2179  return MBG_ERR_TIMEOUT;
2180 
2181  _mbg_mutex_acquire(&ssh_data->mutex);
2182  ssh_rc = ssh_channel_read_nonblocking( ssh_data->channel, buf, len, 0 );
2183  _mbg_mutex_release(&ssh_data->mutex);
2184  }
2185 
2186  if ( ssh_rc > 0 )
2187  return ssh_rc;
2188 
2189  switch ( ssh_rc )
2190  {
2191  case SSH_AGAIN: return MBG_ERR_TIMEOUT;
2192  case SSH_ERROR:
2193  case SSH_EOF: return 0; // 0 evals to disconnected in ::mbgextio_rcv_msg_unlocked
2194  default: return MBG_ERR_GENERIC;
2195  }
2196 }
2197 
2198 
2210 static __mbg_inline SSH_DATA* mbgextio_get_ssh_data( MBG_MSG_CTL *pmctl )
2211 {
2212  return pmctl->priv_data;
2213 }
2214 
2215 
2216 /*HDR*/
2238 _NO_MBG_API_ATTR int _MBG_API mbgextio_open_ssh_socket( const char *host,
2239  MBG_MSG_CTL **ppmctl, SSH_DATA *ssh_data )
2240 {
2241  MBG_MSG_CTL *pmctl;
2242  int rc = alloc_msg_ctl( &pmctl );
2243 
2244  if ( mbg_rc_is_error( rc ) )
2245  return dev_open_finish( rc, pmctl, ppmctl );
2246 
2247  pmctl->st.sockio.use_ssh = 1;
2248  pmctl->st.sockio.read = mbgextio_socket_read_ssh;
2249  pmctl->st.sockio.write = mbgextio_socket_write_ssh;
2250  pmctl->st.sockio.get_ssh_data = mbgextio_get_ssh_data;
2251  pmctl->priv_data = ssh_data;
2252  _mbg_mutex_init( &ssh_data->mutex, "ssh_mutex" );
2253 
2254  rc = socket_init( pmctl, host );
2255 
2256  if ( mbg_rc_is_error( rc ) )
2257  return dev_open_fail_free( rc, &pmctl, ppmctl );
2258 
2259  dev_open_init( pmctl, MBG_CONN_TYPE_SOCKET, MBGEXTIO_MSG_TIMEOUT_SOCKET,
2260  MBGEXTIO_POLL_TIMEOUT_SOCKET );
2261 
2262  return dev_open_finish_setup( &pmctl, ppmctl );
2263 }
2264 
2265 #endif
2266 
2267 #endif // _USE_SOCKET_IO
2268 
2269 
2270 
2271 #if _USE_SERIAL_IO
2272 
2273 /*HDR*/
2274 int mbgextio_open_serial_raw( const char *dev, MBG_MSG_CTL **ppmctl,
2275  uint32_t baud_rate, const char *framing )
2276 {
2277  MBG_MSG_CTL *pmctl;
2278  int rc = alloc_msg_ctl( &pmctl );
2279 
2280  if ( mbg_rc_is_error( rc ) )
2281  return dev_open_finish( rc, pmctl, ppmctl );
2282 
2283  rc = mbgserio_open( &pmctl->st.p_serio, dev );
2284 
2285  if ( mbg_rc_is_error( rc ) )
2286  return dev_open_fail_free( rc, &pmctl, ppmctl );
2287 
2288  dev_open_init( pmctl, MBG_CONN_TYPE_SERIAL, MBGEXTIO_MSG_TIMEOUT_SERIAL,
2290 
2291  rc = mbgserio_set_parms( pmctl->st.p_serio, baud_rate, framing );
2292 
2293  if ( mbg_rc_is_error( rc ) )
2294  return dev_open_fail_close( rc, &pmctl, ppmctl );
2295 
2296  return dev_open_finish( rc, pmctl, ppmctl );
2297 
2298 } // mbgextio_open_serial_raw
2299 
2300 
2301 
2302 /*HDR*/
2327 _NO_MBG_API_ATTR int _MBG_API mbgextio_open_serial( const char *dev, MBG_MSG_CTL **ppmctl,
2328  uint32_t baud_rate, const char *framing )
2329 {
2330  MBG_MSG_CTL *pmctl;
2331  int rc = alloc_msg_ctl( &pmctl );
2332 
2333  if ( mbg_rc_is_error( rc ) )
2334  return dev_open_finish( rc, pmctl, ppmctl );
2335 
2336  rc = mbgserio_open( &pmctl->st.p_serio, dev );
2337 
2338  if ( mbg_rc_is_error( rc ) )
2339  return dev_open_fail_free( rc, &pmctl, ppmctl );
2340 
2341  dev_open_init( pmctl, MBG_CONN_TYPE_SERIAL, MBGEXTIO_MSG_TIMEOUT_SERIAL,
2343 
2344  rc = mbgserio_set_parms( pmctl->st.p_serio, baud_rate, framing );
2345 
2346  if ( mbg_rc_is_error( rc ) )
2347  return dev_open_fail_close( rc, &pmctl, ppmctl );
2348 
2349  return dev_open_finish_setup( &pmctl, ppmctl );
2350 
2351 } // mbgextio_open_serial
2352 
2353 
2354 /*HDR*/
2376 _NO_MBG_API_ATTR int _MBG_API mbgextio_open_serial_force_default( const char *dev, MBG_MSG_CTL **ppmctl, uint32_t baud_rate, const char *framing )
2377 {
2378  const char* cmd_str = force_conn_hs_cmd_str;
2379  int len = (int) strlen( cmd_str );
2380  MBG_MSG_CTL *pmctl = NULL;
2381  int rc;
2382  int high = 1;
2383 
2384  if ( ( baud_rate == MBG_DEFAULT_BAUDRATE_HS ) && ( strcmp( framing, MBG_DEFAULT_FRAMING ) == 0 ) )
2385  return mbgextio_open_serial( dev, ppmctl, baud_rate, framing );
2386 
2387 retry:
2388  rc = mbgextio_open_serial_raw( dev, &pmctl, baud_rate, framing );
2389 
2390  if ( mbg_rc_is_success( rc ) )
2391  {
2392  mbgserio_write( pmctl->st.p_serio, cmd_str, len );
2393 
2394  #ifdef MBG_TGT_WIN32
2395  // Flushing the output when the serial port is closed doesn't
2396  // always work correctly under Windows, so we insert a delay
2397  // here to make sure the string has been set.
2398  // The required delay depends on the number of characters to
2399  // send, and on the transmission speed (baud rate).
2400  Sleep( ( ( 10 * 1000 * len ) / baud_rate ) + 1 );
2401  #endif
2402 
2403  mbgextio_close_connection( &pmctl );
2404 
2405  // Sleep for 10ms, so the device has time to switch to the new baudrate
2406  #if defined( MBG_TGT_WIN32 )
2407  Sleep( 10 );
2408  #elif defined( MBG_TGT_DOS )
2409  delay( 10 );
2410  #else
2411  usleep( 10000 );
2412  #endif
2413 
2415 
2416  if ( mbg_rc_is_error( rc ) && high )
2417  {
2418  // If baud_rate is default baudrate and highspeed baud_rate did not work, simply open the port with default baudrate
2419  if( ( baud_rate == MBG_DEFAULT_BAUDRATE ) && ( strcmp( framing, MBG_DEFAULT_FRAMING ) == 0 ) )
2420  return mbgextio_open_serial( dev, ppmctl, baud_rate, framing );
2421 
2422  high = 0;
2423  cmd_str = force_conn_cmd_str;
2424  len = ( int )strlen( cmd_str );
2425  goto retry;
2426  }
2427  }
2428 
2429  if ( mbg_rc_is_success( rc ) )
2430  *ppmctl = pmctl;
2431 
2432  return rc;
2433 
2434 } // mbgextio_open_serial_force_default
2435 
2436 #endif // _USE_SERIAL_IO
2437 
2438 
2439 
2440 #if _USE_SERIAL_IO_FTDI
2441 
2442 /*HDR*/
2451 {
2452  return pmctl->st.ftdi.port_handle;
2453 
2454 } // mbgextio_get_serial_ftdi_port_handle
2455 
2456 
2457 
2458 /*HDR*/
2483  MBG_MSG_CTL **ppmctl, uint32_t baud_rate, const char *framing )
2484 {
2485  FT_STATUS status;
2486  ULONG ft_baud;
2487  UCHAR ft_data_bits;
2488  UCHAR ft_stopbits;
2489  UCHAR ft_parity;
2490  const char *cp;
2491  MBG_MSG_CTL *pmctl;
2492  int rc = alloc_msg_ctl( &pmctl );
2493 
2494  if ( mbg_rc_is_error( rc ) )
2495  return dev_open_finish( rc, pmctl, ppmctl );
2496 
2497  status = FT_Open( device_num, &pmctl->st.ftdi.port_handle );
2498 
2499  if ( status != FT_OK )
2500  return dev_open_fail_free( mbg_ftdi_ft_status_to_mbg( status ), &pmctl, ppmctl );
2501 
2504 
2505  // setup transmission speed
2506  switch ( baud_rate )
2507  {
2508  case 300: ft_baud = FT_BAUD_300; break;
2509  case 600: ft_baud = FT_BAUD_600; break;
2510  case 1200: ft_baud = FT_BAUD_1200; break;
2511  case 2400: ft_baud = FT_BAUD_2400; break;
2512  case 4800: ft_baud = FT_BAUD_4800; break;
2513  case 9600: ft_baud = FT_BAUD_9600; break;
2514  case 14400: ft_baud = FT_BAUD_14400; break;
2515  case 19200: ft_baud = FT_BAUD_19200; break;
2516  case 38400: ft_baud = FT_BAUD_38400; break;
2517  case 57600: ft_baud = FT_BAUD_57600; break;
2518  case 115200: ft_baud = FT_BAUD_115200; break;
2519  case 230400: ft_baud = FT_BAUD_230400; break;
2520  case 460800: ft_baud = FT_BAUD_460800; break;
2521  case 921600: ft_baud = FT_BAUD_921600; break;
2522 
2523  default:
2524  return dev_open_fail_close( MBG_ERR_INV_PARM, &pmctl, ppmctl );
2525  }
2526 
2527 
2528  // setup framing
2529  for ( cp = framing; *cp; cp++ )
2530  {
2531  char c = toupper( *cp );
2532 
2533  switch ( c )
2534  {
2535  case '7': ft_data_bits = FT_BITS_7; break;
2536  case '8': ft_data_bits = FT_BITS_8; break;
2537 
2538  case 'N': ft_parity = FT_PARITY_NONE; break;
2539  case 'E': ft_parity = FT_PARITY_EVEN; break;
2540  case 'O': ft_parity = FT_PARITY_ODD; break;
2541  // FT_PARITY_MARK and FT_PARITY_SPACE not supp. by Meinberg API
2542 
2543  case '1': ft_stopbits = FT_STOP_BITS_1; break;
2544  case '2': ft_stopbits = FT_STOP_BITS_2; break;
2545 
2546  default:
2547  return dev_open_fail_close( MBG_ERR_INV_PARM, &pmctl, ppmctl );
2548  }
2549  }
2550 
2551 
2552  status = FT_SetBaudRate( pmctl->st.ftdi.port_handle, ft_baud );
2553 
2554  if ( status != FT_OK )
2555  return dev_open_fail_close( mbg_ftdi_ft_status_to_mbg( status ), &pmctl, ppmctl );
2556 
2557  status = FT_SetDataCharacteristics( pmctl->st.ftdi.port_handle,
2558  ft_data_bits, ft_stopbits, ft_parity );
2559 
2560  if ( status != FT_OK )
2561  return dev_open_fail_close( mbg_ftdi_ft_status_to_mbg( status ), &pmctl, ppmctl );
2562 
2563  return dev_open_finish_setup( &pmctl, ppmctl );
2564 
2565 } // mbgextio_open_serial_ftdi
2566 
2567 #endif
2568 
2569 
2570 
2571 #if _USE_USB_IO
2572 
2573 /*HDR*/
2589  MBG_MSG_CTL **ppmctl )
2590 {
2591  MBG_MSG_CTL *pmctl;
2592  int rc = alloc_msg_ctl( &pmctl );
2593 
2594  if ( mbg_rc_is_error( rc ) )
2595  return dev_open_finish( rc, pmctl, ppmctl );
2596 
2597  rc = mbgusbio_open( &pmctl->st.usbio, mdev_info );
2598 
2599  if ( mbg_rc_is_error( rc ) )
2600  return dev_open_fail_free( rc, &pmctl, ppmctl );
2601 
2602  dev_open_init( pmctl, MBG_CONN_TYPE_USB, MBGEXTIO_MSG_TIMEOUT_USB,
2604 
2605  return dev_open_finish_setup( &pmctl, ppmctl );
2606 
2607 } // mbgextio_open_usb
2608 
2609 
2610 
2611 /*HDR*/
2625 {
2626  return mbgusbio_reset( mdev_info );
2627 
2628 } // mbgextio_reset_usb
2629 
2630 
2631 
2632 /*HDR*/
2649 int mbgextio_open_usb_ldev( libusb_device *ldev, MBG_MSG_CTL **ppmctl )
2650 {
2651  MBG_MSG_CTL *pmctl;
2652  int rc = alloc_msg_ctl( &pmctl );
2653 
2654  if ( mbg_rc_is_error( rc ) )
2655  return dev_open_finish( rc, pmctl, ppmctl );
2656 
2657  rc = mbgusbio_open_specific_device( &pmctl->st.usbio, ldev );
2658 
2659  if ( mbg_rc_is_error( rc ) )
2660  return dev_open_fail_free( rc, &pmctl, ppmctl );
2661 
2662  dev_open_init( pmctl, MBG_CONN_TYPE_USB, MBGEXTIO_MSG_TIMEOUT_USB,
2664 
2665  return dev_open_finish_setup( &pmctl, ppmctl );
2666 
2667 } // mbgextio_open_usb_ldev
2668 
2669 #endif
2670 
2671 
2672 
2673 /*HDR*/
2698 {
2699  MBG_MSG_CTL *pmctl = *ppmctl;
2700  int rc = MBG_ERR_UNSPEC;
2701 
2702  switch ( pmctl->conn_type )
2703  {
2704  #if _USE_SERIAL_IO
2705  case MBG_CONN_TYPE_SERIAL:
2706  rc = mbgserio_close( &pmctl->st.p_serio );
2707  break;
2708  #endif // _USE_SERIAL_IO
2709 
2710  #if _USE_SERIAL_IO_FTDI
2712  {
2713  FT_STATUS status = FT_Close( pmctl->st.ftdi.port_handle );
2714  pmctl->st.ftdi.port_handle = NULL; //### TODO FT_Handle is a PVOID
2715  rc = mbg_ftdi_ft_status_to_mbg( status );
2716  } break;
2717  #endif // _USE_SERIAL_IO_FTDI
2718 
2719  #if _USE_SOCKET_IO
2720  case MBG_CONN_TYPE_SOCKET:
2721  rc = socket_close( pmctl );
2722  break;
2723  #endif // _USE_SOCKET_IO
2724 
2725  #if _USE_USB_IO
2726  case MBG_CONN_TYPE_USB:
2727  rc = mbgusbio_close( &pmctl->st.usbio );
2728  break;
2729  #endif // _USE_USB_IO
2730 
2731  default:
2732  rc = MBG_ERR_CONN_TYPE;
2733 
2734  } // switch
2735 
2736  #if _USE_MUTEX
2737  _mbg_mutex_destroy( &pmctl->dev_mutex );
2738  #endif
2739 
2740  dealloc_msg_ctl( ppmctl );
2741 
2742  return rc;
2743 
2744 } // mbgextio_close_connection
2745 
2746 
2747 
2748 #if _USE_SERIAL_IO
2749 
2750 static /*HDR*/
2751 int do_force_conn_serial( const char *dev, int high_speed )
2752 {
2753  MBG_MSG_CTL *pmctl;
2754  const char *cmd_str = high_speed ? force_conn_hs_cmd_str : force_conn_cmd_str;
2755  BAUD_RATE expected_baudrate = high_speed ? MBG_DEFAULT_BAUDRATE_HS : MBG_DEFAULT_BAUDRATE;
2756  #if DEBUG_FORCE_CONN
2757  const char *info = high_speed ? " (hs)" : "";
2758  #endif
2759  int len = (int) strlen( cmd_str );
2760  int baud_idx;
2761  int frame_idx;
2762  int rc = MBG_ERR_UNSPEC;
2763 
2764  for ( baud_idx = 0; baud_idx < N_MBG_BAUD_RATES; baud_idx++ )
2765  {
2766  for ( frame_idx = 0; frame_idx < N_MBG_FRAMINGS; frame_idx++ )
2767  {
2768  uint32_t baud_rate = mbg_baud_rates[baud_idx];
2769  const char *framing = mbg_framing_strs[frame_idx];
2770 
2771  rc = mbgextio_open_serial_raw( dev, &pmctl, baud_rate, framing );
2772 
2773  if ( mbg_rc_is_error( rc ) )
2774  {
2775  if ( rc == MBG_ERR_NO_ENTITY ) //### TODO duplicate code
2776  {
2777  #if DEBUG_FORCE_CONN
2778  fprintf( stderr, "force conn%s probing failed to open port %s: %s: aborting\n",
2779  info, dev, mbg_strerror( rc ) );
2780  #endif
2781  goto out;
2782  }
2783 
2784  if ( rc == MBG_ERR_IO ) //### TODO duplicate code
2785  {
2786  #if DEBUG_FORCE_CONN
2787  fprintf( stderr, "force conn%s failed for port %s with %li/%s: %s: aborting\n",
2788  info, dev, (long) baud_rate, framing, mbg_strerror( rc ) );
2789  #endif
2790  goto out;
2791  }
2792 
2793  #if DEBUG_FORCE_CONN
2794  fprintf( stderr, "force conn%s failed for port %s with %li/%s: %s: skipping\n",
2795  info, dev, (long) baud_rate, framing, mbg_strerror( rc ) );
2796  #endif
2797  continue;
2798  }
2799 
2800  mbgserio_write( pmctl->st.p_serio, cmd_str, len );
2801  // should we check rc here or just continue?
2802 
2803  #ifdef MBG_TGT_WIN32
2804  // Flushing the output when the serial port is closed doesn't
2805  // always work correctly under Windows, so we insert a delay
2806  // here to make sure the string has been set.
2807  // The required delay depends on the number of characters to
2808  // send, and on the transmission speed (baud rate).
2809  Sleep( ( ( 10 * 1000 * len ) / baud_rate ) + 1 );
2810  #endif
2811 
2812  mbgextio_close_connection( &pmctl );
2813  }
2814  }
2815 
2816  rc = mbgextio_open_serial_raw( dev, &pmctl, expected_baudrate, MBG_DEFAULT_FRAMING );
2817 
2818  if ( mbg_rc_is_error( rc ) )
2819  goto out;
2820 
2821  rc = mbgextio_get_receiver_info( pmctl, NULL, NULL );
2822 
2823  if ( mbg_rc_is_success( rc ) )
2824  rc = expected_baudrate;
2825 
2826  mbgextio_close_connection( &pmctl);
2827 
2828 out:
2829  return rc;
2830 
2831 } // do_force_conn_serial
2832 
2833 
2834 
2835 /*HDR*/
2867 {
2868  long rc = do_force_conn_serial( dev, 1 );
2869 
2870  if ( mbg_rc_is_success( rc ) )
2871  goto out;
2872 
2873  // If we failed because the specified port is not available
2874  // then it makes no sense to continue.
2875  if ( ( rc == MBG_ERR_NO_ENTITY ) || ( rc == MBG_ERR_IO ) ) //### TODO duplicate code
2876  goto out;
2877 
2878  rc = do_force_conn_serial( dev, 0 );
2879 
2880 out:
2881  return rc;
2882 
2883 } // mbgextio_force_conn_serial
2884 
2885 #endif // _USE_SERIAL_IO
2886 
2887 
2888 
2889 #if _USE_SERIAL_IO_FTDI
2890 
2891 static /*HDR*/
2892 int do_force_conn_serial_ftdi( int device_num, const char *cmd_str, BAUD_RATE expected_baudrate )
2893 {
2894  int i;
2895  int j;
2896  MBG_MSG_CTL *pmctl;
2897  int len = (int) strlen( force_conn_cmd_str );
2898  long rc = MBG_ERR_UNSPEC;
2899 
2900  for ( i = 0; i < N_MBG_BAUD_RATES; i++ )
2901  {
2902  for ( j = 0; j < N_MBG_FRAMINGS; j++ )
2903  {
2904  uint32_t baud_rate = mbg_baud_rates[i];
2905  const char *framing = mbg_framing_strs[j];
2906  DWORD bytes_written;
2907  FT_HANDLE port_handle;
2908  FT_STATUS status;
2909 
2910  rc = mbgextio_open_serial_ftdi( device_num, &pmctl, baud_rate, framing );
2911 
2912  if ( mbg_rc_is_error( rc ) )
2913  goto out;
2914 
2915  port_handle = pmctl->st.ftdi.port_handle;
2916 
2917  status = FT_Write( port_handle, (LPVOID) force_conn_cmd_str, len, &bytes_written );
2918 
2919  #if 0 //### TODO we need some error checking here
2920  if ( status != FT_OK )
2921  {
2922  rc = mbg_ftdi_ft_status_to_mbg( status );
2923  goto out;
2924  }
2925 
2926  if ( bytes_written != sizeof( len ) )
2927  goto out_write_failed;
2928  #endif
2929 
2930  #ifdef MBG_TGT_WIN32
2931  #if 1
2932  // TODO Check if this works as expected
2933  status = FT_Purge( port_handle, FT_PURGE_TX );
2934  #else
2935 
2936  // Flushing the output when the serial port is closed doesn't
2937  // always work correctly under Windows, so we insert a delay
2938  // here to make sure the string has been set.
2939  // The required delay depends on the number of characters to
2940  // send, and on the transmission speed (baud rate).
2941  Sleep( ( ( 10 * 1000 * len ) / baud_rate ) + 1 );
2942  #endif
2943  #endif
2944 
2945  mbgextio_close_connection( &pmctl );
2946  }
2947  }
2948 
2949  rc = mbgextio_open_serial_ftdi( device_num, &pmctl, expected_baudrate, MBG_DEFAULT_FRAMING );
2950 
2951  if ( mbg_rc_is_error( rc ) )
2952  goto out;
2953 
2954  rc = mbgextio_get_receiver_info( pmctl, NULL, NULL );
2955 
2956  mbgextio_close_connection( &pmctl );
2957 
2958 out:
2959  return rc;
2960 
2961 } // do_force_conn_serial_ftdi
2962 
2963 
2964 
2965 /*HDR*/
2994 {
2995  long rc = do_force_conn_serial_ftdi( device_num, force_conn_hs_cmd_str, MBG_DEFAULT_BAUDRATE_HS );
2996 
2997  if ( mbg_rc_is_success( rc ) )
2998  return MBG_DEFAULT_BAUDRATE_HS;
2999 
3000  rc = do_force_conn_serial_ftdi( device_num, force_conn_cmd_str, MBG_DEFAULT_BAUDRATE );
3001 
3002  if ( mbg_rc_is_success( rc ) )
3003  return MBG_DEFAULT_BAUDRATE;
3004 
3005  return rc;
3006 
3007 } // mbgextio_force_conn_serial_ftdi
3008 
3009 #endif // _USE_SERIAL_IO_FTDI
3010 
3011 
3012 
3013 /*HDR*/
3032  MBG_NACK_HANDLER_FNC *fnc )
3033 {
3034  pmctl->nack_handler_fnc = *fnc;
3035 
3036 } // mbgextio_register_nack_callback
3037 
3038 
3039 
3040 /*HDR*/
3057 {
3058  pmctl->async_msg_handler_fnc = *fnc;
3059 
3060 } // mbgextio_register_async_msg_callback
3061 
3062 
3063 
3064 /*HDR*/
3082 {
3083  pmctl->async_data_handler_fnc = *fnc;
3084 
3085 } // mbgextio_register_async_data_callback
3086 
3087 
3088 
3089 /*HDR*/
3107 {
3108  pmctl->async_data_reset_fnc = *fnc;
3109 
3110 } // mbgextio_register_async_data_reset_callback
3111 
3112 
3113 
3114 /*HDR*/
3129 {
3130  if ( pmctl == NULL )
3131  return NULL;
3132 
3133  return &pmctl->xdev_features.receiver_info;
3134 
3135 } // mbgextio_get_receiver_info_addr
3136 
3137 
3138 
3139 /*HDR*/
3152 {
3153  if ( pmctl == NULL )
3154  return NULL;
3155 
3156  return pmctl->rcv.pmb;
3157 
3158 } // mbgextio_get_rcv_buffer_addr
3159 
3160 
3161 
3162 /*HDR*/
3175 {
3176  if ( pmctl == NULL )
3177  return 0;
3178 
3179  return sizeof( *pmctl->rcv.pmb );
3180 
3181 } // mbgextio_get_rcv_buffer_size
3182 
3183 
3184 
3185 /*HDR*/
3198 {
3199  if ( pmctl == NULL )
3200  return NULL;
3201 
3202  return pmctl->xmt.pmb;
3203 
3204 } // mbgextio_get_xmt_buffer_addr
3205 
3206 
3207 
3208 /*HDR*/
3221 {
3222  if ( pmctl == NULL )
3223  return 0;
3224 
3225  return sizeof( *pmctl->xmt.pmb );
3226 
3227 } // mbgextio_get_xmt_buffer_size
3228 
3229 
3230 
3231 /*HDR*/
3245 {
3246  return xtiocomm_set_dev_poll_timeout( pmctl, new_timeout );
3247 
3248 } // mbgextio_set_dev_poll_timeout
3249 
3250 
3251 
3252 /*HDR*/
3265 {
3266  return xtiocomm_get_dev_poll_timeout( pmctl );
3267 
3268 } // mbgextio_get_dev_poll_timeout
3269 
3270 
3271 
3272 /*HDR*/
3284 {
3285  xtiocomm_set_msg_rcv_timeout( pmctl, new_timeout );
3286 
3287 } // mbgextio_set_msg_rcv_timeout
3288 
3289 
3290 
3291 /*HDR*/
3304 {
3305  return xtiocomm_get_msg_rcv_timeout( pmctl );
3306 
3307 } // mbgextio_get_msg_rcv_timeout
3308 
3309 
3310 
3311 /*HDR*/
3330 {
3332 
3333 } // mbgextio_dev_is_legacy
3334 
3336 
3337 
3338 
3339 /*HDR*/
3341 {
3342  return xdevfeat_has_pos_xyz( &pmctl->xdev_features );
3343 
3344 } // mbgextio_dev_has_pos_xyz
3345 
3347 
3348 
3349 
3350 /*HDR*/
3352 {
3353  return xdevfeat_has_pos_lla( &pmctl->xdev_features );
3354 
3355 } // mbgextio_dev_has_pos_lla
3356 
3358 
3359 
3360 
3361 /*HDR*/
3363 {
3364  return xdevfeat_has_time_ttm( &pmctl->xdev_features );
3365 
3366 } // mbgextio_dev_has_time_ttm
3367 
3369 
3370 
3371 
3372 /*HDR*/
3374 {
3375  return xdevfeat_has_ant_info( &pmctl->xdev_features );
3376 
3377 } // mbgextio_dev_has_ant_info
3378 
3380 
3381 
3382 
3383 /*HDR*/
3385 {
3386  return xdevfeat_has_ant_cable_length( &pmctl->xdev_features );
3387 
3388 } // mbgextio_dev_has_ant_cable_length
3389 
3391 
3392 
3393 
3394 /*HDR*/
3396 {
3397  return xdevfeat_has_io_ports( &pmctl->xdev_features );
3398 
3399 } // mbgextio_dev_has_io_ports
3400 
3402 
3403 
3404 
3405 /*HDR*/
3407 {
3408  return xdevfeat_has_tainted_cfg( &pmctl->xdev_features );
3409 
3410 } // mbgextio_dev_has_tainted_cfg
3411 
3413 
3414 
3415 
3416 /*HDR*/
3418 {
3419  return xdevfeat_has_push_msgs( &pmctl->xdev_features );
3420 
3421 } // mbgextio_dev_has_push_msgs
3422 
3424 
3425 /*HDR*/
3427 {
3428  return xdevfeat_has_clk_res_info( &pmctl->xdev_features );
3429 
3430 } // mbgextio_dev_has_clk_res_info
3431 
3433 
3434 
3435 
3436 
3437 /*HDR*/
3450 {
3451  return xdevfeat_has_gps_stat_info( &pmctl->xdev_features );
3452 
3453 } // mbgextio_dev_has_gps_stat_info
3454 
3456 
3457 
3458 
3459 /*HDR*/
3472 {
3473  return xdevfeat_is_gps( &pmctl->xdev_features );
3474 
3475 } // mbgextio_dev_is_gps
3476 
3478 
3479 
3480 
3481 /*HDR*/
3499 {
3500  return xdevfeat_is_gnss( &pmctl->xdev_features );
3501 
3502 } // mbgextio_dev_is_gnss
3503 
3505 
3506 
3507 
3508 /*HDR*/
3521 {
3522  return xdevfeat_is_tcr( &pmctl->xdev_features );
3523 
3524 } // mbgextio_dev_is_tcr
3525 
3527 
3528 
3529 
3530 /*HDR*/
3543 {
3544  return xdevfeat_is_dcf( &pmctl->xdev_features );
3545 
3546 } // mbgextio_dev_is_dcf
3547 
3549 
3550 
3551 
3552 /*HDR*/
3565 {
3566  return xdevfeat_has_pzf( &pmctl->xdev_features );
3567 
3568 } // mbgextio_dev_has_pzf
3569 
3571 
3572 
3573 
3574 /*HDR*/
3587 {
3588  return xdevfeat_is_bus_lvl_dev( &pmctl->xdev_features );
3589 
3590 } // mbgextio_dev_is_bus_lvl_dev
3591 
3593 
3594 
3595 
3596 /*HDR*/
3598 {
3599  return xdevfeat_has_enable_flags( &pmctl->xdev_features );
3600 
3601 } // mbgextio_dev_has_enable_flags
3602 
3604 
3605 
3606 /*HDR*/
3608 {
3609  return xdevfeat_has_time_scale( &pmctl->xdev_features );
3610 
3611 } // mbgextio_dev_has_time_scale
3612 
3614 
3615 
3616 /*HDR*/
3618 {
3619  return xdevfeat_has_tzdl( &pmctl->xdev_features );
3620 
3621 } // mbgextio_dev_has_tzdl
3622 
3624 
3625 
3626 /*HDR*/
3628 {
3629  return xdevfeat_has_tzcode( &pmctl->xdev_features );
3630 
3631 } // mbgextio_dev_has_tzcode
3632 
3634 
3635 
3636 /*HDR*/
3638 {
3639  return xdevfeat_has_ims( &pmctl->xdev_features );
3640 
3641 } // mbgextio_dev_has_ims
3642 
3644 
3645 
3646 
3647 /*HDR*/
3649 {
3650  return xdevfeat_has_synth( &pmctl->xdev_features );
3651 
3652 } // mbgextio_dev_has_synth
3653 
3655 
3656 
3657 
3658 /*HDR*/
3660 {
3661  return xdevfeat_has_gpio( &pmctl->xdev_features );
3662 
3663 } // mbgextio_dev_has_gpio
3664 
3666 
3667 
3668 
3669 /*HDR*/
3671 {
3672  return xdevfeat_has_prog_pulses( &pmctl->xdev_features );
3673 
3674 } // mbgextio_dev_has_prog_pulses
3675 
3677 
3678 
3679 
3680 /*HDR*/
3682 {
3683  return xdevfeat_has_irig_tx( &pmctl->xdev_features );
3684 
3685 } // mbgextio_dev_has_irig_tx
3686 
3688 
3689 
3690 
3691 /*HDR*/
3693 {
3694  return xdevfeat_has_irig_rx( &pmctl->xdev_features );
3695 
3696 } // mbgextio_dev_has_irig_rx
3697 
3699 
3700 
3701 
3702 /*HDR*/
3704 {
3705  return xdevfeat_has_serouts( &pmctl->xdev_features );
3706 
3707 } // mbgextio_dev_has_serouts
3708 
3710 
3711 
3712 
3713 /*HDR*/
3715 {
3716  return xdevfeat_has_bvar_stat( &pmctl->xdev_features );
3717 
3718 } // mbgextio_dev_has_serouts
3719 
3721 
3722 
3723 
3724 /*HDR*/
3726 {
3727  return xdevfeat_has_service( &pmctl->xdev_features );
3728 
3729 } // mbgextio_dev_has_service
3730 
3732 
3733 
3734 
3735 /*HDR*/
3751 {
3752  return xdevfeat_has_up_conv( &pmctl->xdev_features );
3753 
3754 } // mbgextio_dev_has_up_conv
3755 
3757 
3758 
3759 
3760 /*HDR*/
3775 {
3776  return xdevfeat_has_scu_stat( &pmctl->xdev_features );
3777 
3778 } // mbgextio_dev_has_scu_stat
3779 
3781 
3782 
3783 /*HDR*/
3796 {
3797  return xdevfeat_has_raw_irig_data( &pmctl->xdev_features );
3798 
3799 } // mbgextio_dev_has_raw_irig_data
3800 
3802 
3803 
3804 
3805 /*HDR*/
3825 {
3826  return xdevfeat_has_lan_ip4( &pmctl->xdev_features );
3827 
3828 } // mbgextio_dev_has_lan_ip4
3829 
3831 
3832 
3833 
3834 /*HDR*/
3854 {
3855  return xdevfeat_has_net_cfg( &pmctl->xdev_features );
3856 
3857 } // mbgextio_dev_has_net_cfg
3858 
3860 
3861 
3862 
3863 /*HDR*/
3881 {
3882  return xdevfeat_has_ptp( &pmctl->xdev_features );
3883 
3884 } // mbgextio_dev_has_ptp
3885 
3887 
3888 
3889 /*HDR*/
3907 {
3908  return xdevfeat_has_ntp( &pmctl->xdev_features );
3909 
3910 } // mbgextio_dev_has_ntp
3911 
3913 
3914 
3915 /*HDR*/
3931 {
3932  return xdevfeat_has_fw_mngmnt( &pmctl->xdev_features );
3933 
3934 } // mbgextio_dev_has_fw_mngmnt
3935 
3937 
3938 
3939 /*HDR*/
3941 {
3942  return xdevfeat_has_evt_log( &pmctl->xdev_features );
3943 
3944 } // mbgextio_dev_has_evt_log
3945 
3947 
3948 
3949 /*HDR*/
3951 {
3952  return xdevfeat_has_ucap( &pmctl->xdev_features );
3953 
3954 } // mbgextio_dev_has_ucap
3955 
3957 
3958 
3959 /*HDR*/
3961 {
3962  return xdevfeat_has_ucap_net( &pmctl->xdev_features );
3963 
3964 } // mbgextio_dev_has_ucap_net
3965 
3967 
3968 
3969 /*HDR*/
3982 {
3983  return xdevfeat_has_tlv_api( &pmctl->xdev_features );
3984 
3985 } // mbgextio_dev_has_tlv_api
3986 
3988 
3989 
3990 /*HDR*/
4008 {
4009  int rc = MBG_ERR_CONN_TYPE;
4010 
4011  #if _USE_SOCKET_IO
4012  if( ( pmctl->conn_type == MBG_CONN_TYPE_SOCKET ) &&
4013  ( pmctl->st.sockio.use_ssh > 0 ) )
4014  rc = xdevfeat_has_user_auth( &pmctl->xdev_features );
4015  #endif
4016 
4017  return rc;
4018 
4019 } // mbgextio_dev_has_user_auth
4020 
4022 
4023 
4024 /*HDR*/
4040 {
4041  return xdevfeat_has_user_mngmnt( &pmctl->xdev_features );
4042 
4043 } // mbgextio_dev_has_user_mngmnt
4044 
4046 
4047 
4048 /*HDR*/
4061 {
4062  return xdevfeat_supp_tlv_file_req( &pmctl->xdev_features );
4063 
4064 } // mbgextio_dev_supp_tlv_file_req
4065 
4067 
4068 
4069 
4070 /*HDR*/
4083 {
4084  return xdevfeat_supp_tlv_exec_cmd( &pmctl->xdev_features );
4085 
4086 } // mbgextio_dev_supp_tlv_exec_cmd
4087 
4089 
4090 
4091 
4092 /*HDR*/
4105 {
4106  return xdevfeat_supp_tlv_fw_rollback( &pmctl->xdev_features );
4107 
4108 } // mbgextio_dev_supp_tlv_fw_rollback
4109 
4111 
4112 /*HDR*/
4125 {
4126  return xdevfeat_supp_tlv_fw_update( &pmctl->xdev_features );
4127 
4128 } // mbgextio_dev_supp_tlv_fw_update
4129 
4131 
4132 /*HDR*/
4145 {
4146  return xdevfeat_supp_tlv_diag_file( &pmctl->xdev_features );
4147 
4148 } // mbgextio_dev_supp_tlv_diag_file
4149 
4151 
4152 /*HDR*/
4165 {
4167 
4168 } // mbgextio_dev_supp_tlv_ptpv2_license
4169 
4171 
4172 /*HDR*/
4185 {
4187 
4188 } // mbgextio_dev_supp_tlv_ptpv1_license
4189 
4191 
4192 
4193 /*HDR*/
4206 {
4207  return xdevfeat_supp_tlv_ntp_license( &pmctl->xdev_features );
4208 
4209 } // mbgextio_dev_supp_tlv_ntp_license
4210 
4212 
4213 
4214 /*HDR*/
4227 {
4229 
4230 } // mbgextio_dev_supp_tlv_time_monitor_license
4231 
4233 
4234 
4235 /*HDR*/
4247 {
4248  return xdevfeat_supp_tlv_ufu( &pmctl->xdev_features );
4249 
4250 } // mbgextio_dev_supp_tlv_ufu
4251 
4253 
4254 
4255 /*HDR*/
4268 {
4269  return xdevfeat_has_cmd_save_cfg( &pmctl->xdev_features );
4270 
4271 } // mbgextio_dev_has_cmd_save_cfg
4272 
4274 
4275 
4276 
4277 /*HDR*/
4290 {
4291  return xdevfeat_has_monitoring( &pmctl->xdev_features );
4292 
4293 } // mbgextio_dev_has_monitoring
4294 
4296 
4297 
4298 
4299 /*HDR*/
4312 {
4313  return xdevfeat_has_led_api( &pmctl->xdev_features );
4314 
4315 } // mbgextio_dev_has_led_api
4316 
4318 
4319 
4320 
4321 /*HDR*/
4334 {
4335  return xdevfeat_has_lne_api( &pmctl->xdev_features );
4336 
4337 } // mbgextio_dev_has_lne_api
4338 
4340 
4341 
4342 
4343 /*HDR*/
4356 {
4357  return xdevfeat_has_pwr_ctl_api( &pmctl->xdev_features );
4358 
4359 } // mbgextio_dev_has_pwr_ctl_api
4360 
4362 
4363 
4364 
4365 /*HDR*/
4378 {
4379  return xdevfeat_has_ext_sys_info( &pmctl->xdev_features );
4380 
4381 } // mbgextio_dev_has_ext_sys_info
4382 
4384 
4385 
4386 
4387 /*HDR*/
4400 {
4401  return xdevfeat_has_transactions( &pmctl->xdev_features );
4402 
4403 } // mbgextio_dev_has_transactions
4404 
4406 
4407 
4408 
4409 /*HDR*/
4422 {
4423  return xdevfeat_has_reboot( &pmctl->xdev_features );
4424 
4425 } // mbgextio_dev_has_reboot
4426 
4428 
4429 
4430 
4431 /*HDR*/
4445 {
4446  return xdevfeat_has_req_ttm( &pmctl->xdev_features );
4447 
4448 } // mbgextio_dev_has_req_ttm
4449 
4451 
4452 
4453 /*HDR*/
4466 {
4467  return xdevfeat_has_xmulti_ref( &pmctl->xdev_features );
4468 
4469 } // mbgextio_dev_has_xmulti_ref
4470 
4472 
4473 
4474 
4475 /*HDR*/
4488 {
4489  return xdevfeat_has_xbp( &pmctl->xdev_features );
4490 
4491 } // mbgextio_dev_has_xbp
4492 
4494 
4495 
4496 
4497 /*HDR*/
4510 {
4511  return xdevfeat_has_database( &pmctl->xdev_features );
4512 
4513 } // mbgextio_dev_has_database
4514 
4516 
4517 
4518 
4519 /*HDR*/
4533 {
4534  return xdevfeat_has_gnss_mode( &pmctl->xdev_features );
4535 
4536 } // mbgextio_dev_has_gnss_mode
4537 
4539 
4540 
4541 
4542 static /*HDR*/
4544 {
4545  const MBG_MSG_BUFF *pmb = pmctl->rcv.pmb;
4546  int rc;
4547 
4548  if ( ( pmb->hdr.cmd & GPS_NACK ) == 0 )
4549  return MBG_SUCCESS;
4550 
4551 
4552  // A NACK message has been received from the device.
4553 
4554  if ( pmb->hdr.len == sizeof( pmb->u.msg_data.i16 ) )
4555  {
4556  // The device has returned a code to indicate the reason for
4557  // the NACK. This should be one of the @ref MBG_ERROR_CODES.
4558  // We'll return this error code by default, if appropriate.
4559  rc = pmb->u.msg_data.i16;
4560 
4561  // Make sure the returned code is indeed an error code.
4562  if ( mbg_rc_is_error( rc ) )
4563  {
4564  // Call the NACK handler callback function, if one has
4565  // been registered, and pass the return code from the
4566  // callback function up to the caller.
4567  if ( pmctl->nack_handler_fnc )
4568  rc = pmctl->nack_handler_fnc( pmctl );
4569 
4570  // Return the code received from the device, or
4571  // the return code from the callback function.
4572  goto out;
4573  }
4574 
4575  // The code returned by the device was not an error code,
4576  // as we'd expected. So we ignore that code and continue
4577  // the same way as if no specific code had been received
4578  // from the device.
4579  }
4580 
4581  rc = MBG_ERR_RCVD_NACK;
4582 
4583 out:
4584  return rc;
4585 
4586 } // msg_return_code
4587 
4588 
4589 
4590 /*HDR*/
4615  GPS_CMD cmd, void *buf, size_t buf_size )
4616 {
4617  MBG_MSG_RCV_CTL *prctl;
4618  MBG_MSG_BUFF *pmb;
4619  char buff[MBGEXTIO_READ_BUFFER_SIZE];
4620  ssize_t n_bytes = 0;
4621  int rc = MBG_ERR_UNSPEC;
4622  int i;
4623  #if _DEBUG_MSG_TIMING
4624  MBG_MSG_TIMES *pmt = &pmctl->mt;
4625  #else
4626  MBG_MSG_TIMES mt;
4627  MBG_MSG_TIMES *pmt = &mt;
4628  #endif
4629 
4630  init_transfer( &pmctl->rcv );
4631  mbg_tmo_get_time( &pmt->t_start );
4632  pmt->t_tmo = pmt->t_start;
4633  mbg_tmo_add_ms( &pmt->t_tmo, pmctl->msg_rcv_timeout );
4634 
4635  for (;;) // loop until complete msg received
4636  {
4637  n_bytes = 0;
4638 
4639  mbg_tmo_get_time( &pmt->t_now );
4640 
4641  if ( mbg_tmo_time_is_after( &pmt->t_now, &pmt->t_tmo ) )
4642  {
4643  rc = MBG_ERR_TIMEOUT;
4644  goto out;
4645  }
4646 
4647  switch ( pmctl->conn_type )
4648  {
4649  #if _USE_SOCKET_IO
4650  case MBG_CONN_TYPE_SOCKET:
4651  {
4652  n_bytes = pmctl->st.sockio.read( pmctl, buff, sizeof( buff ) );
4653 
4654  if ( n_bytes == MBG_ERR_TIMEOUT )
4655  continue;
4656 
4657  /* 0 bytes mean remote site closed connection on TCP sockets */
4658  if ( n_bytes == 0 )
4659  {
4660  rc = MBG_ERR_DISCONN;
4661  goto out;
4662  }
4663 
4664  if ( n_bytes < 0 )
4665  {
4666  rc = mbg_get_last_socket_error( "recv failed in mbgextio_rcv_msg_unlocked" );
4667  goto out;
4668  }
4669 
4670  } break;
4671  #endif // _USE_SOCKET_IO
4672 
4673  #if _USE_SERIAL_IO
4674  case MBG_CONN_TYPE_SERIAL:
4675  {
4676  rc = mbgserio_read_wait( pmctl->st.p_serio, &buff[0], sizeof( buff[0] ) );
4677 
4678  if ( mbg_rc_is_error( rc ) )
4679  {
4680  // Do not continue with reception after character timeout
4681  // if ( rc == MBG_ERR_TIMEOUT ) // just a character timeout
4682  // continue; // continue loop to check message timeout
4683 
4684  goto out; // non-timeout error: fatal, quit
4685  }
4686 
4687  // rc contains number of received bytes
4688  n_bytes = rc;
4689 
4690  } break;
4691  #endif // _USE_SERIAL_IO
4692 
4693  #if _USE_SERIAL_IO_FTDI
4695  {
4696  DWORD bytes_read;
4697  FT_STATUS status;
4698 
4699  //### TODO pmctl->dev_poll_timeout
4700  status = FT_Read( pmctl->st.ftdi.port_handle, &buff[0],
4701  sizeof( buff[0] ), &bytes_read );
4702 
4703  if ( status != FT_OK )
4704  {
4705  rc = mbg_ftdi_ft_status_to_mbg( status );
4706  goto out;
4707  }
4708 
4709  n_bytes = bytes_read;
4710 
4711  } break;
4712  #endif // _USE_SERIAL_IO_FTDI
4713 
4714  #if _USE_USB_IO
4715  case MBG_CONN_TYPE_USB:
4716  {
4717  rc = mbgusbio_read( &pmctl->st.usbio, (uint8_t *) buff, sizeof( buff ) );
4718 
4719  if ( mbg_rc_is_error( rc ) )
4720  {
4721  if ( rc == MBG_ERR_TIMEOUT ) // just a character timeout
4722  continue; // continue loop to check message timeout
4723 
4724  goto out; // non-timeout error: fatal, quit
4725  }
4726 
4727  // rc contains number of received bytes
4728  n_bytes = rc;
4729 
4730  } break;
4731  #endif // _USE_USB_IO
4732 
4733  #if _USE_USB_DIRECT_IO
4735  {
4736  struct pollfd pfd;
4737 
4738  pfd.fd = pmctl->st.usbdio.usbdiofd;
4739  pfd.events = POLLIN | POLLRDNORM | POLLRDBAND;
4740  pfd.revents = 0;
4741 
4742  rc = poll( &pfd, 1, pmctl->st.usbdio.poll_timeout );
4743 
4744  if ( rc == 0 ) // timeout
4745  {
4746  rc = MBG_ERR_TIMEOUT;
4747  goto out;
4748  }
4749 
4750  if ( rc < 0 ) // error
4751  {
4752  rc = mbg_get_last_error( "failed to poll direct USB I/O" );
4753  goto out;
4754  }
4755 
4756  if ( pfd.revents & POLLHUP )
4757  {
4758  rc = MBG_ERR_DISCONN;
4759  goto out;
4760  }
4761 
4762  // Other stuff?
4763  if ( pfd.revents & ( POLLERR | POLLNVAL ) )
4764  {
4765  rc = MBG_ERR_UNSPEC;
4766  goto out;
4767  }
4768 
4769  // Read data?
4770  if ( pfd.revents & ( POLLIN | POLLRDNORM | POLLRDBAND ) )
4771  {
4772  rc = read( pmctl->st.usbdio.usbdiofd, (void*)buff, sizeof(buff) );
4773 
4774  if ( rc < 0 )
4775  {
4776  rc = mbg_get_last_error( "failed to read direct USB I/O" );
4777  goto out;
4778  }
4779 
4780  n_bytes = rc;
4781  }
4782 
4783  } break;
4784  #endif
4785 
4786  default:
4787  rc = MBG_ERR_CONN_TYPE;
4788  goto out;
4789 
4790  } // switch
4791 
4792  prctl = &pmctl->rcv;
4793  pmb = prctl->pmb;
4794 
4795  for ( i = 0; i < n_bytes; i++ )
4796  {
4797  char c = buff[i];
4798 
4799  // Check if the new char belongs to binary message.
4800  rc = check_transfer( prctl, c );
4801 
4802  switch ( rc )
4803  {
4804  case TR_WAITING:
4805  // We are waiting for a binary message, but have just received
4806  // some non-protocol data.
4807  // If an async data handler callback function has been registered
4808  // via ::mbgextio_register_async_data_callback then we call that function
4809  // so it can eventually evaluate this data, otherwise it gets lost.
4810  if ( pmctl->async_data_handler_fnc )
4811  pmctl->async_data_handler_fnc( pmctl, c );
4812 
4813  continue;
4814 
4815  case TR_RECEIVING:
4816  // Data transfer sequence is in progress, keep waiting.
4817  continue;
4818 
4819  case TR_COMPLETE:
4820  {
4821  GPS_CMD rcvd_cmd;
4822 
4823  // A valid binary message has been received.
4824  // Eventually we want to discard any partial async
4825  // data that possibly has been received before, and
4826  // re-initialize async data reception.
4827  if ( pmctl->async_data_reset_fnc )
4828  pmctl->async_data_reset_fnc( pmctl );
4829 
4830  rcvd_cmd = pmb->hdr.cmd & ~GPS_CTRL_MSK;
4831 
4832  if ( ( rcvd_cmd == GPS_XBP_PACKET ) && p_addr )
4833  {
4834  if ( memcmp( &pmb->u.xbp_msg_data.xbp_addr, p_addr, sizeof( *p_addr ) ) == 0 )
4835  {
4836  // This packet is from the expected XBP node.
4837  mbg_memcpy( pmb, &pmb->u.xbp_msg_data.std_msg, sizeof( pmb->u.xbp_msg_data.std_msg ) );
4838  rcvd_cmd = pmb->hdr.cmd & ~GPS_CTRL_MSK;
4839  }
4840  }
4841 
4842  if ( rcvd_cmd == cmd )
4843  {
4844  // The received message is the one we've been waiting for.
4845  rc = msg_return_code( pmctl );
4846  goto out;
4847  }
4848 
4849  #if _USE_ENCRYPTION
4850  // If an encrypted packet has been received then decrypt it.
4851  if ( !pmctl->st.sockio.use_ssh && ( rcvd_cmd == GPS_CRYPTED_PACKET ) )
4852  {
4853  rc = decrypt_message( pmctl );
4854 
4855  if ( rc < 0 ) /* decryption error */
4856  goto out;
4857 
4858  rcvd_cmd = pmb->hdr.cmd & ~GPS_CTRL_MSK;
4859 
4860  if ( ( rcvd_cmd == GPS_XBP_PACKET ) && p_addr )
4861  {
4862  if ( memcmp( &pmb->u.xbp_msg_data.xbp_addr, p_addr, sizeof( *p_addr ) ) == 0 )
4863  {
4864  // This packet is from the expected XBP node.
4865  mbg_memcpy( pmb, &pmb->u.xbp_msg_data.std_msg, sizeof( pmb->u.xbp_msg_data.std_msg ) );
4866  rcvd_cmd = pmb->hdr.cmd & ~GPS_CTRL_MSK;
4867  }
4868  }
4869 
4870  if ( rcvd_cmd == cmd )
4871  {
4872  // The received message is the one we've been waiting for.
4873  rc = msg_return_code( pmctl );
4874  goto out;
4875  }
4876  }
4877  #endif
4878 
4879  // Not waiting for a specific message, so return any message that is complete.
4880  if ( cmd == GPS_WILDCARD )
4881  {
4882  rc = MBG_SUCCESS;
4883  goto out;
4884  }
4885 
4886  // We are waiting for a specific message, but have just received
4887  // a message which does not match the expected code.
4888  // If an async message handler callback function has been registered
4889  // via ::mbgextio_register_async_msg_callback then we call that function
4890  // so it can eventually evaluate the message, and the message doesn't
4891  // get lost. Otherwise the message is simply dropped.
4892  // See ::mbgextio_register_async_msg_callback.
4893  if ( pmctl->async_msg_handler_fnc )
4894  pmctl->async_msg_handler_fnc( pmctl );
4895 
4896  init_transfer( prctl ); // restart receiving
4897  }
4898  break;
4899 
4900  case TR_CSUM_HDR:
4901  rc = MBG_ERR_HDR_CSUM;
4902  goto out;
4903 
4904  case TR_CSUM_DATA:
4905  rc = MBG_ERR_DATA_CSUM;
4906  goto out;
4907 
4908  case TR_OVERFLOW:
4909  rc = MBG_ERR_OVERFLOW;
4910  goto out;
4911 
4912  default: /* any error condition */
4913  rc = MBG_ERR_UNSPEC; //##+++++++++++++++++++++ use detailed rc
4914  goto out;
4915 
4916  } /* switch */
4917  }
4918  }
4919 
4920 out:
4921  if ( mbg_rc_is_error( rc ) )
4922  goto out2; //### TODO
4923 
4924  // Successfully received a binary message. If a destinaton buffer
4925  // has been specified then we copy the received data to that buffer
4926  // *before* the device mutex is released, so we can be sure the
4927  // received data isn't overwritten by a different thread.
4928  if ( buf )
4929  {
4930  MBG_MSG_BUFF *pmb = pmctl->rcv.pmb;
4931 
4932  if ( buf_size != pmb->hdr.len )
4933  {
4934  #if defined( DEBUG )
4935  const char *cp = mbgextio_get_cmd_name( cmd );
4936 
4937  fprintf( stderr, "received data size (%u) doesn't match buffer size (%llu) for cmd: %s\n",
4938  pmb->hdr.len, (unsigned long long) buf_size, cp ? cp : "(unknown)" );
4939  #endif
4940 
4941  rc = MBG_ERR_DATA_SIZE;
4942  goto out2;
4943  }
4944 
4945  memcpy( buf, &pmb->u.msg_data, buf_size );
4946  }
4947 
4948 out2:
4949  return rc;
4950 
4951 } // mbgextio_rcv_msg_unlocked
4952 
4953 
4954 
4955 /*HDR*/
4982  GPS_CMD cmd, void *buf, size_t buf_size )
4983 {
4984  int rc;
4985 
4986  #if _USE_MUTEX
4987  _mbg_mutex_acquire( &pmctl->dev_mutex );
4988  #endif
4989 
4990  rc = mbgextio_rcv_msg_unlocked( pmctl, p_addr, cmd, buf, buf_size ); // wait for a message
4991 
4992  #if _USE_MUTEX
4993  _mbg_mutex_release( &pmctl->dev_mutex );
4994  #endif
4995 
4996  return rc;
4997 
4998 } // mbgextio_rcv_msg
4999 
5000 
5001 
5002 static /*HDR*/
5004  GPS_CMD cmd )
5005 {
5006  int rc = MBG_SUCCESS;
5007 
5008  // Simply return if no acknowledge has been requested
5009  if ( !( cmd & GPS_REQACK ) )
5010  goto out;
5011 
5012  rc = mbgextio_rcv_msg_unlocked( pmctl, p_addr, (GPS_CMD) ( cmd & ~GPS_CTRL_MSK ), NULL, 0 );
5013 
5014  if ( mbg_rc_is_error( rc ) )
5015  goto out;
5016 
5017  if ( pmctl->rcv.pmb->hdr.cmd & GPS_NACK )
5018  {
5019  rc = MBG_ERR_RCVD_NACK;
5020  goto out;
5021  }
5022 
5023  if ( !( pmctl->rcv.pmb->hdr.cmd & GPS_ACK ) )
5024  rc = MBG_ERR_RCVD_NO_ACK;
5025 
5026 out:
5027  return rc;
5028 
5029 } // mbgextio_check_ack
5030 
5031 
5032 
5033 /*HDR*/
5059  GPS_CMD cmd, const void *p, uint16_t n_bytes )
5060 {
5061  MBG_MSG_BUFF *pmb;
5062  int rc = MBG_ERR_UNSPEC;
5063 
5064  if ( n_bytes > sizeof( pmb->u.msg_data ) )
5065  {
5066  rc = MBG_ERR_OVERFLOW; // bytes to send exceed transmit buffer size
5067 
5068  // If p is not NULL then the transmit mutex has not yet
5069  // been acquired, and thus we can exit immediately.
5070  if ( p )
5071  goto out;
5072 
5073  // Otherwise we have to release the mutex before we exit.
5074  goto out_release;
5075  }
5076 
5077 
5078  pmb = pmctl->xmt.pmb;
5079 
5080  // If the buffer pointer p is NULL then we assume the transmit buffer
5081  // has already been set up by the caller, and thus the caller has already
5082  // acquired the device mutex.
5083  // However, if a data buffer has been specified (i.e., p != NULL)
5084  // then we have to acquire the device mutex before we start to
5085  // set up the transmit buffer.
5086  if ( p )
5087  {
5088  #if _USE_MUTEX
5089  _mbg_mutex_acquire( &pmctl->dev_mutex );
5090  #endif
5091  memcpy( pmb->u.bytes, p, n_bytes );
5092  }
5093 
5094  pmb->hdr.len = n_bytes;
5095  pmb->hdr.cmd = cmd;
5096 
5097  rc = xmt_tbuff( pmctl, p_addr );
5098 
5099  if ( mbg_rc_is_success( rc ) )
5100  rc = mbgextio_check_ack( pmctl, p_addr, cmd );
5101 
5102 out_release:
5103  #if _USE_MUTEX
5104  _mbg_mutex_release( &pmctl->dev_mutex );
5105  #endif
5106 
5107 out:
5108  return rc;
5109 
5110 } // mbgextio_xmt_msg
5111 
5112 
5113 
5114 /*HDR*/
5137  GPS_CMD cmd )
5138 {
5139  int rc;
5140 
5141  #if _USE_MUTEX
5142  _mbg_mutex_acquire( &pmctl->dev_mutex );
5143  #endif
5144 
5145  rc = xmt_cmd( pmctl, p_addr, cmd );
5146 
5147  // If the call above succeeded then this just means there
5148  // was no transmission error. It does *not* necessarily mean
5149  // the command has been received and understood by the device.
5150  // So if the cmd code has been or'ed with a flag requesting
5151  // an acknowledge then we wait for an ack msg from the device now.
5152  if ( mbg_rc_is_success( rc ) )
5153  rc = mbgextio_check_ack( pmctl, p_addr, cmd );
5154 
5155  #if _USE_MUTEX
5156  _mbg_mutex_release( &pmctl->dev_mutex );
5157  #endif
5158 
5159  return rc;
5160 
5161 } // mbgextio_xmt_cmd
5162 
5163 
5164 
5165 /*HDR*/
5189  GPS_CMD cmd, uint16_t us )
5190 {
5191  int rc;
5192 
5193  #if _USE_MUTEX
5194  _mbg_mutex_acquire( &pmctl->dev_mutex );
5195  #endif
5196 
5197  rc = xmt_cmd_us( pmctl, p_addr, cmd, us );
5198 
5199  if ( mbg_rc_is_success( rc ) )
5200  rc = mbgextio_check_ack( pmctl, p_addr, cmd );
5201 
5202  #if _USE_MUTEX
5203  _mbg_mutex_release( &pmctl->dev_mutex );
5204  #endif
5205 
5206  return rc;
5207 
5208 } // mbgextio_xmt_cmd_us
5209 
5210 
5211 
5212 /*HDR*/
5236  GPS_CMD cmd, uint32_t u32 )
5237 {
5238  int rc;
5239 
5240  #if _USE_MUTEX
5241  _mbg_mutex_acquire( &pmctl->dev_mutex );
5242  #endif
5243 
5244  rc = xmt_cmd_u32( pmctl, p_addr, cmd, u32 );
5245 
5246  if ( mbg_rc_is_success( rc ) )
5247  rc = mbgextio_check_ack( pmctl, p_addr, cmd );
5248 
5249  #if _USE_MUTEX
5250  _mbg_mutex_release( &pmctl->dev_mutex );
5251  #endif
5252 
5253  return rc;
5254 
5255 } // mbgextio_xmt_cmd_u32
5256 
5257 
5258 
5259 /*HDR*/
5281  GPS_CMD cmd, void *buf, size_t buf_size )
5282 {
5283  int rc;
5284 
5285  #if _USE_MUTEX
5286  _mbg_mutex_acquire( &pmctl->dev_mutex );
5287  #endif
5288 
5289  rc = xmt_cmd( pmctl, p_addr, cmd ); // request data
5290 
5291  if ( mbg_rc_is_success( rc ) )
5292  rc = mbgextio_rcv_msg_unlocked( pmctl, p_addr, cmd, buf, buf_size ); // wait for the reply
5293 
5294  #if _USE_MUTEX
5295  _mbg_mutex_release( &pmctl->dev_mutex );
5296  #endif
5297 
5298  return rc;
5299 
5300 } // mbgextio_req_data
5301 
5302 
5303 
5304 /*HDR*/
5330  GPS_CMD cmd, uint16_t idx, void *buf, size_t buf_size )
5331 {
5332  int rc;
5333 
5334  rc = xmt_cmd_us( pmctl, p_addr, cmd, idx ); // request data
5335 
5336  if ( mbg_rc_is_success( rc ) )
5337  rc = mbgextio_rcv_msg_unlocked( pmctl, p_addr, cmd, buf, buf_size ); // wait for the reply
5338 
5339  return rc;
5340 
5341 } // mbgextio_req_data_idx_unlocked
5342 
5343 
5344 
5345 /*HDR*/
5369  GPS_CMD cmd, uint16_t idx, void *buf, size_t buf_size )
5370 {
5371  int rc;
5372 
5373  #if _USE_MUTEX
5374  _mbg_mutex_acquire( &pmctl->dev_mutex );
5375  #endif
5376 
5377  rc = mbgextio_req_data_idx_unlocked( pmctl, p_addr, cmd, idx, buf, buf_size );
5378 
5379  #if _USE_MUTEX
5380  _mbg_mutex_release( &pmctl->dev_mutex );
5381  #endif
5382 
5383  return rc;
5384 
5385 } // mbgextio_req_data_idx
5386 
5387 
5388 
5389 /*HDR*/
5411  const XBP_ADDR *p_addr, RECEIVER_INFO *p )
5412 {
5413  int rc = mbgextio_req_data( pmctl, p_addr, GPS_RECEIVER_INFO, p, sizeof( *p ) );
5414 
5415  if ( mbg_rc_is_success( rc ) && p )
5417 
5418  return rc;
5419 
5420 } // mbgextio_get_receiver_info
5421 
5422 
5423 
5424 /*HDR*/
5440  const XBP_ADDR *p_addr,
5441  MBG_IO_PORT_LIMITS *p )
5442 {
5444 
5445  if ( mbg_rc_is_error( rc ) )
5446  return rc;
5447 
5448  rc = mbgextio_req_data( pmctl, p_addr, GPS_IO_PORT_LIMITS, p, sizeof( *p ) );
5449 
5450  if ( mbg_rc_is_success( rc ) )
5451  /* There is nothing to swaP */
5453 
5454  return rc;
5455 
5456 } // mbgextio_get_io_port_limits
5457 
5458 
5459 
5460 /*HDR*/
5477  const XBP_ADDR *p_addr,
5478  const MBG_IO_PORT_SETTINGS *p,
5479  uint8_t idx )
5480 {
5484  int rc;
5485 
5487  if ( mbg_rc_is_error( rc ) )
5488  return rc;
5489 
5490  #if _USE_MUTEX
5491  _mbg_mutex_acquire( &pmctl->dev_mutex );
5492  #endif
5493 
5494  p_data->settings = *p;
5495  p_data->idx = idx;
5496 
5497  _mbg_swab_io_port_settings_idx( p_data, 0 );
5498 
5499  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizes[p->port_type] );
5500  return rc;
5501 
5502 } // mbgextio_set_io_port_settings_idx
5503 
5504 
5505 
5506 /*HDR*/
5523  const XBP_ADDR *p_addr,
5525  uint8_t idx )
5526 {
5527  size_t len;
5529  MBG_IO_PORT_INFO_IDX *iopi_idx = &rbuf->u.msg_data.iop_info_idx;
5531 
5532  if ( mbg_rc_is_error( rc ) )
5533  return rc;
5534 
5535  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_IO_PORT_INFO_IDX, idx, NULL, 0 );
5536  if ( mbg_rc_is_error( rc ) )
5537  return rc;
5538 
5539  /* Check if at least header part is avail */
5541  return MBG_ERR_NBYTES;
5542 
5543  _mbg_swab_io_port_info_idx( iopi_idx, 1 );
5544 
5545  len = sizeof(*p);
5546  if (len > rbuf->hdr.len)
5547  len = rbuf->hdr.len;
5548 
5549  memcpy(p, &rbuf->u.msg_data, len);
5550 
5551  return MBG_SUCCESS;
5552 
5553 } // mbgextio_get_io_port_info_idx
5554 
5555 
5556 
5557 /*HDR*/
5575  const XBP_ADDR *p_addr,
5577  uint8_t port_idx, uint8_t port_type_idx)
5578 {
5579  size_t len;
5580  uint16_t idx = ((port_idx << 8) | port_type_idx);
5584 
5585  if ( mbg_rc_is_error( rc ) )
5586  return rc;
5587 
5588  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_IO_PORT_TYPE_INFO_IDX, idx, NULL, 0 );
5589  if ( mbg_rc_is_error( rc ) )
5590  return rc;
5591 
5592  /* Check if at least header part is avail */
5594  return MBG_ERR_NBYTES;
5595 
5596  _mbg_swab_io_port_type_info_idx( iopti_idx, 1 );
5597 
5598  len = sizeof(*p);
5599  if (len > rbuf->hdr.len)
5600  len = rbuf->hdr.len;
5601 
5602  memcpy(p, &rbuf->u.msg_data, len);
5603 
5604  return MBG_SUCCESS;
5605 
5606 } // mbgextio_get_io_port_type_info_idx
5607 
5608 
5609 
5610 /*HDR*/
5627  const XBP_ADDR *p_addr,
5629  uint8_t idx)
5630 {
5632 
5633  if ( mbg_rc_is_error( rc ) )
5634  return rc;
5635 
5636  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_IO_PORT_STATUS_IDX, idx, p, sizeof( *p ) );
5637 
5638  if ( mbg_rc_is_success( rc ) && p )
5640 
5641  return rc;
5642 
5643 } // mbgextio_get_io_port_status_idx
5644 
5645 
5646 /*HDR*/
5658  const XBP_ADDR *p_addr,
5659  MBG_CLK_RES_INFO *p )
5660 {
5661  int rc = mbgextio_req_data( pmctl, p_addr, GPS_CLK_RES_INFO, p, sizeof( *p ) );
5662 
5663  if ( mbg_rc_is_success( rc ) )
5665 
5666  return rc;
5667 
5668 } // mbgextio_get_clk_res_info
5669 
5670 
5671 
5672 
5673 static /*HDR*/
5674 int chk_get_rcvr_info( MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr,
5675  RECEIVER_INFO *p )
5676 {
5677  #if DEBUG_INIT_CONN
5678  static int cnt;
5679  #endif
5680 
5681  // Try to read the RECEIVER_INFO structure from the device
5682  int rc = mbgextio_get_receiver_info( pmctl, p_addr, p );
5683 
5684  #if DEBUG_INIT_CONN
5685  printf( "get rcvr info %i: %i\n", ++cnt, rc );
5686  #endif
5687 
5688  if ( mbg_rc_is_success( rc ) )
5689  pmctl->dev_has_receiver_info = true;
5690 
5691  return rc;
5692 
5693 } // chk_get_rcvr_info
5694 
5695 
5696 
5697 /*HDR*/
5717  const XBP_ADDR *p_addr, RECEIVER_INFO *p )
5718 {
5719  int rc;
5720 
5721  #if _USE_USB_IO
5722  // If the device is a legacy USB device then it only supports a
5723  // proprietary protocol instead of the standard binary protocol.
5724  // We try to find this out based on the USB vendor and device IDs,
5725  // and we need to check this *before* we try to read a RECEIVER_INFO
5726  // structure from the device.
5727  // See also ::mbgextio_dev_is_legacy
5728  if ( pmctl->conn_type == MBG_CONN_TYPE_USB )
5729  {
5731  rc = check_setup_legacy_usb_device(&pmctl->st.usbio.mdev_info, p_ri );
5732 
5733  if ( mbg_rc_is_success( rc ) )
5734  {
5735  // A legacy device was detected, and an appropriate RECEIVER_INFO
5736  // for this device has been set up.
5738  goto out;
5739  }
5740  }
5741  #endif // _USE_USB_IO
5742 
5743  // Try to read the RECEIVER_INFO structure from the device
5744  rc = chk_get_rcvr_info( pmctl, p_addr, p );
5745 
5746  if ( mbg_rc_is_success( rc ) )
5747  goto out; // RECEIVER_INFO was read successfully
5748 
5749  // Failed, but eventually some synchronization is required,
5750  // e.g. if the baud rate was just changed, so retry once.
5751  rc = chk_get_rcvr_info( pmctl, p_addr, p );
5752 
5753  if ( mbg_rc_is_success( rc ) )
5754  goto out; // RECEIVER_INFO was read successfully from the device.
5755 
5756  // In all error cases except MBG_ERR_TIMEOUT we return with error anyway.
5757  if ( rc != MBG_ERR_TIMEOUT )
5758  goto out;
5759 
5760 
5761  // There are a few very old devices which support the binary protocol but
5762  // don't support reading a RECEIVER_INFO, so we check if we can set up
5763  // a default structure, depending on a device type.
5764  //
5765  // Affected devices, at least:
5766  // GPS166 (all versions)
5767  // GPS167PC (all versions)
5768  // GPS167PCI < 4.22
5769  // GPS167 < 4.17
5770  // GPS167SV < 4.17
5771  {
5772  SW_REV sw_rev = { 0 };
5773  IDENT ident = { { 0 } };
5774 
5775  rc = mbgextio_get_sw_rev( pmctl, p_addr, &sw_rev );
5776 
5777  if ( mbg_rc_is_error( rc ) ) // Failed to read SW revision, so
5778  goto out; // probably no device connected.
5779 
5780  // set up a default receiver info structure
5782 
5783  // set up some generic device name
5786 
5787  // copy the software revision info we have read from the device
5788  p->sw_rev = sw_rev;
5789  trim_whitespace( p->sw_rev.name );
5790 
5791  #if _USE_MUTEX
5792  _mbg_mutex_acquire( &pmctl->dev_mutex );
5793  #endif
5794 
5795  xmt_cmd( pmctl, p_addr, 0x400 );
5796  xmt_cmd( pmctl, p_addr, 0x20F );
5797  xmt_cmd( pmctl, p_addr, 0x001 );
5798  rc = mbgextio_rcv_msg_unlocked( pmctl, p_addr, 0x20F, &ident, sizeof( ident ) );
5799 
5800  #if _USE_MUTEX
5801  _mbg_mutex_release( &pmctl->dev_mutex );
5802  #endif
5803 
5804  if ( mbg_rc_is_success( rc ) )
5805  {
5806  // Unfortunately there are older devices and firmware versions out there
5807  // where the serial number is saved word-wise, and others where it is
5808  // saved byte-wise, so it can be really tricky to get it right.
5809  // If we want to giver it a try we need to add some other library modules
5810  #if _TRY_IDENT_DECODE
5811  mbg_gps_ident_decode( p->sernum, &ident );
5812  #else
5813  sn_cpy_str_safe( p->sernum, sizeof( p->sernum ), ident.c );
5814  #endif
5815  }
5816 
5817  // Return successful in any case since we could
5818  // at least read the SW_REV structure.
5819  rc = MBG_SUCCESS;
5820  }
5821 
5822 out:
5823  return rc;
5824 
5825 } // mbgextio_setup_receiver_info
5826 
5827 
5828 
5829 /*HDR*/
5846  const XBP_ADDR *p_addr, SW_REV *p )
5847 {
5848  int rc = mbgextio_req_data( pmctl, p_addr, GPS_SW_REV, p, sizeof( *p ) );
5849 
5850  if ( mbg_rc_is_success( rc ) && p )
5851  _mbg_swab_sw_rev( p );
5852 
5853  return rc;
5854 
5855 } // mbgextio_get_sw_rev
5856 
5857 
5858 
5859 /*HDR*/
5874 {
5876  if ( mbg_rc_is_error( rc ) )
5877  return rc;
5878 
5879  rc = mbgextio_req_data( pmctl, p_addr, GPS_IGNORE_LOCK, p, sizeof( *p ) );
5880 
5881  if ( mbg_rc_is_success( rc ) && p )
5882  _mbg_swab16( p );
5883 
5884  return rc;
5885 
5886 } // mbgextio_get_ignore_lock
5887 
5888 
5889 
5890 /*HDR*/
5905 {
5907  IGNORE_LOCK *p_data = &pmctl->xmt.pmb->u.msg_data.ignore_lock;
5909 
5910  if ( mbg_rc_is_error( rc ) )
5911  return rc;
5912 
5913  #if _USE_MUTEX
5914  _mbg_mutex_acquire( &pmctl->dev_mutex );
5915  #endif
5916 
5917  *p_data = *p;
5918  _mbg_swab16( p_data );
5919 
5920  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
5921  return rc;
5922 
5923 } // mbgextio_set_ignore_lock
5924 
5925 
5926 
5927 /*HDR*/
5940  const XBP_ADDR *p_addr, BVAR_STAT *p )
5941 {
5942  int rc = mbgextio_req_data( pmctl, p_addr, GPS_BVAR_STAT, p, sizeof( *p ) );
5943 
5944  if ( mbg_rc_is_success( rc ) && p )
5945  _mbg_swab_bvar_stat( p );
5946 
5947  return rc;
5948 
5949 } // mbgextio_get_bvar_stat
5950 
5951 
5952 
5953 /*HDR*/
5971 {
5973 
5974  if ( mbg_rc_is_error( rc ) )
5975  return rc;
5976 
5977  rc = mbgextio_req_data( pmctl, p_addr, GPS_TIME, p, sizeof( *p ) );
5978 
5979  if ( mbg_rc_is_success( rc ) && p )
5980  _mbg_swab_ttm( p );
5981 
5982  return rc;
5983 
5984 } // mbgextio_get_time
5985 
5986 
5987 
5988 /*HDR*/
6003  const XBP_ADDR *p_addr, const TTM *p )
6004 {
6006  TTM *p_data = &pmctl->xmt.pmb->u.msg_data.ttm;
6008 
6009  if ( mbg_rc_is_error( rc ) )
6010  return rc;
6011 
6012  #if _USE_MUTEX
6013  _mbg_mutex_acquire( &pmctl->dev_mutex );
6014  #endif
6015 
6016  *p_data = *p;
6017  _mbg_swab_ttm( p_data );
6018 
6019  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
6020  return rc;
6021 
6022 } // mbgextio_set_time
6023 
6024 
6025 
6026 /*HDR*/
6039  const XBP_ADDR *p_addr, const LLA lla )
6040 {
6042  double *p_lla = pmctl->xmt.pmb->u.msg_data.lla;
6043  int i, rc;
6044 
6046 
6047  if ( mbg_rc_is_error( rc ) )
6048  return rc;
6049 
6050  #if _USE_MUTEX
6051  _mbg_mutex_acquire( &pmctl->dev_mutex );
6052  #endif
6053 
6054  for ( i = 0; i < N_LLA; i++ )
6055  {
6056  p_lla[i] = lla[i];
6057  swap_double( &p_lla[i] );
6058  _mbg_swab_double( &p_lla[i] );
6059  }
6060 
6061  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( LLA ) );
6062  return rc;
6063 
6064 } // mbgextio_set_pos_lla
6065 
6066 
6067 
6068 /*HDR*/
6081  const XBP_ADDR *p_addr, LLA lla )
6082 {
6084 
6085  if ( mbg_rc_is_error( rc ) )
6086  return rc;
6087 
6088  rc = mbgextio_req_data( pmctl, p_addr, GPS_POS_LLA, lla, sizeof( LLA ) );
6089 
6090  if ( mbg_rc_is_success( rc ) && lla )
6091  {
6092  int i;
6093 
6094  for ( i = 0; i < N_LLA; i++ )
6095  swap_double( &lla[i] );
6096  }
6097 
6098  return rc;
6099 
6100 } // mbgextio_get_pos_lla
6101 
6102 
6103 
6104 /*HDR*/
6117  const XBP_ADDR *p_addr, XYZ xyz )
6118 {
6120 
6121  if ( mbg_rc_is_error( rc ) )
6122  return rc;
6123 
6124  rc = mbgextio_req_data( pmctl, p_addr, GPS_POS_XYZ, xyz, sizeof( XYZ ) );
6125 
6126  if ( mbg_rc_is_success( rc ) && xyz )
6127  {
6128  int i;
6129 
6130  for ( i = 0; i < N_XYZ; i++ )
6131  swap_double( &xyz[i] );
6132  }
6133 
6134  return rc;
6135 
6136 } // mbgextio_get_pos_xyz
6137 
6138 
6139 
6140 /*HDR*/
6153  const XBP_ADDR *p_addr, POS *p_pos )
6154 {
6156 
6157  if ( mbg_rc_is_error( rc ) )
6158  return rc;
6159 
6160  rc = mbgextio_get_pos_xyz( pmctl, p_addr, p_pos->xyz );
6161 
6162  if ( mbg_rc_is_error( rc ) )
6163  goto out;
6164 
6165  rc = mbgextio_get_pos_lla( pmctl, p_addr, p_pos->lla );
6166 
6167  if ( mbg_rc_is_error( rc ) )
6168  goto out;
6169 
6170  lla_to_dms( p_pos );
6171 
6172 out:
6173  return rc;
6174 
6175 } // mbgextio_get_pos
6176 
6177 
6178 
6179 /*HDR*/
6192  const XBP_ADDR *p_addr, TZDL *p )
6193 {
6195 
6196  if ( mbg_rc_is_error( rc ) )
6197  return rc;
6198 
6199  rc = mbgextio_req_data( pmctl, p_addr, GPS_TZDL, p, sizeof( *p ) );
6200 
6201  if ( mbg_rc_is_success( rc ) && p )
6202  _mbg_swab_tzdl( p );
6203 
6204  return rc;
6205 
6206 } // mbgextio_get_tzdl
6207 
6208 
6209 
6210 /*HDR*/
6223  const XBP_ADDR *p_addr, const TZDL *p )
6224 {
6226  TZDL *p_data = &pmctl->xmt.pmb->u.msg_data.tzdl;
6228 
6229  if ( mbg_rc_is_error( rc ) )
6230  return rc;
6231 
6232  #if _USE_MUTEX
6233  _mbg_mutex_acquire( &pmctl->dev_mutex );
6234  #endif
6235 
6236  *p_data = *p;
6237  _mbg_swab_tzdl( p_data );
6238 
6239  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
6240  return rc;
6241 
6242 } // mbgextio_set_tzdl
6243 
6244 
6245 
6246 /*HDR*/
6267  const XBP_ADDR *p_addr, PORT_PARM *p )
6268 {
6269  int rc = mbgextio_req_data( pmctl, p_addr, GPS_PORT_PARM, p, sizeof( *p ) );
6270 
6271  if ( mbg_rc_is_success( rc ) && p )
6272  _mbg_swab_port_parm( p );
6273 
6274  return rc;
6275 
6276 } // mbgextio_get_port_parm
6277 
6278 
6279 
6280 /*HDR*/
6301  const XBP_ADDR *p_addr, const PORT_PARM *p )
6302 {
6304  PORT_PARM *p_data = &pmctl->xmt.pmb->u.msg_data.port_parm;
6305 
6306  #if _USE_MUTEX
6307  _mbg_mutex_acquire( &pmctl->dev_mutex );
6308  #endif
6309 
6310  *p_data = *p;
6311  _mbg_swab_port_parm( p_data );
6312 
6313  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
6314 
6315 } // mbgextio_set_port_parm
6316 
6317 
6318 
6319 /*HDR*/
6334  const XBP_ADDR *p_addr, SYNTH *p )
6335 {
6337 
6338  if ( mbg_rc_is_error( rc ) )
6339  return rc;
6340 
6341  rc = mbgextio_req_data( pmctl, p_addr, GPS_SYNTH, p, sizeof( *p ) );
6342 
6343  if ( mbg_rc_is_success( rc ) && p )
6344  _mbg_swab_synth( p );
6345 
6346  return rc;
6347 
6348 } // mbgextio_get_synth
6349 
6350 
6351 
6352 /*HDR*/
6367  const XBP_ADDR *p_addr, const SYNTH *p )
6368 {
6370  SYNTH *p_data = &pmctl->xmt.pmb->u.msg_data.synth;
6372 
6373  if ( mbg_rc_is_error( rc ) )
6374  return rc;
6375 
6376  #if _USE_MUTEX
6377  _mbg_mutex_acquire( &pmctl->dev_mutex );
6378  #endif
6379 
6380  *p_data = *p;
6381  _mbg_swab_synth( p_data );
6382 
6383  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
6384  return rc;
6385 
6386 } // mbgextio_set_synth
6387 
6388 
6389 
6390 /*HDR*/
6403  const XBP_ADDR *p_addr, ANT_INFO *p )
6404 {
6405  int rc = mbgextio_req_data( pmctl, p_addr, GPS_ANT_INFO, p, sizeof( *p ) );
6406 
6407  if ( mbg_rc_is_success( rc ) && p )
6408  _mbg_swab_ant_info( p );
6409 
6410  return rc;
6411 
6412 } // mbgextio_get_ant_info
6413 
6414 
6415 
6416 /*HDR*/
6429  const XBP_ADDR *p_addr, TTM *p )
6430 {
6432  if ( mbg_rc_is_error( rc ) )
6433  return rc;
6434 
6435  rc = xmt_cmd( pmctl, p_addr, GPS_UCAP ); /* request a set of data */
6436 
6437  if ( mbg_rc_is_error( rc ) )
6438  goto out;
6439 
6440  // Attention: Older firmware versions may reply with GPS_TIME
6441  // messages instead of GPS_UCAP messages, and may not send a reply
6442  // at all if no capture event is available in the on-board FIFO.
6443  for (;;)
6444  {
6445  rc = mbgextio_rcv_msg_unlocked( pmctl, p_addr, -1, NULL, 0 );
6446 
6447  if ( mbg_rc_is_error( rc ) )
6448  goto out;
6449 
6450  if ( pmctl->rcv.pmb->hdr.cmd == GPS_UCAP )
6451  break;
6452 
6453  if ( pmctl->rcv.pmb->hdr.cmd == GPS_TIME )
6454  if ( pmctl->rcv.pmb->hdr.len > 0 )
6455  if ( pmctl->rcv.pmb->u.msg_data.ttm.channel >= 0 )
6456  break;
6457 
6458  if ( pmctl->async_msg_handler_fnc )
6459  pmctl->async_msg_handler_fnc( pmctl );
6460  }
6461 
6462  if ( p )
6463  {
6464  // If the length of the msg header is 0 then the capture buffer
6465  // is empty. This is indicated with 0xFF in the seconds field of
6466  // the GPS time structure.
6467  if ( pmctl->rcv.pmb->hdr.len > 0 )
6468  {
6469  *p = pmctl->rcv.pmb->u.msg_data.ttm;
6470  _mbg_swab_ttm( p );
6471  }
6472  else
6473  _ttm_time_set_unavail( p ); // no capture event available
6474  }
6475 
6476 out:
6477  return rc;
6478 
6479 } // mbgextio_get_ucap
6480 
6481 
6482 
6483 /*HDR*/
6497 {
6499 
6500  if ( mbg_rc_is_error( rc ) )
6501  return rc;
6502 
6503  rc = mbgextio_req_data( pmctl, p_addr, GPS_UCAP_NET_GLB_INFO, p, sizeof( *p ) );
6504 
6505  if ( mbg_rc_is_success( rc ) && p )
6507 
6508  return rc;
6509 
6510 } // mbgextio_get_ucap_net_glb_info
6511 
6512 
6513 
6514 /*HDR*/
6527  const MBG_UCAP_NET_GLB_SETTINGS *p )
6528 {
6532 
6533  if ( mbg_rc_is_error( rc ) )
6534  return rc;
6535 
6536  #if _USE_MUTEX
6537  _mbg_mutex_acquire( &pmctl->dev_mutex );
6538  #endif
6539 
6540  *p_data = *p;
6542 
6543  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
6544  return rc;
6545 
6546 } // mbgextio_set_ucap_net_glb_settings
6547 
6548 
6549 
6550 /*HDR*/
6566 {
6568 
6569  if ( mbg_rc_is_error( rc ) )
6570  return rc;
6571 
6572  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_UCAP_NET_RECV_INFO_IDX, idx, p, sizeof( *p ) );
6573 
6574  if ( mbg_rc_is_success( rc ) && p )
6576 
6577  return rc;
6578 
6579 } // mbgextio_get_ucap_net_recv_info_idx
6580 
6581 
6582 
6583 /*HDR*/
6599 {
6603 
6604  if ( mbg_rc_is_error( rc ) )
6605  return rc;
6606 
6607  #if _USE_MUTEX
6608  _mbg_mutex_acquire( &pmctl->dev_mutex );
6609  #endif
6610 
6611  *p_data = *p;
6612  p_data->idx = idx;
6614 
6615  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
6616  return rc;
6617 
6618 } // mbgextio_set_ucap_net_recv_settings_idx
6619 
6620 
6621 
6622 /*HDR*/
6636 {
6638 
6639  if ( mbg_rc_is_error( rc ) )
6640  return rc;
6641 
6642  rc = mbgextio_req_data( pmctl, p_addr, GPS_USER_MNGMNT_INFO, p, sizeof( *p ) );
6643 
6644  if ( mbg_rc_is_success( rc ) && p )
6646 
6647  return rc;
6648 
6649 } // mbgextio_get_user_mngmnt_info
6650 
6651 
6652 
6653 /*HDR*/
6667  const MBG_USER_MNGMNT_SETTINGS *p )
6668 {
6671  int rc;
6672 
6674  if ( mbg_rc_is_error( rc ) )
6675  return rc;
6676 
6677  #if _USE_MUTEX
6678  _mbg_mutex_acquire( &pmctl->dev_mutex );
6679  #endif
6680 
6681  *p_data = *p;
6683 
6684  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
6685  return rc;
6686 
6687 } // mbgextio_set_user_mngmnt_settings
6688 
6689 
6690 
6691 /*HDR*/
6705  MBG_USER_INFO_IDX *p, uint16_t idx )
6706 {
6708 
6709  if ( mbg_rc_is_error( rc ) )
6710  return rc;
6711 
6712  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_USER_INFO_IDX, idx, p, sizeof( *p ) );
6713 
6714  if ( mbg_rc_is_success( rc ) && p )
6716 
6717  return rc;
6718 
6719 } // mbgextio_get_user_info_idx
6720 
6721 
6722 /*HDR*/
6739  const MBG_USER_SETTINGS *p, uint16_t idx )
6740 {
6743  int rc;
6744 
6746  if ( mbg_rc_is_error( rc ) )
6747  return rc;
6748 
6749  #if _USE_MUTEX
6750  _mbg_mutex_acquire( &pmctl->dev_mutex );
6751  #endif
6752 
6753  p_data->settings = *p;
6754  p_data->idx = idx;
6755  _mbg_swab_user_settings_idx( p_data );
6756 
6757  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
6758  return rc;
6759 
6760 } // mbgextio_set_user_settings_idx
6761 
6762 
6763 /*HDR*/
6777  MBG_USER_INFO_IDX *p, uint16_t idx )
6778 {
6780 
6781  if ( mbg_rc_is_error( rc ) )
6782  return rc;
6783 
6784  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_USER_LEVEL_INFO_IDX, idx, p, sizeof( *p ) );
6785 
6786  if ( mbg_rc_is_success( rc ) && p )
6788 
6789  return rc;
6790 
6791 } // mbgextio_get_user_level_info_idx
6792 
6793 
6794 /*HDR*/
6811  const MBG_USER_SETTINGS *p, uint16_t idx )
6812 {
6815  int rc;
6816 
6818  if ( mbg_rc_is_error( rc ) )
6819  return rc;
6820 
6821  #if _USE_MUTEX
6822  _mbg_mutex_acquire( &pmctl->dev_mutex );
6823  #endif
6824 
6825  p_data->settings = *p;
6826  p_data->idx = idx;
6827  _mbg_swab_user_settings_idx( p_data );
6828 
6829  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
6830  return rc;
6831 
6832 } // mbgextio_set_user_level_settings_idx
6833 
6834 
6835 /*HDR*/
6849  MBG_USER_STATUS_IDX *p, uint16_t idx )
6850 {
6852 
6853  if ( mbg_rc_is_error( rc ) )
6854  return rc;
6855 
6856  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_USER_STATUS_IDX, idx, p, sizeof( *p ) );
6857 
6858  if ( mbg_rc_is_success( rc ) && p )
6860 
6861  return rc;
6862 
6863 } // mbgextio_get_user_status_idx
6864 
6865 
6866 
6867 /*HDR*/
6882  const XBP_ADDR *p_addr, ENABLE_FLAGS *p )
6883 {
6885 
6886  if ( mbg_rc_is_error( rc ) )
6887  return rc;
6888 
6889  rc = mbgextio_req_data( pmctl, p_addr, GPS_ENABLE_FLAGS, p, sizeof( *p ) );
6890 
6891  if ( mbg_rc_is_success( rc ) && p )
6893 
6894  return rc;
6895 
6896 } // mbgextio_get_enable_flags
6897 
6898 
6899 
6900 /*HDR*/
6915  const XBP_ADDR *p_addr, const ENABLE_FLAGS *p )
6916 {
6918  ENABLE_FLAGS *p_data = &pmctl->xmt.pmb->u.msg_data.enable_flags;
6920 
6921  if ( mbg_rc_is_error( rc ) )
6922  return rc;
6923 
6924  #if _USE_MUTEX
6925  _mbg_mutex_acquire( &pmctl->dev_mutex );
6926  #endif
6927 
6928  *p_data = *p;
6929  _mbg_swab_enable_flags( p_data );
6930 
6931  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
6932  return rc;
6933 
6934 } // mbgextio_set_enable_flags
6935 
6936 
6937 
6938 /*HDR*/
6951  const XBP_ADDR *p_addr, STAT_INFO *p )
6952 {
6954 
6955  if ( mbg_rc_is_error( rc ) )
6956  return rc;
6957 
6958  rc = mbgextio_req_data( pmctl, p_addr, GPS_STAT_INFO, p, sizeof( *p ) );
6959 
6960  if ( mbg_rc_is_success( rc ) && p )
6961  _mbg_swab_stat_info( p );
6962 
6963  return rc;
6964 
6965 } // mbgextio_get_gps_stat_info
6966 
6967 
6968 
6969 /*HDR*/
6988  const XBP_ADDR *p_addr, ANT_CABLE_LEN *p )
6989 {
6991 
6992  if ( mbg_rc_is_error( rc ) )
6993  return rc;
6994 
6995  rc = mbgextio_req_data( pmctl, p_addr, GPS_ANT_CABLE_LENGTH, p, sizeof( *p ) );
6996 
6997  if ( mbg_rc_is_success( rc ) && p )
6999 
7000  return rc;
7001 
7002 } // mbgextio_get_ant_cable_len
7003 
7004 
7005 
7006 /*HDR*/
7025  const XBP_ADDR *p_addr, const ANT_CABLE_LEN *p )
7026 {
7028  ANT_CABLE_LEN *p_data = &pmctl->xmt.pmb->u.msg_data.ant_cable_len;
7030 
7031  if ( mbg_rc_is_error( rc ) )
7032  return rc;
7033 
7034  #if _USE_MUTEX
7035  _mbg_mutex_acquire( &pmctl->dev_mutex );
7036  #endif
7037 
7038  *p_data = *p;
7039  _mbg_swab_ant_cable_len( p_data );
7040 
7041  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
7042  return rc;
7043 
7044 } // mbgextio_set_ant_cable_len
7045 
7046 
7047 
7048 /*HDR*/
7063  const XBP_ADDR *p_addr, IRIG_INFO *p )
7064 {
7066 
7067  if ( mbg_rc_is_error( rc ) )
7068  return rc;
7069 
7070  rc = mbgextio_req_data( pmctl, p_addr, GPS_IRIG_TX_INFO, p, sizeof( *p ) );
7071 
7072  if ( mbg_rc_is_success( rc ) && p )
7073  _mbg_swab_irig_info( p );
7074 
7075  return rc;
7076 
7077 } // mbgextio_get_irig_tx_info
7078 
7079 
7080 
7081 /*HDR*/
7096  const XBP_ADDR *p_addr, const IRIG_SETTINGS *p )
7097 {
7099  IRIG_SETTINGS *p_data = &pmctl->xmt.pmb->u.msg_data.irig_tx_settings;
7101 
7102  if ( mbg_rc_is_error( rc ) )
7103  return rc;
7104 
7105  #if _USE_MUTEX
7106  _mbg_mutex_acquire( &pmctl->dev_mutex );
7107  #endif
7108 
7109  *p_data = *p;
7110  _mbg_swab_irig_settings( p_data );
7111 
7112  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
7113  return rc;
7114 
7115 } // mbgextio_set_irig_tx_settings
7116 
7117 
7118 
7119 /*HDR*/
7134  const XBP_ADDR *p_addr, IRIG_INFO *p )
7135 {
7137 
7138  if ( mbg_rc_is_error( rc ) )
7139  return rc;
7140 
7141  rc = mbgextio_req_data( pmctl, p_addr, GPS_IRIG_RX_INFO, p, sizeof( *p ) );
7142 
7143  if ( mbg_rc_is_success( rc ) && p )
7144  _mbg_swab_irig_info( p );
7145 
7146  return rc;
7147 
7148 } // mbgextio_get_irig_rx_info
7149 
7150 
7151 
7152 /*HDR*/
7167  const XBP_ADDR *p_addr, const IRIG_SETTINGS *p )
7168 {
7170  IRIG_SETTINGS *p_data = &pmctl->xmt.pmb->u.msg_data.irig_rx_settings;
7172 
7173  if ( mbg_rc_is_error( rc ) )
7174  return rc;
7175 
7176  #if _USE_MUTEX
7177  _mbg_mutex_acquire( &pmctl->dev_mutex );
7178  #endif
7179 
7180  *p_data = *p;
7181  _mbg_swab_irig_settings( p_data );
7182 
7183  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
7184  return rc;
7185 
7186 } // mbgextio_set_irig_rx_settings
7187 
7188 
7189 
7190 /*HDR*/
7211  const XBP_ADDR *p_addr, MBG_RAW_IRIG_DATA *p )
7212 {
7214 
7215  if ( mbg_rc_is_error( rc ) )
7216  return rc;
7217 
7218  rc = mbgextio_req_data( pmctl, p_addr, GPS_RAW_IRIG_DATA, p, sizeof( *p ) );
7219 
7220  if ( mbg_rc_is_success( rc ) && p )
7222 
7223  return rc;
7224 
7225 } // mbgextio_get_raw_irig_data
7226 
7227 
7228 
7229 /*HDR*/
7245  const XBP_ADDR *p_addr, MBG_REF_OFFS *p )
7246 {
7248 
7249  if ( mbg_rc_is_error( rc ) )
7250  return rc;
7251 
7252  rc = mbgextio_req_data( pmctl, p_addr, GPS_REF_OFFS, p, sizeof( *p ) );
7253 
7254  if ( mbg_rc_is_success( rc ) && p )
7256 
7257  return rc;
7258 
7259 } // mbgextio_get_ref_offs
7260 
7261 
7262 
7263 /*HDR*/
7279  const XBP_ADDR *p_addr, const MBG_REF_OFFS *p )
7280 {
7282  MBG_REF_OFFS *p_data = &pmctl->xmt.pmb->u.msg_data.ref_offs;
7284 
7285  if ( mbg_rc_is_error( rc ) )
7286  return rc;
7287 
7288  #if _USE_MUTEX
7289  _mbg_mutex_acquire( &pmctl->dev_mutex );
7290  #endif
7291 
7292  *p_data = *p;
7293  _mbg_swab_mbg_ref_offs( p_data );
7294 
7295  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
7296  return rc;
7297 
7298 } // mbgextio_set_ref_offs
7299 
7300 
7301 
7302 /*HDR*/
7316  const XBP_ADDR *p_addr, MBG_DEBUG_STATUS *p )
7317 {
7318  int rc = mbgextio_req_data( pmctl, p_addr, GPS_DEBUG_STATUS, p, sizeof( *p ) );
7319 
7320  if ( mbg_rc_is_success( rc ) && p )
7322 
7323  return rc;
7324 
7325 } // mbgextio_get_debug_status
7326 
7327 
7328 
7329 /*HDR*/
7344  const XBP_ADDR *p_addr, MBG_OPT_INFO *p )
7345 {
7346  int rc = mbgextio_req_data( pmctl, p_addr, GPS_OPT_INFO, p, sizeof( *p ) );
7347 
7348  if ( mbg_rc_is_success( rc ) && p )
7350 
7351  return rc;
7352 
7353 } // mbgextio_get_opt_info
7354 
7355 
7356 
7357 /*HDR*/
7372  const XBP_ADDR *p_addr, const MBG_OPT_SETTINGS *p )
7373 {
7375  MBG_OPT_SETTINGS *p_data = &pmctl->xmt.pmb->u.msg_data.opt_settings;
7376 
7377  #if _USE_MUTEX
7378  _mbg_mutex_acquire( &pmctl->dev_mutex );
7379  #endif
7380 
7381  *p_data = *p;
7382  _mbg_swab_mbg_opt_settings( p_data );
7383 
7384  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
7385 
7386 } // mbgextio_set_opt_settings
7387 
7388 
7389 
7390 /*HDR*/
7407  const XBP_ADDR *p_addr, STR_TYPE_INFO_IDX *p, uint16_t idx )
7408 {
7410 
7411  if ( mbg_rc_is_error( rc ) )
7412  return rc;
7413 
7414  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_STR_TYPE_INFO_IDX, idx, p, sizeof( *p ) );
7415 
7416  if ( mbg_rc_is_success( rc ) && p )
7417  {
7419 
7420  #if 0 //##++ TODO: check if received idx matches requested idx
7421  if ( pii.idx != i )
7422  {
7423  printf( "** Info for port %i requested, but for %i received.\n",
7424  pii.idx, i );
7425  rc = ...;
7426  }
7427  #endif
7428  }
7429 
7430  return rc;
7431 
7432 } // mbgextio_get_str_type_info_idx
7433 
7434 
7435 
7436 /*HDR*/
7451  const XBP_ADDR *p_addr, STR_TYPE_INFO_IDX stii[] )
7452 {
7454  int n_str_type = p_ri->n_str_type;
7455  uint16_t i;
7456 
7458  if ( mbg_rc_is_error( rc ) )
7459  return rc;
7460 
7461  for ( i = 0; i < n_str_type; i++ )
7462  {
7463  rc = mbgextio_get_str_type_info_idx( pmctl, p_addr, &stii[i], i );
7464 
7465  if ( mbg_rc_is_error( rc ) )
7466  break;
7467  }
7468 
7469  return rc;
7470 
7471 } // mbgextio_get_all_str_type_info
7472 
7473 
7474 
7475 /*HDR*/
7492  const XBP_ADDR *p_addr, PORT_INFO_IDX *p, uint16_t idx )
7493 {
7495 
7496  if ( mbg_rc_is_error( rc ) )
7497  return rc;
7498 
7499  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_PORT_INFO_IDX, idx, p, sizeof( *p ) );
7500 
7501  if ( mbg_rc_is_success( rc ) && p )
7502  {
7504 
7505  #if 0 //##++ TODO: check if received idx matches requested idx
7506  if ( pii.idx != i )
7507  {
7508  printf( "** Info for port %i requested, but for %i received.\n",
7509  pii.idx, i );
7510  rc = ...;
7511  }
7512  #endif
7513  }
7514 
7515  return rc;
7516 
7517 } // mbgextio_get_port_info_idx
7518 
7519 
7520 
7521 /*HDR*/
7537  const XBP_ADDR *p_addr, PORT_INFO_IDX pii[] )
7538 {
7540  int n_com_ports = p_ri->n_com_ports;
7541  uint16_t i;
7542 
7544 
7545  if ( mbg_rc_is_error( rc ) )
7546  return rc;
7547 
7548  for ( i = 0; i < n_com_ports; i++ )
7549  {
7550  rc = mbgextio_get_port_info_idx( pmctl, p_addr, &pii[i], i );
7551 
7552  if ( mbg_rc_is_error( rc ) )
7553  break;
7554  }
7555 
7556  return rc;
7557 
7558 } // mbgextio_get_all_port_info
7559 
7560 
7561 
7562 /*HDR*/
7579  const XBP_ADDR *p_addr, const PORT_SETTINGS *p, uint16_t idx )
7580 {
7582  PORT_SETTINGS_IDX *p_data = &pmctl->xmt.pmb->u.msg_data.port_settings_idx;
7584 
7585  if ( mbg_rc_is_error( rc ) )
7586  return rc;
7587 
7588  #if _USE_MUTEX
7589  _mbg_mutex_acquire( &pmctl->dev_mutex );
7590  #endif
7591 
7592  p_data->port_settings = *p;
7593  p_data->idx = idx;
7594  _mbg_swab_port_settings_idx( p_data );
7595 
7596  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
7597  return rc;
7598 
7599 } // mbgextio_set_port_settings_idx
7600 
7601 
7602 
7603 /*HDR*/
7620  const XBP_ADDR *p_addr, POUT_INFO_IDX *p, uint16_t idx )
7621 {
7623 
7624  if ( mbg_rc_is_error( rc ) )
7625  return rc;
7626 
7627  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_POUT_INFO_IDX, idx, p, sizeof( *p ) );
7628 
7629  if ( mbg_rc_is_success( rc ) && p )
7630  {
7632 
7633  #if 0 //##++ TODO: check if received idx matches requested idx
7634  if ( pii.idx != i )
7635  {
7636  printf( "** Info for port %i requested, but for %i received.\n",
7637  pii.idx, i );
7638  rc = ...;
7639  }
7640  #endif
7641  }
7642 
7643  return rc;
7644 
7645 } // mbgextio_get_pout_info_idx
7646 
7647 
7648 
7649 /*HDR*/
7665  const XBP_ADDR *p_addr, POUT_INFO_IDX *pii )
7666 {
7668  int n_prg_out = p_ri->n_prg_out;
7669  uint16_t i;
7670 
7672 
7673  if ( mbg_rc_is_error( rc ) )
7674  return rc;
7675 
7676  memset( pii, 0, n_prg_out * sizeof( *pii ) );
7677 
7678  for ( i = 0; i < n_prg_out; i++ )
7679  {
7680  rc = mbgextio_get_pout_info_idx( pmctl, p_addr, &pii[i], i );
7681 
7682  if ( mbg_rc_is_error( rc ) )
7683  break;
7684  }
7685 
7686  return rc;
7687 
7688 } // mbgextio_get_all_pout_info
7689 
7690 
7691 
7692 /*HDR*/
7709  const XBP_ADDR *p_addr, const POUT_SETTINGS *p, uint16_t idx )
7710 {
7712  POUT_SETTINGS_IDX *p_data = &pmctl->xmt.pmb->u.msg_data.pout_settings_idx;
7714 
7715  if ( mbg_rc_is_error( rc ) )
7716  return rc;
7717 
7718  #if _USE_MUTEX
7719  _mbg_mutex_acquire( &pmctl->dev_mutex );
7720  #endif
7721 
7722  p_data->pout_settings = *p;
7723  p_data->idx = idx;
7725 
7726  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
7727  return rc;
7728 
7729 } // mbgextio_set_pout_settings_idx
7730 
7731 
7732 
7733 /*HDR*/
7749  const XBP_ADDR *p_addr, const MBG_GPIO_SETTINGS *p, uint16_t idx )
7750 {
7754 
7755  if ( mbg_rc_is_error( rc ) )
7756  return rc;
7757 
7758  #if _USE_MUTEX
7759  _mbg_mutex_acquire( &pmctl->dev_mutex );
7760  #endif
7761 
7762  p_data->settings = *p;
7763  p_data->idx = idx;
7764 
7765  _mbg_swab_mbg_gpio_settings_idx( p_data, 0 );
7766 
7767  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
7768  return rc;
7769 
7770 } // mbgextio_set_gpio_settings_idx
7771 
7772 
7773 
7774 /*HDR*/
7786  const XBP_ADDR *p_addr )
7787 {
7789 
7790  if ( mbg_rc_is_error( rc ) )
7791  return rc;
7792 
7793  rc = mbgextio_xmt_cmd( pmctl, p_addr, GPS_CLR_UCAP_BUFF );
7794  return rc;
7795 
7796 } // mbgextio_clr_ucap_buff
7797 
7798 
7799 
7800 /*HDR*/
7815  const XBP_ADDR *p_addr, MBG_TIME_SCALE_INFO *p )
7816 {
7818  if ( mbg_rc_is_error( rc ) )
7819  return rc;
7820 
7821  rc = mbgextio_req_data( pmctl, p_addr, GPS_TIME_SCALE, p, sizeof( *p ) );
7822 
7823  if ( mbg_rc_is_success( rc ) && p )
7825 
7826  return rc;
7827 
7828 } // mbgextio_get_time_scale_info
7829 
7830 
7831 
7832 /*HDR*/
7847  const XBP_ADDR *p_addr, const MBG_TIME_SCALE_SETTINGS *p )
7848 {
7852  if ( mbg_rc_is_error( rc ) )
7853  return rc;
7854 
7855  #if _USE_MUTEX
7856  _mbg_mutex_acquire( &pmctl->dev_mutex );
7857  #endif
7858 
7859  *p_data = *p;
7861 
7862  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
7863  return rc;
7864 
7865 } // mbgextio_set_time_scale_settings
7866 
7867 
7868 
7869 /*HDR*/
7885  const XBP_ADDR *p_addr )
7886 {
7888 
7889  if ( mbg_rc_is_error( rc ) )
7890  return rc;
7891 
7892  rc = mbgextio_xmt_cmd( pmctl, p_addr, GPS_CLR_EVT_LOG );
7893  return rc;
7894 
7895 } // mbgextio_clr_evt_log
7896 
7897 
7898 
7899 /*HDR*/
7916  const XBP_ADDR *p_addr, MBG_NUM_EVT_LOG_ENTRIES *p )
7917 {
7919 
7920  if ( mbg_rc_is_error( rc ) )
7921  return rc;
7922 
7923  rc = mbgextio_req_data( pmctl, p_addr, GPS_NUM_EVT_LOG_ENTRIES, p, sizeof( *p ) );
7924 
7925  if ( mbg_rc_is_success( rc ) && p )
7927 
7928  return rc;
7929 
7930 } // mbgextio_get_num_evt_log_entries
7931 
7932 
7933 
7934 /*HDR*/
7954  const XBP_ADDR *p_addr, MBG_EVT_LOG_ENTRY *p )
7955 {
7957 
7958  if ( mbg_rc_is_error( rc ) )
7959  return rc;
7960 
7961  rc = mbgextio_req_data( pmctl, p_addr, GPS_FIRST_EVT_LOG_ENTRY, p, sizeof( *p ) );
7962 
7963  if ( mbg_rc_is_success( rc ) && p )
7965 
7966  return rc;
7967 
7968 } // mbgextio_get_first_evt_log_entry
7969 
7970 
7971 
7972 /*HDR*/
7994  const XBP_ADDR *p_addr, MBG_EVT_LOG_ENTRY *p )
7995 {
7997 
7998  if ( mbg_rc_is_error( rc ) )
7999  return rc;
8000 
8001  rc = mbgextio_req_data( pmctl, p_addr, GPS_NEXT_EVT_LOG_ENTRY, p, sizeof( *p ) );
8002 
8003  if ( mbg_rc_is_success( rc ) && p )
8005 
8006  return rc;
8007 
8008 } // mbgextio_get_next_evt_log_entry
8009 
8010 
8011 
8012 /*HDR*/
8027  const XBP_ADDR *p_addr, MBG_IMS_STATE *p )
8028 {
8030  if ( mbg_rc_is_error( rc ) )
8031  return rc;
8032 
8033  rc = mbgextio_req_data( pmctl, p_addr, GPS_IMS_STATE, p, sizeof( *p ) );
8034 
8035  if ( mbg_rc_is_success( rc ) && p )
8037 
8038  return rc;
8039 
8040 } // mbgextio_get_ims_state
8041 
8042 
8043 
8044 /*HDR*/
8061  const XBP_ADDR *p_addr, MBG_IMS_SENSOR_STATE_IDX *p, uint16_t idx )
8062 {
8064  if ( mbg_rc_is_error( rc ) )
8065  return rc;
8066 
8067  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_IMS_SENSOR_STATE_IDX, idx, p, sizeof( *p ) );
8068 
8069  if ( mbg_rc_is_success( rc ) && p )
8071 
8072  return rc;
8073 
8074 } // mbgextio_get_ims_sensor_state_idx
8075 
8076 
8077 
8078 /*HDR*/
8093  const XBP_ADDR *p_addr, const XMR_HOLDOVER_INTV *p )
8094 {
8096  XMR_HOLDOVER_INTV *p_data = &pmctl->xmt.pmb->u.msg_data.xmr_holdover_intv;
8097 
8098  #if _USE_MUTEX
8099  _mbg_mutex_acquire( &pmctl->dev_mutex );
8100  #endif
8101 
8102  *p_data = *p;
8103  _mbg_swab_xmr_holdover_intv( p_data );
8104 
8105  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
8106 
8107 } // mbgextio_set_holdover_interval
8108 
8109 
8110 
8111 /*HDR*/
8126  const XBP_ADDR *p_addr, XMR_HOLDOVER_INTV *p )
8127 {
8128  int rc = mbgextio_req_data( pmctl, p_addr, GPS_XMR_HOLDOVER_INTV, p, sizeof( *p ) );
8129 
8130  if ( mbg_rc_is_success( rc ) && p )
8132 
8133  return rc;
8134 
8135 } // mbgextio_get_holdover_interval_counter
8136 
8137 
8138 
8139 /*HDR*/
8150  const XBP_ADDR *p_addr, XMULTI_REF_INFO_IDX *p )
8151 {
8152  int rc = mbgextio_req_data( pmctl, p_addr, GPS_MULTI_REF_INFO, p, sizeof( *p ) );
8153 
8154  if ( ( rc == MBG_SUCCESS ) && p )
8155  *p = pmctl->rcv.pmb->u.msg_data.xmulti_ref_info_idx;
8156 
8157  return rc;
8158 
8159 } // mbgextio_get_xmulti_ref_info_idx
8160 
8161 
8162 
8163 /*HDR*/
8178  const XBP_ADDR *p_addr, TZCODE *p )
8179 {
8181  if ( mbg_rc_is_error( rc ) )
8182  return rc;
8183 
8184  rc = mbgextio_req_data( pmctl, p_addr, PZF_TZCODE, p, sizeof( *p ) );
8185 
8186  if ( mbg_rc_is_success( rc ) && p )
8187  _mbg_swab_tzcode( p );
8188 
8189  return rc;
8190 
8191 } // mbgextio_get_tzcode
8192 
8193 
8194 
8195 /*HDR*/
8210  const XBP_ADDR *p_addr, const TZCODE *p )
8211 {
8213  TZCODE *p_data = &pmctl->xmt.pmb->u.msg_data.tzcode;
8215  if ( mbg_rc_is_error( rc ) )
8216  return rc;
8217 
8218  #if _USE_MUTEX
8219  _mbg_mutex_acquire( &pmctl->dev_mutex );
8220  #endif
8221 
8222  *p_data = *p;
8223  _mbg_swab_tzcode( p_data );
8224 
8225  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
8226  return rc;
8227 
8228 } // mbgextio_set_tzcode
8229 
8230 
8231 
8232 /*HDR*/
8247  const XBP_ADDR *p_addr, const HAVEQUICK_SETTINGS *p )
8248 {
8251 
8252  #if _USE_MUTEX
8253  _mbg_mutex_acquire( &pmctl->dev_mutex );
8254  #endif
8255 
8256  *p_data = *p;
8257  _mbg_swab_havequick_settings( p_data );
8258 
8259  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
8260 
8261 } // mbgextio_set_hq_tx_settings
8262 
8263 
8264 
8265 /*HDR*/
8280  const XBP_ADDR *p_addr, const HAVEQUICK_SETTINGS *p )
8281 {
8284 
8285  #if _USE_MUTEX
8286  _mbg_mutex_acquire( &pmctl->dev_mutex );
8287  #endif
8288 
8289  *p_data = *p;
8290  _mbg_swab_havequick_settings( p_data );
8291 
8292  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
8293 
8294 } // mbgextio_set_hq_rx_settings
8295 
8296 
8297 
8298 /*HDR*/
8313  const XBP_ADDR *p_addr, TR_DISTANCE *p )
8314 {
8315  int rc = mbgextio_req_data( pmctl, p_addr, PZF_TR_DISTANCE, p, sizeof( *p ) );
8316 
8317  if ( mbg_rc_is_success( rc ) && p )
8318  _mbg_swab_tr_distance( p );
8319 
8320  return rc;
8321 
8322 } // mbgextio_get_tr_distance
8323 
8324 
8325 
8326 /*HDR*/
8341  const XBP_ADDR *p_addr, const TR_DISTANCE *p )
8342 {
8344  TR_DISTANCE *p_data = &pmctl->xmt.pmb->u.msg_data.tr_distance;
8345 
8346  #if _USE_MUTEX
8347  _mbg_mutex_acquire( &pmctl->dev_mutex );
8348  #endif
8349 
8350  *p_data = *p;
8351  _mbg_swab_tr_distance( p_data );
8352 
8353  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
8354 
8355 } // mbgextio_set_tr_distance
8356 
8357 
8358 
8359 /*HDR*/
8374  const XBP_ADDR *p_addr, MBG_GNSS_MODE_INFO *p )
8375 {
8377 
8378  if ( mbg_rc_is_error( rc ) )
8379  return rc;
8380 
8381  rc = mbgextio_req_data( pmctl, p_addr, GPS_GNSS_MODE, p, sizeof( *p ) );
8382 
8383  if ( mbg_rc_is_success( rc ) && p )
8385 
8386  return rc;
8387 
8388 } // mbgextio_get_gnss_mode_info
8389 
8390 
8391 
8392 /*HDR*/
8407  const XBP_ADDR *p_addr, const MBG_GNSS_MODE_SETTINGS *p )
8408 {
8412 
8413  if ( mbg_rc_is_error( rc ) )
8414  return rc;
8415 
8416  #if _USE_MUTEX
8417  _mbg_mutex_acquire( &pmctl->dev_mutex );
8418  #endif
8419 
8420  *p_data = *p;
8422 
8423  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
8424  return rc;
8425 
8426 } // mbgextio_set_gnss_mode_settings
8427 
8428 
8429 
8430 /*HDR*/
8447  const XBP_ADDR *p_addr, GNSS_SAT_INFO *p )
8448 {
8450 
8451  if ( mbg_rc_is_error( rc ) )
8452  return rc;
8453 
8454  rc = mbgextio_req_data( pmctl, p_addr, GPS_GNSS_SAT_INFO, p, sizeof( *p ) );
8455 
8456  if ( mbg_rc_is_success( rc ) && p )
8458 
8459  return rc;
8460 
8461 } // mbgextio_get_gnss_sat_info
8462 
8463 
8464 
8465 /*HDR*/
8483  const XBP_ADDR *p_addr, GNSS_SAT_INFO_IDX *p, uint16_t idx )
8484 {
8486 
8487  if ( mbg_rc_is_error( rc ) )
8488  return rc;
8489 
8490  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_GNSS_SAT_INFO_IDX, idx, p, sizeof( *p ) );
8491 
8492  if ( mbg_rc_is_success( rc ) && p )
8493  {
8495 
8496  #if 0 //##++ TODO: check if received idx matches requested idx
8497  if ( pii.idx != i )
8498  {
8499  printf( "** Info for port %i requested, but for %i received.\n",
8500  pii.idx, i );
8501  rc = ...;
8502  }
8503  #endif
8504  }
8505 
8506  return rc;
8507 
8508 } // mbgextio_get_gnss_sat_info_idx
8509 
8510 
8511 
8512 /*HDR*/
8528  const XBP_ADDR *p_addr, GNSS_SAT_INFO_IDX gsii[],
8529  const MBG_GNSS_MODE_INFO *p_mi )
8530 {
8531  int rc = MBG_SUCCESS;
8532  int n_supp = num_bits_set( p_mi->supp_gnss_types );
8533  uint16_t i;
8534 
8535  for ( i = 0; i < n_supp; i++ )
8536  {
8537  rc = mbgextio_get_gnss_sat_info_idx( pmctl, p_addr, &gsii[i], i );
8538 
8539  if ( mbg_rc_is_error( rc ) )
8540  break;
8541  }
8542 
8543  return rc;
8544 
8545 } // mbgextio_get_all_gnss_sat_info
8546 
8547 
8548 
8549 /*HDR*/
8565  const XBP_ADDR *p_addr, GNSS_SV_STATUS_IDX *p, uint16_t idx )
8566 {
8567  int rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_GNSS_SV_STATUS_IDX, idx, p, sizeof( *p ) );
8568 
8569  if ( mbg_rc_is_success( rc ) && p )
8570  {
8572 
8573  #if 0 //##++ TODO: check if received idx matches requested idx
8574  if ( pii.idx != i )
8575  {
8576  printf( "** Info for port %i requested, but for %i received.\n",
8577  pii.idx, i );
8578  rc = ...;
8579  }
8580  #endif
8581  }
8582 
8583  return rc;
8584 
8585 } // mbgextio_get_gnss_sv_status_idx
8586 
8587 
8588 
8589 #if 0
8590 
8591  /*HDR*/
8605  const XBP_ADDR *p_addr, GNSS_SAT_INFO_IDX gsii[],
8606  const MBG_GNSS_MODE_INFO *p_mi )
8607 {
8608  int rc = MBG_SUCCESS;
8609  int n_supp = num_bits_set( p_mi->supp_gnss_types );
8610  uint16_t i;
8611 
8612  for ( i = 0; i < n_supp; i++ )
8613  {
8614  rc = mbgextio_get_gnss_sat_info_idx( pmctl, p_addr, &gsii[i], i );
8615 
8616  if ( mbg_rc_is_error( rc ) )
8617  break;
8618  }
8619 
8620  return rc;
8621 
8622 } // mbgextio_get_all_gnss_sat_info
8623 
8624 #endif
8625 
8626 
8627 /*HDR*/
8648  const XBP_ADDR *p_addr,
8650 {
8652 
8653  if ( mbg_rc_is_error( rc ) )
8654  return rc;
8655 
8656  rc = mbgextio_req_data( pmctl, p_addr, GPS_XMR_INSTANCES, p, sizeof( *p ) );
8657 
8658  if ( mbg_rc_is_success( rc ) )
8660 
8661  return rc;
8662 
8663 } // mbgextio_get_xmr_instances
8664 
8665 
8666 
8667 /*HDR*/
8690  const XBP_ADDR *p_addr,
8692  uint16_t idx)
8693 {
8695 
8696  if ( mbg_rc_is_error( rc ) )
8697  return rc;
8698 
8699  p->idx = idx;
8700 
8701  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_XMR_EXT_SRC_INFO_IDX, idx, p, sizeof( *p ) );
8702 
8703  if ( mbg_rc_is_success( rc ) )
8705 
8706  return rc;
8707 
8708 } // mbgextio_get_xmr_ext_src_info_idx
8709 
8710 
8711 
8712 /*HDR*/
8734  const XBP_ADDR *p_addr,
8735  XMR_HOLDOVER_STATUS *p )
8736 {
8738 
8739  if ( mbg_rc_is_error( rc ) )
8740  return rc;
8741 
8742  rc = mbgextio_req_data( pmctl, p_addr, GPS_XMR_HOLDOVER_STATUS, p, sizeof( *p ) );
8743 
8744  if ( mbg_rc_is_success( rc ) )
8746 
8747  return rc;
8748 
8749 } // mbgextio_get_xmr_holdover_status
8750 
8751 
8752 
8753 /*HDR*/
8775  const XBP_ADDR *p_addr,
8777  uint16_t idx)
8778 {
8780 
8781  if ( mbg_rc_is_error( rc ) )
8782  return rc;
8783 
8784  p->idx = idx;
8785 
8786  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_XMR_INFO_IDX, idx, p, sizeof( *p ) );
8787 
8788  if ( mbg_rc_is_success( rc ) )
8790 
8791  return rc;
8792 
8793 } // mbgextio_get_xmr_info_idx
8794 
8795 
8796 /*HDR*/
8819  const XBP_ADDR *p_addr,
8821  uint16_t idx)
8822 {
8823  int rc = MBG_ERR_UNSPEC;
8825 
8827 
8828  if ( mbg_rc_is_error( rc ) )
8829  return rc;
8830 
8831  #if _USE_MUTEX
8832  _mbg_mutex_acquire( &pmctl->dev_mutex );
8833  #endif
8834 
8835  //### TODO FIXME rc = mbgextio_req_data_idx_unlocked( pmctl, p_addr, GPS_XMR_STATUS_IDX, idx, p, sizeof( *p ) );
8836 
8837  rc = xmt_cmd_us( pmctl, p_addr, cmd, idx ); // request data
8838 
8839  if ( mbg_rc_is_error( rc ) )
8840  goto out_release;
8841 
8842  for (;;)
8843  {
8844  rc = mbgextio_rcv_msg_unlocked( pmctl, p_addr, cmd, p, sizeof( *p ) ); // wait for the reply
8845 
8846  if ( mbg_rc_is_error( rc ) )
8847  break;
8848 
8850 
8851  if ( p->idx == idx )
8852  break;
8853 
8854  #if defined( DEBUG )
8855  fprintf( stderr, "GPS_XMR_STATUS_IDX received reply idx %u, expected %u\n", idx, p->idx );
8856  #endif
8857  }
8858 
8859 out_release:
8860 
8861  #if _USE_MUTEX
8862  _mbg_mutex_release( &pmctl->dev_mutex );
8863  #endif
8864 
8865  return rc;
8866 
8867 } // mbgextio_get_xmr_status_idx
8868 
8869 
8870 /*HDR*/
8893  const XBP_ADDR *p_addr,
8894  XMR_STATS_IDX *p,
8895  uint16_t idx)
8896 {
8898 
8899  if ( mbg_rc_is_error( rc ) )
8900  return rc;
8901 
8902  p->idx = idx;
8903 
8904  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_XMR_STATS_IDX, idx, p, sizeof( *p ) );
8905 
8906  if ( mbg_rc_is_success( rc ) )
8908 
8909  return rc;
8910 
8911 } // mbgextio_get_xmr_ext_source_stats_idx
8912 
8913 
8914 /*HDR*/
8936  const XBP_ADDR *p_addr,
8937  XMR_METRICS_IDX *p,
8938  uint16_t idx)
8939 {
8941 
8942  if ( mbg_rc_is_error( rc ) )
8943  return rc;
8944 
8945  p->idx = idx;
8946 
8947  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_XMR_METRICS_IDX, idx, p, sizeof( *p ) );
8948 
8949  if ( mbg_rc_is_success( rc ) )
8951 
8952  return rc;
8953 
8954 } // mbgextio_get_xmr_ext_source_metrics_idx
8955 
8956 
8957 /*HDR*/
8979  const XBP_ADDR *p_addr,
8980  const XMULTI_REF_SETTINGS *p,
8981  uint16_t idx)
8982 {
8986 
8987  if ( mbg_rc_is_error( rc ) )
8988  return rc;
8989 
8990  #if _USE_MUTEX
8991  _mbg_mutex_acquire( &pmctl->dev_mutex );
8992  #endif
8993 
8994  p_data->settings = *p;
8995  p_data->idx = idx;
8997 
8998  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
8999  return rc;
9000 
9001 } // mbgextio_set_xmr_settings_idx
9002 
9003 
9004 
9005 /*HDR*/
9020  const XBP_ADDR *p_addr, LAN_IF_INFO *p )
9021 {
9023  if ( mbg_rc_is_error( rc ) )
9024  return rc;
9025 
9026  rc = mbgextio_req_data( pmctl, p_addr, GPS_LAN_IF_INFO, p, sizeof( *p ) );
9027 
9028  if ( mbg_rc_is_success( rc ) && p )
9029  _mbg_swab_lan_if_info( p );
9030 
9031  return rc;
9032 
9033 } // mbgextio_get_lan_if_info
9034 
9035 
9036 
9037 /*HDR*/
9052  const XBP_ADDR *p_addr, IP4_SETTINGS *p )
9053 {
9055  if ( mbg_rc_is_error( rc ) )
9056  return rc;
9057 
9058  rc = mbgextio_req_data( pmctl, p_addr, GPS_IP4_SETTINGS, p, sizeof( *p ) );
9059 
9060  if ( mbg_rc_is_success( rc ) && p )
9062 
9063  return rc;
9064 
9065 } // mbgextio_get_ip4_settings
9066 
9067 
9068 
9069 /*HDR*/
9084  const XBP_ADDR *p_addr, const IP4_SETTINGS *p )
9085 {
9087  IP4_SETTINGS *p_data = &pmctl->xmt.pmb->u.msg_data.ip4_settings;
9089  if ( mbg_rc_is_error( rc ) )
9090  return rc;
9091 
9092  #if _USE_MUTEX
9093  _mbg_mutex_acquire( &pmctl->dev_mutex );
9094  #endif
9095 
9096  *p_data = *p;
9097  _mbg_swab_ip4_settings( p_data );
9098 
9099  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
9100  return rc;
9101 
9102 } // mbgextio_set_ip4_settings
9103 
9104 
9105 
9106 /*HDR*/
9121  const XBP_ADDR *p_addr, IP4_SETTINGS *p )
9122 {
9124  if ( mbg_rc_is_error( rc ) )
9125  return rc;
9126 
9127  rc = mbgextio_req_data( pmctl, p_addr, GPS_IP4_STATE, p, sizeof( *p ) );
9128 
9129  if ( mbg_rc_is_success( rc ) && p )
9131 
9132  return rc;
9133 
9134 } // mbgextio_get_ip4_state
9135 
9136 
9137 
9138 /*HDR*/
9153  const XBP_ADDR *p_addr, PTP_STATE *p )
9154 {
9156 
9157  if ( mbg_rc_is_error( rc ) )
9158  return rc;
9159 
9160  rc = mbgextio_req_data( pmctl, p_addr, GPS_PTP_STATE, p, sizeof( *p ) );
9161 
9162  if ( mbg_rc_is_success( rc ) && p )
9163  _mbg_swab_ptp_state( p );
9164 
9165  return rc;
9166 
9167 } // mbgextio_get_ptp_state
9168 
9169 
9170 
9171 /*HDR*/
9186  const XBP_ADDR *p_addr, PTP_CFG_INFO *p )
9187 {
9189 
9190  if ( mbg_rc_is_error( rc ) )
9191  return rc;
9192 
9193  rc = mbgextio_req_data( pmctl, p_addr, GPS_PTP_CFG, p, sizeof( *p ) );
9194 
9195  if ( mbg_rc_is_success( rc ) && p )
9197 
9198  return rc;
9199 
9200 } // mbgextio_get_ptp_cfg_info
9201 
9202 
9203 
9204 /*HDR*/
9219  const XBP_ADDR *p_addr, PTP_UC_MASTER_CFG_LIMITS *p )
9220 {
9222 
9223  if ( mbg_rc_is_error( rc ) )
9224  return rc;
9225 
9226  rc = mbgextio_req_data( pmctl, p_addr, GPS_PTP_UC_MASTER_CFG_LIMITS, p, sizeof( *p ) );
9227 
9228  if ( mbg_rc_is_success( rc ) && p )
9230 
9231  return rc;
9232 
9233 } // mbgextio_get_ptp_uc_master_cfg_limits
9234 
9235 
9236 
9237 /*HDR*/
9253  const XBP_ADDR *p_addr, PTP_UC_MASTER_INFO_IDX *ptp_uc_master_info_idx,
9254  const PTP_UC_MASTER_CFG_LIMITS *ptp_uc_master_cfg_limits )
9255 {
9256  uint16_t i;
9258 
9259  if ( mbg_rc_is_error( rc ) )
9260  return rc;
9261 
9262  for ( i = 0; i < ptp_uc_master_cfg_limits->n_supp_master; i++ )
9263  {
9264  xmt_cmd_us( pmctl, p_addr, GPS_PTP_UC_MASTER_CFG, i );
9265 
9266  rc = mbgextio_rcv_msg_unlocked( pmctl, p_addr, GPS_PTP_UC_MASTER_CFG, NULL, 0 ); //### TODO
9267 
9268  if ( mbg_rc_is_success( rc ) && ptp_uc_master_info_idx )
9269  {
9270  PTP_UC_MASTER_INFO_IDX *p = &ptp_uc_master_info_idx[i];
9271  *p = pmctl->rcv.pmb->u.msg_data.ptp_uc_master_info_idx;
9273  }
9274  else
9275  break;
9276  }
9277 
9278  return rc;
9279 
9280 } // mbgextio_get_all_ptp_uc_master_info
9281 
9282 
9283 
9284 /*HDR*/
9299  const XBP_ADDR *p_addr, const PTP_CFG_SETTINGS *p )
9300 {
9302  PTP_CFG_SETTINGS *p_data = &pmctl->xmt.pmb->u.msg_data.ptp_cfg_settings;
9304 
9305  if ( mbg_rc_is_error( rc ) )
9306  return rc;
9307 
9308  #if _USE_MUTEX
9309  _mbg_mutex_acquire( &pmctl->dev_mutex );
9310  #endif
9311 
9312  *p_data = *p;
9313  _mbg_swab_ptp_cfg_settings( p_data );
9314 
9315  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
9316  return rc;
9317 
9318 } // mbgextio_set_ptp_cfg_settings
9319 
9320 
9321 /*HDR*/
9341  const XBP_ADDR *p_addr, const PTP_UC_MASTER_SETTINGS *p, uint16_t idx )
9342 {
9346 
9347  if ( mbg_rc_is_error( rc ) )
9348  return rc;
9349 
9350  #if _USE_MUTEX
9351  _mbg_mutex_acquire( &pmctl->dev_mutex );
9352  #endif
9353 
9354  p_data->settings = *p;
9355  p_data->idx = idx;
9357 
9358  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
9359  return rc;
9360 
9361 } // mbgextio_set_ptp_uc_master_settings_idx
9362 
9363 
9364 
9365 /*HDR*/
9382 {
9384 
9385  if ( mbg_rc_is_error( rc ) )
9386  return rc;
9387 
9388  rc = mbgextio_req_data( pmctl, p_addr, GPS_PTP_V1_DEFAULT_DS, p, sizeof( *p ) );
9389 
9390  if ( mbg_rc_is_success( rc ) && p )
9392 
9393  return rc;
9394 
9395 } // mbgextio_get_ptp_v1_default_dataset
9396 
9397 
9398 
9399 /*HDR*/
9415  const MBG_PTP_V1_DEFAULT_DATASET *p )
9416 {
9420 
9421  if ( mbg_rc_is_error( rc ) )
9422  return rc;
9423 
9424  #if _USE_MUTEX
9425  _mbg_mutex_acquire( &pmctl->dev_mutex );
9426  #endif
9427 
9428  *p_data = *p;
9430 
9431  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
9432  return rc;
9433 
9434 } // mbgextio_set_ptp_v1_default_dataset
9435 
9436 
9437 
9438 /*HDR*/
9455 {
9457 
9458  if ( mbg_rc_is_error( rc ) )
9459  return rc;
9460 
9461  rc = mbgextio_req_data( pmctl, p_addr, GPS_PTP_V1_CURRENT_DS, p, sizeof( *p ) );
9462 
9463  if ( mbg_rc_is_success( rc ) && p )
9465 
9466  return rc;
9467 
9468 } // mbgextio_get_ptp_v1_current_dataset
9469 
9470 
9471 
9472 /*HDR*/
9488  const MBG_PTP_V1_CURRENT_DATASET *p )
9489 {
9493 
9494  if ( mbg_rc_is_error( rc ) )
9495  return rc;
9496 
9497  #if _USE_MUTEX
9498  _mbg_mutex_acquire( &pmctl->dev_mutex );
9499  #endif
9500 
9501  *p_data = *p;
9503 
9504  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
9505  return rc;
9506 
9507 } // mbgextio_set_ptp_v1_current_dataset
9508 
9509 
9510 
9511 /*HDR*/
9528 {
9530 
9531  if ( mbg_rc_is_error( rc ) )
9532  return rc;
9533 
9534  rc = mbgextio_req_data( pmctl, p_addr, GPS_PTP_V1_PARENT_DS, p, sizeof( *p ) );
9535 
9536  if ( mbg_rc_is_success( rc ) && p )
9538 
9539  return rc;
9540 
9541 } // mbgextio_get_ptp_v1_parent_dataset
9542 
9543 
9544 
9545 /*HDR*/
9561  const MBG_PTP_V1_PARENT_DATASET *p )
9562 {
9566 
9567  if ( mbg_rc_is_error( rc ) )
9568  return rc;
9569 
9570  #if _USE_MUTEX
9571  _mbg_mutex_acquire( &pmctl->dev_mutex );
9572  #endif
9573 
9574  *p_data = *p;
9576 
9577  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
9578  return rc;
9579 
9580 } // mbgextio_set_ptp_v1_parent_dataset
9581 
9582 
9583 
9584 /*HDR*/
9601 {
9603 
9604  if ( mbg_rc_is_error( rc ) )
9605  return rc;
9606 
9607  rc = mbgextio_req_data( pmctl, p_addr, GPS_PTP_V1_TIME_PROP_DS, p, sizeof( *p ) );
9608 
9609  if ( mbg_rc_is_success( rc ) && p )
9611 
9612  return rc;
9613 
9614 } // mbgextio_get_ptp_v1_time_properties_dataset
9615 
9616 
9617 
9618 /*HDR*/
9635 {
9639 
9640  if ( mbg_rc_is_error( rc ) )
9641  return rc;
9642 
9643  #if _USE_MUTEX
9644  _mbg_mutex_acquire( &pmctl->dev_mutex );
9645  #endif
9646 
9647  *p_data = *p;
9649 
9650  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
9651  return rc;
9652 
9653 } // mbgextio_set_ptp_v1_time_properties_dataset
9654 
9655 
9656 
9657 /*HDR*/
9675 {
9677 
9678  if ( mbg_rc_is_error( rc ) )
9679  return rc;
9680 
9681  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_PTP_V1_PORT_DS_IDX, idx, p, sizeof( *p ) );
9682 
9683  if ( mbg_rc_is_success( rc ) && p )
9685 
9686  return rc;
9687 
9688 } // mbgextio_get_ptp_v1_port_dataset_idx
9689 
9690 
9691 
9692 /*HDR*/
9709  const MBG_PTP_V1_PORT_DATASET *p, uint16_t idx )
9710 {
9714 
9715  if ( mbg_rc_is_error( rc ) )
9716  return rc;
9717 
9718  #if _USE_MUTEX
9719  _mbg_mutex_acquire( &pmctl->dev_mutex );
9720  #endif
9721 
9722  p_data->port_dataset = *p;
9723  p_data->idx = idx;
9725 
9726  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
9727  return rc;
9728 
9729 } // mbgextio_set_ptp_v1_port_dataset_idx
9730 
9731 
9732 
9733 /*HDR*/
9750 {
9752 
9753  if ( mbg_rc_is_error( rc ) )
9754  return rc;
9755 
9756  rc = mbgextio_req_data( pmctl, p_addr, GPS_PTP_V2_DEFAULT_DS, p, sizeof( *p ) );
9757 
9758  if ( mbg_rc_is_success( rc ) && p )
9760 
9761  return rc;
9762 
9763 } // mbgextio_get_ptp_v2_default_dataset
9764 
9765 
9766 
9767 /*HDR*/
9783  const MBG_PTP_V2_DEFAULT_DATASET *p )
9784 {
9788 
9789  if ( mbg_rc_is_error( rc ) )
9790  return rc;
9791 
9792  #if _USE_MUTEX
9793  _mbg_mutex_acquire( &pmctl->dev_mutex );
9794  #endif
9795 
9796  *p_data = *p;
9798 
9799  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
9800  return rc;
9801 
9802 } // mbgextio_set_ptp_v2_default_dataset
9803 
9804 
9805 
9806 /*HDR*/
9823 {
9825 
9826  if ( mbg_rc_is_error( rc ) )
9827  return rc;
9828 
9829  rc = mbgextio_req_data( pmctl, p_addr, GPS_PTP_V2_CURRENT_DS, p, sizeof( *p ) );
9830 
9831  if ( mbg_rc_is_success( rc ) && p )
9833 
9834  return rc;
9835 
9836 } // mbgextio_get_ptp_v2_current_dataset
9837 
9838 
9839 
9840 /*HDR*/
9856  const MBG_PTP_V2_CURRENT_DATASET *p )
9857 {
9861 
9862  if ( mbg_rc_is_error( rc ) )
9863  return rc;
9864 
9865  #if _USE_MUTEX
9866  _mbg_mutex_acquire( &pmctl->dev_mutex );
9867  #endif
9868 
9869  *p_data = *p;
9871 
9872  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
9873  return rc;
9874 
9875 } // mbgextio_set_ptp_v2_current_dataset
9876 
9877 
9878 
9879 /*HDR*/
9896 {
9898 
9899  if ( mbg_rc_is_error( rc ) )
9900  return rc;
9901 
9902  rc = mbgextio_req_data( pmctl, p_addr, GPS_PTP_V2_PARENT_DS, p, sizeof( *p ) );
9903 
9904  if ( mbg_rc_is_success( rc ) && p )
9906 
9907  return rc;
9908 
9909 } // mbgextio_get_ptp_v2_parent_dataset
9910 
9911 
9912 
9913 /*HDR*/
9929  const MBG_PTP_V2_PARENT_DATASET *p )
9930 {
9934 
9935  if ( mbg_rc_is_error( rc ) )
9936  return rc;
9937 
9938  #if _USE_MUTEX
9939  _mbg_mutex_acquire( &pmctl->dev_mutex );
9940  #endif
9941 
9942  *p_data = *p;
9944 
9945  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
9946  return rc;
9947 
9948 } // mbgextio_set_ptp_v2_parent_dataset
9949 
9950 
9951 
9952 /*HDR*/
9969 {
9971 
9972  if ( mbg_rc_is_error( rc ) )
9973  return rc;
9974 
9975  rc = mbgextio_req_data( pmctl, p_addr, GPS_PTP_V2_TIME_PROP_DS, p, sizeof( *p ) );
9976 
9977  if ( mbg_rc_is_success( rc ) && p )
9979 
9980  return rc;
9981 
9982 } // mbgextio_get_ptp_v2_time_properties_dataset
9983 
9984 
9985 
9986 /*HDR*/
10003 {
10007 
10008  if ( mbg_rc_is_error( rc ) )
10009  return rc;
10010 
10011  #if _USE_MUTEX
10012  _mbg_mutex_acquire( &pmctl->dev_mutex );
10013  #endif
10014 
10015  *p_data = *p;
10017 
10018  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
10019  return rc;
10020 
10021 } // mbgextio_set_ptp_v2_time_properties_dataset
10022 
10023 
10024 
10025 /*HDR*/
10043 {
10045 
10046  if ( mbg_rc_is_error( rc ) )
10047  return rc;
10048 
10049  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_PTP_V2_PORT_DS_IDX, idx, p, sizeof( *p ) );
10050 
10051  if ( mbg_rc_is_success( rc ) && p )
10053 
10054  return rc;
10055 
10056 } // mbgextio_get_ptp_v2_port_dataset_idx
10057 
10058 
10059 
10060 /*HDR*/
10077  const MBG_PTP_V2_PORT_DATASET *p, uint16_t idx )
10078 {
10082 
10083  if ( mbg_rc_is_error( rc ) )
10084  return rc;
10085 
10086  #if _USE_MUTEX
10087  _mbg_mutex_acquire( &pmctl->dev_mutex );
10088  #endif
10089 
10090  p_data->port_dataset = *p;
10091  p_data->idx = idx;
10093 
10094  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
10095  return rc;
10096 
10097 } // mbgextio_set_ptp_v2_port_dataset_idx
10098 
10099 
10100 
10101 /*HDR*/
10116  const XBP_ADDR *p_addr, PTP_SMPTE_PROFILE_CFG *p )
10117 {
10118  int rc = mbgextio_req_data( pmctl, p_addr, GPS_PTP_SMPTE_TLV, p, sizeof( *p ) );
10119 
10120  if ( mbg_rc_is_success( rc ) && p )
10121  _mbg_swab_dummy( p );
10122 
10123  return rc;
10124 
10125 } // mbgextio_get_ptp_smpte_tlv_state
10126 
10127 
10128 
10129 /*HDR*/
10145 {
10147 
10148  if ( mbg_rc_is_error( rc ) )
10149  return rc;
10150 
10151  rc = mbgextio_req_data( pmctl, p_addr, GPS_MONITORING_LIMITS, p, sizeof( *p ) );
10152 
10153  if ( mbg_rc_is_success( rc ) && p )
10155 
10156  return rc;
10157 
10158 } // mbgextio_get_monitoring_limits
10159 
10160 
10161 
10162 /*HDR*/
10178  MBG_SNMP_GLB_INFO *p )
10179 {
10181 
10182  if ( mbg_rc_is_error( rc ) )
10183  return rc;
10184 
10185  rc = mbgextio_req_data( pmctl, p_addr, GPS_SNMP_GLB, p, sizeof( *p ) );
10186 
10187  if ( mbg_rc_is_success( rc ) && p )
10189 
10190  return rc;
10191 
10192 } // mbgextio_get_snmp_glb_info
10193 
10194 
10195 
10196 /*HDR*/
10212  const MBG_SNMP_GLB_SETTINGS *p )
10213 {
10217 
10218  if ( mbg_rc_is_error( rc ) )
10219  return rc;
10220 
10221  #if _USE_MUTEX
10222  _mbg_mutex_acquire( &pmctl->dev_mutex );
10223  #endif
10224 
10225  *p_data = *p;
10226  _mbg_swab_snmp_glb_settings( p_data );
10227 
10228  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
10229  return rc;
10230 
10231 } // mbgextio_set_snmp_glb_settings
10232 
10233 
10234 
10235 /*HDR*/
10254 {
10256 
10257  if ( mbg_rc_is_error( rc ) )
10258  return rc;
10259 
10260  rc = mbgextio_req_data_idx(pmctl, p_addr, GPS_SNMP_V12_IDX, idx, p, sizeof( *p ) );
10261 
10262  if ( mbg_rc_is_success( rc ) && p )
10264 
10265  return rc;
10266 
10267 } // mbgextio_get_snmp_v12_info_idx
10268 
10269 
10270 
10271 /*HDR*/
10289  const MBG_SNMP_V12_SETTINGS *p, uint16_t idx )
10290 {
10294 
10295  if ( mbg_rc_is_error( rc ) )
10296  return rc;
10297 
10298  #if _USE_MUTEX
10299  _mbg_mutex_acquire( &pmctl->dev_mutex );
10300  #endif
10301 
10302  p_data->settings = *p;
10303  p_data->idx = idx;
10305 
10306  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
10307  return rc;
10308 
10309 } // mbgextio_set_snmp_v12_settings_idx
10310 
10311 
10312 
10313 /*HDR*/
10332 {
10334 
10335  if ( mbg_rc_is_error( rc ) )
10336  return rc;
10337 
10338  rc = mbgextio_req_data_idx(pmctl, p_addr, GPS_SNMP_V12_TRAP_IDX, idx, p, sizeof( *p ) );
10339 
10340  if ( mbg_rc_is_success( rc ) && p )
10342 
10343  return rc;
10344 
10345 } // mbgextio_get_snmp_v12_trap_info_idx
10346 
10347 
10348 
10349 /*HDR*/
10367  const MBG_SNMP_V12_TRAP_SETTINGS *p, uint16_t idx )
10368 {
10372 
10373  if ( mbg_rc_is_error( rc ) )
10374  return rc;
10375 
10376  #if _USE_MUTEX
10377  _mbg_mutex_acquire( &pmctl->dev_mutex );
10378  #endif
10379 
10380  p_data->settings = *p;
10381  p_data->idx = idx;
10383 
10384  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
10385  return rc;
10386 
10387 } // mbgextio_set_snmp_v12_trap_settings_idx
10388 
10389 
10390 
10391 /*HDR*/
10409  MBG_SNMP_V3_INFO_IDX *p, uint16_t idx )
10410 {
10412 
10413  if ( mbg_rc_is_error( rc ) )
10414  return rc;
10415 
10416  rc = mbgextio_req_data_idx(pmctl, p_addr, GPS_SNMP_V3_IDX, idx, p, sizeof( *p ) );
10417 
10418  if ( mbg_rc_is_success( rc ) && p )
10420 
10421  return rc;
10422 
10423 } // mbgextio_get_snmp_v3_info_idx
10424 
10425 
10426 
10427 /*HDR*/
10445  const MBG_SNMP_V3_SETTINGS *p, uint16_t idx )
10446 {
10450 
10451  if ( mbg_rc_is_error( rc ) )
10452  return rc;
10453 
10454  #if _USE_MUTEX
10455  _mbg_mutex_acquire( &pmctl->dev_mutex );
10456  #endif
10457 
10458  p_data->settings = *p;
10459  p_data->idx = idx;
10461 
10462  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
10463  return rc;
10464 
10465 } // mbgextio_set_snmp_v3_settings_idx
10466 
10467 
10468 
10469 /*HDR*/
10488 {
10490 
10491  if ( mbg_rc_is_error( rc ) )
10492  return rc;
10493 
10494  rc = mbgextio_req_data_idx(pmctl, p_addr, GPS_SNMP_V3_TRAP_IDX, idx, p, sizeof( *p ) );
10495 
10496  if ( mbg_rc_is_success( rc ) && p )
10498 
10499  return rc;
10500 
10501 } // mbgextio_get_snmp_v3_trap_info_idx
10502 
10503 
10504 
10505 /*HDR*/
10523  const MBG_SNMP_V3_TRAP_SETTINGS *p, uint16_t idx )
10524 {
10528 
10529  if ( mbg_rc_is_error( rc ) )
10530  return rc;
10531 
10532  #if _USE_MUTEX
10533  _mbg_mutex_acquire( &pmctl->dev_mutex );
10534  #endif
10535 
10536  p_data->settings = *p;
10537  p_data->idx = idx;
10539 
10540  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
10541  return rc;
10542 
10543 } // mbgextio_set_snmp_v3_trap_settings_idx
10544 
10545 
10546 
10547 /*HDR*/
10569  MBG_EVENT_INFO_IDX *p, uint16_t idx )
10570 {
10572 
10573  if ( mbg_rc_is_error( rc ) )
10574  return rc;
10575 
10576  rc = mbgextio_req_data_idx(pmctl, p_addr, GPS_EVENT_IDX, idx, p, sizeof( *p ) );
10577 
10578  if ( mbg_rc_is_success( rc ) && p )
10580 
10581  return rc;
10582 
10583 } // mbgextio_get_event_info_idx
10584 
10585 
10586 
10587 /*HDR*/
10607  const MBG_EVENT_SETTINGS *p, uint16_t idx )
10608 {
10612 
10613  if ( mbg_rc_is_error( rc ) )
10614  return rc;
10615 
10616  #if _USE_MUTEX
10617  _mbg_mutex_acquire( &pmctl->dev_mutex );
10618  #endif
10619 
10620  p_data->settings = *p;
10621  p_data->idx = idx;
10622  _mbg_swab_event_settings_idx( p_data );
10623 
10624  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
10625  return rc;
10626 
10627 } // mbgextio_set_event_settings_idx
10628 
10629 
10630 /*HDR*/
10652  uint8_t vtype, MBG_EVENT_STATUS_IDX *p, uint16_t idx )
10653 {
10655 
10656  if ( mbg_rc_is_error( rc ) )
10657  return rc;
10658 
10659  rc = mbgextio_req_data_idx(pmctl, p_addr, GPS_EVENT_STAT_IDX, idx, p, sizeof( *p ) );
10660 
10661  if ( mbg_rc_is_success( rc ) && p )
10662  _mbg_swab_event_status_idx( p, vtype );
10663 
10664  return rc;
10665 
10666 } // mbgextio_get_event_status_idx
10667 
10668 
10669 /*HDR*/
10692  uint16_t eidx, uint8_t vtype,
10693  MBG_EVENT_VALUE_IDX *p, uint16_t vidx )
10694 {
10695  uint32_t idx = ((eidx << 16) | vidx);
10697 
10698  if ( mbg_rc_is_error( rc ) )
10699  return rc;
10700 
10701  #if _USE_MUTEX
10702  _mbg_mutex_acquire( &pmctl->dev_mutex );
10703  #endif
10704 
10705  rc = xmt_cmd_u32( pmctl, p_addr, GPS_EVENT_VALUE_IDX, idx );
10706  if ( mbg_rc_is_success( rc ) )
10707  rc = mbgextio_rcv_msg_unlocked( pmctl, p_addr, GPS_EVENT_VALUE_IDX, p, sizeof( *p ));
10708 
10709  #if _USE_MUTEX
10710  _mbg_mutex_release( &pmctl->dev_mutex );
10711  #endif
10712 
10713  if ( mbg_rc_is_error( rc ) )
10714  return rc;
10715 
10716  _mbg_swab_event_value_idx( p, vtype );
10717 
10718  return MBG_SUCCESS;
10719 
10720 } // mbgextio_get_event_value_idx
10721 
10722 
10723 /*HDR*/
10741  MBG_SYSLOG_GLB_INFO *p )
10742 {
10744 
10745  if ( mbg_rc_is_error( rc ) )
10746  return rc;
10747 
10748  rc = mbgextio_req_data( pmctl, p_addr, GPS_SYSLOG_GLB_INFO, p, sizeof( *p ) );
10749 
10750  if ( mbg_rc_is_success( rc ) && p )
10752 
10753  return rc;
10754 
10755 } // mbgextio_get_syslog_glb_info
10756 
10757 
10758 
10759 /*HDR*/
10777  const MBG_SYSLOG_GLB_SETTINGS *p )
10778 {
10782 
10783  if ( mbg_rc_is_error( rc ) )
10784  return rc;
10785 
10786  #if _USE_MUTEX
10787  _mbg_mutex_acquire( &pmctl->dev_mutex );
10788  #endif
10789 
10790  *p_data = *p;
10792 
10793  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
10794 
10795  return rc;
10796 
10797 } // mbgextio_set_syslog_glb_settings
10798 
10799 
10800 /*HDR*/
10819  MBG_SYSLOG_INFO_IDX *p, uint16_t idx )
10820 {
10822 
10823  if ( mbg_rc_is_error( rc ) )
10824  return rc;
10825 
10826  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_SYSLOG_INFO_IDX, idx, p, sizeof( *p ) );
10827 
10828  if ( mbg_rc_is_success( rc ) && p )
10830 
10831  return rc;
10832 
10833 } // mbgextio_get_syslog_info_idx
10834 
10835 
10836 /*HDR*/
10855  const XBP_ADDR *p_addr,
10856  const MBG_SYSLOG_SETTINGS *p,
10857  uint16_t idx )
10858 {
10861  int rc;
10862 
10864  if ( mbg_rc_is_error( rc ) )
10865  return rc;
10866 
10867  #if _USE_MUTEX
10868  _mbg_mutex_acquire( &pmctl->dev_mutex );
10869  #endif
10870 
10871  p_data->settings = *p;
10872  p_data->idx = idx;
10873 
10875 
10876  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
10877 
10878  return rc;
10879 
10880 } // mbgextio_set_syslog_settings_idx
10881 
10882 
10883 /*HDR*/
10902  const XBP_ADDR *p_addr,
10903  MBG_FW_GLB_INFO *p )
10904 {
10906 
10907  if ( mbg_rc_is_error( rc ) )
10908  return rc;
10909 
10910  rc = mbgextio_req_data( pmctl, p_addr, GPS_FW_GLB_INFO, p, sizeof( *p ) );
10911 
10912  if ( mbg_rc_is_success( rc ) && p )
10913  _mbg_swab_fw_glb_info( p );
10914 
10915  return rc;
10916 
10917 } // mbgextio_get_fw_glb_info
10918 
10919 
10920 /*HDR*/
10940  MBG_FW_INFO_IDX *p, uint16_t idx )
10941 {
10943 
10944  if ( mbg_rc_is_error( rc ) )
10945  return rc;
10946 
10947  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_FW_INFO_IDX, idx, p, sizeof( *p ) );
10948 
10949  if ( mbg_rc_is_success( rc ) && p )
10950  _mbg_swab_fw_info_idx( p );
10951 
10952  return rc;
10953 
10954 } // mbgextio_get_fw_info_idx
10955 
10956 
10957 /*HDR*/
10974  const XBP_ADDR *p_addr,
10975  uint16_t idx)
10976 {
10978  int rc;
10979 
10981  if ( mbg_rc_is_error( rc ) )
10982  return rc;
10983 
10984  return mbgextio_xmt_cmd_us( pmctl, p_addr, cmd, idx );
10985 
10986 } // mbgextio_set_active_fw
10987 
10988 
10989 /*HDR*/
11006  const XBP_ADDR *p_addr,
11007  uint16_t idx)
11008 {
11010  int rc;
11011 
11013  if ( mbg_rc_is_error( rc ) )
11014  return rc;
11015 
11016  return mbgextio_xmt_cmd_us( pmctl, p_addr, cmd, idx );
11017 
11018 } // mbgextio_delete_fw
11019 
11020 
11021 /*HDR*/
11043  MBG_FW_UFU_INFO_IDX *p, uint8_t fw_idx, uint8_t ufu_idx )
11044 {
11045  uint16_t idx;
11047 
11048  if ( mbg_rc_is_error( rc ) )
11049  return rc;
11050 
11051  idx = ( ( fw_idx << 8 ) | ufu_idx );
11052  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_FW_UFU_INFO_IDX, idx, p, sizeof( *p ) );
11053 
11054  if ( mbg_rc_is_success( rc ) && p )
11056 
11057  return rc;
11058 
11059 } // mbgextio_get_fw_ufu_info_idx
11060 
11061 
11062 /*HDR*/
11079  const XBP_ADDR *p_addr,
11080  const MBG_FW_UFU_FLASH_CMD *p )
11081 {
11082  int err;
11085 
11087  if ( mbg_rc_is_error( err ) )
11088  return err;
11089 
11090  #if _USE_MUTEX
11091  _mbg_mutex_acquire( &pmctl->dev_mutex );
11092  #endif
11093 
11094  *p_data = *p;
11095 
11096  _mbg_swab_fw_ufu_flash_cmd( p_data );
11097 
11098  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
11099 
11100 } // mbgextio_fw_ufu_flash
11101 
11102 
11103 
11104 /*HDR*/
11122  const XBP_ADDR *p_addr,
11124 {
11126 
11127  if ( mbg_rc_is_error( rc ) )
11128  return rc;
11129 
11130  rc = mbgextio_req_data( pmctl, p_addr, GPS_DATABASE_GLB_INFO, p, sizeof( *p ) );
11131 
11132  if ( mbg_rc_is_success( rc ) && p )
11134 
11135  return rc;
11136 
11137 } // mbgextio_get_database_glb_info
11138 
11139 
11140 
11141 /*HDR*/
11160  const XBP_ADDR *p_addr,
11162  uint8_t idx)
11163 {
11165 
11166  if ( mbg_rc_is_error( rc ) )
11167  return rc;
11168 
11169  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_DATABASE_INFO_IDX, idx, p, sizeof( *p ) );
11170 
11171  if ( mbg_rc_is_success( rc ) && p )
11173 
11174  return rc;
11175 
11176 } // mbgextio_get_database_info_idx
11177 
11178 
11179 
11180 /*HDR*/
11197  const XBP_ADDR *p_addr,
11198  const MBG_DATABASE_SETTINGS *p,
11199  uint8_t idx )
11200 {
11203  int rc;
11204 
11206  if ( mbg_rc_is_error( rc ) )
11207  return rc;
11208 
11209  #if _USE_MUTEX
11210  _mbg_mutex_acquire( &pmctl->dev_mutex );
11211  #endif
11212 
11213  p_data->settings = *p;
11214  p_data->idx = idx;
11215 
11217 
11218  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
11219 
11220  return rc;
11221 
11222 } // mbgextio_set_database_settings_idx
11223 
11224 
11225 
11226 /*HDR*/
11244  const XBP_ADDR *p_addr,
11245  uint32_t cmd,
11246  const void *payload,
11247  uint32_t payload_len)
11248 {
11249  int rc;
11250  GPS_CMD gps_cmd;
11251  MBG_DATABASE_CMD *p_data;
11252 
11253  if ( ( !payload && payload_len ) || ( payload && !payload_len ))
11254  return MBG_ERR_INV_PARM;
11255 
11256  if ( payload_len > sizeof( p_data->payload ) )
11257  return MBG_ERR_DATA_SIZE;
11258 
11260  if ( mbg_rc_is_error( rc ) )
11261  return rc;
11262 
11263  #if _USE_MUTEX
11264  _mbg_mutex_acquire( &pmctl->dev_mutex );
11265  #endif
11266 
11267  gps_cmd = GPS_DATABASE_CMD | OPT_GPS_ACK_CODE;
11268  p_data = &pmctl->xmt.pmb->u.msg_data.db_cmd;
11269  p_data->cmd = cmd;
11270 
11271  if ( payload && payload_len )
11272  {
11273  memcpy( p_data->payload, payload, payload_len );
11274  p_data->length = payload_len;
11275  }
11276  else
11277  {
11278  p_data->length = 0;
11279  }
11280 
11281  _mbg_swab_database_cmd( p_data );
11282 
11283  return mbgextio_xmt_msg( pmctl, p_addr, gps_cmd, NULL, sizeof( *p_data ) );
11284 
11285 } // mbgextio_send_database_cmd
11286 
11287 
11288 
11289 /*HDR*/
11306  const XBP_ADDR *p_addr, NTP_GLB_INFO *p )
11307 {
11309 
11310  if ( mbg_rc_is_error( rc ) )
11311  return rc;
11312 
11313  rc = mbgextio_req_data( pmctl, p_addr, GPS_NTP_GLB_CFG, p, sizeof( *p ) );
11314 
11315  if ( mbg_rc_is_success( rc ) && p )
11317 
11318  return rc;
11319 
11320 } // mbgextio_get_ntp_glb_info
11321 
11322 
11323 /*HDR*/
11338  const XBP_ADDR *p_addr,
11339  const NTP_GLB_SETTINGS *p )
11340 {
11342  NTP_GLB_SETTINGS *p_data = &pmctl->xmt.pmb->u.msg_data.ntp_glb_settings;
11343  int rc;
11344 
11346  if ( mbg_rc_is_error( rc ) )
11347  return rc;
11348 
11349  #if _USE_MUTEX
11350  _mbg_mutex_acquire( &pmctl->dev_mutex );
11351  #endif
11352 
11353  *p_data = *p;
11354  _mbg_swab_ntp_glb_settings( p_data );
11355 
11356  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
11357  return rc;
11358 
11359 } // mbgextio_set_ntp_glb_info
11360 
11361 
11362 /*HDR*/
11377 {
11379 
11380  if ( mbg_rc_is_error( rc ) )
11381  return rc;
11382 
11383  rc = mbgextio_req_data( pmctl, p_addr, GPS_NTP_SYMM_KEY_LIMITS, p, sizeof( *p ) );
11384 
11385  if ( mbg_rc_is_success( rc ) && p )
11387 
11388  return rc;
11389 
11390 } // mbgextio_get_ntp_symm_key_limits
11391 
11392 
11393 
11394 /*HDR*/
11413 {
11415 
11416  if ( mbg_rc_is_error( rc ) )
11417  return rc;
11418 
11419  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NTP_SYMM_KEY_CFG, idx, p, sizeof( *p ) );
11420 
11421  if ( mbg_rc_is_success( rc ) && p )
11423 
11424  return rc;
11425 
11426 } // mbgextio_get_ntp_symm_key_info_idx
11427 
11428 
11429 
11430 /*HDR*/
11448  const NTP_SYMM_KEY_SETTINGS *p, uint16_t idx )
11449 {
11452  int rc;
11453 
11455  if ( mbg_rc_is_error( rc ) )
11456  return rc;
11457 
11458  #if _USE_MUTEX
11459  _mbg_mutex_acquire( &pmctl->dev_mutex );
11460  #endif
11461 
11462  p_data->settings = *p;
11463  p_data->idx = idx;
11465 
11466  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
11467  return rc;
11468 
11469 } // mbgextio_set_ntp_symm_key_settings_idx
11470 
11471 
11472 
11473 /*HDR*/
11491 {
11493 
11494  if ( mbg_rc_is_error( rc ) )
11495  return rc;
11496 
11497  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NTP_TRUSTED_KEY_CFG, idx, p, sizeof( *p ) );
11498 
11499  if ( mbg_rc_is_success( rc ) && p )
11501 
11502  return rc;
11503 
11504 } // mbgextio_get_ntp_trusted_key_info_idx
11505 
11506 
11507 
11508 /*HDR*/
11525  const NTP_TRUSTED_KEY_SETTINGS *p, uint16_t idx )
11526 {
11529  int rc;
11530 
11532  if ( mbg_rc_is_error( rc ) )
11533  return rc;
11534 
11535  #if _USE_MUTEX
11536  _mbg_mutex_acquire( &pmctl->dev_mutex );
11537  #endif
11538 
11539  p_data->settings = *p;
11540  p_data->idx = idx;
11542 
11543  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
11544  return rc;
11545 
11546 } // mbgextio_set_ntp_trusted_key_settings_idx
11547 
11548 
11549 
11550 /*HDR*/
11565 {
11567 
11568  if ( mbg_rc_is_error( rc ) )
11569  return rc;
11570 
11571  rc = mbgextio_req_data( pmctl, p_addr, GPS_NTP_MISC_LIMITS, p, sizeof( *p ) );
11572 
11573  if ( mbg_rc_is_success( rc ) && p )
11575 
11576  return rc;
11577 
11578 } // mbgextio_get_ntp_misc_limits
11579 
11580 
11581 
11582 /*HDR*/
11600 {
11602 
11603  if ( mbg_rc_is_error( rc ) )
11604  return rc;
11605 
11606  rc = mbgextio_req_data( pmctl, p_addr, GPS_NTP_MISC_ORPHAN_MODE, p, sizeof( *p ) );
11607 
11608  if ( mbg_rc_is_success( rc ) && p )
11610 
11611  return rc;
11612 
11613 } // mbgextio_get_ntp_misc_orphan_mode_info
11614 
11615 
11616 
11617 /*HDR*/
11635 {
11638  int rc;
11639 
11641  if ( mbg_rc_is_error( rc ) )
11642  return rc;
11643 
11644  #if _USE_MUTEX
11645  _mbg_mutex_acquire( &pmctl->dev_mutex );
11646  #endif
11647 
11648  *p_data = *p;
11650 
11651  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
11652  return rc;
11653 
11654 } // mbgextio_set_ntp_misc_orphan_mode_settings
11655 
11656 
11657 
11658 /*HDR*/
11677  const XBP_ADDR *p_addr, NTP_CLNT_MODE_INFO *p )
11678 {
11680 
11681  if ( mbg_rc_is_error( rc ) )
11682  return rc;
11683 
11684  rc = mbgextio_req_data( pmctl, p_addr, GPS_NTP_CLNT_MODE_CFG, p, sizeof( *p ) );
11685 
11686  if ( mbg_rc_is_success( rc ) && p )
11688 
11689  return rc;
11690 
11691 } // mbgextio_get_ntp_clnt_mode_info
11692 
11693 
11694 
11695 /*HDR*/
11713  const XBP_ADDR *p_addr, const NTP_CLNT_MODE_SETTINGS *p )
11714 {
11717  int rc;
11718 
11720  if ( mbg_rc_is_error( rc ) )
11721  return rc;
11722 
11723  #if _USE_MUTEX
11724  _mbg_mutex_acquire( &pmctl->dev_mutex );
11725  #endif
11726 
11727  *p_data = *p;
11729 
11730  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
11731  return rc;
11732 
11733 } // mbgextio_set_ntp_clnt_mode_cfg
11734 
11735 
11736 
11737 /*HDR*/
11753  const XBP_ADDR *p_addr, NTP_PEER_SETTINGS_IDX *p, uint16_t idx )
11754 {
11756 
11757  if ( mbg_rc_is_error( rc ) )
11758  return rc;
11759 
11760  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NTP_PEER_SETTINGS_IDX, idx, p, sizeof( *p ) );
11761 
11762  if ( mbg_rc_is_success( rc ) && p )
11764 
11765  return rc;
11766 
11767 } // mbgextio_get_ntp_peer_settings_idx
11768 
11769 
11770 
11771 /*HDR*/
11789  const XBP_ADDR *p_addr, const NTP_PEER_SETTINGS *p, uint16_t idx )
11790 {
11793  int rc;
11794 
11796  if ( mbg_rc_is_error( rc ) )
11797  return rc;
11798 
11799  #if _USE_MUTEX
11800  _mbg_mutex_acquire( &pmctl->dev_mutex );
11801  #endif
11802 
11803  p_data->peer_settings = *p;
11804  p_data->idx = idx;
11806 
11807  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
11808  return rc;
11809 
11810 } // mbgextio_set_ntp_peer_settings_idx
11811 
11812 
11813 
11814 /*HDR*/
11831 {
11833 
11834  if ( mbg_rc_is_error( rc ) )
11835  return rc;
11836 
11837  rc = mbgextio_req_data( pmctl, p_addr, GPS_NTP_SRV_MODE_CFG, p, sizeof( *p ) );
11838 
11839  if ( mbg_rc_is_success( rc ) && p )
11841 
11842  return rc;
11843 
11844 } // mbgextio_get_ntp_srv_mode_info
11845 
11846 
11847 /*HDR*/
11864 {
11867  int rc;
11868 
11870  if ( mbg_rc_is_error( rc ) )
11871  return rc;
11872 
11873  #if _USE_MUTEX
11874  _mbg_mutex_acquire( &pmctl->dev_mutex );
11875  #endif
11876 
11877  *p_data = *p;
11879 
11880  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
11881  return rc;
11882 
11883 } // mbgextio_set_ntp_srv_mode_cfg
11884 
11885 
11886 /*HDR*/
11906 {
11908 
11909  if ( mbg_rc_is_error( rc ) )
11910  return rc;
11911 
11912  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NTP_REFCLK_CFG, idx, p, sizeof( *p ) );
11913 
11914  if ( mbg_rc_is_success( rc ) && p )
11916 
11917  return rc;
11918 
11919 } // mbgextio_get_ntp_refclk_cfg_info_idx
11920 
11921 
11922 
11923 /*HDR*/
11942  const NTP_REFCLK_CFG_SETTINGS *p, uint16_t idx )
11943 {
11946  int rc;
11947 
11949  if ( mbg_rc_is_error( rc ) )
11950  return rc;
11951 
11952  #if _USE_MUTEX
11953  _mbg_mutex_acquire( &pmctl->dev_mutex );
11954  #endif
11955 
11956  p_data->settings = *p;
11957  p_data->idx = idx;
11959 
11960  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
11961  return rc;
11962 
11963 } // mbgextio_set_ntp_refclk_cfg_settings_idx
11964 
11965 
11966 
11967 /*HDR*/
11983  const XBP_ADDR *p_addr, NTP_SYS_STATE *p )
11984 {
11986 
11987  if ( mbg_rc_is_error( rc ) )
11988  return rc;
11989 
11990  rc = mbgextio_req_data( pmctl, p_addr, GPS_NTP_SYS_STATE, p, sizeof( *p ) );
11991 
11992  if ( mbg_rc_is_success( rc ) && p )
11994 
11995  return rc;
11996 
11997 } // mbgextio_get_ntp_sys_state
11998 
11999 
12000 
12001 /*HDR*/
12017  const XBP_ADDR *p_addr, NTP_PEER_STATE_IDX *p, uint16_t idx )
12018 {
12020 
12021  if ( mbg_rc_is_error( rc ) )
12022  return rc;
12023 
12024  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NTP_PEER_STATE_IDX, idx, p, sizeof( *p ) );
12025 
12026  if ( mbg_rc_is_success( rc ) && p )
12028 
12029  return rc;
12030 
12031 } // mbgextio_get_ntp_peer_state_idx
12032 
12033 
12034 
12035 /*HDR*/
12051  NTP_REFCLK_STATE_IDX *p, uint16_t idx )
12052 {
12054 
12055  if ( mbg_rc_is_error( rc ) )
12056  return rc;
12057 
12058  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NTP_REFCLK_STATE_IDX, idx, p, sizeof( *p ) );
12059 
12060  if ( mbg_rc_is_success( rc ) && p )
12062 
12063  return rc;
12064 
12065 } // mbgextio_get_ntp_refclk_state_idx
12066 
12067 
12068 /*HDR*/
12083  const XBP_ADDR *p_addr, MBG_NET_GLB_CFG_INFO *p )
12084 {
12086  if ( mbg_rc_is_error( rc ) )
12087  return rc;
12088 
12089  rc = mbgextio_req_data( pmctl, p_addr, GPS_NET_GLB_CFG, p, sizeof( *p ) );
12090 
12091  if ( mbg_rc_is_success( rc ) && p )
12093 
12094  return rc;
12095 
12096 } // mbgextio_get_net_glb_cfg_info
12097 
12098 
12099 
12100 /*HDR*/
12115  const XBP_ADDR *p_addr, const MBG_NET_GLB_CFG_SETTINGS *p )
12116 {
12120  if ( mbg_rc_is_error( rc ) )
12121  return rc;
12122 
12123  #if _USE_MUTEX
12124  _mbg_mutex_acquire( &pmctl->dev_mutex );
12125  #endif
12126 
12127  *p_data = *p;
12129 
12130  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
12131  return rc;
12132 
12133 } // mbgextio_set_net_glb_cfg_settings
12134 
12135 
12136 
12137 /*HDR*/
12154  const XBP_ADDR *p_addr, MBG_IP_ADDR_IDX *p, uint16_t idx )
12155 {
12157  if ( mbg_rc_is_error( rc ) )
12158  return rc;
12159 
12160  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NET_DNS_SRVR, idx, p, sizeof( *p ) );
12161 
12162  if ( mbg_rc_is_success( rc ) && p )
12163  _mbg_swab_ip_addr_idx( p );
12164 
12165  return rc;
12166 
12167 } // mbgextio_get_net_dns_srvr_idx
12168 
12169 
12170 
12171 /*HDR*/
12189  const XBP_ADDR *p_addr, const MBG_IP_ADDR *p, uint16_t idx )
12190 {
12192  MBG_IP_ADDR_IDX *p_data = &pmctl->xmt.pmb->u.msg_data.ip_addr_idx;
12194  if ( mbg_rc_is_error( rc ) )
12195  return rc;
12196 
12197  #if _USE_MUTEX
12198  _mbg_mutex_acquire( &pmctl->dev_mutex );
12199  #endif
12200 
12201  p_data->addr = *p;
12202  p_data->idx = idx;
12203  _mbg_swab_ip_addr_idx( p_data );
12204 
12205  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
12206  return rc;
12207 
12208 } // mbgextio_set_net_dns_srvr_idx
12209 
12210 
12211 
12212 /*HDR*/
12230  const XBP_ADDR *p_addr, MBG_NET_NAME_IDX *p, uint16_t idx )
12231 {
12233  if ( mbg_rc_is_error( rc ) )
12234  return rc;
12235 
12236  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NET_DNS_SRCH_DOM, idx, p, sizeof( *p ) );
12237 
12238  if ( mbg_rc_is_success( rc ) && p )
12240 
12241  return rc;
12242 
12243 } // mbgextio_get_net_dns_srch_dom_idx
12244 
12245 
12246 
12247 /*HDR*/
12265  const XBP_ADDR *p_addr, const MBG_NET_NAME *p, uint16_t idx )
12266 {
12268  MBG_NET_NAME_IDX *p_data = &pmctl->xmt.pmb->u.msg_data.net_name_idx;
12270  if ( mbg_rc_is_error( rc ) )
12271  return rc;
12272 
12273  #if _USE_MUTEX
12274  _mbg_mutex_acquire( &pmctl->dev_mutex );
12275  #endif
12276 
12277  p_data->net_name = *p;
12278  p_data->idx = idx;
12279  _mbg_swab_net_name( p_data );
12280 
12281  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
12282  return rc;
12283 
12284 } // mbgextio_set_net_dns_srch_dom_idx
12285 
12286 
12287 
12288 /*HDR*/
12306  const XBP_ADDR *p_addr, MBG_IP_ADDR_IDX *p, uint16_t idx )
12307 {
12309  if ( mbg_rc_is_error( rc ) )
12310  return rc;
12311 
12312  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NET_STAT_DNS_SRVR, idx, p, sizeof( *p ) );
12313 
12314  if ( mbg_rc_is_success( rc ) && p )
12315  _mbg_swab_ip_addr_idx( p );
12316 
12317  return rc;
12318 
12319 } // mbgextio_get_net_stat_dns_srvr_idx
12320 
12321 
12322 
12323 /*HDR*/
12341  const XBP_ADDR *p_addr, MBG_NET_NAME_IDX *p, uint16_t idx )
12342 {
12344  if ( mbg_rc_is_error( rc ) )
12345  return rc;
12346 
12347  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NET_STAT_DNS_SRCH_DOM, idx, p, sizeof( *p ) );
12348 
12349  if ( mbg_rc_is_success( rc ) && p )
12351 
12352  return rc;
12353 
12354 } // mbgextio_get_net_stat_dns_srch_dom_stat_idx
12355 
12356 
12357 
12358 /*HDR*/
12378 {
12380  if ( mbg_rc_is_error( rc ) )
12381  return rc;
12382 
12383  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NET_INTF_LINK_IDX, idx, p, sizeof( *p ) );
12384 
12385  if ( mbg_rc_is_success( rc ) && p )
12387 
12388  return rc;
12389 
12390 } // mbgextio_get_net_intf_link_info_idx
12391 
12392 
12393 
12394 /*HDR*/
12410  const MBG_NET_INTF_LINK_SETTINGS *p, uint16_t idx )
12411 {
12415  if ( mbg_rc_is_error( rc ) )
12416  return rc;
12417 
12418  #if _USE_MUTEX
12419  _mbg_mutex_acquire( &pmctl->dev_mutex );
12420  #endif
12421 
12422  p_data->settings = *p;
12423  p_data->idx = idx;
12425 
12426  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
12427  return rc;
12428 
12429 } // mbgextio_set_net_intf_link_settings_idx
12430 
12431 
12432 
12433 /*HDR*/
12453 {
12455  if ( mbg_rc_is_error( rc ) )
12456  return rc;
12457 
12458  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NET_INTF_ADDR_IDX, idx, p, sizeof( *p ) );
12459 
12460  if ( mbg_rc_is_success( rc ) && p )
12462 
12463  return rc;
12464 
12465 } // mbgextio_get_net_intf_addr_info_idx
12466 
12467 
12468 
12469 /*HDR*/
12485  const MBG_NET_INTF_ADDR_SETTINGS *p, uint16_t idx )
12486 {
12490  if ( mbg_rc_is_error( rc ) )
12491  return rc;
12492 
12493  #if _USE_MUTEX
12494  _mbg_mutex_acquire( &pmctl->dev_mutex );
12495  #endif
12496 
12497  p_data->settings = *p;
12498  p_data->idx = idx;
12500 
12501  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
12502  return rc;
12503 
12504 } // mbgextio_set_net_intf_addr_settings_idx
12505 
12506 
12507 
12508 /*HDR*/
12528 {
12530  if ( mbg_rc_is_error( rc ) )
12531  return rc;
12532 
12533  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NET_INTF_ROUTE_IDX, idx, p, sizeof( *p ) );
12534 
12535  if ( mbg_rc_is_success( rc ) && p )
12537 
12538  return rc;
12539 
12540 } // mbgextio_get_net_intf_route_info_idx
12541 
12542 
12543 
12544 /*HDR*/
12560  const MBG_NET_INTF_ROUTE_SETTINGS *p, uint16_t idx )
12561 {
12565  if ( mbg_rc_is_error( rc ) )
12566  return rc;
12567 
12568  #if _USE_MUTEX
12569  _mbg_mutex_acquire( &pmctl->dev_mutex );
12570  #endif
12571 
12572  p_data->settings = *p;
12573  p_data->idx = idx;
12575 
12576  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
12577  return rc;
12578 
12579 } // mbgextio_set_net_intf_route_settings_idx
12580 
12581 
12582 
12583 /*HDR*/
12599 {
12601  if ( mbg_rc_is_error( rc ) )
12602  return rc;
12603 
12604  rc = mbgextio_req_data( pmctl, p_addr, GPS_NET_STAT_GLB_CFG, p, sizeof( *p ) );
12605 
12606  if ( mbg_rc_is_success( rc ) && p )
12608 
12609  return rc;
12610 
12611 } // mbgextio_get_net_stat_glb_cfg_info
12612 
12613 
12614 
12615 /*HDR*/
12635 {
12637  if ( mbg_rc_is_error( rc ) )
12638  return rc;
12639 
12640  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NET_STAT_INTF_LINK_IDX, idx, p, sizeof( *p ) );
12641 
12642  if ( mbg_rc_is_success( rc ) && p )
12644 
12645  return rc;
12646 
12647 } // mbgextio_get_net_stat_intf_link_info_idx
12648 
12649 
12650 
12651 /*HDR*/
12671 {
12673  if ( mbg_rc_is_error( rc ) )
12674  return rc;
12675 
12676  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NET_STAT_INTF_ADDR_IDX, idx, p, sizeof( *p ) );
12677 
12678  if ( mbg_rc_is_success( rc ) && p )
12680 
12681  return rc;
12682 
12683 } // mbgextio_get_net_stat_intf_addr_info_idx
12684 
12685 
12686 
12687 /*HDR*/
12707 {
12709  if ( mbg_rc_is_error( rc ) )
12710  return rc;
12711 
12712  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_NET_STAT_INTF_ROUTE_IDX, idx, p, sizeof( *p ) );
12713 
12714  if ( mbg_rc_is_success( rc ) && p )
12716 
12717  return rc;
12718 
12719 } // mbgextio_get_net_stat_intf_route_info_idx
12720 
12721 
12722 
12723 /*HDR*/
12739  const XBP_ADDR *p_addr, XBP_LIMITS *p )
12740 {
12741  int rc = mbgextio_req_data( pmctl, p_addr, GPS_XBP_LIMITS, p, sizeof( *p ) );
12742 
12743  if ( mbg_rc_is_success( rc ) && p )
12744  _mbg_swab_xbp_limits( p );
12745 
12746  return rc;
12747 
12748 } // mbgextio_get_xbp_limits
12749 
12750 
12751 
12752 /*HDR*/
12768  const XBP_ADDR *p_addr, XBP_NODE_LIMITS *p )
12769 {
12770  int rc = mbgextio_req_data( pmctl, p_addr, GPS_XBP_NODE_LIMITS, p, sizeof( *p ) );
12771 
12772  if ( mbg_rc_is_success( rc ) && p )
12774 
12775  return rc;
12776 
12777 } // mbgextio_get_xbp_node_limits
12778 
12779 
12780 
12781 /*HDR*/
12798  const XBP_ADDR *p_addr, XBP_NODE_INFO_IDX *p, uint16_t idx )
12799 {
12800  int rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_XBP_NODE_INFO_IDX, idx, p, sizeof( *p ) );
12801 
12802  if ( mbg_rc_is_success( rc ) && p )
12804 
12805  return rc;
12806 
12807 } // mbgextio_get_xbp_node_info_idx
12808 
12809 
12810 
12811 static /*HDR*/
12812 void handle_xbp_node( XBP_NODE_INFO *p_ni, long idx )
12813 {
12814  XBP_ADDR * p_addr = &p_ni->addr;
12815  RECEIVER_INFO *p_ri = &p_ni->ri;
12816  int i;
12817 
12818  printf( "Node info %li:", idx );
12819 
12820  printf( " addr %02X:", p_addr->hop_count );
12821 
12822  for ( i = 0; i < MAX_XBP_CASC_LVL; i++ )
12823  printf( "%02X ", p_addr->addr[i] );
12824 
12825  printf( ", state: %i", p_ni->state );
12826 
12827  printf( ", name: \"%s\"", p_ri->model_name );
12828 
12829  printf( "\n" );
12830 
12831 } // handle_xbp_node
12832 
12833 
12834 
12835 /*HDR*/
12841 {
12842  static int recursion_count;
12843 
12844  XBP_NODE_LIMITS node_limits;
12845  int rc = MBG_SUCCESS;
12846  uint16_t i;
12847 
12848  // This function can be called recursively, so first of all check the recursion level.
12849  if ( recursion_count > MAX_XBP_CASC_LVL ) //##++++ TODO: or even ">=" ??
12850  {
12851  // This should never happen, but we check this anyway.
12852  rc = MBG_ERR_XBP_CASC_LVL;
12853  goto out;
12854  }
12855 
12856  recursion_count++;
12857 
12858  rc = mbgextio_get_xbp_node_limits( pmctl, p_addr, &node_limits );
12859 
12860  if ( mbg_rc_is_error( rc ) )
12861  goto out_dec;
12862 
12863  for ( i = 0; i < node_limits.node_count; i++ )
12864  {
12865  XBP_NODE_INFO_IDX node_info_idx;
12866 
12867  rc = mbgextio_get_xbp_node_info_idx( pmctl, p_addr, &node_info_idx, i );
12868 
12869  if ( mbg_rc_is_error( rc ) )
12870  break;
12871 
12872  #if 1 && DEBUG
12873  if ( (ulong) node_info_idx.idx != (ulong) i )
12874  printf( "** Warning: received XBP index %li for idx %li in %s\n",
12875  (ulong) node_info_idx.idx, (ulong) i, __func__ );
12876  #endif
12877 
12878  handle_xbp_node( &node_info_idx.node_info, node_info_idx.idx );
12879  }
12880 
12881 out_dec:
12882  if ( recursion_count > 0 )
12883  recursion_count--;
12884  else
12885  {
12886  //### recursion count is unexpectedly 0
12887  }
12888 
12889 out:
12890  return rc;
12891 
12892 } // mbgextio_setup_xbp_node_list
12893 
12894 
12895 
12896 /*HDR*/
12910 {
12911  int rc = mbgextio_req_data( pmctl, p_addr, GPS_CFGH, p, sizeof( *p ) );
12912 
12913  if ( mbg_rc_is_success( rc ) && p )
12914  _mbg_swab_dummy( p );
12915 
12916  return rc;
12917 
12918 } // mbgextio_get_cfgh
12919 
12920 
12921 
12922 /*HDR*/
12937 {
12938  int rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_ALM, svno, p, sizeof( *p ) );
12939 
12940  if ( mbg_rc_is_success( rc ) && p )
12941  _mbg_swab_dummy( p );
12942 
12943  return rc;
12944 
12945 } // mbgextio_get_sv_alm
12946 
12947 
12948 
12949 /*HDR*/
12963 {
12964  int rc = mbgextio_req_data( pmctl, p_addr, GPS_IONO, p, sizeof( *p ) );
12965 
12966  if ( mbg_rc_is_success( rc ) && p )
12967  _mbg_swab_dummy( p );
12968 
12969  return rc;
12970 
12971 } // mbgextio_get_iono
12972 
12973 
12974 
12975 /*HDR*/
12993 {
12994  int rc = mbgextio_req_data( pmctl, p_addr, GPS_UTC, p, sizeof( *p ) );
12995 
12996  if ( mbg_rc_is_success( rc ) && p )
12997  _mbg_swab_utc_parm( p );
12998 
12999  return rc;
13000 
13001 } // mbgextio_get_utc_parm
13002 
13003 
13004 
13005 /*HDR*/
13023 {
13025  UTC *p_data = &pmctl->xmt.pmb->u.msg_data.utc;
13026 
13027  #if _USE_MUTEX
13028  _mbg_mutex_acquire( &pmctl->dev_mutex );
13029  #endif
13030 
13031  *p_data = *p;
13032  _mbg_swab_utc_parm( p_data );
13033 
13034  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
13035 
13036 } // mbgextio_set_utc_parm
13037 
13038 
13039 
13040 /*HDR*/
13057 {
13059 
13060  if ( mbg_rc_is_error( rc ) )
13061  return rc;
13062 
13063  rc = mbgextio_req_data( pmctl, p_addr, GPS_SCU_STAT, p, sizeof( *p ) );
13064 
13065  if ( mbg_rc_is_success( rc ) && p )
13067 
13068  return rc;
13069 
13070 } // mbgextio_get_scu_stat_info
13071 
13072 
13073 
13074 /*HDR*/
13091 {
13092  // TODO: request ACK for SCU_STAT_SETTINGS (at the moment, this is not implemented in RSC/MDU)
13093  GPS_CMD cmd = GPS_SCU_STAT;
13094  SCU_STAT_SETTINGS *p_data = &pmctl->xmt.pmb->u.msg_data.scu_stat_settings;
13096 
13097  if ( mbg_rc_is_error( rc ) )
13098  return rc;
13099 
13100  #if _USE_MUTEX
13101  _mbg_mutex_acquire( &pmctl->dev_mutex );
13102  #endif
13103 
13104  *p_data = *p;
13105  _mbg_swab_scu_stat_settings( p_data );
13106 
13107  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
13108  return rc;
13109 
13110 } // mbgextio_set_scu_stat_settings
13111 
13112 
13113 
13114 #if _USE_TIME_MON && defined( _PRELIMINARY_CODE )
13115 
13116 /*HDR*/
13118  const XBP_ADDR *p_addr, MBG_TIME_MON_INST_INFO *p )
13119 {
13120  int rc = mbgextio_req_data( pmctl, p_addr, GPS_TIME_MON_INST_INFO, p, sizeof( *p ) );
13121 
13122  if ( mbg_rc_is_success( rc ) && p )
13123  _mbg_swab_time_mon_inst_info( p );
13124 
13125  return rc;
13126 
13127 } // mbgextio_time_mon_get_inst_info
13128 
13129 
13130 
13131 /*HDR*/
13133  const XBP_ADDR *p_addr, const MBG_TIME_MON_INST_INFO *p )
13134 {
13136  MBG_TIME_MON_INST_INFO *p_data = &pmctl->xmt.pmb->u.msg_data.time_mon_inst_info;
13137 
13138  #if _USE_MUTEX
13139  _mbg_mutex_acquire( &pmctl->dev_mutex );
13140  #endif
13141 
13142  *p_data = *p;
13143  _mbg_swab_time_mon_inst_info( p_data );
13144 
13145  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
13146 
13147 } // mbgextio_time_mon_send_inst_info
13148 
13149 
13150 
13151 /*HDR*/
13153  const XBP_ADDR *p_addr, const MBG_TIME_MON_TARGET_SETTINGS *p )
13154 {
13156  MBG_TIME_MON_TARGET_SETTINGS *p_data = &pmctl->xmt.pmb->u.msg_data.time_mon_target_settings;
13157 
13158  #if _USE_MUTEX
13159  _mbg_mutex_acquire( &pmctl->dev_mutex );
13160  #endif
13161 
13162  *p_data = *p;
13163  _mbg_swab_time_mon_target_settings( p_data );
13164 
13165  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
13166 
13167 } // mbgextio_time_mon_send_target_settings
13168 
13169 
13170 
13171 /*HDR*/
13173  const XBP_ADDR *p_addr, MBG_TIME_MON_TARGET_STATUS_IDX *p, uint16_t idx )
13174 {
13175  int rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_TIME_MON_TARGET_STATUS_IDX, idx, p, sizeof( *p ) );
13176 
13177  if ( mbg_rc_is_success( rc ) && p )
13178  _mbg_swab_time_mon_target_status_idx( p );
13179 
13180  return rc;
13181 
13182 } // mbgextio_time_mon_get_target_status_idx
13183 
13184 
13185 
13186 /*HDR*/
13188  const XBP_ADDR *p_addr, MBG_TIME_MON_TARGET_EXT_DATA_SET_IDX *p, uint16_t idx )
13189 {
13190  int rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_TIME_MON_TARGET_EXT_DATA_SET_IDX, idx, p, sizeof( *p ) );
13191 
13192  if ( mbg_rc_is_success( rc ) && p )
13193  _mbg_swab_time_mon_target_ext_data_set_idx( p );
13194 
13195  return rc;
13196 
13197 } // mbgextio_time_mon_get_target_ext_data_set_idx()
13198 
13199 #endif // _USE_TIME_MON && defined( _PRELIMINARY_CODE )
13200 
13201 
13202 /*HDR*/
13217 {
13218  int rc = mbgextio_req_data( pmctl, p_addr, GPS_FDM_FREQ, p, sizeof( *p ) );
13219 
13220  if ( mbg_rc_is_success( rc ) && p )
13222 
13223  return rc;
13224 
13225 } // mbgextio_get_fdm_freq
13226 
13227 
13228 /*HDR*/
13243 {
13245 
13246  if ( mbg_rc_is_error( rc ) )
13247  return rc;
13248 
13249  rc = mbgextio_req_data( pmctl, p_addr, GPS_FDM_INFO, p, sizeof( *p ) );
13250 
13251  if ( mbg_rc_is_success( rc ) && p )
13253 
13254  return rc;
13255 
13256 } // mbgextio_get_ims_fdm_info
13257 
13258 
13259 /*HDR*/
13274 {
13276 
13277  if ( mbg_rc_is_error( rc ) )
13278  return rc;
13279 
13280  rc = mbgextio_req_data( pmctl, p_addr, GPS_FDM_LIMITS, p, sizeof( *p ) );
13281 
13282  if ( mbg_rc_is_success( rc ) && p )
13284 
13285  return rc;
13286 
13287 } // mbgextio_get_ims_fdm_limits
13288 
13289 
13290 /*HDR*/
13306 {
13308 
13309  if ( mbg_rc_is_error( rc ) )
13310  return rc;
13311 
13312  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_FDM_OUTPUT_INFO_IDX, idx, p, sizeof( *p ) );
13313 
13314  if ( mbg_rc_is_success( rc ) && p )
13316 
13317  return rc;
13318 
13319 } // mbgextio_get_ims_fdm_output_info_idx
13320 
13321 
13322 
13323 /*HDR*/
13339 {
13341 
13342  if ( mbg_rc_is_error( rc ) )
13343  return rc;
13344 
13345  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_FDM_OUTPUT_STATE_IDX, idx, p, sizeof( *p ) );
13346 
13347  if ( mbg_rc_is_success( rc ) && p )
13349 
13350  return rc;
13351 
13352 } // mbgextio_get_ims_fdm_output_state_idx
13353 
13354 
13355 /*HDR*/
13370 {
13372 
13373  if ( mbg_rc_is_error( rc ) )
13374  return rc;
13375 
13376  rc = mbgextio_req_data( pmctl, p_addr, GPS_FDM_STATE, p, sizeof( *p ) );
13377 
13378  if ( mbg_rc_is_success( rc ) && p )
13380 
13381  return rc;
13382 
13383 } // mbgextio_get_ims_fdm_state
13384 
13385 
13386 /*HDR*/
13401 {
13403  MBG_IMS_FDM_SETTINGS *p_data = &pmctl->xmt.pmb->u.msg_data.fdm_settings;
13405 
13406  if ( mbg_rc_is_error( rc ) )
13407  return rc;
13408 
13409  #if _USE_MUTEX
13410  _mbg_mutex_acquire( &pmctl->dev_mutex );
13411  #endif
13412 
13413  *p_data = *p;
13415 
13416  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
13417  return rc;
13418 
13419 } // mbgextio_set_ims_fdm_settings
13420 
13421 
13422 /*HDR*/
13438  const MBG_IMS_FDM_OUTPUT_SETTINGS *p, uint16_t idx )
13439 {
13443 
13444  if ( mbg_rc_is_error( rc ) )
13445  return rc;
13446 
13447  #if _USE_MUTEX
13448  _mbg_mutex_acquire( &pmctl->dev_mutex );
13449  #endif
13450 
13451  p_data->settings = *p;
13452  p_data->idx = idx;
13454 
13455  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
13456  return rc;
13457 
13458 } // mbgextio_set_ims_fdm_output_settings_idx
13459 
13460 
13461 /*HDR*/
13475 {
13477  NANO_TIME_64 *p_data = &pmctl->xmt.pmb->u.msg_data.nano_time_64;
13479 
13480  if ( mbg_rc_is_error( rc ) )
13481  return rc;
13482 
13483  #if _USE_MUTEX
13484  _mbg_mutex_acquire( &pmctl->dev_mutex );
13485  #endif
13486 
13487  *p_data = *p;
13488  _mbg_swab_nano_time_64( p_data );
13489 
13490  rc = mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
13491  return rc;
13492 
13493 } // mbgextio_set_fdm_tdev
13494 
13495 
13496 /*HDR*/
13510 {
13512 
13513  if ( mbg_rc_is_error( rc ) )
13514  return rc;
13515 
13516  rc = mbgextio_xmt_cmd( pmctl, p_addr, GPS_SAVE_CFG | OPT_GPS_ACK_CODE );
13517  return rc;
13518  //### TODO: check if ACK works
13519 
13520 } // mbgextio_cmd_save_cfg
13521 
13522 
13523 
13524 /*HDR*/
13538 {
13539  int rc = mbgextio_req_data( pmctl, p_addr, GPS_LNE_LIMITS, p, sizeof( *p ) );
13540 
13541  if ( mbg_rc_is_success( rc ) && p )
13543 
13544  return rc;
13545 
13546 } // mbgextio_get_lne_limits
13547 
13548 
13549 
13550 /*HDR*/
13564 {
13565  int rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_LNE_PORT_INFO_IDX, idx, p, sizeof( *p ) );
13566 
13567  if ( mbg_rc_is_success( rc ) && p )
13569 
13570  return rc;
13571 
13572 } // mbgextio_get_lne_port_info_idx
13573 
13574 
13575 
13576 /*HDR*/
13590 {
13591  int rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_LNE_PORT_SETTINGS_IDX, idx, p, sizeof( *p ) );
13592 
13593  if ( mbg_rc_is_success( rc ) && p )
13595 
13596  return rc;
13597 
13598 } // mbgextio_get_lne_port_settings_idx
13599 
13600 
13601 
13602 /*HDR*/
13616 {
13619 
13620  #if _USE_MUTEX
13621  _mbg_mutex_acquire( &pmctl->dev_mutex );
13622  #endif
13623 
13624  p_data->settings = *p;
13625  p_data->idx = idx;
13627 
13628  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
13629 
13630 } // mbgextio_set_lne_port_settings_idx
13631 
13632 
13633 
13634 /*HDR*/
13647 {
13649  MBG_PWR_CTL *p_data = &pmctl->xmt.pmb->u.msg_data.pwr_ctl;
13650 
13651  #if _USE_MUTEX
13652  _mbg_mutex_acquire( &pmctl->dev_mutex );
13653  #endif
13654 
13655  *p_data = *p;
13656  _mbg_swab_mbg_pwr_ctl( p_data );
13657 
13658  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
13659 
13660 } // mbgextio_set_pwr_ctl
13661 
13662 
13663 
13664 /*HDR*/
13677 {
13678  int rc = mbgextio_req_data( pmctl, p_addr, GPS_PWR_CTL, p, sizeof( *p ) );
13679 
13680  if ( mbg_rc_is_success( rc ) && p )
13681  _mbg_swab_mbg_pwr_ctl( p );
13682 
13683  return rc;
13684 
13685 } // mbgextio_get_pwr_ctl
13686 
13687 
13688 
13689 /*HDR*/
13712  MBG_LED_LIMITS *p )
13713 {
13714  int rc = mbgextio_req_data( pmctl, p_addr, GPS_LED_LIMITS, p, sizeof( *p ) );
13715 
13716  if ( mbg_rc_is_success( rc ) && p )
13718 
13719  return rc;
13720 
13721 } // mbgextio_get_led_limits
13722 
13723 
13724 
13725 /*HDR*/
13746  MBG_LED_INFO_IDX *p, uint16_t idx )
13747 {
13748  int rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_LED_INFO_IDX, idx, p, sizeof( *p ) );
13749 
13750  if ( mbg_rc_is_success( rc ) && p )
13752 
13753  return rc;
13754 
13755 } // mbgextio_get_led_info_idx
13756 
13757 
13758 
13759 /*HDR*/
13780 {
13781  int rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_LED_SETTINGS_IDX, idx, p, sizeof( *p ) );
13782 
13783  if ( mbg_rc_is_success( rc ) && p )
13785 
13786  return rc;
13787 
13788 } // mbgextio_get_led_settings_idx
13789 
13790 
13791 
13792 /*HDR*/
13813 {
13816 
13817  #if _USE_MUTEX
13818  _mbg_mutex_acquire( &pmctl->dev_mutex );
13819  #endif
13820 
13821  p_data->settings = *p;
13822  p_data->idx = idx;
13824 
13825  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
13826 
13827 } // mbgextio_set_led_settings_idx
13828 
13829 
13830 
13831 /*HDR*/
13844  const XBP_ADDR *p_addr,
13845  MBG_TAINTED_CFG *p )
13846 {
13847  int rc = mbgextio_req_data( pmctl, p_addr, GPS_TAINTED_CFG, p, sizeof( *p ) );
13848 
13849  if ( mbg_rc_is_success( rc ) && p )
13850  _mbg_swab_tainted_cfg( p );
13851 
13852  return rc;
13853 
13854 } // mbgextio_get_tainted_cfg
13855 
13856 
13857 
13858 /*HDR*/
13871  const XBP_ADDR *p_addr,
13872  GPS_CMD cmd)
13873 {
13874  return mbgextio_xmt_cmd_us( pmctl, p_addr, GPS_REGISTER_PUSH_MSGS | OPT_GPS_ACK_CODE, cmd);
13875 
13876 } // mbgextio_register_push_msg
13877 
13878 
13879 
13880 /*HDR*/
13893  const XBP_ADDR *p_addr,
13894  GPS_CMD cmd)
13895 {
13896  return mbgextio_xmt_cmd_us( pmctl, p_addr, GPS_UNREGISTER_PUSH_MSGS | OPT_GPS_ACK_CODE, cmd);
13897 
13898 } // mbgextio_unregister_push_msg
13899 
13900 
13901 
13902 /*HDR*/
13904  const XBP_ADDR *p_addr,
13905  MBG_EXT_SYS_INFO *p )
13906 {
13907  int rc = mbgextio_req_data( pmctl, p_addr, GPS_EXT_SYS_INFO, p, sizeof( *p ) );
13908 
13909  if ( mbg_rc_is_success( rc ) && p )
13911 
13912  return rc;
13913 
13914 } // mbgextio_get_ext_sys_info
13915 
13916 
13917 /*HDR*/
13919  const XBP_ADDR *p_addr,
13920  CORR_INFO *p )
13921 {
13923 
13924  if ( mbg_rc_is_error( rc ) )
13925  return rc;
13926 
13927  rc = mbgextio_req_data( pmctl, p_addr, PZF_CORR_INFO, p, sizeof( *p ) );
13928 
13929  if ( mbg_rc_is_success( rc ) && p )
13930  _mbg_swab_corr_info( p );
13931 
13932  return rc;
13933 
13934 } // mbgextio_get_core_info
13935 
13936 
13937 
13938 /*HDR*/
13949  uint16_t perm,
13950  uint32_t scope_mask )
13951 {
13953  {
13954  if ( ( scope_mask & USER_SCOPE_STATUS_READ_MSK ) == USER_SCOPE_STATUS_READ_MSK )
13955  {
13957  return MBG_SUCCESS;
13958  }
13959 
13960  if ( ( scope_mask & USER_SCOPE_CONFIG_READ_MSK ) == USER_SCOPE_CONFIG_READ_MSK )
13961  {
13963  return MBG_SUCCESS;
13964  }
13965 
13966  if ( ( scope_mask & USER_SCOPE_CONFIG_WRITE_MSK ) == USER_SCOPE_CONFIG_WRITE_MSK )
13967  {
13969  return MBG_SUCCESS;
13970  }
13971 
13972  return MBG_ERR_PERM;
13973  }
13974 
13975  return MBG_SUCCESS;
13976 
13977 } // mbgextio_chk_usr_perm
13978 
13979 
13980 
13981 /*HDR*/
13999 {
14001 
14002  if ( mbg_rc_is_error( rc ) )
14003  return rc;
14004 
14005  rc = mbgextio_req_data( pmctl, p_addr, GPS_SVC_MGMT_INFO, p, sizeof( *p ) );
14006 
14007  if ( mbg_rc_is_success( rc ) && p )
14009 
14010  return rc;
14011 
14012 } // mbgextio_get_svc_mgmt_info
14013 
14014 
14015 
14016 /*HDR*/
14034  MBG_SERVICE_INFO_IDX *p, uint16_t idx )
14035 {
14037 
14038  if ( mbg_rc_is_error( rc ) )
14039  return rc;
14040 
14041  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_SVC_INFO_IDX, idx, p, sizeof( *p ) );
14042 
14043  if ( mbg_rc_is_success( rc ) && p )
14045 
14046  return rc;
14047 
14048 } // mbgextio_get_svc_info_idx
14049 
14050 
14051 
14052 /*HDR*/
14070  const MBG_SERVICE_SETTINGS *p, uint16_t idx )
14071 {
14074  int rc;
14075 
14077  if ( mbg_rc_is_error( rc ) )
14078  return rc;
14079 
14080  #if _USE_MUTEX
14081  _mbg_mutex_acquire( &pmctl->dev_mutex );
14082  #endif
14083 
14084  p_data->settings = *p;
14085  p_data->idx = idx;
14086  _mbg_swab_svc_settings_idx( p_data );
14087 
14088  return mbgextio_xmt_msg( pmctl, p_addr, cmd, NULL, sizeof( *p_data ) );
14089 
14090 } // mbgextio_set_svc_settings_idx
14091 
14092 
14093 
14094 /*HDR*/
14113 {
14115 
14116  if ( mbg_rc_is_error( rc ) )
14117  return rc;
14118 
14119  rc = mbgextio_req_data_idx( pmctl, p_addr, GPS_SVC_STATUS_IDX, idx, p, sizeof( *p ) );
14120 
14121  if ( mbg_rc_is_success( rc ) && p )
14123 
14124  return rc;
14125 
14126 } // mbgextio_get_svc_status_idx
14127 
14128 
14129 
14130 /*HDR*/
14148  uint16_t idx, uint16_t ctl )
14149 {
14151  uint32_t u32 = ( ( idx << 16 ) | ctl );
14152  int rc;
14153 
14155  if ( mbg_rc_is_error( rc ) )
14156  return rc;
14157 
14158  return mbgextio_xmt_cmd_u32( pmctl, p_addr, cmd, u32 );
14159 
14160 } // mbgextio_set_svc_ctl_idx
PTP_UC_MASTER_SETTINGS_IDX ptp_uc_master_settings_idx
Definition: gpsserio.h:1414
MBG_IO_PORT_INFO_IDX iop_info_idx
Definition: gpsserio.h:1480
Binary reception in progress, i.e. after START_OF_HEADER received.
Definition: gpsserio.h:714
int mbgextio_get_net_intf_route_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_NET_INTF_ROUTE_INFO_IDX *p, uint16_t idx)
Read MBG_NET_INTF_ROUTE_INFO_IDX from the config with the given index.
Definition: mbgextio.c:12526
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_io_ports
Definition: mbgextio.c:3401
from device: acknowledge a command
Definition: gpsserio.h:741
XDEVFEAT_CHK_SUPP_FNC xdevfeat_supp_tlv_ptpv2_license
Check if a device supports PTPv2 license infos.
Definition: xdevfeat.c:1212
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_prog_pulses
Definition: xdevfeat.c:429
MBG_PTP_V2_PORT_DATASET port_dataset
see MBG_PTP_V2_PORT_DATASET
Definition: gpsdefs.h:15076
A structure to used to read the status of the PTP protocol stack.
Definition: gpsdefs.h:13184
MBG_IP_ADDR addr
network address
Definition: gpsdefs.h:11948
int mbgextio_free_lan_devices(MBG_LAN_DEV_LIST *list)
Frees the MBG_LAN_DEV_LIST allocated by mbgextio_find_lan_devices.
int mbgextio_get_ntp_refclk_state_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_REFCLK_STATE_IDX *p, uint16_t idx)
Read the NTP refclock state of current idx in NTP_REFCLK_STATE format.
Definition: mbgextio.c:12050
uint16_t TR_DISTANCE
Receiver distance from transmitter [km].
Definition: pcpsdefs.h:1553
Query MBG_NET_INTF_ROUTE_SETTINGS by its index.
Definition: gpsdefs.h:12303
int mbgextio_get_net_stat_dns_srvr_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IP_ADDR_IDX *p, uint16_t idx)
Read the current network DNS server in MBG_IP_ADDR_IDX format.
Definition: mbgextio.c:12305
PTP_CFG_SETTINGS ptp_cfg_settings
Definition: gpsserio.h:1410
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_service
Definition: mbgextio.c:3731
NTP_PEER_SETTINGS_IDX ntp_peer_settings_idx
Definition: gpsserio.h:1421
Configuration settings for a specific PTP unicast master.
Definition: gpsdefs.h:14329
#define MBGEXTIO_MSG_TIMEOUT_SERIAL
Definition: mbgextio.c:713
#define _mbg_swab_xbp_node_info_idx(_p)
Definition: gpsdefs.h:18051
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_fw_mngmnt
Check if a device supports the FW management API.
Definition: xdevfeat.c:993
#define _mbg_swab_mbg_ims_fdm_output_settings_idx(_p)
Definition: gpsdefs.h:10033
int mbgextio_open_usb(const MBG_USB_DEV_INFO *mdev_info, MBG_MSG_CTL **ppmctl)
Open a binary communication channel using direct USB I/O.
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_supp_tlv_diag_file
Check if a device supports creating / sending a diagnostics file via TLV.
Definition: mbgextio.c:4150
(r–) MBG_IMS_FDM_OUTPUT_INFO, only if MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in MBG_IMS_STATE::flags ...
Definition: gpsserio.h:882
Number of event log entries that can be stored and yet have been saved.
Definition: gpsdefs.h:9540
(r–) MBG_LNE_LIMITS, LNE API capabilities, only if MBG_XFEATURE_LNE_API
Definition: gpsserio.h:893
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_is_bus_lvl_dev
Check if a device is a bus level device.
Definition: mbgextio.c:3592
(r–) XMULTI_REF_INFO_IDX, idx 0..XMULTI_REF_INSTANCES::n_xmr_settings-1, only if GPS_HAS_XMULTI_REF ...
Definition: gpsserio.h:832
int32_t BAUD_RATE
A data type to configure a serial port&#39;s baud rate.
Definition: gpsdefs.h:3190
(-w-) Transmit index of MBG_FW_INFO_IDX to be deleted
Definition: gpsserio.h:976
RECEIVER_INFO ri
Definition: gpsdefs.h:18013
#define _mbg_swab_havequick_settings(_p)
Definition: gpsdefs.h:9466
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_is_tcr
Check if a device is a time code receiver(TCR)
Definition: mbgextio.c:3526
Summary of configuration and health data of all satellites.
Definition: gpsdefs.h:18512
NTP trusted key settings.
Definition: gpsdefs.h:15989
int mbgextio_cmd_save_cfg(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr)
Send a command to let the device save it&#39;s current configuration as default.
Definition: mbgextio.c:13509
Configuration settings of a specific serial port.
Definition: gpsdefs.h:3594
uint8_t n_str_type
max num of string types supported by any port
Definition: gpsdefs.h:888
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_pos_lla
Check if a device supports reading the position as LLA array.
Definition: xdevfeat.c:550
#define _mbg_swab_event_status_idx(_p, _type)
Definition: gpsdefs.h:22106
int mbgextio_set_net_intf_route_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_NET_INTF_ROUTE_SETTINGS *p, uint16_t idx)
Send the network addr configuration in MBG_NET_INTF_ROUTE_SETTINGS format.
Definition: mbgextio.c:12559
(rw-) ENABLE_FLAGS, when to enable serial, pulses, and synth, only if GPS_MODEL_HAS_ENABLE_FLAGS ...
Definition: gpsserio.h:805
int mbgextio_get_event_status_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, uint8_t vtype, MBG_EVENT_STATUS_IDX *p, uint16_t idx)
Read monitoring event status in MBG_EVENT_STATUS_IDX format.
Definition: mbgextio.c:10651
uint16_t len
length of the data portion appended after the header
Definition: gpsserio.h:1334
NTP trusted key info, with index.
Definition: gpsdefs.h:16051
(-w-) MBG_IO_PORT_SETTINGS_IDX, only supp. if MBG_XFEATURE_IO_PORTS is set in extended features ...
Definition: gpsserio.h:921
#define USB_DEV_CPC_01
USB device ID numbers assigned by Meinberg.
Definition: usbdefs.h:208
int mbgextio_req_data(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd, void *buf, size_t buf_size)
Transmit a message without a single ushort (16 bit) parameter.
Definition: mbgextio.c:5280
#define _mbg_swab_mbg_lne_port_settings_idx(_p)
Definition: gpsdefs.h:19068
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_gps_stat_info
Check if a device supports the STAT_INFO structure and API.
Definition: mbgextio.c:3455
#define _mbg_swab_gnss_sv_status_idx(_p)
Definition: gpsdefs.h:10975
MBG_MUTEX dev_mutex
Mutex to serialize device access.
Definition: gpsserio.h:1978
int mbgextio_set_ignore_lock(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const IGNORE_LOCK *p)
Send the ignore lock configuration.
Definition: mbgextio.c:5904
Output settings for FDM devices plus index.
Definition: gpsdefs.h:10026
#define _mbg_swab_syslog_info_idx(_p)
Definition: gpsdefs.h:22240
IO Port Type Info Index.
Definition: gpsdefs.h:21046
(r–) NTP_PEER_STATE_IDX, with index 0 ... NTP_CLNT_MODE_SETTINGS::num_peers - 1
Definition: gpsserio.h:865
int mbgextio_xmt_secu_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const char *old_passwd, const char *new_passwd)
Send security settings for the socket connection.
IO Port Type Status.
Definition: gpsdefs.h:21225
int mbgserio_read_wait(MBGSERIO_DEV *mdev, void *buffer, uint count)
int mbgextio_get_xmr_holdover_status(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XMR_HOLDOVER_STATUS *p)
Read XMR_HOLDOVER_STATUS.
Definition: mbgextio.c:8733
int mbgextio_set_ptp_v2_current_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_PTP_V2_CURRENT_DATASET *p)
Send PTPv2 current dataset to a device in MBG_PTP_V2_CURRENT_DATASET format.
Definition: mbgextio.c:9855
#define GPS_MODEL_NAME_FCU_01
Definition: gpsdefs.h:1114
(rw-) CFGH, SVs&#39; configuration and health codes
Definition: gpsserio.h:983
(rw-) ANT_CABLE_LEN, length of antenna cable, only if GPS_MODEL_HAS_ANT_CABLE_LEN ...
Definition: gpsserio.h:809
int mbgextio_get_gnss_sat_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GNSS_SAT_INFO_IDX *p, uint16_t idx)
::TODO
Definition: mbgextio.c:8482
MBG_NET_INTF_ROUTE_SETTINGS settings
see MBG_NET_INTF_ROUTE_SETTINGS
Definition: gpsdefs.h:12306
An IPv4 or IPv6 network address.
Definition: gpsdefs.h:11906
(-w-) no data, only if RECEIVER_INFO::n_ucaps > 0
Definition: gpsserio.h:836
int mbgextio_get_xbp_limits(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XBP_LIMITS *p)
Read the XBP_LIMITS to check which XBP features are supported.
Definition: mbgextio.c:12738
int mbgextio_set_net_dns_srvr_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_IP_ADDR *p, uint16_t idx)
Send the network DNS server address in MBG_IP_ADDR format.
Definition: mbgextio.c:12188
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_evt_log
Definition: mbgextio.c:3946
(r–) MBG_DATABASE_GLB_INFO, only supp. if MBG_XFEATURE_DATABASE is set
Definition: gpsserio.h:978
(rw-) NTP_SRV_MODE_INFO/NTP_SRV_MODE_SETTINGS, only if NTP_MSK_ROLE_SERVER
Definition: gpsserio.h:862
int mbgextio_get_syslog_glb_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_SYSLOG_GLB_INFO *p)
Read the syslog global info in MBG_SYSLOG_GLB_INFO format.
Definition: mbgextio.c:10740
connection via direct USB I/O operation
Definition: gpsserio.h:2056
uint32_t idx
the index of the user
Definition: gpsdefs.h:22855
int mbgextio_get_xmr_ext_src_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XMR_EXT_SRC_INFO_IDX *p, uint16_t idx)
Read XMR_EXT_SRC_INFO_IDX.
Definition: mbgextio.c:8689
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_irig_tx
Definition: mbgextio.c:3687
(rw-) IRIG_SETTINGS, only if GPS_HAS_IRIG_RX
Definition: gpsserio.h:827
int mbgextio_get_ext_sys_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_EXT_SYS_INFO *p)
Definition: mbgextio.c:13903
int mbgextio_get_ptp_v2_parent_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_PTP_V2_PARENT_DATASET *p)
Read the PTPv2 parent dataset in MBG_PTP_V2_PARENT_DATASET format.
Definition: mbgextio.c:9894
(rw-) MBG_REF_OFFS, only if GPS_HAS_REF_OFFS
Definition: gpsserio.h:829
(r–) MBG_NET_INTF_ADDR_INFO_IDX, addr status, only if MBG_NET_GLB_SUPP_STAGE_2_MASK is set in MBG_NE...
Definition: gpsserio.h:916
#define GPS_WILDCARD
A wildcard command code.
Definition: gpsserio.h:754
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_ptp
Check if a device supports the PTP API.
Definition: xdevfeat.c:943
int mbgextio_get_all_ptp_uc_master_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, PTP_UC_MASTER_INFO_IDX *ptp_uc_master_info_idx, const PTP_UC_MASTER_CFG_LIMITS *ptp_uc_master_cfg_limits)
Read the ptp configuration ALL_PTP_UC_MASTER_INFO_IDX format.
Definition: mbgextio.c:9252
#define _mbg_swab_mbg_pwr_ctl(_p)
Definition: gpsdefs.h:19200
MBG_NET_INTF_ROUTE_SETTINGS_IDX net_intf_route_settings_idx
Definition: gpsserio.h:1436
#define MBG_FORCE_CONN_CMD_STR
Strings used to force connection settings for the binary protocol.
Definition: gpsdefs.h:3439
(r–) MBG_EVENT_STATUS_IDX, only supp. if MBG_XFEATURE_MONITORING is set in extended features ...
Definition: gpsserio.h:943
Global settings for user captures via network.
Definition: gpsdefs.h:12466
int mbgextio_get_net_stat_intf_link_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_NET_INTF_LINK_INFO_IDX *p, uint16_t idx)
Read MBG_NET_INTF_LINK_INFO_IDX from the status with the given index.
Definition: mbgextio.c:12633
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_clk_res_info
Check if a device supports the MBG_CLK_RES_INFO structure.
Definition: xdevfeat.c:1654
connection via serial port
Definition: gpsserio.h:2052
int mbgextio_get_ptp_v1_time_properties_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_PTP_V1_TIME_PROPERTIES_DATASET *p)
Read the PTPv1 time properties dataset in MBG_PTP_V1_TIME_PROPERTIES_DATASET format.
Definition: mbgextio.c:9599
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
uint32_t node_count
Number of XBP nodes available in the system.
Definition: gpsdefs.h:17928
GPS UTC correction parameters.
Definition: gpsdefs.h:18564
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_ant_cable_length
Check if a device supports the ANT_CABLE_LEN structure and API.
Definition: xdevfeat.c:724
#define _mbg_swab_snmp_v12_trap_info_idx(_p)
Definition: gpsdefs.h:21543
(rw-) PTP_CFG_INFO/PTP_CFG_SETTINGS, only if GPS_HAS_PTP
Definition: gpsserio.h:856
(r–) MBG_SERVICE_STATUS_IDX, index 0 .. MBG_SERVICE_MGMT_INFO::num_services - 1, only supp...
Definition: gpsserio.h:968
int mbgextio_get_ignore_lock(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, IGNORE_LOCK *p)
Read the status of ignore lock.
Definition: mbgextio.c:5873
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_pos_xyz
Check if a device supports reading the position as XYZ array.
Definition: xdevfeat.c:528
uint16_t n_supp_master
number of unicast masters which can be specified
Definition: gpsdefs.h:14233
#define MBG_ERR_DATA_SIZE
the received data size toesn&#39;t match the expected data size
Definition: mbgerror.h:354
TR_DISTANCE tr_distance
Definition: gpsserio.h:1577
(rw-) MBG_UCAP_NET_GLB_INFO/MBG_UCAP_NET_GLB_SETTINGS, only supp. if MBG_XFEATURE_UCAP_NET is set in ...
Definition: gpsserio.h:918
XDEVFEAT_CHK_SUPP_FNC xdevfeat_supp_tlv_ptpv1_license
Check if a device supports PTPv1 License Infos via TLV.
Definition: xdevfeat.c:1254
int mbgextio_get_ip4_state(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, IP4_SETTINGS *p)
Read the current lan ipv4 state IP4_SETTINGS format.
Definition: mbgextio.c:9120
(r–) MBG_IMS_FDM_OUTPUT_STATE_IDX, only if MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in MBG_IMS_STATE::f...
Definition: gpsserio.h:880
A structure used to configure a PTP port.
Definition: gpsdefs.h:13278
(r–) IRIG_INFO, only if GPS_HAS_IRIG_RX
Definition: gpsserio.h:828
int mbgextio_get_ptp_uc_master_cfg_limits(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, PTP_UC_MASTER_CFG_LIMITS *p)
Read the ptp configuration PTP_UC_MASTER_CFG_LIMITS format.
Definition: mbgextio.c:9218
int MBGEXTIO_CHK_SUPP_FNC(const MBG_MSG_CTL *pmctl)
Type of functions to check if a feature is supported.
Definition: mbgextio.h:563
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_ucap
Definition: mbgextio.c:3956
int xmt_cmd(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd)
Send a binary command message without parameters.
ulong mbgextio_get_msg_rcv_timeout(const MBG_MSG_CTL *pmctl)
Get message receive timeout value.
Definition: mbgextio.c:3303
(rw-) PTP_UC_MASTER_INFO_IDX/PTP_UC_MASTER_SETTINGS_IDX, only if PTP_CFG_CAN_BE_UNICAST_SLAVE ...
Definition: gpsserio.h:859
int mbgextio_get_led_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_LED_SETTINGS_IDX *p, uint16_t idx)
Read a MBG_LED_SETTINGS_IDX parameter structure from a device.
Definition: mbgextio.c:13779
int mbgextio_get_snmp_v12_trap_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_SNMP_V12_TRAP_INFO_IDX *p, uint16_t idx)
Read SNMP v1 or v2 trap info in MBG_SNMP_V12_TRAP_INFO_IDX format.
Definition: mbgextio.c:10330
int mbgextio_get_ims_state(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IMS_STATE *p)
Read the current IMS state and supported IMS features.
Definition: mbgextio.c:8026
Structure that contains an index value and the NTP peer state.
Definition: gpsdefs.h:17539
POUT_SETTINGS pout_settings
Definition: gpsdefs.h:6252
(r–) STR_TYPE_INFO_IDX, names and capabilities of supp. string types, only if RECEIVER_INFO::n_str_t...
Definition: gpsserio.h:815
MBG_IO_PORT_SETTINGS_IDX iop_settings_idx
Definition: gpsserio.h:1479
A The structure used to store the configuration of two serial ports.
Definition: gpsdefs.h:3929
int mbgextio_get_ptp_state(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, PTP_STATE *p)
Read the current state of PTP device PTP_STATE format.
Definition: mbgextio.c:9152
#define _mbg_swab_nano_time_64(_p)
Definition: words.h:632
int xmt_cmd_us(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd, uint16_t us)
Send a binary command message with ushort (16 bit) parameter.
(r–) MBG_IP_ADDR_IDX, DNS status, only if MBG_NET_GLB_CFG_INFO::n_supp_dns_srvr > 0 ...
Definition: gpsserio.h:871
(r–) MBG_LED_INFO_IDX, settings and capabilities of an LED, only if MBG_XFEATURE_LED_API ...
Definition: gpsserio.h:898
MSG_CTL_DEVICE_FLAGS
Binary message control device flags.
Definition: mbgextio.c:746
#define _mbg_swab_net_glb_cfg_info(_p)
Definition: gpsdefs.h:11885
(rw-) MBG_NET_NAME_IDX, DNS cfg., only if MBG_NET_GLB_CFG_INFO::n_supp_dns_srch_dom > 0 ...
Definition: gpsserio.h:870
MBG_PTP_V1_PORT_DATASET_IDX ptp_v1_port_dataset_idx
Definition: gpsserio.h:1527
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_database
Check if a device supports database(s) feature.
Definition: mbgextio.c:4515
#define _mbg_swab_ext_sys_info(_p)
Definition: gpsdefs.h:19443
MBG_USER_PERM_BUF cfg_write_perm
current config write permissions, see MBG_USER_PERM_BUF and MBG_USER_PERMS
Definition: gpsdefs.h:22944
#define MBG_INVALID_SOCK_FD
A value to mark an MBG_SOCK_FD as invalid.
Definition: mbg_tgt.h:1003
static int msg_return_code(MBG_MSG_CTL *pmctl)
Definition: mbgextio.c:4543
Time scale configuration settings plus capabilities.
Definition: gpsdefs.h:5519
#define _mbg_swab_mbg_led_limits(_p)
Definition: gpsdefs.h:18736
#define _mbg_swab_io_port_limits(_p)
Definition: gpsdefs.h:20434
int mbgextio_get_opt_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_OPT_INFO *p)
Read current optional settings and supported options.
Definition: mbgextio.c:7343
(rw-) TZCODE, time zone code, only if GPS_MODEL_IS_DCF_PZF
Definition: gpsserio.h:1017
#define USB_DEV_FCU_01
Definition: usbdefs.h:235
void mbgextio_register_async_data_callback(MBG_MSG_CTL *pmctl, MBG_ASYNC_DATA_HANDLER_FNC *fnc)
Register an asynchronous data handler callback function.
Definition: mbgextio.c:3080
#define _mbg_swab_xmr_stats_idx(_p)
Definition: gpsdefs.h:7410
(r–) MBG_IMS_FDM_LIMITS, only if MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in MBG_IMS_STATE::flags ...
Definition: gpsserio.h:883
int mbgextio_get_net_dns_srvr_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IP_ADDR_IDX *p, uint16_t idx)
Read a network DNS server entry in MBG_IP_ADDR_IDX format.
Definition: mbgextio.c:12153
IP4_SETTINGS ip4_settings
Definition: gpsserio.h:1569
void set_encryption_mode(MBG_MSG_CTL *pmctl, int mode, const char *key)
Set communication channel to specified encryption mode.
IRIG_SETTINGS irig_tx_settings
Definition: gpsserio.h:1367
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_user_auth
Check if a device supports user authentication.
Definition: mbgextio.c:4021
(rw-) NTP_PEER_SETTINGS_IDX, only if ??? //### TODO
Definition: gpsserio.h:863
Global network configuration settings.
Definition: gpsdefs.h:11844
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_enable_flags
Check if a device supports the ENABLE_FLAGS structure and API.
Definition: xdevfeat.c:680
int mbgextio_get_port_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, PORT_INFO_IDX *p, uint16_t idx)
Read current settings and capabilities of a specific serial port.
Definition: mbgextio.c:7491
MBG_UCAP_NET_RECV_SETTINGS_IDX ucap_net_recv_settings_idx
Definition: gpsserio.h:1476
NTP refclock settings index.
Definition: gpsdefs.h:15724
(rw-) MBG_EVENT_INFO_IDX / MBG_EVENT_SETTINGS_IDX, only supp. if MBG_XFEATURE_MONITORING is set in ex...
Definition: gpsserio.h:942
int mbgextio_get_corr_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, CORR_INFO *p)
Definition: mbgextio.c:13918
int mbgextio_get_ntp_glb_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_GLB_INFO *p)
Read the ntp global information NTP_GLB_INFO format.
Definition: mbgextio.c:11305
long mbgextio_force_conn_serial(const char *dev)
Try to force a serial connection to a device.
#define _mbg_swab_mbg_ims_state(_p)
Definition: gpsdefs.h:9800
int mbgextio_socket_write_ssh(MBG_MSG_CTL *pmctl, const void *buf, size_t len)
Function, which can be used to write data to an SSH binary protocol channel.
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_monitoring
Check if a device supports the extended feature monitoring.
Definition: mbgextio.c:4295
size_t mbgextio_get_rcv_buffer_size(MBG_MSG_CTL *pmctl)
Retrieve size of the allocated receive buffer.
Definition: mbgextio.c:3174
(-w-) no data, save current config as default, only if MBG_XFEATURE_SAVE_CFG
Definition: gpsserio.h:890
int mbgextio_get_xmr_status_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XMULTI_REF_STATUS_IDX *p, uint16_t idx)
Read XMULTI_REF_STATUS_IDX for a specific XMR source.
Definition: mbgextio.c:8818
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_user_mngmnt
Check if a device supports user management.
Definition: mbgextio.c:4045
NTP_SRV_MODE_SETTINGS ntp_srv_mode_settings
Definition: gpsserio.h:1420
NTP orphan mode settings to be read from / written to a device.
Definition: gpsdefs.h:16168
int mbgextio_get_ntp_symm_key_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_SYMM_KEY_INFO_IDX *p, uint16_t idx)
Read the NTP symmetric key info with the given index in NTP_SYMM_KEY_INFO_IDX format.
Definition: mbgextio.c:11411
#define _mbg_swab_mbg_gpio_freq(_p)
Definition: gpsdefs.h:7757
MBG_SNMP_V3_SETTINGS_IDX snmp_v3_settings_idx
Definition: gpsserio.h:1491
#define _mbg_swab_ptp_v2_current_dataset(_p)
Definition: gpsdefs.h:14910
(r–) MBG_XFEATURE_BUFFER, only if GPS_HAS_XFEATURE
Definition: gpsserio.h:889
Detailed GNSS satellite status, plus index.
Definition: gpsdefs.h:10968
int mbgextio_set_snmp_v12_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_SNMP_V12_SETTINGS *p, uint16_t idx)
Write SNMP v1 or v2 settings in MBG_SNMP_V12_SETTINGS format.
Definition: mbgextio.c:10288
#define MBG_DEFAULT_FRAMING
Definitions used with the Meinberg binary protocol.
Definition: gpsdefs.h:3411
MBG_NET_NAME net_name
Definition: gpsdefs.h:12006
MBG_PTP_V2_DEFAULT_DATASET ptp_v2_default_dataset
Definition: gpsserio.h:1498
IRIG_SETTINGS irig_rx_settings
Definition: gpsserio.h:1381
(rw-) MBG_PTP_V2_PARENT_DATASET, only supp. if PTP_CFG_MSK_HAS_V2_COMMON_DATASETS is set in PTP_CFG_I...
Definition: gpsserio.h:938
#define _mbg_swab_user_mngmnt_info(_p)
Definition: gpsdefs.h:22767
MBG_IP_ADDR_IDX ip_addr_idx
Definition: gpsserio.h:1429
(r–) MBG_IO_PORT_STATUS_IDX, only supp. if MBG_XFEATURE_IO_PORTS is set in extended features and fro...
Definition: gpsserio.h:924
XDEVFEAT_CHK_SUPP_FNC xdevfeat_is_gps
Check if a device can receive the GPS satellite system.
Definition: xdevfeat.c:183
PTP_UC_MASTER_INFO_IDX ptp_uc_master_info_idx
Definition: gpsserio.h:1413
#define MBG_ERR_UNKNOWN
Unknown error code from external API.
Definition: mbgerror.h:366
(w–) MBG_SERVICE_CTL, index 0 .. MBG_SERVICE_MGMT_INFO::num_services - 1, only supp. if MBG_XFEATURE_SERVICE
Definition: gpsserio.h:969
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_bvar_stat
Definition: mbgextio.c:3720
PTPv1 current dataset containing information about the synchronization status of the device...
Definition: gpsdefs.h:14611
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_supp_tlv_exec_cmd
Check if a device supports command execution via TLV.
Definition: mbgextio.c:4088
A timestamp with nanosecond resolution, but 64 bit size.
Definition: words.h:621
#define _mbg_swab_svc_status_idx(_p)
Definition: gpsdefs.h:23159
#define _mbg_swab_io_port_status_idx(_p)
Definition: gpsdefs.h:21232
uint16_t idx
port index, 0..RECEIVER_INFO::n_com_ports-1
Definition: gpsdefs.h:3596
(-w-) MBG_TIME_MON_TARGET_SETTINGS
Definition: gpsserio.h:1025
connection via direct USB
Definition: gpsserio.h:2054
#define _mbg_swab_ntp_srv_mode_info(_p)
Definition: gpsdefs.h:16451
(rw-) MBG_PTP_V1_PARENT_DATASET, only supp. if PTP_CFG_MSK_HAS_V1_COMMON_DATASETS is set in PTP_CFG_I...
Definition: gpsserio.h:952
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_irig_rx
Definition: xdevfeat.c:457
#define _mbg_swab_snmp_v12_info_idx(_p)
Definition: gpsdefs.h:21472
int mbgextio_register_push_msg(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd)
Register for command specific push messages.
Definition: mbgextio.c:13870
int MBG_TIME_MON_TARGET_EXT_DATA_SET_IDX
Definition: gpsserio.h:680
(r–) MBG_EXT_SYS_INFO, extended revision information, only if MBG_XFEATURE_EXT_SYS_INFO ...
Definition: gpsserio.h:900
int mbgextio_set_ims_fdm_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_IMS_FDM_SETTINGS *p)
Write a MBG_IMS_FDM_SETTINGS parameter structure to a device.
Definition: mbgextio.c:13400
char name[(16+1)]
Optional string identifying a customized firmware version, should be empty in standard versions...
Definition: gpsdefs.h:735
#define MBG_ERR_CONN_TYPE
Binary protocol no valid/supported connection type specified.
Definition: mbgerror.h:318
#define _mbg_swab_database_cmd(_p)
Definition: gpsdefs.h:23611
Status information on a ref time source at a specific priority level.
Definition: gpsdefs.h:6885
#define MBG_ERR_INV_PARM
Invalid parameter.
Definition: mbgerror.h:329
int mbgextio_open_serial_ftdi(int device_num, MBG_MSG_CTL **ppmctl, uint32_t baud_rate, const char *framing)
Open a binary communication channel using serial FTDI D2xx port.
int mbgextio_get_user_status_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_USER_STATUS_IDX *p, uint16_t idx)
Read the user status with the given index in MBG_USER_STATUS_IDX format.
Definition: mbgextio.c:6848
PTPv1 port dataset containing information about the appropriate port of the device.
Definition: gpsdefs.h:14785
int mbgextio_get_pos_lla(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, LLA lla)
Read the current receiver position as LLA array.
Definition: mbgextio.c:6080
(rw-) MBG_TIME_SCALE_SETTINGS/MBG_TIME_SCALE_INFO, only if GPS_HAS_TIME_SCALE
Definition: gpsserio.h:837
int mbgextio_get_net_glb_cfg_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_NET_GLB_CFG_INFO *p)
Read the network global config information MBG_NET_GLB_CFG_INFO format.
Definition: mbgextio.c:12082
int mbgextio_set_ant_cable_len(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const ANT_CABLE_LEN *p)
Send the GPS antenna cable length configuration.
Definition: mbgextio.c:7024
int16_t channel
-1: the current on-board time; >= 0 the capture channel number
Definition: gpsdefs.h:2715
#define _mbg_swab_snmp_v3_settings_idx(_p)
Definition: gpsdefs.h:21644
#define _mbg_swab_mbg_opt_info(_p)
Definition: gpsdefs.h:5349
PORT_PARM port_parm
Definition: gpsserio.h:1360
int _MBG_API MBG_ASYNC_MSG_HANDLER_FNC(MBG_MSG_CTL *pmctl)
Type of a callback function to handle spurious binary messages.
Definition: gpsserio.h:1934
int mbgextio_get_xbp_node_limits(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XBP_NODE_LIMITS *p)
Read the XBP_NODE_LIMITS to check how many ports are provided.
Definition: mbgextio.c:12767
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_scu_stat
Check if the device supports the SCU_STAT structures.
Definition: xdevfeat.c:816
int mbgextio_time_mon_send_inst_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_TIME_MON_INST_INFO *p)
#define _mbg_swab_mbg_gnss_mode_settings(_p)
Definition: gpsdefs.h:10685
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_irig_tx
Definition: xdevfeat.c:443
int mbgextio_set_tzdl(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const TZDL *p)
Set the local time conversion parameters in TZDL format.
Definition: mbgextio.c:6222
(r–) MBG_TLV_INFO, query information on which TLV stuff is supported, only if MBG_XFEATURE_TLV_API ...
Definition: gpsserio.h:901
NTP_TRUSTED_KEY_SETTINGS settings
Definition: gpsdefs.h:16012
(r–) deprecated, SW_REV, software revision, use only if GPS_RECEIVER_INFO not supp.
Definition: gpsserio.h:795
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_pos_lla
Definition: mbgextio.c:3357
MBGSERIO_DEV * p_serio
Definition: gpsserio.h:2020
int mbgextio_set_fdm_tdev(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const NANO_TIME_64 *p)
Set time deviation of powerline time in relation to the current reference time.
Definition: mbgextio.c:13474
int mbgextio_get_ims_fdm_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IMS_FDM_INFO *p)
Read a MBG_IMS_FDM_INFO parameter structure from a device.
Definition: mbgextio.c:13242
#define _mbg_swab_xmulti_ref_instances(_p)
Definition: gpsdefs.h:7064
uint16_t idx
Definition: gpsdefs.h:12005
#define _mbg_swab_gnss_sat_info_idx(_p)
Definition: gpsdefs.h:10786
int mbgextio_set_tr_distance(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const TR_DISTANCE *p)
Set the transmitter distance (km) in TR_DISTANCE format.
Definition: mbgextio.c:8340
uint32_t ticks_per_sec
resolution of fractions of seconds, see GPS_TICKS_PER_SEC
Definition: gpsdefs.h:881
static int dev_open_finish_setup(MBG_MSG_CTL **ppmctl, MBG_MSG_CTL **caller_ppmctl)
Definition: mbgextio.c:981
NTP symmetric key specific settings.
Definition: gpsdefs.h:15892
#define _mbg_swab_net_name(_p)
Definition: gpsdefs.h:11992
(r–) XMULTI_REF_STATUS_IDX, idx 0..XMULTI_REF_INSTANCES::n_xmr_settings-1, only if GPS_HAS_XMULTI_RE...
Definition: gpsserio.h:833
Current IRIG settings and supported codes.
Definition: gpsdefs.h:5054
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_net_cfg
Check if a device supports the new NET_CFG API.
Definition: mbgextio.c:3859
#define _mbg_swab_net_glb_cfg_settings(_p)
Definition: gpsdefs.h:11859
Configuration settings of a serial port.
Definition: gpsdefs.h:3507
MBG_LED_SETTINGS_IDX led_settings_idx
Definition: gpsserio.h:1461
NTP_REFCLK_CFG_SETTINGS settings
See NTP_REFCLK_CFG_SETTINGS.
Definition: gpsdefs.h:15727
(rw-) NTP_GLB_INFO/NTP_GLB_SETTINGS, only if GPS_HAS_NTP
Definition: gpsserio.h:860
unsigned short uint16_t
Definition: words.h:213
(r–) next MBG_EVT_LOG_ENTRY, only if GPS_HAS_EVT_LOG
Definition: gpsserio.h:847
A structure used to configure optional settings.
Definition: gpsdefs.h:5342
int mbgextio_get_ims_fdm_state(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IMS_FDM_STATE *p)
Read a MBG_IMS_FDM_STATE parameter structure from a device.
Definition: mbgextio.c:13369
int mbgextio_set_ntp_refclk_cfg_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const NTP_REFCLK_CFG_SETTINGS *p, uint16_t idx)
Send NTP refclk config settings with the given index in NTP_REFCLK_CFG_SETTINGS format.
Definition: mbgextio.c:11941
#define _mbg_swab_user_status_idx(_p)
Definition: gpsdefs.h:22968
int mbgextio_open_socket(const char *host, MBG_MSG_CTL **ppmctl, const char *passwd)
Open a binary communication channel via a LAN/socket connection.
int mbgextio_get_xmr_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XMULTI_REF_INFO_IDX *p, uint16_t idx)
Read XMULTI_REF_INFO_IDX for a specific XMR source.
Definition: mbgextio.c:8774
XMR holdover status.
Definition: gpsdefs.h:7157
int mbgextio_set_pwr_ctl(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_PWR_CTL *p)
Write a MBG_PWR_CTL parameter structure to a device.
Definition: mbgextio.c:13646
#define _mbg_swab_mbg_ims_fdm_settings(_p)
Definition: gpsdefs.h:10275
int mbgserio_write(MBGSERIO_DEV *mdev, const void *buffer, unsigned int count)
#define GPS_MODEL_NAME_SCU_01
Definition: gpsdefs.h:1113
(r–) BVAR_STAT, status of buffered variables, only if GPS_MODEL_HAS_BVAR_STAT
Definition: gpsserio.h:796
see USER_SCOPE_STATUS_READ
Definition: gpsdefs.h:22574
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_pos_xyz
Definition: mbgextio.c:3346
Information on available XBP nodes.
Definition: gpsdefs.h:17926
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_transactions
Check if a device has MBG_XFEATURE_TRANSACTIONS.
Definition: mbgextio.c:4405
#define _mbg_swab_xmulti_ref_status_idx(_p)
Definition: gpsdefs.h:6892
static int chk_get_rcvr_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, RECEIVER_INFO *p)
Definition: mbgextio.c:5674
NTP refclock info, with index.
Definition: gpsdefs.h:15795
The data checksum of a received message is invalid.
Definition: gpsserio.h:718
static __mbg_inline int num_bits_set(long val)
Count the number of bits which are not 0.
Definition: cfg_hlp.h:1024
#define _mbg_swab_snmp_v12_settings_idx(_p)
Definition: gpsdefs.h:21441
uint8_t hop_count
Used as index to the addr array.
Definition: gpsdefs.h:17863
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_user_mngmnt
Check if a device supports user management.
Definition: xdevfeat.c:1696
NTP_TRUSTED_KEY_SETTINGS_IDX ntp_trusted_key_settings_idx
Definition: gpsserio.h:1516
Peer settings for NTP devices to configure an upload NTP server.
Definition: gpsdefs.h:16358
(r–) PTP_UC_MASTER_CFG_LIMITS, only if PTP_CFG_CAN_BE_UNICAST_SLAVE
Definition: gpsserio.h:858
(rwa) encrypted binary packet
Definition: gpsserio.h:1006
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_ims
Definition: mbgextio.c:3643
#define _mbg_swab_net_intf_addr_settings_idx(_p)
Definition: gpsdefs.h:12211
int mbgextio_open_serial(const char *dev, MBG_MSG_CTL **ppmctl, uint32_t baud_rate, const char *framing)
Open a binary communication channel using direct serial I/O.
int mbgserio_open(MBGSERIO_DEV **pp_mdev, const char *dev_name)
Open a serial port and set up a MBGSERIO_DEV structure.
int mbgextio_get_holdover_interval_counter(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XMR_HOLDOVER_INTV *p)
Read the XMR holdover interval counter.
Definition: mbgextio.c:8125
MBG_MSG_BUFF * mbgextio_get_rcv_buffer_addr(MBG_MSG_CTL *pmctl)
Retrieve address of the allocated receive buffer.
Definition: mbgextio.c:3151
(r–) MBG_LED_LIMITS, LED API capabilities, only if MBG_XFEATURE_LED_API
Definition: gpsserio.h:897
#define _mbg_swab_svc_settings_idx(_p)
Definition: gpsdefs.h:23079
An event log entry.
Definition: gpsdefs.h:9564
uint16_t idx
0..MBG_UCAP_NET_GLB_SETTINGS::num_recvs-1
Definition: gpsdefs.h:12562
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_tainted_cfg
Check if a device supports the Tainted config Tainted Config API.
Definition: xdevfeat.c:1612
(r–) XBP_LIMITS, only if GPS_HAS_XBP
Definition: gpsserio.h:877
IO Port Settings Index.
Definition: gpsdefs.h:20738
#define GPS_MODEL_NAME_GPS16X
Definition: gpsdefs.h:1139
int mbgextio_get_fw_glb_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_FW_GLB_INFO *p)
Read the firmware global information in MBG_FW_GLB_INFO format.
Definition: mbgextio.c:10901
int mbgextio_get_irig_tx_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, IRIG_INFO *p)
Read configuration info and supported features of the device&#39;s IRIG output.
Definition: mbgextio.c:7062
int mbgextio_get_tzcode(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, TZCODE *p)
Read the local time conversion configuration in TZCODE format.
Definition: mbgextio.c:8177
XMR timing metrics for a particular source, with index.
Definition: gpsdefs.h:7468
(r–) XMR_STATS_IDX, only if XMR_EXT_SRC_FEAT_FLAG_MSK_STATS
Definition: gpsserio.h:891
static const char force_conn_hs_cmd_str[]
Definition: mbgextio.c:735
IO Port Settings.
Definition: gpsdefs.h:20689
(r–) MBG_USER_INFO for the authenticated user, see MBG_XFEATURE_USER_AUTH
Definition: gpsserio.h:959
uint32_t idx
index, 0..PTP_UC_MASTER_CFG_LIMITS::n_supp_master-1
Definition: gpsdefs.h:14331
PTPv1 parent dataset containing information about the master (parent) of the device.
Definition: gpsdefs.h:14670
(rw-) MBG_SYSLOG_GLB_INFO / MBG_SYSLOG_GLB_SETTINGS, only supp. if MBG_MONITORING_TYPE_MSK_SYSLOG is ...
Definition: gpsserio.h:970
#define _check_user_perm(_user_perm_bit, _user_perm_buffp)
Check a user permission in a MBG_USER_PERM_BUF.
Definition: gpsdefs.h:22660
MBG_MSG_BUFF * pmb
points to unencrypted message buffer
Definition: gpsserio.h:1736
XDEVFEAT_CHK_SUPP_FNC xdevfeat_is_bus_lvl_dev
Check if a device is a bus level device.
Definition: xdevfeat.c:371
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_is_gnss
Check if a device supports the GNSS API.
Definition: mbgextio.c:3504
#define _mbg_swab_ntp_symm_key_limits(_p)
Definition: gpsdefs.h:15869
int mbgextio_get_snmp_v3_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_SNMP_V3_INFO_IDX *p, uint16_t idx)
Read SNMP v3 info in MBG_SNMP_V3_INFO_IDX format.
Definition: mbgextio.c:10408
int mbgextio_set_ptp_v2_default_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_PTP_V2_DEFAULT_DATASET *p)
Send PTPv2 default dataset to a device in MBG_PTP_V2_DEFAULT_DATASET format.
Definition: mbgextio.c:9782
legacy device with proprietary protocol, see mbgextio_dev_is_legacy
Definition: mbgextio.c:748
PORT_SETTINGS_IDX port_settings_idx
Definition: gpsserio.h:1371
int mbgextio_get_all_gnss_sat_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GNSS_SAT_INFO_IDX gsii[], const MBG_GNSS_MODE_INFO *p_mi)
::TODO Read an array of all supported string types
Definition: mbgextio.c:8527
(r–) MBG_CLK_RES_INFO, only if MBG_XFEATURE_CLK_RES_INFO
Definition: gpsserio.h:910
Client settings of an NTP device.
Definition: gpsdefs.h:16233
(r–) PORT_INFO_IDX, serial port settings and capabilities, only if RECEIVER_INFO::n_com_ports > 0 ...
Definition: gpsserio.h:816
MBG_SYSLOG_SETTINGS_IDX syslog_settings_idx
Definition: gpsserio.h:1548
Configuration settings for a HaveQuick input or output.
Definition: gpsdefs.h:9456
Current settings and general capabilities of a specific unicast master.
Definition: gpsdefs.h:14382
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
(rw-) MBG_TIME_MON_INST_INFO
Definition: gpsserio.h:1024
int mbgextio_get_lan_if_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, LAN_IF_INFO *p)
Read the lan interface configuration LAN_IF_INFO format.
Definition: mbgextio.c:9019
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_supp_tlv_ntp_license
Check if a device supports supports NTP license infos via TLV.
Definition: mbgextio.c:4211
Information on an XBP node with specific index.
Definition: gpsdefs.h:18044
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_pzf
Check if a device can receive DCF77 PZF.
Definition: xdevfeat.c:283
#define _NO_MBG_API
Definition: mbg_tgt.h:1028
#define MBG_ERR_GENERIC
Generic error.
Definition: mbgerror.h:269
int mbgextio_set_ptp_v1_port_dataset_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_PTP_V1_PORT_DATASET *p, uint16_t idx)
Send PTPv1 port dataset with the appropriate index to a device in MBG_PTP_V1_PORT_DATASET format...
Definition: mbgextio.c:9708
int mbgextio_set_user_mngmnt_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_USER_MNGMNT_SETTINGS *p)
Send the user configuration in MBG_USER_MNGMNT_SETTINGS format.
Definition: mbgextio.c:6666
int mbgextio_get_ntp_refclk_cfg_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_REFCLK_CFG_INFO_IDX *p, uint16_t idx)
Read the NTP refclock config info with the given index in NTP_REFCLK_CFG_INFO_IDX format...
Definition: mbgextio.c:11904
#define _NO_MBG_API_ATTR
Definition: mbg_tgt.h:1032
int mbgextio_get_fdm_freq(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_GPIO_FREQ *p)
Read a MBG_GPIO_FREQ parameter structure from a device.
Definition: mbgextio.c:13216
int mbgextio_get_gnss_mode_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_GNSS_MODE_INFO *p)
Read current GNSS mode settings and supported features.
Definition: mbgextio.c:8373
RI_FEATURES features
optional features, see GPS_FEATURE_MASKS
Definition: gpsdefs.h:882
#define mbg_rc_is_success(_rc)
Definition: mbgerror.h:618
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_serouts
Definition: xdevfeat.c:484
(r–) MBG_TIME_MON_TARGET_EXT_DATA_SET_IDX
Definition: gpsserio.h:1027
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_user_auth
Check if a device supports user authentification.
Definition: xdevfeat.c:1675
int mbgextio_get_ntp_sys_state(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_SYS_STATE *p)
Read the current system state of ntp device NTP_SYS_STATE format.
Definition: mbgextio.c:11982
uint32_t idx
port index, 0..MBG_GPIO_CFG_LIMITS::num_io-1
Definition: gpsdefs.h:9186
int mbgextio_rcv_msg_unlocked(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd, void *buf, size_t buf_size)
Generic reception of a binary message.
Definition: mbgextio.c:4614
(rw-) MBG_LED_SETTINGS_IDX, settings of a specific LED, only if MBG_XFEATURE_LED_API ...
Definition: gpsserio.h:899
PTPv1 time drop dataset.
Definition: gpsdefs.h:14737
(r-a) TTM, user capture events, only if RECEIVER_INFO::n_ucaps > 0
Definition: gpsserio.h:804
uint16_t GPS_CMD
The type of a GPS command code.
Definition: gpsdefs.h:719
(rw-) NTP_CLNT_MODE_INFO/NTP_CLNT_MODE_SETTINGS, only if NTP_MSK_ROLE_CLIENT
Definition: gpsserio.h:861
int mbgextio_get_syslog_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_SYSLOG_INFO_IDX *p, uint16_t idx)
Read syslog server information in MBG_SYSLOG_INFO_IDX format.
Definition: mbgextio.c:10818
XDEVFEAT_CHK_SUPP_FNC xdevfeat_supp_tlv_fw_rollback
Check if a device supports a factory reset via TLV.
Definition: xdevfeat.c:1147
int mbgextio_set_user_level_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_USER_SETTINGS *p, uint16_t idx)
Write user level settings in MBG_USER_SETTINGS_IDX format.
Definition: mbgextio.c:6810
int mbgextio_get_fw_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_FW_INFO_IDX *p, uint16_t idx)
Read the firmware info with the given index in MBG_FW_INFO_IDX format.
Definition: mbgextio.c:10939
#define MBG_ERR_DATA_CSUM
Binary protocol data checksum error.
Definition: mbgerror.h:315
int mbgextio_get_svc_status_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_SERVICE_STATUS_IDX *p, uint16_t idx)
Read the service status with the given index in MBG_SERVICE_STATUS_IDX format.
Definition: mbgextio.c:14111
MBG_OPT_SETTINGS opt_settings
Definition: gpsserio.h:1388
#define _mbg_swab_ntp_glb_info(_p)
Definition: gpsdefs.h:15261
#define _mbg_swab_ant_info(_p)
Definition: gpsdefs.h:3109
int mbgextio_get_xmr_ext_source_metrics_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XMR_METRICS_IDX *p, uint16_t idx)
Read XMR_METRICS_IDX for a specific XMR source.
Definition: mbgextio.c:8935
int mbgextio_set_opt_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_OPT_SETTINGS *p)
Send new optional settings flags.
Definition: mbgextio.c:7371
MBG_SNMP_V3_TRAP_SETTINGS_IDX snmp_v3_trap_settings_idx
Definition: gpsserio.h:1493
#define _mbg_swab_ucap_net_glb_settings(_p)
Definition: gpsdefs.h:12476
SYNTH synth
Definition: gpsserio.h:1361
#define _mbg_swab_mbg_clk_res_info(_p)
Definition: gpsdefs.h:19870
MBG_GPIO_SETTINGS_IDX gpio_settings_idx
Definition: gpsserio.h:1399
MBG_XDEV_FEATURES xdev_features
Receiver info plus extended device features.
Definition: gpsserio.h:1987
(r–) GNSS_SAT_INFO_IDX, only if MBG_GNSS_FLAG_MSK_SAT_INFO_IDX_SUPP_SER, deprecates GPS_GNSS_SAT_INF...
Definition: gpsserio.h:873
XDEVFEAT_CHK_SUPP_FNC xdevfeat_supp_tlv_ntp_license
Check if a device supports NTP license infos via TLV.
Definition: xdevfeat.c:1233
MBG_SNMP_V12_SETTINGS_IDX snmp_v12_settings_idx
Definition: gpsserio.h:1487
(r–) MBG_LNE_PORT_INFO_IDX, settings and capabilities of an LED, only if MBG_XFEATURE_LNE_API ...
Definition: gpsserio.h:894
int mbgextio_socket_read_ssh(MBG_MSG_CTL *pmctl, void *buf, size_t len)
Function, which can be used to read data from an SSH binary protocol channel.
int mbgextio_unregister_push_msg(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd)
Unregister for command specific push messages.
Definition: mbgextio.c:13892
MBG_SERVICE_SETTINGS_IDX svc_settings_idx
Definition: gpsserio.h:1541
PTPv2 port dataset.
Definition: gpsdefs.h:15035
#define _mbg_swab_ntp_glb_settings(_p)
Definition: gpsdefs.h:15234
int mbgextio_get_database_glb_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_DATABASE_GLB_INFO *p)
Read global database information in MBG_DATABASE_GLB_INFO format.
Definition: mbgextio.c:11121
uint8_t n_com_ports
number of on-board serial ports
Definition: gpsdefs.h:887
int mbgextio_get_ptp_v1_current_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_PTP_V1_CURRENT_DATASET *p)
Read the PTPv1 current dataset in MBG_PTP_V1_CURRENT_DATASET format.
Definition: mbgextio.c:9453
A generic structure used to specify FDM limits.
Definition: gpsdefs.h:10114
int mbgextio_set_ntp_srv_mode_cfg(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const NTP_SRV_MODE_SETTINGS *p)
Send the NTP server mode configuration.
Definition: mbgextio.c:11863
#define _mbg_swab_corr_info(_p)
Definition: pcpsdefs.h:1571
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_req_ttm
Check if a device has MBG_XFEATURE_REQ_TTM.
Definition: mbgextio.c:4450
(rw-) MBG_GNSS_MODE_INFO/MBG_GNSS_MODE_SETTINGS, GNSS operation mode
Definition: gpsserio.h:993
#define _mbg_swab_ntp_symm_key_settings_idx(_p)
Definition: gpsdefs.h:15933
XBP_MSG_DATA xbp_msg_data
XBP address field plus encapsulated standard message.
Definition: gpsserio.h:1719
Query MBG_NET_INTF_ADDR_SETTINGS by its index.
Definition: gpsdefs.h:12204
#define _mbg_swab_tzcode(_p)
Definition: gpsserio.h:1304
(r–) MBG_IO_PORT_TYPE_INFO_IDX, only supp. if MBG_XFEATURE_IO_PORTS is set in extended features and ...
Definition: gpsserio.h:923
XMR statistics for a particular source, with index.
Definition: gpsdefs.h:7403
#define MBGEXTIO_READ_BUFFER_SIZE
Definition: mbgextio.h:475
#define _mbg_swab_mbg_time_scale_settings(_p)
Definition: gpsdefs.h:5512
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_net_cfg
Check if a device supports the new NET_CFG API.
Definition: xdevfeat.c:916
#define _mbg_swab_snmp_glb_settings(_p)
Definition: gpsdefs.h:21369
int mbgextio_set_ptp_cfg_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const PTP_CFG_SETTINGS *p)
Send configuration settings for PTP.
Definition: mbgextio.c:9298
int mbgextio_set_pout_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const POUT_SETTINGS *p, uint16_t idx)
Send configuration settings for a specific programmable pulse output.
Definition: mbgextio.c:7708
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_serouts
Definition: mbgextio.c:3709
(r–) MBG_MONITORING_LIMITS, only supp. if MBG_XFEATURE_MONITORING is set in extended features ...
Definition: gpsserio.h:925
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_pwr_ctl_api
Check if a device supports the power control API.
Definition: mbgextio.c:4361
MBG_MSG_BUFF * pmb
points to unencrypted message buffer
Definition: gpsserio.h:1791
#define _mbg_swab_ptp_v1_time_properties_dataset(_p)
Definition: gpsdefs.h:14746
int xdevfeat_has_time_ttm(const MBG_XDEV_FEATURES *p_xdf)
Check if the device supports the builtin feature TIME.
Definition: xdevfeat.c:566
A generic structure used to hold a GPIO port&#39;s settings.
Definition: gpsdefs.h:9127
LLA lla
Definition: gpsserio.h:1358
ulong msg_rcv_timeout
Binary message receive timeout [ms].
Definition: gpsserio.h:1983
XBP_NODE_INFO node_info
RECEIVER_INFO of the device behind this node
Definition: gpsdefs.h:18047
MBG_IMS_FDM_OUTPUT_SETTINGS settings
Definition: gpsdefs.h:10029
int mbgextio_get_user_level_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_USER_INFO_IDX *p, uint16_t idx)
Read the user level info with the given index in MBG_USER_INFO_IDX format.
Definition: mbgextio.c:6776
void mbgextio_register_async_msg_callback(MBG_MSG_CTL *pmctl, MBG_ASYNC_MSG_HANDLER_FNC *fnc)
Register an asynchronous message handler callback function.
Definition: mbgextio.c:3055
#define MBG_ERR_NBLOCK_WAIT_SLCT
Select timed out when waiting for non-blocking network port to become ready.
Definition: mbgerror.h:325
#define _mbg_swab_io_port_settings_idx(_p, _recv)
Definition: gpsdefs.h:20745
int mbgextio_set_net_glb_cfg_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_NET_GLB_CFG_SETTINGS *p)
Set the device&#39;s global network configuration settings.
Definition: mbgextio.c:12114
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_lne_api
Check if a device supports the LNE API.
Definition: xdevfeat.c:1382
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_is_dcf
Check if a device is a DCF77 receiver.
Definition: mbgextio.c:3548
#define GPS_MODEL_NAME_TSU_01
Definition: gpsdefs.h:1111
static int mbgextio_check_ack(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd)
Definition: mbgextio.c:5003
Configuration settings for a single programmable pulse output.
Definition: gpsdefs.h:5692
int mbgextio_get_ref_offs(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_REF_OFFS *p)
Read current ref offset to UTC configuration.
Definition: mbgextio.c:7244
Structure that represents the current system status of an NTP device.
Definition: gpsdefs.h:16872
#define _mbg_swab_bvar_stat(_p)
Definition: gpsdefs.h:772
int mbgextio_get_tainted_cfg(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_TAINTED_CFG *p)
Read MBG_TAINTED_CFG structure from a device.
Definition: mbgextio.c:13843
uint16_t BVAR_STAT
Status flags of battery buffered data.
Definition: gpsdefs.h:770
MBG_NET_INTF_LINK_SETTINGS_IDX net_intf_link_settings_idx
Definition: gpsserio.h:1432
MBG_NET_NAME_IDX net_name_idx
Definition: gpsserio.h:1430
NTP_MISC_ORPHAN_MODE_SETTINGS ntp_misc_orphan_mode_settings
Definition: gpsserio.h:1521
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_gpio
Definition: xdevfeat.c:399
int mbgextio_set_ptp_v1_current_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_PTP_V1_CURRENT_DATASET *p)
Send PTPv1 current dataset to a device in MBG_PTP_V1_CURRENT_DATASET format.
Definition: mbgextio.c:9487
PTPv2 time properties dataset.
Definition: gpsdefs.h:15009
XDEVFEAT_CHK_SUPP_FNC xdevfeat_supp_tlv_fw_update
Check if a device supports a firmware update via TLV.
Definition: xdevfeat.c:1169
(rw-) NTP_REFCLK_CFG_INFO_IDX, only if NTP_SRV_MODE_SETTINGS::num_refclks > 0
Definition: gpsserio.h:944
NANO_TIME_64 nano_time_64
Definition: gpsserio.h:1454
Time scale configuration settings.
Definition: gpsdefs.h:5505
MBG_EVENT_SETTINGS_IDX event_settings_idx
Definition: gpsserio.h:1508
#define _mbg_swab_mbg_evt_log_entry(_p)
Definition: gpsdefs.h:9572
int mbg_win32_wsa_err_to_mbg(int wsa_err, const char *info)
Translate a Windows socket API error code to one of the MBG_ERROR_CODES.
#define _mbg_swab_database_info_idx(_p)
Definition: gpsdefs.h:23586
int mbgextio_get_ntp_srv_mode_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_SRV_MODE_INFO *p)
Read the ntp server mode information in NTP_SRV_MODE_INFO format.
Definition: mbgextio.c:11830
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_gps_stat_info
Check if a device supports the STAT_INFO structure and API.
Definition: xdevfeat.c:702
NTP refclock specific settings.
Definition: gpsdefs.h:15681
int mbgextio_time_mon_send_target_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_TIME_MON_TARGET_SETTINGS *p)
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_time_ttm
Definition: mbgextio.c:3368
#define _mbg_swab_tainted_cfg(_p)
Definition: gpsdefs.h:22312
int mbgextio_xmt_msg(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd, const void *p, uint16_t n_bytes)
Set up and send a generic binary message.
Definition: mbgextio.c:5058
(rw-) MBG_USER_INFO_IDX / MBG_USER_SETTINGS_IDX, index 0 .. MBG_USER_MNGMNT_SETTINGS::num_users, only supp. if MBG_XFEATURE_USER_MNGMNT
Definition: gpsserio.h:962
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_raw_irig_data
Check if a timecode receiver provides MBG_RAW_IRIG_DATA.
Definition: mbgextio.c:3801
(rw-) MBG_IP_ADDR_IDX, DNS cfg., only if MBG_NET_GLB_CFG_INFO::n_supp_dns_srvr > 0 ...
Definition: gpsserio.h:869
int mbgextio_get_ntp_peer_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_PEER_SETTINGS_IDX *p, uint16_t idx)
Read the ntp peer settings of current idx NTP_PEER_SETTINGS format.
Definition: mbgextio.c:11752
SCU_STAT_SETTINGS scu_stat_settings
Definition: gpsserio.h:1573
#define _mbg_swab_ptp_uc_master_info_idx(_p)
Definition: gpsdefs.h:14389
(-w-) no data, clear event log command, only if GPS_HAS_EVT_LOG
Definition: gpsserio.h:844
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_up_conv
Check if the device has an L1 frequency up converter.
Definition: xdevfeat.c:1776
#define _mbg_swab_xmr_ext_src_info_idx(_p)
Definition: gpsdefs.h:7302
MBG_USER_PERM_BUF stat_read_perm
current status read permissions, see MBG_USER_PERM_BUF and MBG_USER_PERMS
Definition: gpsdefs.h:22942
int MBG_SOCK_FD
A socket file descriptor type.
Definition: mbg_tgt.h:991
MBG_LNE_PORT_SETTINGS settings
LNE settings.
Definition: gpsdefs.h:19064
MBG_NET_INTF_ADDR_SETTINGS settings
see MBG_NET_INTF_ADDR_SETTINGS
Definition: gpsdefs.h:12207
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_raw_irig_data
Check if a timecode receiver provides MBG_RAW_IRIG_DATA.
Definition: xdevfeat.c:858
Configuration settings for a single LNE port.
Definition: gpsdefs.h:19035
#define GPS_MODEL_NAME_CMC_01
Definition: gpsdefs.h:1112
(rw-) NTP_SYMM_KEY_INFO_IDX / NTP_SYMM_KEY_SETTINGS_IDX, only if NTP_MSK_SYMM_KEYS is set in NTP_SRV_...
Definition: gpsserio.h:948
(r-a) ANT_INFO, time diff after antenna disconnect, only if GPS_MODEL_HAS_ANT_INFO ...
Definition: gpsserio.h:803
int mbg_posix_errno_to_mbg(int posix_errno, const char *info)
Translate a POSIX errno error code to one of the MBG_ERROR_CODES.
Definition: mbgerror.c:920
int mbgextio_get_xbp_node_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XBP_NODE_INFO_IDX *p, uint16_t idx)
Read the XBP_NODE_INFO for a specific node in XBP_NODE_INFO_IDX format.
Definition: mbgextio.c:12797
XMULTI_REF_SETTINGS_IDX xmulti_ref_settings_idx
Definition: gpsserio.h:1385
int mbgextio_get_all_port_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, PORT_INFO_IDX pii[])
Read an array of current settings and capabilities of all serial ports.
Definition: mbgextio.c:7536
int mbgextio_set_irig_rx_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const IRIG_SETTINGS *p)
Send new configuration settings for the device&#39;s IRIG input.
Definition: mbgextio.c:7166
#define _mbg_swab_dummy(_x)
A placeholder for yet missing mbg_swab..() macros.
Definition: mbg_arch.h:192
(r–) NTP_REFCLK_STATE_IDX, with index 0 ... NTP_SRV_MODE_SETTINGS::num_refclks - 1 ...
Definition: gpsserio.h:955
void init_transfer(MBG_MSG_RCV_CTL *prctl)
Init reception of a binary message.
int mbgextio_get_io_port_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IO_PORT_INFO_IDX *p, uint8_t idx)
Read I/O port info in MBG_IO_PORT_INFO_IDX format.
Definition: mbgextio.c:5522
NTP symm key info, with index.
Definition: gpsdefs.h:15969
int mbgextio_get_first_evt_log_entry(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_EVT_LOG_ENTRY *p)
Return the first entry from the on-board event log.
Definition: mbgextio.c:7953
union MBG_MSG_CTL_s::st st
uint16_t model_code
identifier for receiver model, see GPS_MODEL_CODES
Definition: gpsdefs.h:875
#define _mbg_swab_ntp_srv_mode_settings(_p)
Definition: gpsdefs.h:16425
char sernum[(16+1)]
ASCIIZ, serial number.
Definition: gpsdefs.h:878
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_evt_log
Check if a device supports the event log API.
Definition: xdevfeat.c:1013
(rw-) req: uint16_t SV num, SV_ALM, one SV&#39;s almanac
Definition: gpsserio.h:984
int mbgextio_get_pwr_ctl(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_PWR_CTL *p)
Read a MBG_PWR_CTL parameter structure from a device.
Definition: mbgextio.c:13676
#define _mbg_swab_scu_stat_info(_p)
Definition: gpsdefs.h:10456
Additional parameters for SMPTE ST 2059-2 profile.
Definition: gpsdefs.h:13795
(rw-) HAVEQUICK_SETTINGS for input, only if GPS_HAS_HAVEQUICK
Definition: gpsserio.h:852
int mbgextio_req_data_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd, uint16_t idx, void *buf, size_t buf_size)
Read a specific element of an array of data structures.
Definition: mbgextio.c:5368
MBG_PTP_V2_PORT_DATASET_IDX ptp_v2_port_dataset_idx
Definition: gpsserio.h:1502
MBG_SNMP_V12_SETTINGS settings
Definition: gpsdefs.h:21437
bool dev_has_receiver_info
Definition: gpsserio.h:1986
uint32_t length
Payload data length of MBG_DATABASE_CMD::payload.
Definition: gpsdefs.h:23604
Information on a specific supported string format.
Definition: gpsdefs.h:3733
#define _mbg_swab_xmr_holdover_status(_p)
Definition: gpsdefs.h:7170
int _MBG_API MBG_ASYNC_DATA_RESET_FNC(MBG_MSG_CTL *pmctl)
Type of a callback function to reset handling of spurious asynchronous data bytes.
Definition: gpsserio.h:1964
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_supp_tlv_ptpv1_license
Check if a device supports supports PTPv1 License Infos via TLV.
Definition: mbgextio.c:4190
A structure used to specify a variable frequency.
Definition: gpsdefs.h:7750
(rw-) MBG_DATABASE_INFO_IDX / MBG_DATABASE_SETTINGS_IDX, index 0..MBG_DATABASE_GLB_INFO::num_dbs - 1...
Definition: gpsserio.h:979
(r–) RECEIVER_INFO, model specific info, not supported by very old devices
Definition: gpsserio.h:814
int _MBG_API MBG_NACK_HANDLER_FNC(MBG_MSG_CTL *pmctl)
Type of a callback function to optionally handle NACK messages.
Definition: gpsserio.h:1918
int mbgextio_get_time(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, TTM *p)
Read the current time as TTM strucure.
Definition: mbgextio.c:5970
Reference source configuration for a specific priority level.
Definition: gpsdefs.h:6749
#define _mbg_swab_event_info_idx(_p)
Definition: gpsdefs.h:21922
Settings, features and flags for receivers of user captures via network.
Definition: gpsdefs.h:12613
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_prog_pulses
Definition: mbgextio.c:3676
Client settings info of an NTP device.
Definition: gpsdefs.h:16260
#define MBG_ERR_RCVD_NO_ACK
Binary protocol received reply msg without expected ACK code. //### TODO.
Definition: mbgerror.h:317
#define _mbg_swab_ntp_clnt_mode_info(_p)
Definition: gpsdefs.h:16277
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_reboot
Check if a device has MBG_XFEATURE_REBOOT.
Definition: xdevfeat.c:1480
#define _mbg_mutex_destroy(_pm)
Definition: mbgmutex.h:183
int mbgextio_get_sv_alm(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, SV_ALM *p, SVNO svno)
Read the GPS almanach for the specified SV from a device.
Definition: mbgextio.c:12936
HAVEQUICK_SETTINGS havequick_settings
Definition: gpsserio.h:1407
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_supp_tlv_time_monitor_license
Check if a device supports supportsTime Monitor License infos via TLV.
Definition: mbgextio.c:4232
size_t mbgextio_get_xmt_buffer_size(MBG_MSG_CTL *pmctl)
Retrieve size of the allocated transmit buffer.
Definition: mbgextio.c:3220
connection via FTDI D2xx USB-To-Serial converter
Definition: gpsserio.h:2055
(rwa) eXtended Binary Packet, only if GPS_HAS_XBP, see eXtended Binary Protocol definitions ...
Definition: gpsserio.h:1008
#define mbg_rc_is_success_or_err_perm(_rc)
Definition: mbgerror.h:620
#define _mbg_swab_ptp_v1_current_dataset(_p)
Definition: gpsdefs.h:14620
int mbgextio_set_time_scale_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_TIME_SCALE_SETTINGS *p)
Send new time scale configuration settings.
Definition: mbgextio.c:7846
#define _mbg_swab_fw_ufu_info_idx(_p)
Definition: gpsdefs.h:23332
MBG_USER_SETTINGS_IDX user_settings_idx
Definition: gpsserio.h:1537
int mbgextio_get_scu_stat_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, SCU_STAT_INFO *p)
Read SCU_STAT_INFO from the device.
Definition: mbgextio.c:13056
#define _mbg_swab_database_settings_idx(_p)
Definition: gpsdefs.h:23499
int mbgextio_open_ssh_socket(const char *host, MBG_MSG_CTL **ppmctl, SSH_DATA *ssh_data)
#define _mbg_swab_pout_settings_idx_on_set(_p)
Definition: gpsdefs.h:6256
#define MBG_ERR_TIMEOUT
Timeout accessing the device.
Definition: mbgerror.h:270
(r–) XMULTI_REF_INSTANCES, only if GPS_HAS_XMRS_MULT_INSTC
Definition: gpsserio.h:843
(rw-) MBG_UCAP_NET_RECV_INFO_IDX/MBG_UCAP_NET_RECV_SETTINGS_IDX, only supp. if MBG_XFEATURE_UCAP_NET ...
Definition: gpsserio.h:919
#define GPS_MODEL_NAME_CPC180
Definition: gpsdefs.h:1106
int mbgextio_req_data_idx_unlocked(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd, uint16_t idx, void *buf, size_t buf_size)
Read a specific element of an array of data structures.
Definition: mbgextio.c:5329
void mbgextio_register_nack_callback(MBG_MSG_CTL *pmctl, MBG_NACK_HANDLER_FNC *fnc)
Register a NACK message handler callback function.
Definition: mbgextio.c:3031
int mbgextio_set_utc_parm(MBG_MSG_CTL *pmctl, XBP_ADDR *p_addr, const UTC *p)
Write a UTC parameter structure to a device.
Definition: mbgextio.c:13022
int check_transfer(MBG_MSG_RCV_CTL *prctl, uint8_t c)
Check an incoming data stream for a binary message.
XDEVFEAT_CHK_SUPP_FNC xdevfeat_supp_tlv_time_monitor_license
Check if a device supports Time Monitor License infos via TLV.
Definition: xdevfeat.c:1275
int mbgextio_get_ntp_misc_orphan_mode_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_MISC_ORPHAN_MODE_INFO *p)
Read the NTP orphan mode information in NTP_MISC_ORPHAN_MODE_INFO format.
Definition: mbgextio.c:11598
see USER_SCOPE_CONFIG_WRITE
Definition: gpsdefs.h:22576
#define _mbg_swab_user_info_idx(_p)
Definition: gpsdefs.h:22907
(rw-) MBG_PTP_V1_CURRENT_DATASET, only supp. if PTP_CFG_MSK_HAS_V1_COMMON_DATASETS is set in PTP_CFG_...
Definition: gpsserio.h:951
(r–) XBP_NODE_INFO_IDX, 0..XBP_NODE_LIMITS::node_count-1 instances can be retrieved ...
Definition: gpsserio.h:879
#define _mbg_swab_mbg_led_settings_idx(_p)
Definition: gpsdefs.h:18890
int mbgextio_get_receiver_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, RECEIVER_INFO *p)
Read a receiver info structure.
Definition: mbgextio.c:5410
MBG_XFEATURE_BUFFER xfeature_buffer
Extended features provided by the device.
Definition: xdevfeat.h:92
MBG_LNE_PORT_SETTINGS_IDX lne_port_settings_idx
Definition: gpsserio.h:1457
uint16_t ANT_CABLE_LEN
A data type used to configure the length of an antenna cable [m].
Definition: gpsdefs.h:11012
(rw-) POUT_SETTINGS_IDX, programmable pulse output settings, only if RECEIVER_INFO::n_prg_out > 0 ...
Definition: gpsserio.h:819
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_ucap
Check if a device supports the user capture API.
Definition: xdevfeat.c:1038
#define MBGEXTIO_MSG_TIMEOUT_USB
Definition: mbgextio.c:724
(rwa) SCU_STAT_SETTINGS/SCU_STAT_INFO, SCU board control, only if ::GPS_MODEL_IS_SCU ...
Definition: gpsserio.h:1004
int mbgextio_set_gnss_mode_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_GNSS_MODE_SETTINGS *p)
Write GNSS mode settings.
Definition: mbgextio.c:8406
#define MBG_SOCKET_ERR_RETVAL
The return code of socket functions in case of error.
Definition: mbg_tgt.h:1014
(r–) MBG_NET_INTF_LINK_INFO_IDX, link status, only if MBG_NET_GLB_SUPP_STAGE_2_MASK is set in MBG_NE...
Definition: gpsserio.h:915
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_ntp
Check if a device supports the NTP API.
Definition: mbgextio.c:3912
A structure to used to query the current configuration and capabilities of a PTP port.
Definition: gpsdefs.h:13342
MBG_SERVICE_SETTINGS settings
Definition: gpsdefs.h:23074
#define MBG_ERR_NO_ENTITY
no such file or directory
Definition: mbgerror.h:355
uint16_t idx
Definition: gpsdefs.h:7470
int mbgextio_fw_ufu_flash(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_FW_UFU_FLASH_CMD *p)
Send UFU flash instruction(s)
Definition: mbgextio.c:11078
State of FDM device.
Definition: gpsdefs.h:10158
(r–) MBG_FW_INFO_IDX, with index 0 ... MBG_FW_GLB_INFO::installed_fws - 1
Definition: gpsserio.h:973
#define _mbg_swab_ntp_peer_state_idx(_p)
Definition: gpsdefs.h:17547
uint8_t state
The device state, see XBP_DEVICE_STATES.
Definition: gpsdefs.h:18015
int mbgextio_get_raw_irig_data(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_RAW_IRIG_DATA *p)
Read raw IRIG data.
Definition: mbgextio.c:7210
PTP_UC_MASTER_SETTINGS settings
specification for the unicast master with that index
Definition: gpsdefs.h:14332
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_supp_tlv_fw_update
Check if a device supports a firmware update via TLV.
Definition: mbgextio.c:4130
int xmt_tbuff(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr)
Complete message header and transmit message.
(rw-) MBG_SYSLOG_INFO_IDX / MBG_SYSLOG_SETTINGS_IDX, only supp. if MBG_MONITORING_TYPE_MSK_SYSLOG is ...
Definition: gpsserio.h:971
double XYZ[N_XYZ]
A position in cartesian coordinates.
Definition: gpsdefs.h:2742
Ionospheric correction parameters.
Definition: gpsdefs.h:18597
#define _mbg_swab_lan_if_info(_p)
Definition: gpsdefs.h:11287
TZCODE tzcode
Definition: gpsserio.h:1578
int mbgextio_set_ntp_peer_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const NTP_PEER_SETTINGS *p, uint16_t idx)
Send configuration settings for a specific NTP peer.
Definition: mbgextio.c:11788
(r–) MBG_DEBUG_STATUS, only if GPS_HAS_DEBUG_STATUS
Definition: gpsserio.h:830
Specific FDM settings and limits.
Definition: gpsdefs.h:10316
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_pwr_ctl_api
Check if a device supports the power control API.
Definition: xdevfeat.c:1404
int mbgextio_set_ntp_clnt_mode_cfg(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const NTP_CLNT_MODE_SETTINGS *p)
Send the NTP client mode configuration.
Definition: mbgextio.c:11712
(rw-) MBG_GPIO_SETTINGS_IDX, settings of a specific port, only if GPS_HAS_GPIO
Definition: gpsserio.h:842
(r–) MBG_GPIO_FREQ, only if MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in MBG_IMS_STATE::flags ...
Definition: gpsserio.h:888
#define _mbg_swab_mbg_ims_fdm_output_info_idx(_p)
Definition: gpsdefs.h:10073
#define _mbg_swab_ttm(_p)
Definition: gpsdefs.h:2721
Index structure for PTPv2 port dataset.
Definition: gpsdefs.h:15073
MSG_HDR hdr
The message header.
Definition: gpsserio.h:1712
(-w-) Send GPS command as payload, only supp. if MBG_XFEATURE_PUSH_MSGS
Definition: gpsserio.h:957
#define _mbg_swab_event_settings_idx(_p)
Definition: gpsdefs.h:21819
A structure used to transmit information on date and time.
Definition: gpsdefs.h:2713
MBG_TLV_INFO tlv_info
TLV info provided by a device.
Definition: xdevfeat.h:93
PTPv2 default dataset.
Definition: gpsdefs.h:14865
Index structure for PTPv1 port dataset.
Definition: gpsdefs.h:14822
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_clk_res_info
Definition: mbgextio.c:3432
#define _ttm_time_set_unavail(_t)
Definition: mbgextio.h:437
(r–) MBG_IMS_FDM_INFO, only if MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in MBG_IMS_STATE::flags ...
Definition: gpsserio.h:886
(-wa) TTM, current time or capture, or init board time
Definition: gpsserio.h:797
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_xbp
Check if a device supports the extended binary protocol (XBP) feature.
Definition: xdevfeat.c:1548
MBG_TIME_SCALE_SETTINGS time_scale_settings
Definition: gpsserio.h:1391
int mbgextio_set_tzcode(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const TZCODE *p)
Set the local time conversion configuration in TZCODE format.
Definition: mbgextio.c:8209
PTPv2 parent dataset.
Definition: gpsdefs.h:14947
A generic message send and receive control structure.
Definition: gpsserio.h:1972
#define _mbg_swab_mbg_ims_fdm_state(_p)
Definition: gpsdefs.h:10172
Generic state of an IMS device.
Definition: gpsdefs.h:9790
int mbgextio_reset_usb(const MBG_USB_DEV_INFO *mdev_info)
Reset an USB device in case that the open_usb function return MBG_ERR_BUSY.
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_tzdl
Definition: mbgextio.c:3623
GNSS mode settings.
Definition: gpsdefs.h:10677
(r–) MBG_SERVICE_MGMT_INFO, only supp. if MBG_XFEATURE_SERVICE
Definition: gpsserio.h:966
(-w-) Transmit index of MBG_FW_INFO_IDX to be activated
Definition: gpsserio.h:975
int mbgextio_set_ptp_v1_default_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_PTP_V1_DEFAULT_DATASET *p)
Send PTPv1 default dataset to a device in MBG_PTP_V1_DEFAULT_DATASET format.
Definition: mbgextio.c:9414
int mbgextio_get_gnss_sv_status_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GNSS_SV_STATUS_IDX *p, uint16_t idx)
::TODO
Definition: mbgextio.c:8564
(rw-) NTP_MISC_ORPHAN_MODE_SETTINGS, only if NTP_MISC_MSK_ORPHAN_MODE is set in NTP_MISC_LIMITS::supp...
Definition: gpsserio.h:946
int mbgextio_get_monitoring_limits(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_MONITORING_LIMITS *p)
Read the monitoring limits in MBG_MONITORING_LIMITS format.
Definition: mbgextio.c:10143
(r–) MBG_IMS_SENSOR_STATE_IDX, only if GPS_HAS_IMS
Definition: gpsserio.h:850
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_ims
Definition: xdevfeat.c:385
#define _mbg_swab_synth(_p)
Definition: gpsdefs.h:2864
int mbgextio_set_event_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_EVENT_SETTINGS *p, uint16_t idx)
Write monitoring event settings in MBG_EVENT_SETTINGS format.
Definition: mbgextio.c:10606
A GPIO port&#39;s current settings, plus port index.
Definition: gpsdefs.h:9184
#define _mbg_swab_xbp_limits(_p)
Definition: gpsdefs.h:17886
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_supp_tlv_ptpv2_license
Check if a device supports upports PTPv2 license infos.
Definition: mbgextio.c:4170
uint32_t XMR_HOLDOVER_INTV
XMR holdover interval, or elapsed holdover time, in [s].
Definition: gpsdefs.h:7116
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_ant_info
Check if a device supports the ANT_INFO structure and API.
Definition: xdevfeat.c:658
(r–) NTP_SYMM_KEY_LIMITS, only if NTP_MSK_SYMM_KEYS is set in NTP_SRV_MODE_SETTINGS::flags ...
Definition: gpsserio.h:947
int mbgextio_set_led_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_LED_SETTINGS *p, uint16_t idx)
Write a MBG_LED_SETTINGS parameter structure to a device.
Definition: mbgextio.c:13812
MBG_PTP_V1_PORT_DATASET port_dataset
see MBG_PTP_V1_PORT_DATASET
Definition: gpsdefs.h:14825
int mbgextio_get_iono(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, IONO *p)
Read the ionospheric correction parameters from a device.
Definition: mbgextio.c:12962
int mbgextio_get_str_type_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, STR_TYPE_INFO_IDX *p, uint16_t idx)
Read information on a specific supported string format.
Definition: mbgextio.c:7406
void lla_to_dms(POS *pos)
Convert mathematic coords to to geographic coords.
int mbgextio_get_net_dns_srch_dom_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_NET_NAME_IDX *p, uint16_t idx)
Read the network DNS search domain in MBG_NET_NAME_IDX format.
Definition: mbgextio.c:12229
#define _mbg_swab_ptp_v1_parent_dataset(_p)
Definition: gpsdefs.h:14689
int mbgextio_get_svc_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_SERVICE_INFO_IDX *p, uint16_t idx)
Read the service info with the given index in MBG_SERVICE_INFO_IDX format.
Definition: mbgextio.c:14033
MBG_NET_GLB_CFG_SETTINGS net_glb_cfg_settings
Definition: gpsserio.h:1428
int mbgextio_set_synth(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const SYNTH *p)
Write the frequency synthesizer settings.
Definition: mbgextio.c:6366
int mbgextio_clr_evt_log(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr)
Clear the on-board event log.
Definition: mbgextio.c:7884
Global configuration info of an NTP device (client/server)
Definition: gpsdefs.h:15246
Limits to be considered when specifying PTP unicast masters.
Definition: gpsdefs.h:14231
MBG_ASYNC_DATA_HANDLER_FNC * async_data_handler_fnc
See mbgextio_register_async_data_callback.
Definition: gpsserio.h:1991
int mbgextio_get_ip4_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, IP4_SETTINGS *p)
Read the lan ipv4 configuration state IP4_SETTINGS format.
Definition: mbgextio.c:9051
#define _mbg_swab_ptp_v2_default_dataset(_p)
Definition: gpsdefs.h:14880
int mbgextio_get_port_parm(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, PORT_PARM *p)
Read serial port parameters in PORT_PARM format.
Definition: mbgextio.c:6266
#define USB_DEV_CMC
Definition: usbdefs.h:218
ulong mbgextio_set_dev_poll_timeout(MBG_MSG_CTL *pmctl, ulong new_timeout)
Set device poll timeout.
Definition: mbgextio.c:3244
MBG_USER_STATUS user_status
User status for the logged in user.
Definition: xdevfeat.h:95
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_fw_mngmnt
Check if a device supports the FW management API.
Definition: mbgextio.c:3936
(-w-) Send GPS command as payload, only supp. if MBG_XFEATURE_PUSH_MSGS
Definition: gpsserio.h:958
int mbgextio_set_hq_tx_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const HAVEQUICK_SETTINGS *p)
Send new configuration settings for the device&#39;s HAVEQUICK output.
Definition: mbgextio.c:8246
void * priv_data
Definition: gpsserio.h:2041
int mbgextio_get_event_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_EVENT_INFO_IDX *p, uint16_t idx)
Read monitoring event info in MBG_EVENT_INFO_IDX format.
Definition: mbgextio.c:10568
int mbgextio_get_fw_ufu_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_FW_UFU_INFO_IDX *p, uint8_t fw_idx, uint8_t ufu_idx)
Read the firmware ufu info of the given firmware with the also given index in MBG_FW_UFU_INFO_IDX for...
Definition: mbgextio.c:11042
MBG_SNMP_V12_TRAP_SETTINGS_IDX snmp_v12_trap_settings_idx
Definition: gpsserio.h:1489
#define _mbg_swab_ucap_net_recv_info_idx(_p)
Definition: gpsdefs.h:12621
(r–) MBG_TAINTED_CFG, only supp. if MBG_XFEATURE_TAINTED_CFG is set in extended features ...
Definition: gpsserio.h:941
int mbgextio_set_net_dns_srch_dom_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_NET_NAME *p, uint16_t idx)
Send the network DNS search domain in MBG_NET_NAME format.
Definition: mbgextio.c:12264
MBG_SYSLOG_SETTINGS settings
Definition: gpsdefs.h:22206
Satellite information for a particular GNSS type.
Definition: gpsdefs.h:10749
Clock resolution information.
Definition: gpsdefs.h:19853
#define _mbg_swab_stat_info(_p)
Definition: gpsdefs.h:10601
#define _mbg_swab_gnss_sat_info(_p)
Definition: gpsdefs.h:10759
NTP_CLNT_MODE_SETTINGS ntp_clnt_mode_settings
Definition: gpsserio.h:1418
#define MBG_ERR_IO
Input/output error.
Definition: mbgerror.h:328
#define _mbg_swab_ptp_v1_port_dataset_idx(_p)
Definition: gpsdefs.h:14830
int mbgextio_set_ucap_net_glb_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_UCAP_NET_GLB_SETTINGS *p)
Send the user capture network global configuration in MBG_UCAP_NET_GLB_SETTINGS format.
Definition: mbgextio.c:6526
int mbgextio_set_ntp_misc_orphan_mode_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const NTP_MISC_ORPHAN_MODE_SETTINGS *p)
Send the NTP orphan mode configuration in NTP_MISC_ORPHAN_MODE_SETTINGS format.
Definition: mbgextio.c:11633
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_xbp
Check if a device supports the extended binary protocl (XBP) feature.
Definition: mbgextio.c:4493
int mbgextio_get_time_scale_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_TIME_SCALE_INFO *p)
Read time scale configuration parameters.
Definition: mbgextio.c:7814
(r–) MBG_FW_GLB_INFO, only supp. if MBG_XFEATURE_FW_MNGMNT is set
Definition: gpsserio.h:972
An IPv4 or IPv6 network address, plus index.
Definition: gpsdefs.h:11945
#define MBG_ERR_UNSPEC
Unspecified error.
Definition: mbgerror.h:312
(-w-) MBG_DATABASE_CMD, only supp. if MBG_XFEATURE_DATABASE
Definition: gpsserio.h:980
#define _mbg_swab_ntp_refclk_state_idx(_p)
Definition: gpsdefs.h:17555
uint16_t idx
Definition: gpsdefs.h:11947
#define MBG_ERR_BYTES_WRITTEN
Binary protocol failed to write all bytes.
Definition: mbgerror.h:319
int mbgextio_set_xmr_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const XMULTI_REF_SETTINGS *p, uint16_t idx)
Set XMULTI_REF_SETTINGS for a specific XMR source.
Definition: mbgextio.c:8978
int mbgextio_get_lne_limits(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_LNE_LIMITS *p)
Read a MBG_IMS_FDM_STATE parameter structure from a device. ::TODO ###.
Definition: mbgextio.c:13537
Configuration settings for a specific programmable pulse output.
Definition: gpsdefs.h:6249
MBG_PWR_CTL pwr_ctl
Definition: gpsserio.h:1458
(rw-) XMR_HOLDOVER_INTV, only if ::GPS_MODEL_HAS_XMR_HOLDOVER_INTV, see also GPS_XMR_HOLDOVER_STATUS ...
Definition: gpsserio.h:851
Structure for monitoring event settings.
Definition: gpsdefs.h:21812
#define _mbg_swab_double(_p)
Definition: mbg_arch.h:177
(rw-) MBG_USER_INFO_IDX / MBG_USER_SETTINGS_IDX, index 0 .. MBG_USER_MNGMNT_SETTINGS::num_levels, only supp. if MBG_XFEATURE_USER_MNGMNT
Definition: gpsserio.h:963
#define MBG_DEFAULT_BAUDRATE
The standard baud rate used for the binary protocol.
Definition: gpsdefs.h:3419
int mbgextio_get_pout_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, POUT_INFO_IDX *p, uint16_t idx)
Read current settings and capabilities of a specific programmable pulse output.
Definition: mbgextio.c:7619
int mbgextio_get_lne_port_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_LNE_PORT_SETTINGS_IDX *p, uint16_t idx)
Read a MBG_LNE_PORT_SETTINGS_IDX parameter structure from a device.
Definition: mbgextio.c:13589
A structure used to configure optional settings.
Definition: gpsdefs.h:5323
#define USB_DEV_CPC180
Definition: usbdefs.h:209
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_led_api
Check if a device supports the LED API.
Definition: xdevfeat.c:1360
XMULTI_REF_SETTINGS settings
the settings configured for this level
Definition: gpsdefs.h:6752
#define _mbg_swab_ip4_settings(_p)
Definition: gpsdefs.h:11250
MBG_DATABASE_SETTINGS_IDX db_settings_idx
Definition: gpsserio.h:1556
int mbgextio_clr_ucap_buff(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr)
Clear the user capture event buffer on-board the device.
Definition: mbgextio.c:7785
int16_t MBG_REF_OFFS
A data type used to configure the ref offset.
Definition: gpsdefs.h:5297
TTM ttm
Definition: gpsserio.h:1356
#define GPS_CTRL_MSK
bit mask of all GPS_CMD_CTRL_CODES
Definition: gpsserio.h:745
#define MBGEXTIO_POLL_TIMEOUT_SERIAL
Definition: mbgextio.c:718
#define _mbg_swab_mbg_gnss_mode_info(_p)
Definition: gpsdefs.h:10703
#define FT_HANDLE
Definition: mbgextio.h:444
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_cmd_save_cfg
Check if a device supports the GPS_SAVE_CFG command.
Definition: mbgextio.c:4273
MBG_PTP_V2_CURRENT_DATASET ptp_v2_current_dataset
Definition: gpsserio.h:1499
int mbgextio_get_ucap_net_recv_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_UCAP_NET_RECV_INFO_IDX *p, uint16_t idx)
Read the user capture network receiver info with the given index in MBG_UCAP_NET_RECV_INFO_IDX format...
Definition: mbgextio.c:6564
uint16_t idx
0..MBG_NET_GLB_CFG_SETTINGS::num_intf_route-1
Definition: gpsdefs.h:12305
(rw-) MBG_NET_INTF_ADDR_INFO_IDX/MBG_NET_INTF_ADDR_SETTINGS_IDX, only if MBG_NET_GLB_SUPP_STAGE_2_MAS...
Definition: gpsserio.h:912
int mbgextio_get_user_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_USER_INFO_IDX *p, uint16_t idx)
Read the user info with the given index in MBG_USER_INFO_IDX format.
Definition: mbgextio.c:6704
int mbgextio_socket_read_default(MBG_MSG_CTL *pmctl, void *buf, size_t len)
Function, which can be used to read data from a standard LAN socket.
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_service
Check if a device supports services.
Definition: xdevfeat.c:1717
int mbgextio_get_serial_ftdi_port_handle(MBG_MSG_CTL *pmctl)
Get the port handle of a serial FTDI device.
int mbgextio_set_ucap_net_recv_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_UCAP_NET_RECV_SETTINGS_IDX *p, uint16_t idx)
Send the user capture network receiver configuration with the given index in MBG_UCAP_NET_RECV_SETTIN...
Definition: mbgextio.c:6597
Global settings, features and flags for user captures via network.
Definition: gpsdefs.h:12493
#define MBG_IO_PORT_SETTINGS_IDX_SIZES
Definition: gpsdefs.h:20756
#define _mbg_swab_mbg_opt_settings(_p)
Definition: gpsdefs.h:5329
int mbgextio_get_num_evt_log_entries(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_NUM_EVT_LOG_ENTRIES *p)
Read the current number of entries in the on-board event log.
Definition: mbgextio.c:7915
#define USB_DEV_TSU_01
Definition: usbdefs.h:212
uint16_t IGNORE_LOCK
Definition: gpsdefs.h:10401
MBG_IMS_FDM_SETTINGS fdm_settings
Definition: gpsserio.h:1448
int mbgextio_get_net_stat_glb_cfg_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_NET_GLB_CFG_INFO *p)
Read the network global status information MBG_NET_GLB_CFG_INFO format.
Definition: mbgextio.c:12597
uint16_t idx
the priority level index (highest == 0), 0..XMULTI_REF_INSTANCES::n_xmr_settings-1 ...
Definition: gpsdefs.h:6751
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_pzf
Check if a device supports DCF77 PZF decoding.
Definition: mbgextio.c:3570
#define _mbg_swab_mbg_num_evt_log_entries(_p)
Definition: gpsdefs.h:9547
unsigned char uint8_t
Definition: words.h:210
Information on a specific XBP node.
Definition: gpsdefs.h:18006
MBG_USER_MNGMNT_SETTINGS user_mngmnt_settings
Definition: gpsserio.h:1535
(rw-) HAVEQUICK_SETTINGS for output, only if GPS_HAS_HAVEQUICK
Definition: gpsserio.h:854
#define _mbg_swab_snmp_v3_trap_info_idx(_p)
Definition: gpsdefs.h:21744
int _MBG_API MBG_ASYNC_DATA_HANDLER_FNC(MBG_MSG_CTL *pmctl, char c)
Type of a callback function to handle spurious asynchronous data bytes.
Definition: gpsserio.h:1948
int mbgextio_set_enable_flags(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const ENABLE_FLAGS *p)
Send the enable flags controlling when output signals are enabled.
Definition: mbgextio.c:6914
(-w-) NANO_TIME_64, set time deviation, only if MBG_IMS_FDM_FLAG_MASK_CAN_SET_TDEV ...
Definition: gpsserio.h:892
IO Port Limits.
Definition: gpsdefs.h:20411
#define _mbg_swab_ucap_net_recv_settings_idx(_p)
Definition: gpsdefs.h:12568
#define _mbg_swab_ptp_state(_p)
Definition: gpsdefs.h:13219
(rw-) MBG_PTP_V2_PORT_DATASET_IDX, only supp. if PTP_CFG_MSK_HAS_V2_COMMON_DATASETS is set in PTP_CFG...
Definition: gpsserio.h:940
#define DEFAULT_GPS_TICKS_PER_SEC
system time base, see GPS_TICKS_PER_SEC
Definition: gpsdefs.h:682
NTP orphan mode info.
Definition: gpsdefs.h:16188
(r–) GNSS_SV_STATUS_IDX, only supp. if MBG_GNSS_FLAG_MSK_HAS_SV_STATUS is set
Definition: gpsserio.h:935
see USER_SCOPE_CONFIG_READ
Definition: gpsdefs.h:22575
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_database
Check if a device supports database(s) feature.
Definition: xdevfeat.c:1569
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_time_scale
Check if a device supports the MBG_TIME_SCALE_INFO structure and API.
Definition: xdevfeat.c:592
int decrypt_message(MBG_MSG_CTL *pmctl)
Decrypt an encrypted binary message.
General info on supported XMR sources and instances.
Definition: gpsdefs.h:7054
int mbgextio_set_ntp_glb_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const NTP_GLB_SETTINGS *p)
Send the NTP global configuration.
Definition: mbgextio.c:11337
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_tzdl
Check if a device supports the TZDL structure and API.
Definition: xdevfeat.c:614
int mbgextio_delete_fw(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, uint16_t idx)
Delete the firmware with the given index.
Definition: mbgextio.c:11005
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_xmulti_ref
Check if a device supports the up-to-date extended multi ref API.
Definition: mbgextio.c:4471
int mbgextio_time_mon_get_target_status_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_TIME_MON_TARGET_STATUS_IDX *p, uint16_t idx)
int mbgextio_get_ptp_smpte_tlv_state(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, PTP_SMPTE_PROFILE_CFG *p)
Read the current SMPTE TLV.
Definition: mbgextio.c:10115
void mbgextio_register_async_data_reset_callback(MBG_MSG_CTL *pmctl, MBG_ASYNC_DATA_RESET_FNC *fnc)
Register an asynchronous data reset callback function.
Definition: mbgextio.c:3105
int mbgextio_setup_xdevfeat(MBG_MSG_CTL *pmctl, XBP_ADDR *addr)
Set up MBG_XDEV_FEATURES for a device which has just been opened.
Definition: mbgextio.c:922
ANT_CABLE_LEN ant_cable_len
Definition: gpsserio.h:1366
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_lne_api
Check if a device supports the LNE API.
Definition: mbgextio.c:4339
#define _mbg_mutex_release(_pm)
Definition: mbgmutex.h:185
#define FT_STATUS
Definition: gpsserio.h:646
(r–) MBG_FW_UFU_INFO_IDX, with index 0 ... MBG_FW_INFO::num_ufus - 1
Definition: gpsserio.h:974
int mbgextio_set_ntp_symm_key_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const NTP_SYMM_KEY_SETTINGS *p, uint16_t idx)
Send NTP symmetric key settings with the given index in NTP_SYMM_KEY_SETTINGS format.
Definition: mbgextio.c:11447
Network host or domain name, plus index.
Definition: gpsdefs.h:12003
IO Port Info Index.
Definition: gpsdefs.h:20862
General LED info to be read from a device.
Definition: gpsdefs.h:18727
XMULTI_REF_INFO_IDX xmulti_ref_info_idx
Definition: gpsserio.h:1386
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_lan_ip4
Check if a device supports the old LAN_IP4 API.
Definition: xdevfeat.c:887
(rw-) PORT_SETTINGS_IDX, settings for specified serial port, only if RECEIVER_INFO::n_com_ports > 0 ...
Definition: gpsserio.h:817
#define _mbg_swab_ntp_trusted_key_info_idx(_p)
Definition: gpsdefs.h:16058
(rw-) XYZ, current position in ECEF coordinates, only if GPS_MODEL_HAS_POS_XYZ
Definition: gpsserio.h:798
int mbgextio_set_snmp_v3_trap_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_SNMP_V3_TRAP_SETTINGS *p, uint16_t idx)
Write SNMP v3 trap settings in MBG_SNMP_V3_TRAP_SETTINGS format.
Definition: mbgextio.c:10522
A structure used to control the reception of binary messages.
Definition: gpsserio.h:1734
#define MBG_ERR_HDR_CSUM
Binary protocol header checksum error.
Definition: mbgerror.h:314
int mbgextio_get_led_limits(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_LED_LIMITS *p)
Read the MBG_LED_LIMITS to check how many LEDs are provided.
Definition: mbgextio.c:13711
Structure for monitoring event info.
Definition: gpsdefs.h:21915
#define _mbg_swab_mbg_gpio_settings_idx(_p, _recv)
Definition: gpsdefs.h:9191
(r–) NTP_MISC_LIMITS, only if NTP_MSK_MISCELLANEOUS is set in NTP_GLB_INFO::supp_flags ...
Definition: gpsserio.h:945
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_tlv_api
Check if a device supports the TLV API.
Definition: mbgextio.c:3987
int mbgextio_find_lan_devices(MBG_LAN_DEV_LIST **list, uint16_t timeout_ms)
Sets up a list of all available Meinberg LAN devices in the network.
int mbgextio_get_led_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_LED_INFO_IDX *p, uint16_t idx)
Read the current settings and features of a particular LED.
Definition: mbgextio.c:13745
int mbgextio_set_pos_lla(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const LLA lla)
Set the device&#39;s position by sending an LLA array.
Definition: mbgextio.c:6038
(r–) POUT_INFO_IDX, programmable pulse output settings and capabilities, only if RECEIVER_INFO::n_pr...
Definition: gpsserio.h:818
NTP_GLB_SETTINGS ntp_glb_settings
Definition: gpsserio.h:1416
uint32_t cmd
See MBG_DATABASE_CMDS.
Definition: gpsdefs.h:23603
#define _mbg_swab_irig_info(_p)
Definition: gpsdefs.h:5061
int mbgextio_get_ntp_trusted_key_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_TRUSTED_KEY_INFO_IDX *p, uint16_t idx)
Read the NTP trusted key info with the given index in NTP_TRUSTED_KEY_INFO_IDX format.
Definition: mbgextio.c:11489
(rw-) MBG_PTP_V2_TIME_PROPERTIES_DATASET, only supp. if PTP_CFG_MSK_HAS_V2_COMMON_DATASETS is set in ...
Definition: gpsserio.h:939
#define _mbg_swab_port_parm(_p)
Definition: gpsdefs.h:3936
Settings for receivers of user captures via network.
Definition: gpsdefs.h:12560
int mbgextio_set_irig_tx_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const IRIG_SETTINGS *p)
Send new configuration settings for the device&#39;s IRIG output.
Definition: mbgextio.c:7095
#define _mbg_swab_mbg_ims_fdm_info(_p)
Definition: gpsdefs.h:10325
MBG_USER_PERM_BUF cfg_read_perm
current config read permissions, see MBG_USER_PERM_BUF and MBG_USER_PERMS
Definition: gpsdefs.h:22943
(r–) MBG_NUM_EVT_LOG_ENTRIES, num. of log entries, only if GPS_HAS_EVT_LOG
Definition: gpsserio.h:845
int mbgextio_get_ucap_net_glb_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_UCAP_NET_GLB_INFO *p)
Read the user capture network global info in MBG_UCAP_NET_GLB_INFO format.
Definition: mbgextio.c:6495
(r–) MBG_RAW_IRIG_DATA, only if GPS_HAS_RAW_IRIG_DATA
Definition: gpsserio.h:839
(r–) MBG_USER_STATUS for the authenticated user, see MBG_XFEATURE_USER_AUTH
Definition: gpsserio.h:960
#define _mbg_swab_fw_glb_info(_p)
Definition: gpsdefs.h:23192
MBG_PTP_V2_PARENT_DATASET ptp_v2_parent_dataset
Definition: gpsserio.h:1500
Device power control.
Definition: gpsdefs.h:19192
int mbgextio_set_database_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_DATABASE_SETTINGS *p, uint8_t idx)
Write database settings in MBG_DATABASE_SETTINGS_IDX format.
Definition: mbgextio.c:11196
Configuration settings specifiying how to query a PTP unicast master.
Definition: gpsdefs.h:14274
(rw-) XMULTI_REF_SETTINGS_IDX, idx 0..XMULTI_REF_INSTANCES::n_xmr_settings-1, only if GPS_HAS_XMULTI_...
Definition: gpsserio.h:831
#define MBG_ERR_NO_MEM
Failed to allocate memory.
Definition: mbgerror.h:282
encrypted transmission, usually over network
Definition: gpsserio.h:1807
void mbg_gps_ident_decode(char *s, const IDENT *p_id)
Definition: identdec.c:92
(rw-) MBG_PTP_V1_TIME_PROPERTIES_DATASET, only supp. if PTP_CFG_MSK_HAS_V1_COMMON_DATASETS is set in ...
Definition: gpsserio.h:953
XDEVFEAT_CHK_SUPP_FNC xdevfeat_is_gnss
Check if a device supports the GNSS API.
Definition: xdevfeat.c:211
#define MBG_ERR_RCVD_NACK
Binary protocol received reply msg with a NACK code.
Definition: mbgerror.h:316
int mbgextio_time_mon_get_target_ext_data_set_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_TIME_MON_TARGET_EXT_DATA_SET_IDX *p, uint16_t idx)
int mbgextio_set_holdover_interval(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const XMR_HOLDOVER_INTV *p)
Set the XMR holdover interval.
Definition: mbgextio.c:8092
One of several sets of satellite information for a particular GNSS type.
Definition: gpsdefs.h:10773
(rw-) IGNORE_LOCK, if != 0 always claim to be sync, only if GPS_HAS_IGNORE_LOCK
Definition: gpsserio.h:826
int mbgextio_get_ims_fdm_output_state_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IMS_FDM_OUTPUT_STATE_IDX *p, uint16_t idx)
Read a MBG_IMS_FDM_OUTPUT_STATE_IDX parameter structure from a device.
Definition: mbgextio.c:13338
#define MBG_ERR_ACCESS
Access denied, e.g. when trying to access a file or device without sufficient permissions.
Definition: mbgerror.h:336
int mbgextio_set_port_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const PORT_SETTINGS *p, uint16_t idx)
Send configuration settings for a specific serial port.
Definition: mbgextio.c:7578
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_bvar_stat
Check if a device supports the BVAR_STAT structure and API.
Definition: xdevfeat.c:506
int mbgextio_set_scu_stat_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const SCU_STAT_SETTINGS *p)
Send SCU_STAT_SETTINGS to the device.
Definition: mbgextio.c:13090
void trim_whitespace(char *s)
Trim both leading and trailing whitespace from a string.
Definition: str_util.c:387
#define MBG_ERR_NBLOCK_WAIT_WR_FD
Write fd not set after select when waiting for non-blocking network port to become ready...
Definition: mbgerror.h:326
(rw-) MBG_PTP_V1_DEFAULT_DATASET, only supp. if PTP_CFG_MSK_HAS_V1_COMMON_DATASETS is set in PTP_CFG_...
Definition: gpsserio.h:950
(rw-) MBG_SNMP_GLB_INFO / MBG_SNMP_GLB_SETTINGS, only supp. if MBG_MONITORING_TYPE_MSK_SNMP is set in...
Definition: gpsserio.h:926
int mbgextio_get_ptp_v1_parent_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_PTP_V1_PARENT_DATASET *p)
Read the PTPv1 parent dataset in MBG_PTP_V1_PARENT_DATASET format.
Definition: mbgextio.c:9526
int mbgextio_get_tr_distance(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, TR_DISTANCE *p)
Read the distance from transmitter TR_DISTANCE format.
Definition: mbgextio.c:8312
the number of known baud rates
Definition: gpsdefs.h:3246
MBG_EVENT_SETTINGS settings
Definition: gpsdefs.h:21815
int mbgextio_get_ntp_symm_key_limits(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_SYMM_KEY_LIMITS *p)
Read the NTP symmetric key limits in NTP_SYMM_KEY_LIMITS format.
Definition: mbgextio.c:11376
int MBG_TIME_MON_TARGET_SETTINGS
Definition: gpsserio.h:676
MBG_ASYNC_MSG_HANDLER_FNC * async_msg_handler_fnc
See mbgextio_register_async_msg_callback.
Definition: gpsserio.h:1990
Time zone / daylight saving parameters.
Definition: gpsdefs.h:2940
#define _mbg_swab_str_type_info_idx(_p)
Definition: gpsdefs.h:3740
MBG_NET_INTF_ADDR_SETTINGS_IDX net_intf_addr_settings_idx
Definition: gpsserio.h:1434
uint32_t device_flags
See MSG_CTL_DEVICE_FLAG_MSKS.
Definition: gpsserio.h:1982
PORT_SETTINGS port_settings
Definition: gpsdefs.h:3597
int mbgextio_set_gpio_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_GPIO_SETTINGS *p, uint16_t idx)
Send configuration settings for a specific GPIO.
Definition: mbgextio.c:7748
int mbgextio_get_ims_sensor_state_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IMS_SENSOR_STATE_IDX *p, uint16_t idx)
Read sensor values from a specified sensor on the device.
Definition: mbgextio.c:8060
int mbgextio_get_pos(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, POS *p_pos)
Read the current receiver position as POS structure.
Definition: mbgextio.c:6152
(r–) LAN_IF_INFO, only if GPS_HAS_LAN_IP4
Definition: gpsserio.h:999
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_ucap_net
Check if a device supports the user capture via network feature.
Definition: xdevfeat.c:1059
int mbgextio_xmt_cmd_us(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd, uint16_t us)
Transmit a message with a single ushort (uint16_t) parameter.
Definition: mbgextio.c:5188
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
Definition: mbgerror.h:259
void mbg_memcpy(void *dst, const void *src, size_t n_bytes)
Copy array of bytes starting at beginning of buffer.
Definition: str_util.c:412
#define _mbg_swab_enable_flags(_p)
Definition: gpsdefs.h:3151
#define _mbg_swab_xmulti_ref_info_idx(_p)
Definition: gpsdefs.h:6846
int mbgextio_close_connection(MBG_MSG_CTL **ppmctl)
Close a binary communication channel and release resources.
Definition: mbgextio.c:2697
MBG_UCAP_NET_GLB_SETTINGS ucap_net_glb_settings
Definition: gpsserio.h:1474
int mbgextio_set_ref_offs(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_REF_OFFS *p)
Send new ref offset to UTC settings.
Definition: mbgextio.c:7278
uint16_t idx
Index of the port dataset, 0..MBG_PTP_V1_DEFAULT_DATASET::number_ports - 1.
Definition: gpsdefs.h:14824
#define _mbg_swab_pout_info_idx_on_get(_p)
Definition: gpsdefs.h:6358
int mbgextio_get_cfgh(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, CFGH *p)
Read configuration and health data of all satellites from a device.
Definition: mbgextio.c:12909
MBG_SYSLOG_GLB_SETTINGS syslog_glb_settings
Definition: gpsserio.h:1546
(rw-) MBG_PTP_V2_CURRENT_DATASET, only supp. if PTP_CFG_MSK_HAS_V2_COMMON_DATASETS is set in PTP_CFG_...
Definition: gpsserio.h:937
MBG_PTP_V1_CURRENT_DATASET ptp_v1_current_dataset
Definition: gpsserio.h:1524
MSG_CTL_DEVICE_FLAG_MSKS
Binary message control device flag masks.
Definition: mbgextio.c:759
int mbgextio_set_port_parm(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const PORT_PARM *p)
Send serial port parameters in PORT_PARM format.
Definition: mbgextio.c:6300
#define GPS_MODEL_NAME_CPC_01
Definition: gpsdefs.h:1110
(r–) MBG_IO_PORT_LIMITS, only supp. if MBG_XFEATURE_IO_PORTS is set in extended features ...
Definition: gpsserio.h:920
(r–) GPS_XMR_METRICS_IDX, only if XMR_EXT_SRC_FEAT_FLAG_MSK_METRICS
Definition: gpsserio.h:907
int mbgextio_get_synth(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, SYNTH *p)
Read the frequency synthesizer settings.
Definition: mbgextio.c:6333
MBG_IMS_FDM_OUTPUT_SETTINGS_IDX fdm_output_settings_idx
Definition: gpsserio.h:1444
Peer settings for NTP devices.
Definition: gpsdefs.h:16393
XDEVFEAT_CHK_SUPP_FNC xdevfeat_supp_tlv_exec_cmd
Check if a device supports a command execution via TLV.
Definition: xdevfeat.c:1125
GPS_CMD cmd
see GPS_CMD_CODES and GPS_CMD_CTRL_CODES
Definition: gpsserio.h:1333
MBG_STD_MSG std_msg
Encapsulated standard binary message.
Definition: gpsserio.h:1646
Synthesizer configuration parameters.
Definition: gpsdefs.h:2856
MBG_USER_INFO user_info
User info for the logged in user.
Definition: xdevfeat.h:94
const char * str_unknown
int mbgextio_get_snmp_v12_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_SNMP_V12_INFO_IDX *p, uint16_t idx)
Read SNMP v1 or v2 info in MBG_SNMP_V12_INFO_IDX format.
Definition: mbgextio.c:10252
int mbgextio_set_syslog_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_SYSLOG_SETTINGS *p, uint16_t idx)
Write syslog server information in MBG_SYSLOG_SETTINGS_IDX format.
Definition: mbgextio.c:10854
Generic state of an IMS sensor, with sensor index.
Definition: gpsdefs.h:9863
int mbgextio_set_ntp_trusted_key_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const NTP_TRUSTED_KEY_SETTINGS *p, uint16_t idx)
Send NTP trusted key settings with the given index in NTP_TRUSTED_KEY_SETTINGS format.
Definition: mbgextio.c:11524
int mbgextio_set_syslog_glb_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_SYSLOG_GLB_SETTINGS *p)
Send the syslog global settings in MBG_SYSLOG_GLB_SETTINGS format.
Definition: mbgextio.c:10776
int mbgextio_setup_receiver_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, RECEIVER_INFO *p)
Setup a receiver info structure.
Definition: mbgextio.c:5716
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_synth
Definition: mbgextio.c:3654
Reference source capabilities and current configuration for a specific priority level.
Definition: gpsdefs.h:6839
int mbgextio_send_database_cmd(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, uint32_t cmd, const void *payload, uint32_t payload_len)
Send a specific command to database in MBG_DATABASE_CMD format.
Definition: mbgextio.c:11243
MSG_DATA msg_data
Standard message data structures.
Definition: gpsserio.h:1717
#define _mbg_swab_ntp_refclk_cfg_info_idx(_p)
Definition: gpsdefs.h:15802
#define _mbg_swab_ntp_misc_limits(_p)
Definition: gpsdefs.h:16109
uint32_t idx
node index, 0..XBP_NODE_LIMITS::node_count-1
Definition: gpsdefs.h:18046
XBP_PORT addr[7]
An array of port numbers on cascaded controllers.
Definition: gpsdefs.h:17864
int mbgextio_set_svc_ctl_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, uint16_t idx, uint16_t ctl)
Set service control command.
Definition: mbgextio.c:14147
#define _mbg_swab_snmp_glb_info(_p)
Definition: gpsdefs.h:21392
#define MAX_XBP_CASC_LVL
Maximum XBP bus/controller cascading level.
Definition: gpsdefs.h:17853
int mbgextio_set_ims_fdm_output_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_IMS_FDM_OUTPUT_SETTINGS *p, uint16_t idx)
Write a MBG_IMS_FDM_OUTPUT_SETTINGS parameter structure to a device.
Definition: mbgextio.c:13437
Network host or domain name.
Definition: gpsdefs.h:11986
A geographic position represented in different formats.
Definition: mbggeo.h:113
Definition: myutil.h:117
A buffer used to read raw IRIG data bits from an IRIG receiver.
Definition: gpsdefs.h:5423
(r–) MBG_USER_STATUS_IDX, index 0 .. MBG_USER_MNGMNT_SETTINGS::num_users, only supp. if MBG_XFEATURE_USER_MNGMNT
Definition: gpsserio.h:964
int mbgextio_get_ptp_v1_default_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_PTP_V1_DEFAULT_DATASET *p)
Read the PTPv1 default dataset in MBG_PTP_V1_DEFAULT_DATASET format.
Definition: mbgextio.c:9380
#define _mbg_swab_ant_cable_len(_p)
Definition: gpsdefs.h:11014
uint32_t DWORD
Definition: mbgerror.h:222
unsigned char payload[240]
Payload data.
Definition: gpsdefs.h:23606
MBG_IO_PORT_SETTINGS settings
Definition: gpsdefs.h:20741
int mbgextio_set_active_fw(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, uint16_t idx)
Activate the firmware with the given index.
Definition: mbgextio.c:10973
PTPv1 default dataset containing global information about the device.
Definition: gpsdefs.h:14581
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_ant_info
Definition: mbgextio.c:3379
(r–) XMR_HOLDOVER_STATUS, only if XMRIF_MSK_HOLDOVER_STATUS_SUPP, deprecates GPS_XMR_HOLDOVER_ELAPSE...
Definition: gpsserio.h:876
#define _mbg_mutex_init(_pm, _n)
Definition: mbgmutex.h:182
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_gnss_mode
Check if a device supports GNSS mode feature All GNSS receivers support this feature by default...
Definition: xdevfeat.c:1591
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_cmd_save_cfg
Check if a device supports the GPS_SAVE_CFG command.
Definition: xdevfeat.c:1317
#define GPS_HAS_XFEATURE
see GPS_FEAT_XFEATURE
Definition: gpsdefs.h:2308
MBG_GPIO_SETTINGS settings
current settings
Definition: gpsdefs.h:9187
#define _mbg_swab_port_settings_idx(_p)
Definition: gpsdefs.h:3601
int mbgextio_set_net_intf_link_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_NET_INTF_LINK_SETTINGS *p, uint16_t idx)
Send the network link configuration in MBG_NET_INTF_LINK_SETTINGS format.
Definition: mbgextio.c:12409
int MBG_LAN_DEV_CFG
Definition: mbgextio.h:554
(rw-) IRIG_SETTINGS, only if GPS_HAS_IRIG_TX
Definition: gpsserio.h:813
(rw-) reserved for public key LAN interface
Definition: gpsserio.h:1011
#define _mbg_swab_mbg_ims_sensor_state_idx(_p)
Definition: gpsdefs.h:9870
int mbgextio_get_net_stat_intf_route_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_NET_INTF_ROUTE_INFO_IDX *p, uint16_t idx)
Read MBG_NET_INTF_ROUTE_INFO_IDX from the status with the given index.
Definition: mbgextio.c:12705
(r–) XBP_NODE_LIMITS, only if XBP_FEAT_MASK_NODES is set in XBP_LIMITS::features ...
Definition: gpsserio.h:878
#define MBG_ERR_BUSY
Device or resource busy, can&#39;t be used.
Definition: mbgerror.h:338
int MBG_TIME_MON_TARGET_STATUS_IDX
Definition: gpsserio.h:679
Server settings of an NTP device.
Definition: gpsdefs.h:16413
const char * mbg_framing_strs[N_MBG_FRAMINGS]
int SSH_DATA
Definition: gpsserio.h:594
uint16_t idx
the priority level index (highest == 0), 0..XMULTI_REF_INSTANCES::n_xmr_settings-1 ...
Definition: gpsdefs.h:6887
(rw-) IONO, GPS ionospheric correction parameters
Definition: gpsserio.h:987
MBG_ASYNC_DATA_RESET_FNC * async_data_reset_fnc
See mbgextio_register_async_data_reset_callback.
Definition: gpsserio.h:1992
int mbgextio_get_ims_fdm_output_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IMS_FDM_OUTPUT_INFO_IDX *p, uint16_t idx)
Read a MBG_IMS_FDM_OUTPUT_INFO_IDX parameter structure from a device.
Definition: mbgextio.c:13305
(r–) STAT_INFO, satellite info, mode of operation, and DAC info, only if GPS_MODEL_HAS_STAT_INFO ...
Definition: gpsserio.h:806
(rw-) MBG_IMS_FDM_SETTINGS, only if MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in MBG_IMS_STATE::flags ...
Definition: gpsserio.h:885
see MSG_CTL_DEVICE_FLAG_LEGACY
Definition: mbgextio.c:761
XDEVFEAT_CHK_SUPP_FNC xdevfeat_supp_tlv_file_req
Check if a device supports a file request via TLV.
Definition: xdevfeat.c:1103
PZF correlation status info.
Definition: pcpsdefs.h:1562
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_is_legacy
Check if a device is a legacy device.
Definition: mbgextio.c:3335
int mbgextio_get_ptp_cfg_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, PTP_CFG_INFO *p)
Read the ptp configuration PTP_CFG_INFO format.
Definition: mbgextio.c:9185
(r–) IRIG_INFO, only if GPS_HAS_IRIG_TX
Definition: gpsserio.h:820
(r–) MBG_TIME_MON_TARGET_STATUS_IDX
Definition: gpsserio.h:1026
uint16_t idx
0..MBG_LED_LIMITS::num_leds-1
Definition: gpsdefs.h:18885
(rw-) MBG_OPT_SETTINGS, only if GPS_HAS_OPT_SETTINGS
Definition: gpsserio.h:834
#define _mbg_swab_tr_distance(_p)
Definition: pcpsdefs.h:1555
MBG_NACK_HANDLER_FNC * nack_handler_fnc
See mbgextio_register_nack_callback.
Definition: gpsserio.h:1989
MBG_USER_SETTINGS settings
settings, see MBG_USER_SETTINGS
Definition: gpsdefs.h:22856
XYZ xyz
Always WGS84 ECEF coordinates.
Definition: mbggeo.h:115
#define MBG_IO_PORT_INFO_IDX_MIN_SIZE
Definition: gpsdefs.h:20878
MBG_DATABASE_SETTINGS settings
Definition: gpsdefs.h:23494
int mbgextio_set_snmp_v3_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_SNMP_V3_SETTINGS *p, uint16_t idx)
Write SNMP v3 settings in MBG_SNMP_V3_SETTINGS format.
Definition: mbgextio.c:10444
#define MBG_ERR_INV_SOCK_FD
Invalid socket when tried to open network socket.
Definition: mbgerror.h:323
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_up_conv
Check if the device has an L1 frequency up converter.
Definition: mbgextio.c:3756
#define _mbg_swab_irig_settings(_p)
Definition: gpsdefs.h:5006
POUT_SETTINGS_IDX pout_settings_idx
Definition: gpsserio.h:1373
int mbgextio_set_ptp_v2_time_properties_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_PTP_V2_TIME_PROPERTIES_DATASET *p)
Send PTPv2 time properties dataset to a device in MBG_PTP_V2_TIME_PROPERTIES_DATASET format...
Definition: mbgextio.c:10001
An SV number plus the SV&#39;s almanac data.
Definition: gpsserio.h:1273
#define _mbg_swab_ptp_cfg_settings(_p)
Definition: gpsdefs.h:13311
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_tzcode
Check if a device supports the TZCODE API.
Definition: xdevfeat.c:636
MBG_SNMP_V3_SETTINGS settings
Definition: gpsdefs.h:21640
#define _mbg_swab_xbp_node_limits(_p)
Definition: gpsdefs.h:17935
#define _mbg_swab_ntp_trusted_key_settings_idx(_p)
Definition: gpsdefs.h:16016
static const char force_conn_cmd_str[]
Definition: mbgextio.c:734
#define _setup_default_receiver_info_gps(_p)
Initialize a RECEIVER_INFO structure for legacy GPS receivers.
Definition: gpsdefs.h:1996
RECEIVER_INFO receiver_info
Receiver info provided by the device.
Definition: xdevfeat.h:91
#define _mbg_swab_net_intf_link_info_idx(_p)
Definition: gpsdefs.h:12151
#define _mbg_swab_ptp_uc_master_cfg_limits(_p)
Definition: gpsdefs.h:14246
int mbgextio_get_xmr_ext_source_stats_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XMR_STATS_IDX *p, uint16_t idx)
Read XMR_STATS_IDX for a specific XMR source.
Definition: mbgextio.c:8892
#define _mbg_swab_user_mngmnt_settings(_p)
Definition: gpsdefs.h:22740
(r–) PTP_SMPTE_PROFILE_CFG, only supp. if PTP_CFG_MSK_HAS_SMPTE_TLV_STATE is set in PTP_CFG_INFO::su...
Definition: gpsserio.h:965
Reference source configuration settings.
Definition: gpsdefs.h:6720
int mbgextio_get_net_stat_intf_addr_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_NET_INTF_ADDR_INFO_IDX *p, uint16_t idx)
Read MBG_NET_INTF_ADDR_INFO_IDX from the status with the given index.
Definition: mbgextio.c:12669
#define _mbg_swab_ptp_v2_parent_dataset(_p)
Definition: gpsdefs.h:14964
A buffer for a message header plus data part.
Definition: gpsserio.h:1710
int mbgextio_set_ptp_v2_parent_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_PTP_V2_PARENT_DATASET *p)
Send PTPv2 parent dataset to a device in MBG_PTP_V2_PARENT_DATASET format.
Definition: mbgextio.c:9928
int mbgextio_open_usb_ldev(libusb_device *ldev, MBG_MSG_CTL **ppmctl)
Open a binary communication channel using direct USB I/O.
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_supp_tlv_ufu
Check if a device supports a UFU (Unified Firmware Update) via TLV.
Definition: mbgextio.c:4252
(r–) MBG_NET_INTF_ROUTE_INFO_IDX, route status, only if MBG_NET_GLB_SUPP_STAGE_2_MASK is set in MBG_...
Definition: gpsserio.h:917
#define _mbg_swab_ntp_peer_settings_idx(_p)
Definition: gpsdefs.h:16400
int mbgextio_get_pos_xyz(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XYZ xyz)
Read the current receiver position as XYZ array.
Definition: mbgextio.c:6116
Received message was too long for the message receive buffer.
Definition: gpsserio.h:724
uint16_t SVNO
the number of an SV (Space Vehicle, i.e. satellite)
Definition: gpsdefs.h:696
#define _mbg_swab_mbg_led_info_idx(_p)
Definition: gpsdefs.h:18943
XDEVFEAT_CHK_SUPP_FNC xdevfeat_supp_tlv_ufu
Check if a device supports UFU (Unified Firmware Update) via TLV.
Definition: xdevfeat.c:1295
NTP_SYMM_KEY_SETTINGS_IDX ntp_symm_key_settings_idx
Definition: gpsserio.h:1514
uint16_t idx
0..MBG_NET_GLB_CFG_SETTINGS::num_intf_addr-1
Definition: gpsdefs.h:12206
#define _mbg_swab_syslog_settings_idx(_p)
Definition: gpsdefs.h:22211
#define _mbg_swab_svc_info_idx(_p)
Definition: gpsdefs.h:23131
#define _mbg_swab_xmr_metrics_idx(_p)
Definition: gpsdefs.h:7475
int mbgextio_get_ant_cable_len(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, ANT_CABLE_LEN *p)
Read the configured length of the antenna cable.
Definition: mbgextio.c:6987
Satellite receiver status information.
Definition: gpsdefs.h:10591
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_supp_tlv_file_req
Check if a device supports file request via TLV.
Definition: mbgextio.c:4066
(rw-) MBG_PWR_CTL, set or retrieve device power state, only if MBG_XFEATURE_PWR_CTL_API ...
Definition: gpsserio.h:896
(rw-) IP4_SETTINGS, only if GPS_HAS_LAN_IP4
Definition: gpsserio.h:998
void swap_double(double *p)
Swap the bytes of a single variable of type "double".
Definition: gpsutils.c:101
Waiting for a binary message, i.e. no START_OF_HEADER received, yet.
Definition: gpsserio.h:715
#define _mbg_swab_tzdl(_p)
Definition: gpsdefs.h:2950
(r–) CORR_INFO, correlation info, only if GPS_MODEL_IS_DCF_PZF
Definition: gpsserio.h:1018
#define _mbg_swab_ptp_v2_time_properties_dataset(_p)
Definition: gpsdefs.h:15018
int mbgextio_xmt_cmd(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd)
Transmit a command-only message without additional data.
Definition: mbgextio.c:5136
#define MBG_ERR_PERM
Operation not permitted, e.g. when trying to set the system time without sufficient permissions...
Definition: mbgerror.h:337
MBG_PTP_V1_TIME_PROPERTIES_DATASET ptp_v1_time_properties_dataset
Definition: gpsserio.h:1526
#define USB_DEV_MDU300
Definition: usbdefs.h:270
int mbgextio_open_serial_force_default(const char *dev, MBG_MSG_CTL **ppmctl, uint32_t baud_rate, const char *framing)
Open a binary communication channel forcing default serial parameters.
#define _mbg_swab_snmp_v3_trap_settings_idx(_p)
Definition: gpsdefs.h:21713
NTP_SYMM_KEY_SETTINGS settings
Definition: gpsdefs.h:15929
#define MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE
Definition: gpsdefs.h:21006
Software revision information.
Definition: gpsdefs.h:732
int xmt_cmd_u32(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd, uint32_t u32)
Send a binary command message with 32 bit parameter.
#define _mbg_mutex_acquire(_pm)
Definition: mbgmutex.h:184
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_push_msgs
Definition: mbgextio.c:3423
#define _mbg_swab_fw_info_idx(_p)
Definition: gpsdefs.h:23295
int mbgextio_get_svc_mgmt_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_SERVICE_MGMT_INFO *p)
Read service management info in MBG_SERVICE_MGMT_INFO format.
Definition: mbgextio.c:13997
A structure used to report XBP features and limits.
Definition: gpsdefs.h:17875
int mbgextio_get_bvar_stat(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, BVAR_STAT *p)
Read the status of buffered variables.
Definition: mbgextio.c:5939
#define _mbg_swab_mbg_ims_fdm_output_state_idx(_p)
Definition: gpsdefs.h:9994
Current settings and general capabilities of a specific serial port.
Definition: gpsdefs.h:3677
#define _mbg_swab_net_intf_route_settings_idx(_p)
Definition: gpsdefs.h:12310
int mbg_ftdi_ft_status_to_mbg(int status)
Translate a FTDI API status code to one of the MBG_ERROR_CODES.
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_monitoring
Check if a device supports the extended feature monitoring.
Definition: xdevfeat.c:1338
(rw-) deprecated, PORT_PARM, use PORT_SETTINGS etc. if GPS_RECEIVER_INFO supported ...
Definition: gpsserio.h:801
MBG_MSG_XMT_CTL xmt
Definition: gpsserio.h:1975
int mbgextio_set_svc_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_SERVICE_SETTINGS *p, uint16_t idx)
Write service settings in MBG_SERVICE_SETTINGS_IDX format.
Definition: mbgextio.c:14069
uint8_t bytes[(sizeof(MSG_DATA)+0)]
Data part as a number of bytes.
Definition: gpsserio.h:1716
(rw-) MBG_SERVICE_INFO_IDX / MBG_SERVICE_SETTINGS_IDX, index 0 .. MBG_SERVICE_MGMT_INFO::num_services...
Definition: gpsserio.h:967
NTP_PEER_SETTINGS peer_settings
Definition: gpsdefs.h:16396
int mbgextio_set_io_port_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_IO_PORT_SETTINGS *p, uint8_t idx)
Send I/O port settings in MBG_IO_PORT_SETTINGS format.
Definition: mbgextio.c:5476
#define _mbg_swab_svc_mgmt_info(_p)
Definition: gpsdefs.h:23023
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_ext_sys_info
Check if a device has MBG_XFEATURE_EXT_SYS_INFO.
Definition: mbgextio.c:4383
#define _mbg_swab_ntp_sys_state(_p)
Definition: gpsdefs.h:16921
void mbgextio_set_msg_rcv_timeout(MBG_MSG_CTL *pmctl, ulong new_timeout)
Set message receive timeout value.
Definition: mbgextio.c:3283
LLA lla
Longitude, latitude and altitude, depending on the ellipsoid used for reference.
Definition: mbggeo.h:116
int mbgextio_get_ptp_v1_port_dataset_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_PTP_V1_PORT_DATASET_IDX *p, uint16_t idx)
Read the PTPv1 port dataset with the appropriate index in MBG_PTP_V1_PORT_DATASET_IDX format...
Definition: mbgextio.c:9673
NTP_REFCLK_CFG_SETTINGS_IDX ntp_refclk_cfg_settings_idx
Definition: gpsserio.h:1518
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_ptp
Check if a device supports the PTP API.
Definition: mbgextio.c:3886
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_led_api
Check if a device supports the LED API.
Definition: mbgextio.c:4317
int mbgextio_time_mon_get_inst_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_TIME_MON_INST_INFO *p)
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_tzcode
Definition: mbgextio.c:3633
int libusb_device
Definition: mbgextio.h:451
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_synth
Definition: xdevfeat.c:413
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_ntp
Check if a device supports the NTP API.
Definition: xdevfeat.c:969
(r–) MBG_IMS_STATE, only if GPS_HAS_IMS
Definition: gpsserio.h:849
#define _mbg_swab_mbg_lne_limits(_p)
Definition: gpsdefs.h:18985
#define _mbg_swab_snmp_v3_info_idx(_p)
Definition: gpsdefs.h:21675
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_is_gps
Check if a device can receive the GPS satellite system.
Definition: mbgextio.c:3477
#define MBG_ERR_DISCONN
connection closed by remote site / host
Definition: mbgerror.h:345
uint16_t idx
0..RECEIVER_INFO::n_prg_out-1
Definition: gpsdefs.h:6251
double LLA[N_LLA]
A geographic position based on latitude, longitude, and altitude.
Definition: gpsdefs.h:2764
int mbgextio_get_gnss_sat_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GNSS_SAT_INFO *p)
::TODO
Definition: mbgextio.c:8446
#define MBG_DEFAULT_BAUDRATE_HS
The high speed baud rate used for the binary protocol.
Definition: gpsdefs.h:3427
(rw-) TZDL, time zone / daylight saving, only if GPS_MODEL_HAS_TZDL
Definition: gpsserio.h:800
union MBG_MSG_BUFF::@7 u
#define _mbg_swab_ucap_net_glb_info(_p)
Definition: gpsdefs.h:12507
#define _mbg_swab_utc_parm(_p)
Definition: gpsdefs.h:18580
A structure combining all device feature information.
Definition: xdevfeat.h:88
int mbgextio_get_net_stat_dns_srch_dom_stat_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_NET_NAME_IDX *p, uint16_t idx)
Read the current network DNS search domain in MBG_NET_NAME_IDX format.
Definition: mbgextio.c:12340
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_req_ttm
Check if a device has MBG_XFEATURE_REQ_TTM.
Definition: xdevfeat.c:1502
int mbgextio_get_user_mngmnt_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_USER_MNGMNT_INFO *p)
Read the user management info in MBG_USER_MNGMNT_INFO format.
Definition: mbgextio.c:6634
XDEVFEAT_CHK_SUPP_FNC xdevfeat_is_tcr
Check if a device is a time code receiver (IRIG or similar)
Definition: xdevfeat.c:235
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_scu_stat
Check if the device supports the SCU_STAT structures.
Definition: mbgextio.c:3780
#define _mbg_swab_xmr_holdover_intv(_p)
Definition: gpsdefs.h:7118
int mbgextio_get_ptp_v2_current_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_PTP_V2_CURRENT_DATASET *p)
Read the PTPv2 current dataset in MBG_PTP_V2_CURRENT_DATASET format.
Definition: mbgextio.c:9821
int16_t i16
Definition: gpsserio.h:1350
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_lan_ip4
Check if a device supports the old LAN_IP4 API.
Definition: mbgextio.c:3830
XDEVFEAT_CHK_SUPP_FNC xdevfeat_supp_tlv_diag_file
Check if a device supports creating / sending a diagnostics file via TLV.
Definition: xdevfeat.c:1191
Configuration settings of an IRIG input or output.
Definition: gpsdefs.h:4999
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_supp_tlv_fw_rollback
Check if a device supports a factory reset via TLV.
Definition: mbgextio.c:4110
int mbgextio_set_ptp_uc_master_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const PTP_UC_MASTER_SETTINGS *p, uint16_t idx)
Send PTP unicast master configuration settings for a PTP unicast slave mode device.
Definition: mbgextio.c:9340
int mbgextio_open_serial_raw(const char *dev, MBG_MSG_CTL **ppmctl, uint32_t baud_rate, const char *framing)
Network interface route specific settings.
Definition: gpsdefs.h:12264
#define _MBG_API
Definition: mbg_tgt.h:1020
General info to be read from an LNE device.
Definition: gpsdefs.h:18974
#define _mbg_swab_event_value_idx(_p, _type)
Definition: gpsdefs.h:22050
int mbgextio_get_sw_rev(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, SW_REV *p)
Read the software revision.
Definition: mbgextio.c:5845
uint8_t n_prg_out
number of programmable pulse outputs
Definition: gpsdefs.h:889
(r–) GNSS_SAT_INFO, GLONASS-only satellite info (deprecated by GPS_GNSS_SAT_INFO_IDX) ...
Definition: gpsserio.h:992
(rw-) UTC, GPS UTC correction parameters
Definition: gpsserio.h:986
(rw-) LLA, current position in geographic coordinates, only if GPS_MODEL_HAS_POS_LLA ...
Definition: gpsserio.h:799
(r–) first/oldest MBG_EVT_LOG_ENTRY, only if GPS_HAS_EVT_LOG
Definition: gpsserio.h:846
Query MBG_NET_INTF_ADDR_INFO by its index.
Definition: gpsdefs.h:12244
(r–) NTP_SYS_STATE
Definition: gpsserio.h:864
int mbgextio_get_ucap(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, TTM *p)
Read a user capture event in TTM format.
Definition: mbgextio.c:6428
#define MBG_ERR_NOT_SUPP_BY_DEV
Command or feature not supported by device.
Definition: mbgerror.h:286
Current settings and general capabilities of an LED, plus index.
Definition: gpsdefs.h:18936
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_tlv_api
Check if a device supports the TLV API.
Definition: xdevfeat.c:1081
int mbgextio_xmt_cmd_u32(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd, uint32_t u32)
Transmit a message with a single ushort (uint32_t) parameter.
Definition: mbgextio.c:5235
int mbgextio_set_ip4_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const IP4_SETTINGS *p)
Save the current ipv4 settings IP4_SETTINGS format.
Definition: mbgextio.c:9083
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_transactions
Check if a device has MBG_XFEATURE_TRANSACTIONS.
Definition: xdevfeat.c:1459
MBG_DATABASE_CMD db_cmd
Definition: gpsserio.h:1558
int mbgextio_get_xmr_instances(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XMULTI_REF_INSTANCES *p)
TODO
Definition: mbgextio.c:8647
int mbgextio_get_clk_res_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_CLK_RES_INFO *p)
Read clk_res_info from device.
Definition: mbgextio.c:5657
int mbgextio_get_net_intf_addr_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_NET_INTF_ADDR_INFO_IDX *p, uint16_t idx)
Read MBG_NET_INTF_ADDR_INFO_IDX from the config with the given index.
Definition: mbgextio.c:12451
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_ucap_net
Definition: mbgextio.c:3966
Configuration settings for a single LNE port, plus index.
Definition: gpsdefs.h:19061
#define MBG_ERR_OVERFLOW
range or buffer overflow
Definition: mbgerror.h:333
The header checksum of a received message is invalid.
Definition: gpsserio.h:717
Configuration settings for a single LED, plus index.
Definition: gpsdefs.h:18883
(rw-) NTP_TRUSTED_KEY_INFO_IDX / NTP_TRUSTED_KEY_SETTINGS_IDX, only if NTP_GLB_INFO::max_trusted_keys...
Definition: gpsserio.h:949
char model_name[(16+1)]
ASCIIZ, name of receiver model.
Definition: gpsdefs.h:877
#define _mbg_swab_xmulti_ref_settings_idx(_p)
Definition: gpsdefs.h:6756
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_time_scale
Definition: mbgextio.c:3613
MBG_GNSS_MODE_SETTINGS gnss_mode_settings
Definition: gpsserio.h:1396
int mbg_get_last_socket_error(const char *info)
Get and translate last error after socket function call.
Definition: mbgerror.c:1038
BAUD_RATE mbg_baud_rates[N_MBG_BAUD_RATES]
#define MBG_ERR_XBP_CASC_LVL
too many XBP cascading levels
Definition: mbgerror.h:341
int mbgextio_get_ntp_peer_state_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_PEER_STATE_IDX *p, uint16_t idx)
Read the NTP peer state of current idx NTP_PEER_STATE format.
Definition: mbgextio.c:12016
int mbgextio_set_ptp_v2_port_dataset_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_PTP_V2_PORT_DATASET *p, uint16_t idx)
Send PTPv2 port dataset with the appropriate index to a device in MBG_PTP_V2_PORT_DATASET format...
Definition: mbgextio.c:10076
#define _mbg_swab_mbg_ref_offs(_p)
Definition: gpsdefs.h:5299
int conn_type
One of the MBG_CONN_TYPES.
Definition: gpsserio.h:1981
#define _mbg_swab_ntp_misc_orphan_mode_settings(_p)
Definition: gpsdefs.h:16178
#define mbg_rc_is_error(_rc)
Definition: mbgerror.h:617
int mbgextio_set_snmp_v12_trap_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_SNMP_V12_TRAP_SETTINGS *p, uint16_t idx)
Write SNMP v1 or v2 trap settings in MBG_SNMP_V12_TRAP_SETTINGS format.
Definition: mbgextio.c:10366
int mbgextio_get_next_evt_log_entry(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_EVT_LOG_ENTRY *p)
Return the next entry from the on-board event log.
Definition: mbgextio.c:7993
int mbgextio_get_tzdl(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, TZDL *p)
Read the local time conversion parameters in TZDL format.
Definition: mbgextio.c:6191
int mbgextio_get_ant_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, ANT_INFO *p)
Read the GPS antenna info structure.
Definition: mbgextio.c:6402
MBG_LED_SETTINGS settings
LED settings.
Definition: gpsdefs.h:18886
An XBP address specifier.
Definition: gpsdefs.h:17861
int mbgextio_socket_write_default(MBG_MSG_CTL *pmctl, const void *buf, size_t len)
Function, which can be used to write data to a standard LAN socket.
int mbgserio_close(MBGSERIO_DEV **pp_mdev)
Close a serial port specified by a MBGSERIO_DEV structure.
#define _mbg_swab_sw_rev(_p)
Definition: gpsdefs.h:740
#define _mbg_swab_user_settings_idx(_p)
Definition: gpsdefs.h:22861
uint16_t idx
the priority level index (highest == 0), 0..XMULTI_REF_INSTANCES::n_xmr_settings-1 ...
Definition: gpsdefs.h:7405
(r–) MBG_IO_PORT_INFO_IDX, only supp. if MBG_XFEATURE_IO_PORTS is set in extended features and from ...
Definition: gpsserio.h:922
Specific output settings and limits, plus index.
Definition: gpsdefs.h:10066
#define USB_DEV_SCU_USB
Definition: usbdefs.h:231
#define _mbg_swab_fw_ufu_flash_cmd(_p)
Definition: gpsdefs.h:23388
int mbgextio_get_xmulti_ref_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, XMULTI_REF_INFO_IDX *p)
Read the multi ref info from a device.
Definition: mbgextio.c:8149
const char * mbg_strerror(int mbg_errno)
Return an error string associated with the MBG_ERROR_CODES.
Definition: mbgerror.c:685
FDM device settings.
Definition: gpsdefs.h:10262
int mbgextio_get_debug_status(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_DEBUG_STATUS *p)
Read current debug status.
Definition: mbgextio.c:7315
#define _mbg_swab_ntp_refclk_cfg_settings_idx(_p)
Definition: gpsdefs.h:15731
#define _mbg_swab_ptp_v1_default_dataset(_p)
Definition: gpsdefs.h:14594
(rw-) MBG_NET_INTF_ROUTE_INFO_IDX/MBG_NET_INTF_ROUTE_SETTINGS_IDX, only if MBG_NET_GLB_SUPP_STAGE_2_M...
Definition: gpsserio.h:913
A binary message has been received successfully.
Definition: gpsserio.h:713
#define MBGEXTIO_POLL_TIMEOUT_USB
Definition: mbgextio.c:729
int mbgextio_get_irig_rx_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, IRIG_INFO *p)
Read configuration info and supported features for the device&#39;s IRIG input.
Definition: mbgextio.c:7133
MBG_PTP_V2_TIME_PROPERTIES_DATASET ptp_v2_time_properties_dataset
Definition: gpsserio.h:1501
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_xmulti_ref
Check if a device supports the extended multi ref features including multi instances.
Definition: xdevfeat.c:1527
int mbgextio_get_all_pout_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, POUT_INFO_IDX *pii)
Read an array of current settings and capabilities of all programmable pulse outputs.
Definition: mbgextio.c:7664
int mbgextio_set_net_intf_addr_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_NET_INTF_ADDR_SETTINGS *p, uint16_t idx)
Send the network addr configuration in MBG_NET_INTF_ADDR_SETTINGS format.
Definition: mbgextio.c:12484
(r–) MULTI_REF_INFO, only if GPS_HAS_MULTI_REF
Definition: gpsserio.h:822
#define _mbg_swab_snmp_v12_trap_settings_idx(_p)
Definition: gpsdefs.h:21512
Antenna status and error at reconnect information.
Definition: gpsdefs.h:3100
#define _mbg_swab_ntp_clnt_mode_settings(_p)
Definition: gpsdefs.h:16245
MBG_FW_UFU_FLASH_CMD fw_ufu_flash_cmd
Definition: gpsserio.h:1553
(rw-) MBG_PTP_V1_PORT_DATASET_IDX, only supp. if PTP_CFG_MSK_HAS_V1_COMMON_DATASETS is set in PTP_CFG...
Definition: gpsserio.h:954
SW_REV sw_rev
software revision and ID
Definition: gpsdefs.h:876
RECEIVER_INFO * mbgextio_get_receiver_info_addr(MBG_MSG_CTL *pmctl)
Retrieve address of the RECEIVER_INFO read from the device.
Definition: mbgextio.c:3128
#define _mbg_swab_net_intf_link_settings_idx(_p)
Definition: gpsdefs.h:12094
#define _mbg_swab_ptp_v2_port_dataset_idx(_p)
Definition: gpsdefs.h:15081
uint16_t port_type
MBG_IO_PORT_TYPES
Definition: gpsdefs.h:20691
#define _mbg_swab_ptp_cfg_info(_p)
Definition: gpsdefs.h:13364
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_tainted_cfg
Definition: mbgextio.c:3412
MBG_PTP_V1_PARENT_DATASET ptp_v1_parent_dataset
Definition: gpsserio.h:1525
int mbgextio_get_io_port_limits(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IO_PORT_LIMITS *p)
Read I/O port limits in MBG_IO_PORT_LIMITS format.
Definition: mbgextio.c:5439
#define _mbg_swab_mbg_time_scale_info(_p)
Definition: gpsdefs.h:5527
#define _mbg_swab_ip_addr_idx(_p)
Definition: gpsdefs.h:11952
#define USB_VENDOR_MEINBERG
Definition: usbdefs.h:131
#define _mbg_swab_database_glb_info(_p)
Definition: gpsdefs.h:23436
MBG_IO_PORT_TYPE_INFO_IDX iop_type_info_idx
Definition: gpsserio.h:1481
int mbgextio_get_net_intf_link_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_NET_INTF_LINK_INFO_IDX *p, uint16_t idx)
Read MBG_NET_INTF_LINK_INFO_IDX from the config with the given index.
Definition: mbgextio.c:12376
#define _mbg_swab16(_p)
Definition: mbg_arch.h:173
int mbgserio_set_parms(MBGSERIO_DEV *mdev, uint32_t baud_rate, const char *framing)
const char * mbgextio_get_cmd_name(GPS_CMD cmd_code)
Definition: mbgextio.c:768
int mbgextio_get_ptp_v2_port_dataset_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_PTP_V2_PORT_DATASET_IDX *p, uint16_t idx)
Read the PTPv2 port dataset with the appropriate index in MBG_PTP_V2_PORT_DATASET_IDX format...
Definition: mbgextio.c:10041
#define _mbg_swab_net_name_idx(_p)
Definition: gpsdefs.h:12010
to device: request acknowledge
Definition: gpsserio.h:740
(r–) MBG_IMS_FDM_STATE, only if MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in MBG_IMS_STATE::flags ...
Definition: gpsserio.h:884
#define _mbg_swab_monitoring_limits(_p)
Definition: gpsdefs.h:21289
#define _mbg_swab_net_intf_addr_info_idx(_p)
Definition: gpsdefs.h:12251
(rw-) MBG_NET_GLB_CFG_INFO/MBG_NET_GLB_CFG_SETTINGS, only if GPS_HAS_NET_CFG
Definition: gpsserio.h:868
int MBG_LAN_DEV_LIST
Definition: mbgextio.h:555
#define MBG_ERR_NOT_SUPP_ON_OS
Function is not supported on this operating system.
Definition: mbgerror.h:289
the number of known framings
Definition: gpsdefs.h:3346
MBG_MSG_BUFF * mbgextio_get_xmt_buffer_addr(MBG_MSG_CTL *pmctl)
Retrieve address of the allocated transmit buffer.
Definition: mbgextio.c:3197
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_gnss_mode
Check if a device supports GNSS mode feature All GNSS receivers support this feature by default...
Definition: mbgextio.c:4538
XMR_HOLDOVER_INTV xmr_holdover_intv
Definition: gpsserio.h:1406
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_push_msgs
Check if a device supports (un)registering for push messages.
Definition: xdevfeat.c:1633
IGNORE_LOCK ignore_lock
Definition: gpsserio.h:1380
#define _mbg_swab_mbg_lne_port_info_idx(_p)
Definition: gpsdefs.h:19123
int mbgextio_get_event_value_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, uint16_t eidx, uint8_t vtype, MBG_EVENT_VALUE_IDX *p, uint16_t vidx)
Read monitoring event status in MBG_EVENT_STATUS_IDX format.
Definition: mbgextio.c:10691
Server settings info of an NTP device.
Definition: gpsdefs.h:16437
char c[16]
Definition: gpsdefs.h:10991
XBP_ADDR xbp_addr
XBP address of the transmitter or receiver.
Definition: gpsserio.h:1645
General NTP symmetric key limits to be read from a device.
Definition: gpsdefs.h:15859
(rw-) MBG_PTP_V2_DEFAULT_DATASET, only supp. if PTP_CFG_MSK_HAS_V2_COMMON_DATASETS is set in PTP_CFG_...
Definition: gpsserio.h:936
#define _mbg_swab_receiver_info(_p)
Definition: gpsdefs.h:894
int mbgextio_set_ptp_v1_parent_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_PTP_V1_PARENT_DATASET *p)
Send PTPv1 parent dataset to a device in MBG_PTP_V1_PARENT_DATASET format.
Definition: mbgextio.c:9560
(-w-) Transmit UFU flash instructions MBG_FW_UFU_FLASH_CMD
Definition: gpsserio.h:977
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_reboot
Check if a device has MBG_XFEATURE_REBOOT.
Definition: mbgextio.c:4427
MBG_SNMP_V3_TRAP_SETTINGS settings
Definition: gpsdefs.h:21709
#define _mbg_swab_net_intf_route_info_idx(_p)
Definition: gpsdefs.h:12351
(rw-) MBG_NET_INTF_LINK_INFO_IDX/MBG_NET_INTF_LINK_SETTINGS_IDX, only if MBG_NET_GLB_SUPP_STAGE_2_MAS...
Definition: gpsserio.h:911
MBG_SNMP_GLB_SETTINGS snmp_glb_settings
Definition: gpsserio.h:1485
ENABLE_FLAGS enable_flags
Definition: gpsserio.h:1364
Current settings and general capabilities of an LNE port, plus index.
Definition: gpsdefs.h:19116
#define _mbg_swab_ptp_uc_master_settings_idx(_p)
Definition: gpsdefs.h:14336
#define MBG_ERR_AUTH
Binary protocol failed authentication.
Definition: mbgerror.h:320
(rw-) MBG_LNE_PORT_SETTINGS_IDX, settings of a specific LED, only if MBG_XFEATURE_LNE_API ...
Definition: gpsserio.h:895
int mbgextio_get_ntp_misc_limits(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_MISC_LIMITS *p)
Read the NTP misc limits in NTP_MISC_LIMITS format.
Definition: mbgextio.c:11564
MBG_REF_OFFS ref_offs
Definition: gpsserio.h:1383
static void handle_xbp_node(XBP_NODE_INFO *p_ni, long idx)
Definition: mbgextio.c:12812
#define MBG_ERR_NBYTES
match the number of bytes expected by the device.
Definition: mbgerror.h:272
unsigned long ulong
Definition: words.h:292
int MBG_TIME_MON_INST_INFO
Definition: gpsserio.h:674
int mbgextio_chk_user_perm(MBG_MSG_CTL *pmctl, uint16_t perm, uint32_t scope_mask)
Check user permission for one of the given scopes.
Definition: mbgextio.c:13948
int mbgextio_get_database_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_DATABASE_INFO_IDX *p, uint8_t idx)
Read a database info with given index in MBG_DATABASE_INFO_IDX format.
Definition: mbgextio.c:11159
#define _mbg_swab_ntp_misc_orphan_mode_info(_p)
Definition: gpsdefs.h:16199
(r–) PTP_STATE, current PTP status, only if GPS_HAS_PTP
Definition: gpsserio.h:857
int mbgextio_get_utc_parm(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, UTC *p)
Read a UTC parameter structure from a device.
Definition: mbgextio.c:12992
(rw-) MBG_IMS_FDM_OUTPUT_SETTINGS_IDX, only if MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in MBG_IMS_STATE...
Definition: gpsserio.h:881
A structure used to identify a device type and supported features.
Definition: gpsdefs.h:873
int MBG_USB_DEV_INFO
Definition: mbgextio.h:450
#define _mbg_swab_io_port_type_info_idx(_p, _recv)
Definition: gpsdefs.h:21054
int mbgextio_get_ptp_v2_time_properties_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_PTP_V2_TIME_PROPERTIES_DATASET *p)
Read the PTPv2 time properties dataset in MBG_PTP_V2_TIME_PROPERTIES_DATASET format.
Definition: mbgextio.c:9967
Global configuration settings of an NTP device (client/server)
Definition: gpsdefs.h:15220
int mbgextio_get_io_port_status_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IO_PORT_STATUS_IDX *p, uint8_t idx)
Read I/O port status in MBG_IO_PORT_STATUS_IDX format.
Definition: mbgextio.c:5626
#define _mbg_swab_syslog_glb_info(_p)
Definition: gpsdefs.h:22176
PTPv2 current dataset.
Definition: gpsdefs.h:14901
connection via network socket
Definition: gpsserio.h:2053
int mbgextio_set_ptp_v1_time_properties_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_PTP_V1_TIME_PROPERTIES_DATASET *p)
Send PTPv1 time properties dataset to a device in MBG_PTP_V1_TIME_PROPERTIES_DATASET format...
Definition: mbgextio.c:9633
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_irig_rx
Definition: mbgextio.c:3698
int mbgextio_get_snmp_v3_trap_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_SNMP_V3_TRAP_INFO_IDX *p, uint16_t idx)
Read SNMP v3 trap info in MBG_SNMP_V3_TRAP_INFO_IDX format.
Definition: mbgextio.c:10486
#define _mbg_swab_mbg_raw_irig_data(_p)
Definition: gpsdefs.h:5429
uint16_t TZCODE
Type of variable to hold a TZ code.
Definition: gpsserio.h:1302
int mbgextio_get_io_port_type_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IO_PORT_TYPE_INFO_IDX *p, uint8_t port_idx, uint8_t port_type_idx)
Read I/O port type info in MBG_IO_PORT_TYPE_INFO_IDX format.
Definition: mbgextio.c:5574
NTP trusted key settings, with index.
Definition: gpsdefs.h:16009
from device: error evaluating a command
Definition: gpsserio.h:742
(r–) MBG_OPT_INFO, only if GPS_HAS_OPT_SETTINGS
Definition: gpsserio.h:835
MBG_SNMP_V12_TRAP_SETTINGS settings
Definition: gpsdefs.h:21508
int mbgextio_get_enable_flags(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, ENABLE_FLAGS *p)
Read the enable flags controlling when output signals are enabled.
Definition: mbgextio.c:6881
int mbgextio_get_lne_port_info_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_LNE_PORT_INFO_IDX *p, uint16_t idx)
Read a MBG_LNE_PORT_INFO_IDX parameter structure from a device.
Definition: mbgextio.c:13563
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_enable_flags
Definition: mbgextio.c:3603
#define MBG_ERR_DEV_NOT_SUPP
Device type not supported by driver.
Definition: mbgerror.h:284
(r–) XMR_EXT_SRC_INFO_IDX, only if XMRIF_MSK_EXT_SRC_INFO_SUPP
Definition: gpsserio.h:887
Output state of FDM device plus index.
Definition: gpsdefs.h:9987
Global current network settings and supported features.
Definition: gpsdefs.h:11869
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_ant_cable_length
Definition: mbgextio.c:3390
Network interface address specific settings, flags and supported features.
Definition: gpsdefs.h:12164
(rw-) SYNTH, synthesizer settings, only if GPS_HAS_SYNTH
Definition: gpsserio.h:802
General NTP misc limits to be read from a device.
Definition: gpsdefs.h:16101
int mbg_get_last_error(const char *info)
Get and translate last error after non-socket function call.
Definition: mbgerror.c:993
uint32_t MBG_DEBUG_STATUS
A data type used to read the board&#39;s debug status.
Definition: gpsdefs.h:5204
#define _mbg_swab_debug_status(_p)
Definition: gpsdefs.h:5206
(r–) MBG_NET_NAME_IDX, DNS status, only if MBG_NET_GLB_CFG_INFO::n_supp_dns_srch_dom > 0 ...
Definition: gpsserio.h:872
#define _mbg_swab_ntp_symm_key_info_idx(_p)
Definition: gpsdefs.h:15976
int mbgextio_setup_xbp_node_list(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr)
Read the XBP_NODE_INFO for a specific node in XBP_NODE_INFO_IDX format //##+++++++++++++++++++++++++...
Definition: mbgextio.c:12840
int mbgextio_get_ims_fdm_limits(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_IMS_FDM_LIMITS *p)
Read a MBG_IMS_FDM_LIMITS parameter structure from a device.
Definition: mbgextio.c:13273
(r–) MBG_EVENT_VALUE_IDX, only supp. if MBG_EVENT_INFO::value_dict_entries > 0
Definition: gpsserio.h:956
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_io_ports
Definition: xdevfeat.c:1437
NTP symmetric key settings, with index.
Definition: gpsdefs.h:15926
Simple LAN interface information.
Definition: gpsdefs.h:11274
MBG_PTP_V1_DEFAULT_DATASET ptp_v1_default_dataset
Definition: gpsserio.h:1523
(r–) IP4_SETTINGS, only if GPS_HAS_LAN_IP4
Definition: gpsserio.h:1000
int mbgextio_get_ptp_v2_default_dataset(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_PTP_V2_DEFAULT_DATASET *p)
Read the PTPv2 default dataset in MBG_PTP_V2_DEFAULT_DATASET format.
Definition: mbgextio.c:9748
int mbgextio_set_user_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_USER_SETTINGS *p, uint16_t idx)
Write user settings in MBG_USER_SETTINGS_IDX format.
Definition: mbgextio.c:6738
uint16_t idx
0..MBG_LNE_LIMITS::num_ports-1
Definition: gpsdefs.h:19063
MBGEXTIO_CHK_SUPP_FNC mbgextio_dev_has_gpio
Definition: mbgextio.c:3665
(rw-) MBG_USER_MNGMNT_INFO / MBG_USER_MNGMNT_SETTINGS, only supp. if MBG_XFEATURE_USER_MNGMNT ...
Definition: gpsserio.h:961
XBP_ADDR addr
The address of the specific node.
Definition: gpsdefs.h:18008
#define OPT_GPS_ACK_CODE
Definition: mbgextio.h:464
int mbgextio_get_ntp_clnt_mode_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, NTP_CLNT_MODE_INFO *p)
Read the ntp global information NTP_CLNT_MODE_INFO format.
Definition: mbgextio.c:11676
uint16_t idx
the priority level index (highest == 0), 0..XMULTI_REF_INSTANCES::n_xmr_settings-1 ...
Definition: gpsdefs.h:6841
XDEVFEAT_CHK_SUPP_FNC xdevfeat_has_ext_sys_info
Check if a device supports the MBG_EXT_SYS_INFO command.
Definition: xdevfeat.c:1426
int mbgextio_set_lne_port_settings_idx(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_LNE_PORT_SETTINGS *p, uint16_t idx)
Write a MBG_LNE_PORT_SETTINGS parameter structure to a device.
Definition: mbgextio.c:13615
#define _mbg_swab_syslog_glb_settings(_p)
Definition: gpsdefs.h:22157
int mbgextio_get_all_str_type_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, STR_TYPE_INFO_IDX stii[])
Read an array of all supported string types.
Definition: mbgextio.c:7450
int mbgextio_set_time(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const TTM *p)
Set the device&#39;s time by sending a TTM strucure.
Definition: mbgextio.c:6002
(r–) MBG_NET_GLB_CFG_INFO, network status, only if MBG_NET_GLB_SUPP_STAGE_2_MASK is set in MBG_NET_G...
Definition: gpsserio.h:914
ulong mbgextio_get_dev_poll_timeout(const MBG_MSG_CTL *pmctl)
Get device poll timeout.
Definition: mbgextio.c:3264
TZDL tzdl
Definition: gpsserio.h:1359
#define MBG_FORCE_CONN_HS_CMD_STR
switch to MBG_DEFAULT_BAUDRATE_HS
Definition: gpsdefs.h:3440
A structure controlling when output signals are enabled.
Definition: gpsdefs.h:3142
Current settings and general capabilities of a specific programmable pulse output.
Definition: gpsdefs.h:6351
int mbgextio_get_snmp_glb_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, MBG_SNMP_GLB_INFO *p)
Read the SNMP global info in MBG_SNMP_GLB_INFO format.
Definition: mbgextio.c:10177
XDEVFEAT_CHK_SUPP_FNC xdevfeat_is_dcf
Check if a device is a DCF77 AM receiver.
Definition: xdevfeat.c:259
#define _mbg_swab_scu_stat_settings(_p)
Definition: gpsdefs.h:10478
int mbgextio_set_hq_rx_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const HAVEQUICK_SETTINGS *p)
Send new configuration settings for the device&#39;s HAVEQUICK input.
Definition: mbgextio.c:8279
(rw-) TR_DISTANCE, dist. from transmitter [km], only if GPS_MODEL_IS_DCF_PZF
Definition: gpsserio.h:1016
#define _mbg_swab_io_port_info_idx(_p, _recv)
Definition: gpsdefs.h:20869
#define _mbg_swab_port_info_idx(_p)
Definition: gpsdefs.h:3684
#define USB_DEV_SDI_01
Definition: usbdefs.h:265
MBG_MSG_RCV_CTL rcv
Definition: gpsserio.h:1974
Configuration settings for a single LED.
Definition: gpsdefs.h:18859
int mbgextio_set_snmp_glb_settings(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, const MBG_SNMP_GLB_SETTINGS *p)
Send the SNMP global settings in MBG_SNMP_GLB_SETTINGS format.
Definition: mbgextio.c:10211
Output settings of FDM device.
Definition: gpsdefs.h:10008
uint16_t idx
Index of the port dataset, 0..MBG_PTP_V2_DEFAULT_DATASET::number_ports - 1.
Definition: gpsdefs.h:15075
uint32_t supp_gnss_types
Bit masks of supported GNSS types, see MBG_GNSS_TYPE_MASKS.
Definition: gpsdefs.h:10697
UTC utc
Definition: gpsserio.h:1565
#define _mbg_swab_mbg_ims_fdm_limits(_p)
Definition: gpsdefs.h:10132
long mbgextio_force_conn_serial_ftdi(int device_num)
Try to force a serial connection to a device via the FTDI API.
int mbgextio_rcv_msg(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, GPS_CMD cmd, void *buf, size_t buf_size)
Generic reception of a binary message.
Definition: mbgextio.c:4981
int mbgextio_get_gps_stat_info(MBG_MSG_CTL *pmctl, const XBP_ADDR *p_addr, STAT_INFO *p)
Read GPS status info.
Definition: mbgextio.c:6950
uint32_t u32
Definition: lan_util.c:100
#define MBG_ERR_SOCK_INIT
Socket interface not initialized, or failed to initialize.
Definition: mbgerror.h:322