diff options
author | Josh Blum <josh@joshknows.com> | 2010-03-18 08:15:15 +0000 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-03-18 08:15:15 +0000 |
commit | d105f614477c7f2a4f24a4efc802de7eb750bd7a (patch) | |
tree | 6c5f6e615f153862e546e5fb3879a400b73bfec1 /host/include | |
parent | 5de235715b36ef9a98ea418832a5382cbf25d4d6 (diff) | |
parent | f2a86eb6389210a8ebd475782ab707f814c6e49c (diff) | |
download | uhd-d105f614477c7f2a4f24a4efc802de7eb750bd7a.tar.gz uhd-d105f614477c7f2a4f24a4efc802de7eb750bd7a.tar.bz2 uhd-d105f614477c7f2a4f24a4efc802de7eb750bd7a.zip |
Merge branch 'master' of git@ettus.sourcerepo.com:ettus/uhd into u1e_uhd
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/device_addr.hpp | 5 | ||||
-rw-r--r-- | host/include/uhd/dict.hpp | 43 | ||||
-rw-r--r-- | host/include/uhd/metadata.hpp | 8 | ||||
-rw-r--r-- | host/include/uhd/props.hpp | 7 | ||||
-rw-r--r-- | host/include/uhd/time_spec.hpp | 8 | ||||
-rw-r--r-- | host/include/uhd/transport/vrt.hpp | 14 | ||||
-rw-r--r-- | host/include/uhd/usrp/dboard_id.hpp | 4 | ||||
-rw-r--r-- | host/include/uhd/usrp/dboard_interface.hpp | 12 |
8 files changed, 46 insertions, 55 deletions
diff --git a/host/include/uhd/device_addr.hpp b/host/include/uhd/device_addr.hpp index ed538453a..1b624b770 100644 --- a/host/include/uhd/device_addr.hpp +++ b/host/include/uhd/device_addr.hpp @@ -19,10 +19,9 @@ #define INCLUDED_UHD_DEVICE_ADDR_HPP #include <uhd/dict.hpp> +#include <boost/cstdint.hpp> #include <string> #include <iostream> -#include <netinet/ether.h> -#include <stdint.h> #include <vector> namespace uhd{ @@ -32,7 +31,7 @@ namespace uhd{ * Provides conversion between string and binary formats. */ struct mac_addr_t{ - struct ether_addr mac_addr; + boost::uint8_t mac_addr[6]; mac_addr_t(const std::string &mac_addr_str = "00:00:00:00:00:00"); std::string to_string(void) const; }; diff --git a/host/include/uhd/dict.hpp b/host/include/uhd/dict.hpp index 2224a0063..8f7cd5a0f 100644 --- a/host/include/uhd/dict.hpp +++ b/host/include/uhd/dict.hpp @@ -18,7 +18,7 @@ #ifndef INCLUDED_UHD_DICT_HPP #define INCLUDED_UHD_DICT_HPP -#include <map> +#include <list> #include <vector> #include <stdexcept> #include <boost/foreach.hpp> @@ -27,11 +27,9 @@ namespace uhd{ /*! * A templated dictionary class with a python-like interface. - * Its wraps around a std::map internally. */ template <class Key, class Val> class dict{ public: - typedef std::map<Key, Val> map_t; typedef std::pair<Key, Val> pair_t; /*! @@ -42,14 +40,6 @@ namespace uhd{ } /*! - * Create a dictionary from a map. - * \param map a map with key value pairs - */ - dict(const map_t &map){ - _map = map; - } - - /*! * Destroy this dict. */ ~dict(void){ @@ -66,11 +56,12 @@ namespace uhd{ /*! * Get a list of the keys in this dict. + * Key order depends on insertion precedence. * \return vector of keys */ std::vector<Key> get_keys(void) const{ std::vector<Key> keys; - BOOST_FOREACH(pair_t p, _map){ + BOOST_FOREACH(const pair_t &p, _map){ keys.push_back(p.first); } return keys; @@ -78,11 +69,12 @@ namespace uhd{ /*! * Get a list of the values in this dict. + * Value order depends on insertion precedence. * \return vector of values */ std::vector<Val> get_vals(void) const{ std::vector<Val> vals; - BOOST_FOREACH(pair_t p, _map){ + BOOST_FOREACH(const pair_t &p, _map){ vals.push_back(p.second); } return vals; @@ -94,7 +86,7 @@ namespace uhd{ * \return true if found */ bool has_key(const Key &key) const{ - BOOST_FOREACH(pair_t p, _map){ + BOOST_FOREACH(const pair_t &p, _map){ if (p.first == key) return true; } return false; @@ -108,8 +100,8 @@ namespace uhd{ * \throw an exception when not found */ const Val &operator[](const Key &key) const{ - if (has_key(key)){ - return _map.find(key)->second; + BOOST_FOREACH(const pair_t &p, _map){ + if (p.first == key) return p.second; } throw std::invalid_argument("key not found in dict"); } @@ -121,7 +113,11 @@ namespace uhd{ * \return a reference to the value */ Val &operator[](const Key &key){ - return _map[key]; + BOOST_FOREACH(pair_t &p, _map){ + if (p.first == key) return p.second; + } + _map.push_back(pair_t(key, Val())); + return _map.back().second; } /*! @@ -130,17 +126,14 @@ namespace uhd{ * \return the value of the item * \throw an exception when not found */ - Val pop_key(const Key &key){ - if (has_key(key)){ - Val val = _map.find(key)->second; - _map.erase(key); - return val; - } - throw std::invalid_argument("key not found in dict"); + Val pop(const Key &key){ + Val val = (*this)[key]; + _map.remove(pair_t(key, val)); + return val; } private: - map_t _map; //private container + std::list<pair_t> _map; //private container }; } //namespace uhd diff --git a/host/include/uhd/metadata.hpp b/host/include/uhd/metadata.hpp index 0588ef0ed..ce72ff14b 100644 --- a/host/include/uhd/metadata.hpp +++ b/host/include/uhd/metadata.hpp @@ -28,9 +28,9 @@ namespace uhd{ * The receive routines will convert IF data headers into metadata. */ struct rx_metadata_t{ - uint32_t stream_id; - bool has_stream_id; + boost::uint32_t stream_id; time_spec_t time_spec; + bool has_stream_id; bool has_time_spec; bool is_fragment; @@ -44,9 +44,9 @@ struct rx_metadata_t{ * The send routines will convert the metadata to IF data headers. */ struct tx_metadata_t{ - uint32_t stream_id; - bool has_stream_id; + boost::uint32_t stream_id; time_spec_t time_spec; + bool has_stream_id; bool has_time_spec; bool start_of_burst; bool end_of_burst; diff --git a/host/include/uhd/props.hpp b/host/include/uhd/props.hpp index 0dddba647..6d4414d3a 100644 --- a/host/include/uhd/props.hpp +++ b/host/include/uhd/props.hpp @@ -122,7 +122,8 @@ namespace uhd{ enum dboard_prop_t{ DBOARD_PROP_NAME, //ro, std::string DBOARD_PROP_SUBDEV, //ro, wax::obj - DBOARD_PROP_SUBDEV_NAMES //ro, prop_names_t + DBOARD_PROP_SUBDEV_NAMES, //ro, prop_names_t + DBOARD_PROP_USED_SUBDEVS //ro, prop_names_t //DBOARD_PROP_CODEC //ro, wax::obj //----> not sure, dont have to deal with yet }; @@ -135,9 +136,7 @@ namespace uhd{ CODEC_PROP_NAME, //ro, std::string CODEC_PROP_OTHERS, //ro, prop_names_t CODEC_PROP_GAIN, //rw, gain_t - CODEC_PROP_GAIN_MAX, //ro, gain_t - CODEC_PROP_GAIN_MIN, //ro, gain_t - CODEC_PROP_GAIN_STEP, //ro, gain_t + CODEC_PROP_GAIN_RANGE, //ro, gain_range_t CODEC_PROP_GAIN_NAMES, //ro, prop_names_t //CODEC_PROP_CLOCK_RATE //ro, freq_t //----> not sure we care to know };*/ diff --git a/host/include/uhd/time_spec.hpp b/host/include/uhd/time_spec.hpp index 7e182236b..588758824 100644 --- a/host/include/uhd/time_spec.hpp +++ b/host/include/uhd/time_spec.hpp @@ -16,7 +16,7 @@ // #include <boost/date_time/posix_time/posix_time.hpp> -#include <stdint.h> +#include <boost/cstdint.hpp> #ifndef INCLUDED_UHD_TIME_SPEC_HPP #define INCLUDED_UHD_TIME_SPEC_HPP @@ -30,8 +30,8 @@ namespace uhd{ * and for controlling the start of streaming for applicable dsps. */ struct time_spec_t{ - uint32_t secs; - uint32_t ticks; + boost::uint32_t secs; + boost::uint32_t ticks; /*! * Create a time_spec_t that holds a wildcard time. @@ -44,7 +44,7 @@ namespace uhd{ * \param new_secs the new seconds * \param new_ticks the new ticks (default = 0) */ - time_spec_t(uint32_t new_secs, uint32_t new_ticks = 0); + time_spec_t(boost::uint32_t new_secs, boost::uint32_t new_ticks = 0); /*! * Create a time_spec_t from boost posix time. diff --git a/host/include/uhd/transport/vrt.hpp b/host/include/uhd/transport/vrt.hpp index 1700d2785..3b5bf41bf 100644 --- a/host/include/uhd/transport/vrt.hpp +++ b/host/include/uhd/transport/vrt.hpp @@ -38,7 +38,7 @@ namespace vrt{ */ void pack( const tx_metadata_t &metadata, //input - uint32_t *header_buff, //output + boost::uint32_t *header_buff, //output size_t &num_header_words32, //output size_t num_payload_words32, //input size_t &num_packet_words32, //output @@ -55,12 +55,12 @@ namespace vrt{ * \param packet_count the packet count sequence number */ void unpack( - rx_metadata_t &metadata, //output - const uint32_t *header_buff, //input - size_t &num_header_words32, //output - size_t &num_payload_words32, //output - size_t num_packet_words32, //input - size_t &packet_count //output + rx_metadata_t &metadata, //output + const boost::uint32_t *header_buff, //input + size_t &num_header_words32, //output + size_t &num_payload_words32, //output + size_t num_packet_words32, //input + size_t &packet_count //output ); } //namespace vrt diff --git a/host/include/uhd/usrp/dboard_id.hpp b/host/include/uhd/usrp/dboard_id.hpp index 34406863d..62c61661c 100644 --- a/host/include/uhd/usrp/dboard_id.hpp +++ b/host/include/uhd/usrp/dboard_id.hpp @@ -15,15 +15,15 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // +#include <boost/cstdint.hpp> #include <string> -#include <stdint.h> #ifndef INCLUDED_UHD_USRP_DBOARD_ID_HPP #define INCLUDED_UHD_USRP_DBOARD_ID_HPP namespace uhd{ namespace usrp{ -typedef uint16_t dboard_id_t; +typedef boost::uint16_t dboard_id_t; static const dboard_id_t ID_NONE = 0xffff; diff --git a/host/include/uhd/usrp/dboard_interface.hpp b/host/include/uhd/usrp/dboard_interface.hpp index 84e1f5b22..b00643550 100644 --- a/host/include/uhd/usrp/dboard_interface.hpp +++ b/host/include/uhd/usrp/dboard_interface.hpp @@ -19,8 +19,8 @@ #define INCLUDED_UHD_USRP_DBOARD_INTERFACE_HPP #include <boost/shared_ptr.hpp> +#include <boost/cstdint.hpp> #include <vector> -#include <stdint.h> namespace uhd{ namespace usrp{ @@ -33,7 +33,7 @@ namespace uhd{ namespace usrp{ class dboard_interface{ public: typedef boost::shared_ptr<dboard_interface> sptr; - typedef std::vector<uint8_t> byte_vector_t; + typedef std::vector<boost::uint8_t> byte_vector_t; //tells the host which unit to use enum unit_type_t{ @@ -96,7 +96,7 @@ public: * \param rx_value 16-bits, 0=FPGA output low, 1=FPGA output high * \param mask 16-bits, 0=software, 1=atr */ - virtual void set_atr_reg(gpio_bank_t bank, uint16_t tx_value, uint16_t rx_value, uint16_t mask) = 0; + virtual void set_atr_reg(gpio_bank_t bank, boost::uint16_t tx_value, boost::uint16_t rx_value, boost::uint16_t mask) = 0; /*! * Set daughterboard GPIO data direction register. @@ -105,7 +105,7 @@ public: * \param value 16-bits, 0=FPGA input, 1=FPGA output * \param mask 16-bits, 0=ignore, 1=set */ - virtual void set_gpio_ddr(gpio_bank_t bank, uint16_t value, uint16_t mask) = 0; + virtual void set_gpio_ddr(gpio_bank_t bank, boost::uint16_t value, boost::uint16_t mask) = 0; /*! * Set daughterboard GPIO pin values. @@ -114,7 +114,7 @@ public: * \param value 16 bits, 0=low, 1=high * \param mask 16 bits, 0=ignore, 1=set */ - virtual void write_gpio(gpio_bank_t bank, uint16_t value, uint16_t mask) = 0; + virtual void write_gpio(gpio_bank_t bank, boost::uint16_t value, boost::uint16_t mask) = 0; /*! * Read daughterboard GPIO pin values @@ -122,7 +122,7 @@ public: * \param bank GPIO_TX_BANK or GPIO_RX_BANK * \return the value of the gpio bank */ - virtual uint16_t read_gpio(gpio_bank_t bank) = 0; + virtual boost::uint16_t read_gpio(gpio_bank_t bank) = 0; /*! * \brief Write to I2C peripheral |