mbgtools-lx  4.2.8
irig_cal.h
Go to the documentation of this file.
1 
2 /**************************************************************************
3  *
4  * $Id: irig_cal.h 1.4 2018/03/21 14:58:06 martin REL_M $
5  *
6  * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
7  *
8  * Description:
9  * Definitions and inline functions to calibrate IRIG inputs.
10  *
11  * -----------------------------------------------------------------------
12  * $Log: irig_cal.h $
13  * Revision 1.4 2018/03/21 14:58:06 martin
14  * Fixed a compiler warning.
15  * Revision 1.3 2015/08/31 09:35:30Z martin
16  * Quieted a compiler warning.
17  * Revision 1.2 2012/01/17 09:58:36Z martin
18  * Added new function mbg_icode_rx_to_group_idx().
19  * Do a pausibility check in mbg_get_cal_rec_irig_rx_num_rec().
20  * Revision 1.1 2011/11/23 17:50:02 martin
21  * Initial revision.
22  *
23  **************************************************************************/
24 
25 #ifndef _IRIG_CAL_H
26 #define _IRIG_CAL_H
27 
28 
29 /* Other headers to be included */
30 
31 #include <mbgdevio.h>
32 #include <use_pack.h>
33 
34 
35 #ifdef _IRIG_CAL
36  #define _ext
37 #else
38  #define _ext extern
39 #endif
40 
41 
42 /* Start of header body */
43 
44 #if defined( _USE_PACK ) // set byte alignment
45  #pragma pack( 1 )
46  #define _USING_BYTE_ALIGNMENT
47 #endif
48 
49 
61 static __mbg_inline
62 int mbg_icode_rx_to_group_idx( int icode_rx )
63 {
64  ulong icode_mask = 1UL << icode_rx;
65 
66  if ( icode_mask & MSK_ICODE_RX_DC )
67  {
68  // for DCLS codes check the bit rate
69 
70  if ( icode_mask & MSK_ICODE_RX_100BPS )
71  return IRIG_RX_COMP_B0;
72 
73  if ( icode_mask & MSK_ICODE_RX_1000BPS )
74  return IRIG_RX_COMP_A0;
75 
76  if ( icode_mask & MSK_ICODE_RX_10000BPS )
77  return IRIG_RX_COMP_G0;
78 
79  return -1; // unknown DLCS code
80  }
81 
82 
83  // for modulated codes check the carrier frequency
84 
85  if ( icode_mask & MSK_ICODE_RX_1KHZ )
86  return IRIG_RX_COMP_B1;
87 
88  if ( icode_mask & MSK_ICODE_RX_10KHZ )
89  return IRIG_RX_COMP_A1;
90 
91  if ( icode_mask & MSK_ICODE_RX_100KHZ )
92  return IRIG_RX_COMP_G1;
93 
94  return -1; // unknown modulated code
95 
96 } // mbg_icode_rx_to_group_idx
97 
98 
99 
113 static __mbg_inline
115 {
116  int rc;
117 
119 
120  rc = mbg_generic_io( dh, PCPS_GEN_IO_GET_INFO, &type, sizeof( type ), p, sizeof( *p ) );
121 
122  if ( rc == MBG_SUCCESS )
124 
125  return rc;
126 
127 } // mbg_get_gen_io_info
128 
129 
130 
143 static __mbg_inline
145 {
146  GEN_IO_INFO tmp = { 0 };
148 
149  if ( rc == MBG_SUCCESS )
150  {
151  _mbg_swab_gen_io_info( &tmp );
152  *p_num_rec = ( tmp.type == PCPS_GEN_IO_CAL_REC_IRIG_RX_COMP ) ? tmp.num : 0;
153  }
154 
155  return rc;
156 
157 } // mbg_get_cal_rec_irig_rx_num_rec
158 
159 
160 
174 static __mbg_inline
176 {
177  CAL_REC_HDR hdr;
178  int rc;
179 
181  hdr.idx = idx;
182 
183  _mbg_swab_cal_rec_hdr( &hdr );
184 
186  &hdr, sizeof( hdr ), p, sizeof( *p ) );
187 
188  if ( rc == MBG_SUCCESS )
190 
191  return rc;
192 
193 } // mbg_get_cal_rec_irig_rx_comp
194 
195 
196 
209 static __mbg_inline
211 {
212  int rc;
213 
214  #if defined( MBG_ARCH_BIG_ENDIAN )
215  CAL_REC_IRIG_RX_COMP tmp = *p;
217  p = &tmp;
218  #endif
219 
221  p, sizeof( *p ), NULL, 0 );
222 
223  return rc;
224 
225 } // mbg_set_cal_rec_irig_rx_comp
226 
227 
228 
229 #ifdef __cplusplus
230 extern "C" {
231 #endif
232 
233 /* ----- function prototypes begin ----- */
234 
235 /* This section was generated automatically */
236 /* by MAKEHDR, do not remove the comments. */
237 
238 /* (no header definitions found) */
239 
240 /* ----- function prototypes end ----- */
241 
242 #ifdef __cplusplus
243 }
244 #endif
245 
246 #if defined( _USING_BYTE_ALIGNMENT )
247  #pragma pack() // set default alignment
248  #undef _USING_BYTE_ALIGNMENT
249 #endif
250 
251 /* End of header body */
252 
253 
254 #undef _ext
255 
256 #endif /* _IRIG_CAL_H */
257 
uint16_t type
record type, see CAL_REC_TYPES
Definition: gpsdefs.h:5120
#define MSK_ICODE_RX_10000BPS
A mask of IRIG RX formats with 10 kbps data rate.
Definition: gpsdefs.h:4803
uint16_t idx
index if several records of same type are supported, see IRIG_RX_COMP_GROUPS
Definition: gpsdefs.h:5121
#define _mbg_swab_cal_rec_irig_rx_comp(_p)
Definition: gpsdefs.h:5186
static __mbg_inline int mbg_get_cal_rec_irig_rx_comp(MBG_DEV_HANDLE dh, uint16_t idx, CAL_REC_IRIG_RX_COMP *p)
Retrieve IRIG RX calibration record with specific index.
Definition: irig_cal.h:175
#define MSK_ICODE_RX_DC
A mask of IRIG RX DCLS formats.
Definition: gpsdefs.h:4703
The data structure used with the PCPS_GEN_IO_GET_INFO command.
Definition: gpsdefs.h:10364
static __mbg_inline int mbg_get_cal_rec_irig_rx_num_rec(MBG_DEV_HANDLE dh, int *p_num_rec)
Get supported number of IRIG RX calibration records.
Definition: irig_cal.h:144
Structure used to transfer calibration records.
Definition: gpsdefs.h:5179
unsigned short uint16_t
Definition: words.h:213
code A1xx
Definition: gpsdefs.h:5152
#define MSK_ICODE_RX_100BPS
A mask of IRIG RX formats with 100 bps data rate.
Definition: gpsdefs.h:4771
codes B1xx, AFNOR, IEEE1344
Definition: gpsdefs.h:5151
#define MSK_ICODE_RX_10KHZ
A mask of IRIG RX formats with 10 kHz carrier.
Definition: gpsdefs.h:4744
CAL_REC_IRIG_RX_COMP (read/write)
Definition: gpsdefs.h:10391
codes B0xx, AFNOR DC, IEEE1344 DC
Definition: gpsdefs.h:5153
uint16_t GEN_IO_INFO_TYPE
Definition: gpsdefs.h:10351
#define MSK_ICODE_RX_1KHZ
A mask of IRIG RX formats with 1 kHz carrier.
Definition: gpsdefs.h:4730
Structure used to retrieve the number of records for a given type.
Definition: gpsdefs.h:5118
GEN_IO_INFO_TYPE type
Definition: gpsdefs.h:10366
#define MSK_ICODE_RX_100KHZ
A mask of IRIG RX formats with 100 kHz carrier.
Definition: gpsdefs.h:4753
static __mbg_inline int mbg_get_gen_io_info(MBG_DEV_HANDLE dh, GEN_IO_INFO_TYPE type, GEN_IO_INFO *p)
Get generic I/O support info for a certain data type.
Definition: irig_cal.h:114
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
Definition: mbgerror.h:259
code G00x
Definition: gpsdefs.h:5156
_MBG_API_ATTR int _MBG_API mbg_generic_io(MBG_DEV_HANDLE dh, int type, const void *in_p, int in_sz, void *out_p, int out_sz)
Definition: mbgdevio.c:4448
Definition: myutil.h:117
IRIG receiver delay compensation.
Definition: gpsdefs.h:5139
#define _mbg_swab_gen_io_info(_p)
Definition: gpsdefs.h:10371
code G14x
Definition: gpsdefs.h:5155
#define MSK_ICODE_RX_1000BPS
A mask of IRIG RX formats with 1000 bps data rate.
Definition: gpsdefs.h:4792
code A0xx
Definition: gpsdefs.h:5154
#define _mbg_swab_cal_rec_hdr(_p)
Definition: gpsdefs.h:5125
uint16_t num
Definition: gpsdefs.h:10367
static __mbg_inline int mbg_set_cal_rec_irig_rx_comp(MBG_DEV_HANDLE dh, const CAL_REC_IRIG_RX_COMP *p)
Write an IRIG RX calibration record to a device.
Definition: irig_cal.h:210
static __mbg_inline int mbg_icode_rx_to_group_idx(int icode_rx)
Get the IRIG calibration group index for a given IRIG RX code.
Definition: irig_cal.h:62
unsigned long ulong
Definition: words.h:292
GEN_IO_INFO (read only)
Definition: gpsdefs.h:10390
#define _mbg_swab_gen_io_info_type(_p)
Definition: gpsdefs.h:10353