aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authormichael-west <michael.west@ettus.com>2017-01-23 16:32:27 -0800
committerMartin Braun <martin.braun@ettus.com>2017-01-26 08:35:33 +0100
commitb99f94f65040363b25dc2db18b1d2b6a8575457f (patch)
treeaa1422c96925c5d2118a4e927929b8f3d0cad5e2 /host/lib
parent457e94dd2be98dece8215b993d94a11af55cba96 (diff)
downloaduhd-b99f94f65040363b25dc2db18b1d2b6a8575457f.tar.gz
uhd-b99f94f65040363b25dc2db18b1d2b6a8575457f.tar.bz2
uhd-b99f94f65040363b25dc2db18b1d2b6a8575457f.zip
X300: Fix issue with GPSDO sometimes not being recognized properly
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/x300/x300_fw_uart.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/host/lib/usrp/x300/x300_fw_uart.cpp b/host/lib/usrp/x300/x300_fw_uart.cpp
index 6e7425c4d..a2cbcc908 100644
--- a/host/lib/usrp/x300/x300_fw_uart.cpp
+++ b/host/lib/usrp/x300/x300_fw_uart.cpp
@@ -76,8 +76,9 @@ struct x300_uart_iface : uart_iface
if (rxoffset == _last_device_rxoffset)
return -1;
+ int ret = static_cast<int>(_rxcache[((rxoffset)/4) % poolsize] >> ((rxoffset%4)*8) & 0xFF);
rxoffset++;
- return static_cast<int>(_rxcache[(rxoffset/4) % poolsize] >> ((rxoffset%4)*8) & 0xFF);
+ return ret;
}
void update_cache(void)
@@ -91,30 +92,42 @@ struct x300_uart_iface : uart_iface
{
// all the data is new - reload the entire cache
for (uint32_t i = 0; i < poolsize; i++)
+ {
_rxcache[i] = _iface->peek32(SR_ADDR(rxpool, i));
+ }
+
+ // set the head to the same character as the current device
+ // offset (tail) one loop earlier
+ rxoffset = device_rxoffset - (poolsize*4);
+
+ // set the tail to the current device offset
+ _last_device_rxoffset = device_rxoffset;
- // set rxoffset to the end of the first string
- rxoffset = device_rxoffset - (poolsize*4) + 1;
- while (static_cast<char>((_rxcache[(rxoffset/4) % poolsize] >> ((rxoffset%4)*8) & 0xFF)) != '\n')
- ++rxoffset;
+ // the string at the head is a partial, so skip it
+ for (int c = getchar(); c != '\n' and c != -1; c = getchar()) {}
- // clear the partial string in the buffer;
+ // clear the partial string in the buffer, if any
_rxbuff.clear();
}
else if (rxoffset == _last_device_rxoffset)
{
// new data was added - refresh the portion of the cache that was updated
- for (uint32_t i = ((_last_device_rxoffset+1)/4) % poolsize; i != (((device_rxoffset)/4)+1) % poolsize; i = (i+1) % poolsize)
+ for (uint32_t i = (_last_device_rxoffset/4) % poolsize;
+ i != ((device_rxoffset/4)+1) % poolsize;
+ i = (i+1) % poolsize)
{
_rxcache[i] = _iface->peek32(SR_ADDR(rxpool, i));
}
- } else {
+
+ // set the tail to the current device offset
+ _last_device_rxoffset = device_rxoffset;
+ }
+ else
+ {
// there is new data, but we aren't done with what we have - check back later
break;
}
- _last_device_rxoffset = device_rxoffset;
-
// check again to see if anything changed while we were updating the cache
device_rxoffset = _iface->peek32(SR_ADDR(X300_FW_SHMEM_BASE, X300_FW_SHMEM_UART_RX_INDEX));
delta = device_rxoffset - rxoffset;