diff options
author | Josh Blum <josh@joshknows.com> | 2010-01-12 14:43:43 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-01-12 14:43:43 -0800 |
commit | cbb8e474bb5592753a340ba31d3afbab7226f7c6 (patch) | |
tree | 6dd14d37d8d46f3a506a309f57d82ed1ed05f781 /include/usrp_uhd | |
parent | 4e94574aeaa46c671bba0a6fc83cb967d228c880 (diff) | |
download | uhd-cbb8e474bb5592753a340ba31d3afbab7226f7c6.tar.gz uhd-cbb8e474bb5592753a340ba31d3afbab7226f7c6.tar.bz2 uhd-cbb8e474bb5592753a340ba31d3afbab7226f7c6.zip |
Reorganized structure into include, lib, test, firmware, fpga.
The fpga and firmware are empty placeholders for now.
Diffstat (limited to 'include/usrp_uhd')
-rw-r--r-- | include/usrp_uhd/.gitignore | 2 | ||||
-rw-r--r-- | include/usrp_uhd/Makefile.am | 12 | ||||
-rw-r--r-- | include/usrp_uhd/device_addr.hpp | 90 | ||||
-rw-r--r-- | include/usrp_uhd/quadradio/.gitignore | 2 | ||||
-rw-r--r-- | include/usrp_uhd/quadradio/Makefile.am | 7 | ||||
-rw-r--r-- | include/usrp_uhd/usrp/.gitignore | 2 | ||||
-rw-r--r-- | include/usrp_uhd/usrp/Makefile.am | 7 | ||||
-rw-r--r-- | include/usrp_uhd/usrp/dboard/.gitignore | 2 | ||||
-rw-r--r-- | include/usrp_uhd/usrp/dboard/Makefile.am | 7 | ||||
-rw-r--r-- | include/usrp_uhd/usrp/mboard/.gitignore | 2 | ||||
-rw-r--r-- | include/usrp_uhd/usrp/mboard/Makefile.am | 7 | ||||
-rw-r--r-- | include/usrp_uhd/wax.hpp | 129 |
12 files changed, 269 insertions, 0 deletions
diff --git a/include/usrp_uhd/.gitignore b/include/usrp_uhd/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/include/usrp_uhd/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/include/usrp_uhd/Makefile.am b/include/usrp_uhd/Makefile.am new file mode 100644 index 000000000..9d12f2097 --- /dev/null +++ b/include/usrp_uhd/Makefile.am @@ -0,0 +1,12 @@ +# +# Copyright 2010 Ettus Research LLC +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = usrp quadradio + +this_includedir = $(includedir)/usrp_uhd +this_include_HEADERS = \ + device_addr.hpp \ + wax.hpp diff --git a/include/usrp_uhd/device_addr.hpp b/include/usrp_uhd/device_addr.hpp new file mode 100644 index 000000000..f0be44c1f --- /dev/null +++ b/include/usrp_uhd/device_addr.hpp @@ -0,0 +1,90 @@ +// +// Copyright 2010 Ettus Research LLC +// + +#ifndef INCLUDED_USRP_UHD_DEVICE_ADDR_HPP +#define INCLUDED_USRP_UHD_DEVICE_ADDR_HPP + +#include <string> +#include <iostream> +#include <netinet/ether.h> +#include <arpa/inet.h> + +namespace usrp_uhd{ + + /*! + * Wrapper for an ethernet mac address. + * Provides conversion between string and binary formats. + */ + struct mac_addr_t{ + struct ether_addr mac_addr; + mac_addr_t(const std::string &str = "00:00:00:00:00:00"); + std::string to_string(void) const; + }; + + /*! + * Wrapper for an ipv4 address. + * Provides conversion between string and binary formats. + */ + struct ip_addr_t{ + struct in_addr ip_addr; + ip_addr_t(const std::string &str = "0.0.0.0"); + std::string to_string(void) const; + }; + + /*! + * Possible usrp device interface types. + */ + enum device_addr_type_t{ + DEVICE_ADDR_TYPE_AUTO, + DEVICE_ADDR_TYPE_VIRTUAL, + DEVICE_ADDR_TYPE_USB, + DEVICE_ADDR_TYPE_ETH, + DEVICE_ADDR_TYPE_UDP, + DEVICE_ADDR_TYPE_GPMC + }; + + /*! + * Structure to hold properties that identify a usrp device. + */ + struct device_addr_t{ + device_addr_type_t type; + struct{ + size_t num_rx_dsps; + size_t num_tx_dsps; + size_t num_dboards; + } virtual_args; + struct{ + uint16_t vendor_id; + uint16_t product_id; + } usb_args; + struct{ + std::string ifc; + mac_addr_t mac_addr; + } eth_args; + struct{ + ip_addr_t ip_addr; + } udp_args; + struct{ + //TODO unknown for now + } gpmc_args; + + /*! + * \brief Convert a usrp device_addr_t into a string representation + */ + std::string to_string(void) const; + + /*! + * \brief Default constructor to initialize the device_addr_t struct + */ + device_addr_t(device_addr_type_t device_addr_type = DEVICE_ADDR_TYPE_AUTO); + }; + +} //namespace usrp_uhd + +//ability to use types with stream operators +std::ostream& operator<<(std::ostream &os, const usrp_uhd::device_addr_t &x); +std::ostream& operator<<(std::ostream &os, const usrp_uhd::mac_addr_t &x); +std::ostream& operator<<(std::ostream &os, const usrp_uhd::ip_addr_t &x); + +#endif /* INCLUDED_USRP_UHD_DEVICE_ADDR_HPP */ diff --git a/include/usrp_uhd/quadradio/.gitignore b/include/usrp_uhd/quadradio/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/include/usrp_uhd/quadradio/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/include/usrp_uhd/quadradio/Makefile.am b/include/usrp_uhd/quadradio/Makefile.am new file mode 100644 index 000000000..66fc4dd71 --- /dev/null +++ b/include/usrp_uhd/quadradio/Makefile.am @@ -0,0 +1,7 @@ +# +# Copyright 2010 Ettus Research LLC +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = diff --git a/include/usrp_uhd/usrp/.gitignore b/include/usrp_uhd/usrp/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/include/usrp_uhd/usrp/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/include/usrp_uhd/usrp/Makefile.am b/include/usrp_uhd/usrp/Makefile.am new file mode 100644 index 000000000..913f80a6d --- /dev/null +++ b/include/usrp_uhd/usrp/Makefile.am @@ -0,0 +1,7 @@ +# +# Copyright 2010 Ettus Research LLC +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = mboard dboard diff --git a/include/usrp_uhd/usrp/dboard/.gitignore b/include/usrp_uhd/usrp/dboard/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/include/usrp_uhd/usrp/dboard/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/include/usrp_uhd/usrp/dboard/Makefile.am b/include/usrp_uhd/usrp/dboard/Makefile.am new file mode 100644 index 000000000..66fc4dd71 --- /dev/null +++ b/include/usrp_uhd/usrp/dboard/Makefile.am @@ -0,0 +1,7 @@ +# +# Copyright 2010 Ettus Research LLC +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = diff --git a/include/usrp_uhd/usrp/mboard/.gitignore b/include/usrp_uhd/usrp/mboard/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/include/usrp_uhd/usrp/mboard/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/include/usrp_uhd/usrp/mboard/Makefile.am b/include/usrp_uhd/usrp/mboard/Makefile.am new file mode 100644 index 000000000..66fc4dd71 --- /dev/null +++ b/include/usrp_uhd/usrp/mboard/Makefile.am @@ -0,0 +1,7 @@ +# +# Copyright 2010 Ettus Research LLC +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = diff --git a/include/usrp_uhd/wax.hpp b/include/usrp_uhd/wax.hpp new file mode 100644 index 000000000..9d32314f7 --- /dev/null +++ b/include/usrp_uhd/wax.hpp @@ -0,0 +1,129 @@ +// +// Copyright 2010 Ettus Research LLC +// + +#ifndef INCLUDED_WAX_HPP +#define INCLUDED_WAX_HPP + +#include <boost/any.hpp> +#include <boost/function.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/weak_ptr.hpp> +#include <boost/pointer_cast.hpp> +#include <iostream> + +/*! + * WAX - it's a metaphor! + * + * The WAX framework allows object to have generic/anytype properties. + * These properties can be addressed through generic/anytype identifiers. + * A property of a WAX object may even be another WAX object. + * + * When a property is a WAX object, the returned value must be an obj pointer. + * A WAX object provides two types of pointers: obj::ptr and obj::sptr. + * The choice of pointer vs smart pointer depends on the owner of the memory. + * + * Proprties may be referenced though the [] overloaded operator. + * The [] operator returns a special proxy that allows for assigment. + * Also, the [] operators may be chained as in the folowing examples: + * my_obj[prop1][prop2][prop3] = value + * value = my_obj[prop1][prop2][prop3] + * + * Any value returned from an access operation is of wax::type. + * To use this value, it must be cast with wax::cast<new_type>(value). + */ + +namespace wax{ + + //general typedefs + typedef boost::any type; + typedef boost::bad_any_cast bad_cast; + + //dummy class declarations + class obj; class proxy; + + /*! + * WAX object base class: + * A wax object subclass should override the set and get methods. + * The magic of operator chaining is handled by the [] operator. + */ + class obj{ + public: + //obj pointer typedefs + typedef boost::shared_ptr<obj> sptr; + typedef obj* ptr; + + //cast derived pointer to obj base class pointer + template <class T> static sptr cast(boost::shared_ptr<T> r){ + return boost::static_pointer_cast<obj>(r); + } + template <class T> static ptr cast(T *r){ + return dynamic_cast<ptr>(r); + } + + //structors + obj(void); + virtual ~obj(void); + + //public interface + proxy operator[](const type &key); + + private: + //private interface + virtual void get(const type &key, type &val) = 0; + virtual void set(const type &key, const type &val) = 0; + }; + + /*! + * WAX proxy class: + * Allows the obj [] operator to return a proxy result. + * This result can be assigned to via the = operator. + * Or this result can be called again with the [] operator. + */ + class proxy{ + public: + //destructors + ~proxy(void); + + //overloaded + type operator()(void); + proxy operator[](const type &key); + proxy operator=(const type &key); + + private: + //typedefs for callables from the object that built this proxy + typedef boost::function<void(const type &)> setter_t; + typedef boost::function<void(type &)> getter_t; + + //private contructor + proxy(getter_t, setter_t); + //access to private contructor + friend proxy obj::operator[](const type &key); + + getter_t d_getter; + setter_t d_setter; + }; + + /*! + * Cast a wax::type into the desired type + * Usage wax::cast<new_type>(my_value). + * + * \param val the any type to cast + * \return data of the desired type + * \throw wax::bad_cast when the cast fails + */ + template<typename T> T cast(const type & val){ + //special case to handle the proxy + if (val.type() == typeid(proxy)){ + return cast<T>(boost::any_cast<proxy>(val)()); + } + //do the type cast + return boost::any_cast<T>(val); + } + +} //namespace wax + +//ability to use types with stream operators +std::ostream& operator<<(std::ostream &os, const wax::type &x); + +#endif /* INCLUDED_WAX_HPP */ |