diff options
author | Josh Blum <josh@joshknows.com> | 2010-03-29 12:58:06 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-03-29 12:58:06 -0700 |
commit | 1295df8cbba76c088a36f9d546a68c1d00e7a1a8 (patch) | |
tree | d8e0fdc72589d6d7614a14788caf31dbe6df6140 /host/include | |
parent | 7396b53e1bdd1aa5f9dcba760c8993a0cf620b6a (diff) | |
download | uhd-1295df8cbba76c088a36f9d546a68c1d00e7a1a8.tar.gz uhd-1295df8cbba76c088a36f9d546a68c1d00e7a1a8.tar.bz2 uhd-1295df8cbba76c088a36f9d546a68c1d00e7a1a8.zip |
Added utility methods to device addr and mac addr to make them more usable.
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/types/device_addr.hpp | 37 | ||||
-rw-r--r-- | host/include/uhd/types/dict.hpp | 7 | ||||
-rw-r--r-- | host/include/uhd/types/mac_addr.hpp | 35 |
3 files changed, 67 insertions, 12 deletions
diff --git a/host/include/uhd/types/device_addr.hpp b/host/include/uhd/types/device_addr.hpp index d32dfa77e..1162884fb 100644 --- a/host/include/uhd/types/device_addr.hpp +++ b/host/include/uhd/types/device_addr.hpp @@ -26,15 +26,40 @@ namespace uhd{ /*! - * The device address args are just a mapping of key/value string pairs. - * When left empty, the discovery routine will try to find all usrps. - * The discovery can be narrowed down by specifying the transport type arguments. + * Mapping of key/value pairs for locating devices on the system. + * When left empty, the device discovery routines will search + * all available transports on the system (ethernet, usb...). * - * For example, to access a specific usrp2 one would specify the transport type - * ("type", "udp") and the transport args ("addr", "<resolvable_hostname_or_addr>"). + * To narrow down the discovery process to a particular device, + * specify a transport key/value pair specific to your device. + * Ex, to find a usrp2: my_dev_addr["addr"] = <resolvable_hostname_or_ip> + * + * The device address can also be used to pass arguments into + * the transport layer control to set (for example) buffer sizes. */ class UHD_API device_addr_t : public dict<std::string, std::string>{ - public: std::string to_string(void) const; + public: + + /*! + * Convert a device address into a printable string. + * \return string good for use with std::cout << + */ + std::string to_string(void) const; + + /*! + * Convert the device address into an args string. + * The args string contains delimiter symbols. + * \return a string with delimiter markup + */ + std::string to_args_str(void) const; + + /*! + * Make a device address from an args string. + * The args string contains delimiter symbols. + * \param args_str the arguments string + * \return the new device address + */ + static device_addr_t from_args_str(const std::string &args_str); }; //handy typedef for a vector of device addresses diff --git a/host/include/uhd/types/dict.hpp b/host/include/uhd/types/dict.hpp index 5b9883704..7fb712e76 100644 --- a/host/include/uhd/types/dict.hpp +++ b/host/include/uhd/types/dict.hpp @@ -18,10 +18,11 @@ #ifndef INCLUDED_UHD_TYPES_DICT_HPP #define INCLUDED_UHD_TYPES_DICT_HPP -#include <list> -#include <vector> -#include <stdexcept> +#include <uhd/config.hpp> #include <boost/foreach.hpp> +#include <stdexcept> +#include <vector> +#include <list> namespace uhd{ diff --git a/host/include/uhd/types/mac_addr.hpp b/host/include/uhd/types/mac_addr.hpp index 2cac7d343..3cd1fe86b 100644 --- a/host/include/uhd/types/mac_addr.hpp +++ b/host/include/uhd/types/mac_addr.hpp @@ -28,10 +28,39 @@ namespace uhd{ * Wrapper for an ethernet mac address. * Provides conversion between string and binary formats. */ - struct UHD_API mac_addr_t{ - boost::uint8_t mac_addr[6]; - mac_addr_t(const std::string &mac_addr_str = "00:00:00:00:00:00"); + class UHD_API mac_addr_t{ + public: + static const size_t hlen = 6; + + /*! + * Create a mac address a byte array. + * \param bytes a pointer for the byte array + * \return a new mac address + */ + static mac_addr_t from_bytes(const boost::uint8_t *bytes); + + /*! + * Create a mac address from a string. + * \param mac_addr_str the string with delimiters + * \return a new mac address + */ + static mac_addr_t from_string(const std::string &mac_addr_str); + + /*! + * Get the byte representation of the mac address. + * \return a pointer to the internal byte array + */ + const boost::uint8_t *to_bytes(void) const; + + /*! + * Get the string representation of this mac address. + * \return a string with delimiters + */ std::string to_string(void) const; + + private: + mac_addr_t(const boost::uint8_t *bytes); //private constructor + boost::uint8_t _bytes[hlen]; //internal representation }; } //namespace uhd |