aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-06-14 17:34:51 -0700
committerJosh Blum <josh@joshknows.com>2010-06-17 18:19:39 -0700
commite2bde1a9a38be9ca6c3bf3979d31c6a67904ab9a (patch)
treeddcba8005b04454f6efcac9c8312cdc6b450eef0
parent1db016bc6503cdca76025f131773e550bd895d48 (diff)
downloaduhd-e2bde1a9a38be9ca6c3bf3979d31c6a67904ab9a.tar.gz
uhd-e2bde1a9a38be9ca6c3bf3979d31c6a67904ab9a.tar.bz2
uhd-e2bde1a9a38be9ca6c3bf3979d31c6a67904ab9a.zip
usrp2: enlarged the i2c transaction size, rev-ed the firmware protocol number, added constants for packet sizes
-rw-r--r--host/lib/usrp/usrp2/fw_common.h8
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.cpp2
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp4
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp6
4 files changed, 11 insertions, 9 deletions
diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index 75f5b1779..242d268ec 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -32,9 +32,13 @@ extern "C" {
#define _SINS_
#endif
+// define limits on bytes per udp packet
+#define USRP2_MTU_BYTES 1500
+#define USRP2_UDP_BYTES ((USRP2_MTU_BYTES) - (2 + 14 + 20 + 8)) //size of headers (pad, eth, ip, udp)
+
//defines the protocol version in this shared header
//increment this value when the protocol is changed
-#define USRP2_PROTO_VERSION 3
+#define USRP2_PROTO_VERSION 4
//used to differentiate control packets over data port
#define USRP2_INVALID_VRT_HEADER 0
@@ -102,7 +106,7 @@ typedef struct{
struct {
_SINS_ uint8_t addr;
_SINS_ uint8_t bytes;
- _SINS_ uint8_t data[sizeof(_SINS_ uint32_t)];
+ _SINS_ uint8_t data[20];
} i2c_args;
struct {
_SINS_ uint32_t addr;
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp
index 6e0d3266a..83e98904e 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.cpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.cpp
@@ -146,7 +146,7 @@ public:
_ctrl_transport->send(boost::asio::buffer(&out_copy, sizeof(usrp2_ctrl_data_t)));
//loop until we get the packet or timeout
- boost::uint8_t usrp2_ctrl_data_in_mem[1500]; //allocate MTU bytes for recv
+ boost::uint8_t usrp2_ctrl_data_in_mem[USRP2_UDP_BYTES]; //allocate max bytes for recv
usrp2_ctrl_data_t *ctrl_data_in = reinterpret_cast<usrp2_ctrl_data_t *>(usrp2_ctrl_data_in_mem);
while(true){
size_t len = _ctrl_transport->recv(boost::asio::buffer(usrp2_ctrl_data_in_mem));
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index 0837f4ac4..36c264c3c 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -79,12 +79,12 @@ uhd::device_addrs_t usrp2::find(const device_addr_t &hint){
udp_transport->send(boost::asio::buffer(&ctrl_data_out, sizeof(ctrl_data_out)));
//loop and recieve until the timeout
- boost::uint8_t usrp2_ctrl_data_in_mem[1500]; //allocate MTU bytes for recv
+ boost::uint8_t usrp2_ctrl_data_in_mem[USRP2_UDP_BYTES]; //allocate max bytes for recv
usrp2_ctrl_data_t *ctrl_data_in = reinterpret_cast<usrp2_ctrl_data_t *>(usrp2_ctrl_data_in_mem);
while(true){
size_t len = udp_transport->recv(asio::buffer(usrp2_ctrl_data_in_mem));
//std::cout << len << "\n";
- if (len >= sizeof(usrp2_ctrl_data_t)){
+ if (len > offsetof(usrp2_ctrl_data_t, data)){
//handle the received data
switch(ntohl(ctrl_data_in->id)){
case USRP2_CTRL_ID_WAZZUP_DUDE:
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index ccc09003e..2126b9565 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -141,15 +141,13 @@ private:
/*******************************************************************
* Deal with the rx and tx packet sizes
******************************************************************/
- static const size_t _mtu = 1500; //FIXME we have no idea
- static const size_t _hdrs = (2 + 14 + 20 + 8); //size of headers (pad, eth, ip, udp)
static const size_t _max_rx_bytes_per_packet =
- _mtu - _hdrs -
+ USRP2_UDP_BYTES -
USRP2_HOST_RX_VRT_HEADER_WORDS32*sizeof(boost::uint32_t) -
USRP2_HOST_RX_VRT_TRAILER_WORDS32*sizeof(boost::uint32_t)
;
static const size_t _max_tx_bytes_per_packet =
- _mtu - _hdrs -
+ USRP2_UDP_BYTES -
uhd::transport::vrt::max_header_words32*sizeof(boost::uint32_t)
;