summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blossom2010-09-23 21:24:37 -0700
committerEric Blossom2010-09-27 14:56:43 -0700
commitdd02d4590ea0c782dc812d4ab41c4ad05a1817c8 (patch)
tree11e611e12bf2864fadb193912fcd510808faf222
parentd2452adf306502b1f7489f49454e8814bc84c6d4 (diff)
downloadgnuradio-dd02d4590ea0c782dc812d4ab41c4ad05a1817c8.tar.gz
gnuradio-dd02d4590ea0c782dc812d4ab41c4ad05a1817c8.tar.bz2
gnuradio-dd02d4590ea0c782dc812d4ab41c4ad05a1817c8.zip
Add expanded_if_context_section
-rw-r--r--vrt/include/vrt/bits.h172
-rw-r--r--vrt/include/vrt/expanded_if_context_section.h94
-rw-r--r--vrt/include/vrt/types.h159
3 files changed, 366 insertions, 59 deletions
diff --git a/vrt/include/vrt/bits.h b/vrt/include/vrt/bits.h
index 54eeec7b4..117a4eb38 100644
--- a/vrt/include/vrt/bits.h
+++ b/vrt/include/vrt/bits.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Free Software Foundation, Inc.
+ * Copyright 2009,2010 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,8 +18,18 @@
#ifndef INCLUDED_VRT_BITS_H
#define INCLUDED_VRT_BITS_H
+/*!
+ * \brief Definitions of bit and fields in VRT packets
+ *
+ * See "ANSI/VITA 49.0, VRT Standard" for details
+ */
+
#include <stdint.h>
+#include <vrt/types.h>
+// ------------------------------------------------------------------------
+// Common VRT header info
+// ------------------------------------------------------------------------
/* VRT Header bits */
@@ -52,7 +62,7 @@
#define VRTH_PKT_CNT_SHIFT 16
#define VRTH_PKT_CNT_MASK (0xf << 16)
-#define VRTH_PKT_SIZE_MASK 0xffff
+#define VRTH_PKT_SIZE_MASK 0xffff
static inline int
@@ -89,4 +99,162 @@ vrth_pkt_size(uint32_t h)
#define TR_USER_1 (1 << 1)
#define TR_USER_0 (1 << 0)
+// ------------------------------------------------------------------------
+// IF-Context packets
+// ------------------------------------------------------------------------
+
+// ------------------------------------------------------------------------
+// Context Indicator field bits (Table 7.1.5.1-1)
+
+#define CI_CHANGE_INDICATOR (1 << 31)
+#define CI_REF_POINT_ID (1 << 30)
+#define CI_BANDWIDTH (1 << 29)
+#define CI_IF_REF_FREQ (1 << 28)
+#define CI_RF_REF_FREQ (1 << 27)
+#define CI_RF_REF_FREQ_OFFSET (1 << 26)
+#define CI_IF_BAND_OFFSET (1 << 25)
+#define CI_REF_LEVEL (1 << 24)
+#define CI_GAIN (1 << 23)
+#define CI_OVER_RANGE_COUNT (1 << 22)
+#define CI_SAMPLE_RATE (1 << 21)
+#define CI_TIMESTAMP_ADJ (1 << 20)
+#define CI_TIMESTAMP_CAL_TIME (1 << 19)
+#define CI_TEMPERATURE (1 << 18)
+#define CI_DEVICE_ID (1 << 17)
+#define CI_STATE_AND_EVENT_IND (1 << 16)
+#define CI_PAYLOAD_FMT (1 << 15)
+#define CI_FORMATTED_GPS (1 << 14)
+#define CI_FORMATTED_INS (1 << 13)
+#define CI_ECEF_EPHEMERIS (1 << 12)
+#define CI_REL_EPHEMERIS (1 << 11)
+#define CI_EPHEMERIS_REF_ID (1 << 10)
+#define CI_GPS_ASCII (1 << 9)
+#define CI_CNTX_ASSOC_LISTS (1 << 8)
+#define CI_RESERVED_7 (1 << 7)
+#define CI_RESERVED_6 (1 << 6)
+#define CI_RESERVED_5 (1 << 5)
+#define CI_RESERVED_4 (1 << 4)
+#define CI_RESERVED_3 (1 << 3)
+#define CI_RESERVED_2 (1 << 2)
+#define CI_RESERVED_1 (1 << 1)
+#define CI_RESERVED_0 (1 << 0)
+
+
+// ------------------------------------------------------------------------
+// Types that may be in the Context Section
+
+
+typedef struct {
+ uint32_t hi; // most significant 32-bits
+ uint32_t lo; // least significant 32-bits
+} vrt_frac_secs_t;
+
+static inline uint64_t
+get_frac_secs(const vrt_frac_secs_t *fs)
+{
+ return (((uint64_t)fs->hi) << 32) | fs->lo;
+}
+
+static inline void
+put_frac_secs(vrt_frac_secs_t *fs, uint64_t x)
+{
+ fs->hi = (x >> 32);
+ fs->lo = x;
+}
+
+//! See VITA-49.0 section 7.1.5.19
+
+typedef struct vrt_formatted_gps_tag {
+ uint32_t tsi_tsf_manuf_oui;
+ uint32_t integer_secs; // timestamp of position fix
+ vrt_frac_secs_t fractional_secs; // timestamp of position fix
+ vrt_angle_t latitude; // degrees Q10.22
+ vrt_angle_t longitude; // degrees Q10.22
+ vrt_distance_t altitude; // meters Q27.5
+ vrt_velocity_t speed_over_ground; // meters/s Q16.16
+ vrt_angle_t heading_angle; // degrees Q10.22
+ vrt_angle_t track_angle; // degrees Q10.22
+ vrt_angle_t magnetic_variation; // degrees Q10.22
+} vrt_formatted_gps_t;
+
+/*!
+ * \brief GPS Unknown value indicator
+ *
+ * May be used in: latitude, longitude, altitude, speed_over_ground,
+ * heading_angle, track_angle, and magnetic_variation fields.
+ */
+#define VRT_GPS_UNKNOWN_VALUE 0x7fffffff
+
+
+
+//! Data Packet Payload Format Field 7.1.5.18
+
+typedef struct vrt_payload_format_tag {
+ uint32_t word0;
+ uint32_t word1;
+} vrt_payload_format_t;
+
+#define DF0_PACKED (1 << 31)
+#define DF0_REAL_CMPLX_TYPE_MASK (0x3 << 29)
+#define DF0_REAL_CMPLX_TYPE_REAL (0 << 29)
+#define DF0_REAL_CMPLX_TYPE_CMPLX_CART (1 << 29)
+#define DF0_REAL_CMPLX_TYPE_CMPLX_POLAR (2 << 29)
+#define DF0_REAL_CMPLX_TYPE_RESERVED (3 << 29)
+#define DF0_ITEM_FMT_MASK (0x1f << 24)
+#define DF0_ITEM_FMT_SIGNED_FIXED_POINT (0x00 << 24)
+#define DF0_ITEM_FMT_UNSIGNED_FIXED_POINT (0x10 << 24)
+// lots more we're not using
+#define DF0_SAMPLE_COMPONENT_REPEATING (1 << 23)
+#define DF0_EVENT_TAG_SIZE_SHIFT 20
+#define DF0_EVENT_TAG_SIZE_MASK (0x7 << 20)
+#define DF0_CHANNEL_TAG_SIZE_SHIFT 16
+#define DF0_CHANNEL_TAG_SIZE_MASK (0xf << 16)
+#define DF0_RESERVED_SHIFT 12
+#define DF0_RESERVED_MASK (0xf << 12)
+#define DF0_ITEM_PACKING_FIELD_SIZE_SHIFT 6
+#define DF0_ITEM_PACKING_FIELD_SIZE_MASK (0x3f << 6)
+#define DF0_DATA_ITEM_SIZE_SHIFT 0
+#define DF0_DATA_ITEM_SIZE_MASK (0x3f << 0)
+
+#define DF1_REPEAT_COUNT_SHIFT 16
+#define DF1_REPEAT_COUNT_MASK (0xffff << 16)
+#define DF1_VECTOR_SIZE_SHIFT 0
+#define DF1_VECTOR_SIZE_MASK (0xffff << 0)
+
+
+// Composite values
+
+// 16-bit I & Q, no events, no channel tags
+#define DF0_16_BIT_IQ \
+ (0 \
+ | DF0_REAL_CMPLX_TYPE_CMPLX_CART \
+ | DF0_ITEM_FMT_SIGNED_FIXED_POINT \
+ | (15 << DF0_ITEM_PACKING_FIELD_SIZE_SHIFT) \
+ | (15 << DF0_DATA_ITEM_SIZE_SHIFT))
+
+// Vector of length 1
+#define DF1_VECTOR_1 (0 << DF1_VECTOR_SIZE_SHIFT)
+
+// Vector of length 4
+#define DF1_VECTOR_4 (3 << DF1_VECTOR_SIZE_SHIFT)
+
+
+//! ECEF Ephemeris Field 7.1.5.21
+
+typedef struct {
+ uint32_t tsi_tsf_manuf_oui;
+ uint32_t integer_secs; // timestamp of position fix
+ vrt_frac_secs_t fractional_secs; // timestamp of position fix
+ vrt_distance_t position_x; // meters Q27.5
+ vrt_distance_t position_y; // meters Q27.5
+ vrt_distance_t position_z; // meters Q27.5
+ vrt_angle_t attitude_alpha; // degrees Q10.22
+ vrt_angle_t attitude_beta; // degrees Q10.22
+ vrt_angle_t attitude_phi; // degrees Q10.22
+ vrt_velocity_t velocity_dx; // meters/s Q16.16
+ vrt_velocity_t velocity_dy; // meters/s Q16.16
+ vrt_velocity_t velocity_dz; // meters/s Q16.16
+} vrt_ecef_ephemeris_t;
+
+
#endif /* INCLUDED_VRT_BITS_H */
diff --git a/vrt/include/vrt/expanded_if_context_section.h b/vrt/include/vrt/expanded_if_context_section.h
new file mode 100644
index 000000000..1c82b97a5
--- /dev/null
+++ b/vrt/include/vrt/expanded_if_context_section.h
@@ -0,0 +1,94 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_VRT_EXPANDED_IF_CONTEXT_SECTION_H
+#define INCLUDED_VRT_EXPANDED_IF_CONTEXT_SECTION_H
+
+#include <string>
+
+/*!
+ * Expanded (unpacked) version of Context Section, defined in VRT section 7.1.5
+ */
+
+
+#include <stdint.h>
+#include <stddef.h>
+#include <vrt/bits.h>
+#include <vrt/types.h>
+
+namespace vrt {
+
+ //! Expanded GPS ASCII field
+ struct exp_gps_ascii {
+ uint32_t manuf_oui; // GSP/INS Manufacturer OUI
+ std::string ascii;
+ };
+
+ //! Expanded Context Association Lists
+ struct exp_context_assocs {
+ std::vector<uint32_t> source; // stream-ids
+ std::vector<uint32_t> system; // stream-ids
+ std::vector<uint32_t> vector_comp; // stream-ids
+ std::vector<uint32_t> async_channel;// stream-ids
+ std::vector<uint32_t> async_tag; // channel tags
+ };
+
+ /*!
+ * \brief Expanded (unpacked) version of the contents of an
+ * IF-Context packet's Context Section, as defined in VRT section 7.1.5
+ *
+ * There are fields allocated for each possible field. Their
+ * content may or may not be valid. Check the context_indicator
+ * field to determinte their validity. If the associated CI_* bit
+ * is set the corresponding field is valid.
+ *
+ * All values are in host-endian format.
+ */
+ struct expanded_if_context_section {
+ uint32_t context_indicator; //< 7.1.5.1
+ // 7.1.5.2 (no field)
+ uint32_t ref_point_id; //< 7.1.5.3
+ vrt_hertz_t bandwidth; //< 7.1.5.4
+ vrt_hertz_t if_ref_freq; //< 7.1.5.5
+ vrt_hertz_t rf_ref_freq; //< 7.1.5.6
+ vrt_hertz_t rf_ref_freq_offset; //< 7.1.5.7
+ vrt_hertz_t if_band_offset; //< 7.1.5.8
+ vrt_db_t ref_level; //< 7.1.5.9 (dBm)
+ vrt_gain_t gain; //< 7.1.5.10
+ uint32_t over_range_count; //< 7.1.5.11
+ vrt_hertz_t sample_rate; //< 7.1.5.12
+ int64_t timestamp_adj; //< 7.1.5.13 (picoseconds)
+ uint32_t timestamp_cal_time; //< 7.1.5.14 (TSI seconds)
+ vrt_temp_t temperature; //< 7.1.5.15
+ uint32_t device_id[2]; //< 7.1.5.16 (0: OUI; 1: dev code)
+ uint32_t state_and_event_ind; //< 7.1.5.17
+ vrt_payload_fmt_t payload_fmt; //< 7.1.5.18
+ vrt_formatted_gps_t formatted_gps; //< 7.1.5.19
+ vrt_formatted_gps_t formatted_ins; //< 7.1.5.20
+ vrt_ephemeris_t ecef_ephemeris; //< 7.1.5.21
+ vrt_ephemeris_t rel_ephemeris; //< 7.1.5.22
+ int32_t ephemeris_ref_id; //< 7.1.5.23
+ exp_gps_ascii gps_ascii; //< 7.1.5.24
+ exp_context_assocs cntx_assoc_lists;//< 7.1.5.25
+ };
+
+}; // namespace vrt
+
+#endif /* INCLUDED_VRT_EXPANDED_IF_CONTEXT_SECTION_H */
diff --git a/vrt/include/vrt/types.h b/vrt/include/vrt/types.h
index edfa4ec37..6e05b8eb8 100644
--- a/vrt/include/vrt/types.h
+++ b/vrt/include/vrt/types.h
@@ -1,6 +1,6 @@
-/* -*- c++ -*- */
+/* -*- c -*- */
/*
- * Copyright 2009 Free Software Foundation, Inc.
+ * Copyright 2009,2010 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,97 +25,119 @@
#define _FXPT_TO_INT(_x, _one) (((_x) + ((_one)/2))/(_one))
#define _FXPT_TO_DOUBLE(_x, _one) ((double)(_x) * (1.0/(_one)))
-/***********************************************************************
- * The VRT Altitude Type (meters)
- **********************************************************************/
-typedef int32_t vrt_altitude_t;
-#define VRT_ALTITUDE_RP 5
-#define VRT_ALTITUDE_C(_x) _FXPT_C(vrt_altitude_t, _x, VRT_ALTITUDE_RP)
+/*
+ * The VRT Distance type (meters)
+ */
+typedef int32_t vrt_distance_t;
+#define VRT_DISTANCE_RP 5
+#define VRT_DISTANCE_C(_x) _FXPT_C(vrt_distance_t, _x, VRT_DISTANCE_RP)
-static inline vrt_altitude_t
-double_to_vrt_altitude(double num){
- return VRT_ALTITUDE_C(num);
+static inline vrt_distance_t
+double_to_vrt_distance(double num){
+ return VRT_DISTANCE_C(num);
}
static inline int32_t
-vrt_altitude_round_to_int(vrt_altitude_t fx){
- return _FXPT_TO_INT(fx, VRT_ALTITUDE_C(1));
+vrt_distance_round_to_int(vrt_distance_t fx){
+ return _FXPT_TO_INT(fx, VRT_DISTANCE_C(1));
}
static inline double
-vrt_altitude_to_double(vrt_altitude_t fx){
- return _FXPT_TO_DOUBLE(fx, VRT_ALTITUDE_C(1));
+vrt_distance_to_double(vrt_distance_t fx){
+ return _FXPT_TO_DOUBLE(fx, VRT_DISTANCE_C(1));
+}
+
+/*
+ * The VRT Velocity type (meters/second)
+ */
+typedef int32_t vrt_velocity_t;
+#define VRT_VELOCITY_RP 16
+#define VRT_VELOCITY_C(_x) _FXPT_C(vrt_velocity_t, _x, VRT_VELOCITY_RP)
+
+static inline vrt_velocity_t
+double_to_vrt_velocity(double num){
+ return VRT_VELOCITY_C(num);
}
-/***********************************************************************
- * The VRT Geolocation Angle Type (degrees)
- **********************************************************************/
-typedef int32_t vrt_geo_angle_t;
-#define VRT_GEO_ANGLE_RP 22
-#define VRT_GEO_ANGLE_C(_x) _FXPT_C(vrt_geo_angle_t, _x, VRT_GEO_ANGLE_RP)
+static inline int32_t
+vrt_velocity_round_to_int(vrt_velocity_t fx){
+ return _FXPT_TO_INT(fx, VRT_VELOCITY_C(1));
+}
+
+static inline double
+vrt_velocity_to_double(vrt_velocity_t fx){
+ return _FXPT_TO_DOUBLE(fx, VRT_VELOCITY_C(1));
+}
+
+/*
+ * The VRT Angle type (degrees)
+ */
+typedef int32_t vrt_angle_t;
+#define VRT_ANGLE_RP 22
+#define VRT_ANGLE_C(_x) _FXPT_C(vrt_angle_t, _x, VRT_ANGLE_RP)
-static inline vrt_geo_angle_t
-double_to_vrt_geo_angle(double num){
- return VRT_GEO_ANGLE_C(num);
+static inline vrt_angle_t
+double_to_vrt_angle(double num){
+ return VRT_ANGLE_C(num);
}
static inline int16_t
-vrt_geo_angle_round_to_int(vrt_geo_angle_t fx){
- return _FXPT_TO_INT(fx, VRT_GEO_ANGLE_C(1));
+vrt_angle_round_to_int(vrt_angle_t fx){
+ return _FXPT_TO_INT(fx, VRT_ANGLE_C(1));
}
static inline double
-vrt_geo_angle_to_double(vrt_geo_angle_t fx){
- return _FXPT_TO_DOUBLE(fx, VRT_GEO_ANGLE_C(1));
+vrt_angle_to_double(vrt_angle_t fx){
+ return _FXPT_TO_DOUBLE(fx, VRT_ANGLE_C(1));
}
-/***********************************************************************
- * The VRT Frequency Type (Hz)
- **********************************************************************/
-typedef int64_t vrt_freq_t;
-#define VRT_FREQ_RP 20
-#define VRT_FREQ_C(_x) _FXPT_C(vrt_freq_t, _x, VRT_FREQ_RP)
+/*
+ * The VRT Hertz type
+ */
+typedef int64_t vrt_hertz_t;
+#define VRT_HERTZ_RP 20
+#define VRT_HERTZ_C(_x) _FXPT_C(vrt_hertz_t, _x, VRT_HERTZ_RP)
-static inline vrt_freq_t
-double_to_vrt_freq(double num){
- return VRT_FREQ_C(num);
+static inline vrt_hertz_t
+double_to_vrt_hertz(double num){
+ return VRT_HERTZ_C(num);
}
static inline int64_t
-vrt_freq_round_to_int(vrt_freq_t fx){
- return _FXPT_TO_INT(fx, VRT_FREQ_C(1));
+vrt_hertz_round_to_int(vrt_hertz_t fx){
+ return _FXPT_TO_INT(fx, VRT_HERTZ_C(1));
}
static inline double
-vrt_freq_to_double(vrt_freq_t fx){
- return _FXPT_TO_DOUBLE(fx, VRT_FREQ_C(1));
+vrt_hertz_to_double(vrt_hertz_t fx){
+ return _FXPT_TO_DOUBLE(fx, VRT_HERTZ_C(1));
}
-/***********************************************************************
- * The VRT Gain Type (dB)
- **********************************************************************/
-typedef int16_t vrt_gain_t;
-#define VRT_GAIN_RP 7
-#define VRT_GAIN_C(_x) _FXPT_C(vrt_gain_t, _x, VRT_GAIN_RP)
+/*
+ * The VRT dB (& dBm) type
+ */
+typedef int16_t vrt_db_t;
+#define VRT_DB_RP 7
+#define VRT_DB_C(_x) _FXPT_C(vrt_db_t, _x, VRT_DB_RP)
-static inline vrt_gain_t
-double_to_vrt_gain(double num){
- return VRT_GAIN_C(num);
+static inline vrt_db_t
+double_to_vrt_db(double num){
+ return VRT_DB_C(num);
}
static inline int16_t
-vrt_gain_round_to_int(vrt_gain_t fx){
- return _FXPT_TO_INT(fx, VRT_GAIN_C(1));
+vrt_db_round_to_int(vrt_db_t fx){
+ return _FXPT_TO_INT(fx, VRT_DB_C(1));
}
static inline double
-vrt_gain_to_double(vrt_gain_t fx){
- return _FXPT_TO_DOUBLE(fx, VRT_GAIN_C(1));
+vrt_db_to_double(vrt_db_t fx){
+ return _FXPT_TO_DOUBLE(fx, VRT_DB_C(1));
}
-/***********************************************************************
- * The VRT Temperature Type (Celcius)
- **********************************************************************/
+/*
+ * The VRT Temperature type (Celsius)
+ */
typedef int16_t vrt_temp_t;
#define VRT_TEMP_RP 6
#define VRT_TEMP_C(_x) _FXPT_C(vrt_temp_t, _x, VRT_TEMP_RP)
@@ -135,4 +157,27 @@ vrt_temp_to_double(vrt_temp_t fx){
return _FXPT_TO_DOUBLE(fx, VRT_TEMP_C(1));
}
+/*
+ * The VRT Gain type (7.1.5.10 Gain -- two Q10.6 dB fields)
+ */
+typedef uint32_t vrt_gain_t;
+
+static inline uint32_t
+vrt_make_gain(vrt_db_t stage1, vrt_db_t stage2)
+{
+ return (((uint32_t) stage2) << 16) | (stage1 & 0xffff);
+}
+
+static inline vrt_db_t
+vrt_gain_stage1(uint32_t field)
+{
+ return (vrt_db_t)(field & 0xffff);
+}
+
+static inline vrt_db_t
+vrt_gain_stage2(uint32_t field)
+{
+ return (vrt_db_t)((field >> 16) & 0xffff);
+}
+
#endif /* INCLUDED_VRT_TYPES_H */