diff options
author | Josh Blum <josh@joshknows.com> | 2011-06-15 10:37:40 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-06-15 10:37:40 -0700 |
commit | ff143516a8371aca85144887caabec91e5d8801e (patch) | |
tree | 6a18f342d465499efa50b235fe5718f728dd35cb /host | |
parent | ed3439eebb51ab5ef8f184624212ded30a8544bb (diff) | |
parent | a6ca4778f8ae05b7f24e8c64bd58d7f39b3a9c14 (diff) | |
download | uhd-ff143516a8371aca85144887caabec91e5d8801e.tar.gz uhd-ff143516a8371aca85144887caabec91e5d8801e.tar.bz2 uhd-ff143516a8371aca85144887caabec91e5d8801e.zip |
Merge branch 'philip/e100-fpga-test-fixes' into next
Diffstat (limited to 'host')
-rw-r--r-- | host/usrp_e_utils/usrp-e-loopback.c | 27 | ||||
-rw-r--r-- | host/usrp_e_utils/usrp-e-timed.c | 2 |
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", |