aboutsummaryrefslogtreecommitdiffstats
path: root/host/usrp_e_utils
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-06-15 14:50:02 -0700
committerJosh Blum <josh@joshknows.com>2011-06-15 14:50:02 -0700
commit0cef788d3d34a298c975e32c488e800a5c65ccce (patch)
tree14b7f4242a28927b1701a73a3e8ec0df3fa04811 /host/usrp_e_utils
parent7951170c6161d9266726ec19e8c009500cf11f75 (diff)
parent27f1622d439ceb787e7dada733d0eb82270c5532 (diff)
downloaduhd-0cef788d3d34a298c975e32c488e800a5c65ccce.tar.gz
uhd-0cef788d3d34a298c975e32c488e800a5c65ccce.tar.bz2
uhd-0cef788d3d34a298c975e32c488e800a5c65ccce.zip
Merge branch 'next'
Diffstat (limited to 'host/usrp_e_utils')
-rw-r--r--host/usrp_e_utils/usrp-e-loopback.c27
-rw-r--r--host/usrp_e_utils/usrp-e-timed.c2
2 files changed, 24 insertions, 5 deletions
diff --git a/host/usrp_e_utils/usrp-e-loopback.c b/host/usrp_e_utils/usrp-e-loopback.c
index 0bd3d3100..762e55ac8 100644
--- a/host/usrp_e_utils/usrp-e-loopback.c
+++ b/host/usrp_e_utils/usrp-e-loopback.c
@@ -51,12 +51,27 @@ static int calc_checksum(struct pkt *p)
return sum;
}
+static struct timeval delta_time(struct timeval f, struct timeval s)
+{
+ struct timeval d;
+
+ if (f.tv_usec > s.tv_usec) {
+ d.tv_usec = f.tv_usec - s.tv_usec;
+ d.tv_sec = f.tv_sec - s.tv_sec;
+ } else {
+ d.tv_usec = f.tv_usec - s.tv_usec + 1e6;
+ d.tv_sec = f.tv_sec - s.tv_sec - 1;
+ }
+
+ return d;
+}
+
static void *read_thread(void *threadid)
{
int cnt, prev_seq_num, pkt_count, seq_num_failure;
struct pkt *p;
- unsigned long bytes_transfered, elapsed_seconds;
- struct timeval start_time, finish_time;
+ unsigned long bytes_transfered;
+ struct timeval start_time;
int rb_read;
printf("Greetings from the reading thread!\n");
@@ -125,11 +140,15 @@ static void *read_thread(void *threadid)
bytes_transfered += cnt;
if (bytes_transfered > (100 * 1000000)) {
+ struct timeval finish_time, d_time;
+ float elapsed_seconds;
+
gettimeofday(&finish_time, NULL);
- elapsed_seconds = finish_time.tv_sec - start_time.tv_sec;
+ d_time = delta_time(finish_time, start_time);
+ elapsed_seconds = (float)d_time.tv_sec + ((float)d_time.tv_usec * 1e-6f);
printf("RX data transfer rate = %f K Samples/second\n",
- (float) bytes_transfered / (float) elapsed_seconds / 4000);
+ (float) bytes_transfered / elapsed_seconds / 4000.0f);
start_time = finish_time;
diff --git a/host/usrp_e_utils/usrp-e-timed.c b/host/usrp_e_utils/usrp-e-timed.c
index 06dfdf512..407564429 100644
--- a/host/usrp_e_utils/usrp-e-timed.c
+++ b/host/usrp_e_utils/usrp-e-timed.c
@@ -273,7 +273,7 @@ static void *write_thread(void *threadid)
d_time = delta_time(finish_time, start_time);
- elapsed_seconds = (float)d_time.tv_sec - ((float)d_time.tv_usec * 1e-6f);
+ elapsed_seconds = (float)d_time.tv_sec + ((float)d_time.tv_usec * 1e-6f);
printf("Bytes transfered = %ld, elapsed seconds = %f\n", bytes_transfered, elapsed_seconds);
printf("TX data transfer rate = %f K Samples/second\n",