summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorPhilip Balister <philip@opensdr.com>2011-01-26 15:52:33 -0800
committerPhilip Balister <philip@opensdr.com>2011-01-26 15:52:33 -0800
commit867240ac5d9298fe971e9c7b9ba0bc02ac1dcfe4 (patch)
treeb12ce7365856f510fe03f6341d94f8b2d2f597a5 /host
parentb0ecd1c7d323eeb94754db7cbfef362e390a32d3 (diff)
downloaduhd-867240ac5d9298fe971e9c7b9ba0bc02ac1dcfe4.tar.gz
uhd-867240ac5d9298fe971e9c7b9ba0bc02ac1dcfe4.tar.bz2
uhd-867240ac5d9298fe971e9c7b9ba0bc02ac1dcfe4.zip
Start converting the timed test program to work with mmap interface.
Diffstat (limited to 'host')
-rw-r--r--host/apps/omap_debug/usrp-e-crc-rw.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/host/apps/omap_debug/usrp-e-crc-rw.c b/host/apps/omap_debug/usrp-e-crc-rw.c
index 7ae496fcd..9e3e7eb5d 100644
--- a/host/apps/omap_debug/usrp-e-crc-rw.c
+++ b/host/apps/omap_debug/usrp-e-crc-rw.c
@@ -52,7 +52,6 @@ static u_int32_t chksum_crc32_gentab(void)
static void *read_thread(void *threadid)
{
int cnt;
- struct usrp_transfer_frame *rx_data;
int rx_pkt_cnt, rb_read;
int i;
unsigned long crc;
@@ -65,8 +64,7 @@ static void *read_thread(void *threadid)
printf("Greetings from the reading thread!\n");
// IMPORTANT: must assume max length packet from fpga
- rx_data = malloc(2048);
-
+
rx_pkt_cnt = 0;
rb_read = 0;
@@ -75,12 +73,13 @@ static void *read_thread(void *threadid)
while (1) {
- if (!((*rxi)[rb_read].flags & RB_USER)) {
+ while (!((*rxi)[rb_read].flags & RB_USER)) {
struct pollfd pfd;
pfd.fd = fp;
pfd.events = POLLIN;
ssize_t ret = poll(&pfd, 1, -1);
}
+ (*rxi)[rb_read].flags = RB_USER_PROCESS;
rx_pkt_cnt++;
cnt = (*rxi)[rb_read].len;
@@ -91,12 +90,14 @@ static void *read_thread(void *threadid)
for (i = 0; i < cnt - 4; i+=2) {
crc = ((crc >> 8) & 0x00FFFFFF) ^
crc_tab[(crc ^ p[i+1]) & 0xFF];
-printf("idx = %d, data = %X, crc = %X\n", i, p[i+1],crc);
+//printf("idx = %d, data = %X, crc = %X\n", i, p[i+1],crc);
crc = ((crc >> 8) & 0x00FFFFFF) ^
crc_tab[(crc ^ p[i]) & 0xFF];
-printf("idx = %d, data = %X, crc = %X\n", i, p[i],crc);
+//printf("idx = %d, data = %X, crc = %X\n", i, p[i],crc);
}
+ (*rxi)[rb_read].flags = RB_KERNEL;
+
if (rx_crc != (crc & 0xFFFFFFFF)) {
printf("CRC Error, calc crc: %X, rx_crc: %X\n",
(crc & 0xFFFFFFFF), rx_crc);
@@ -145,6 +146,8 @@ static void *write_thread(void *threadid)
tx_pkt_cnt++;
p = tx_buf + (rb_write * 2048);
+// printf("p = %p\n", p);
+
if (packet_data_length > 0)
tx_len = packet_data_length;
else
@@ -166,12 +169,14 @@ static void *write_thread(void *threadid)
}
#endif
- if (!((*txi)[rb_write].flags & RB_KERNEL)) {
+// printf("Checking for space at rb entry = %d\n", rb_write);
+ while (!((*txi)[rb_write].flags & RB_KERNEL)) {
struct pollfd pfd;
pfd.fd = fp;
pfd.events = POLLOUT;
ssize_t ret = poll(&pfd, 1, -1);
}
+// printf("Got space\n");
crc = 0xFFFFFFFF;
for (i = 0; i < tx_len-4; i++) {
@@ -186,6 +191,10 @@ static void *write_thread(void *threadid)
(*txi)[rb_write].len = tx_len;
(*txi)[rb_write].flags = RB_USER;
+ rb_write++;
+ if (rb_write == rb_size.num_tx_frames)
+ rb_write = 0;
+
bytes_transfered += tx_len;
if (bytes_transfered > (100 * 1000000)) {
@@ -194,7 +203,7 @@ static void *write_thread(void *threadid)
printf("Bytes transfered = %d, elapsed seconds = %d\n", bytes_transfered, elapsed_seconds);
printf("TX data transfer rate = %f K Samples/second\n",
- (float) bytes_transfered / (float) elapsed_seconds / 250);
+ (float) bytes_transfered / (float) elapsed_seconds / 4000);
start_time = finish_time;