summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Balister <philip@opensdr.com>2010-09-21 19:47:32 +0000
committerPhilip Balister <philip@opensdr.com>2010-09-21 19:47:32 +0000
commit380889798a9a9b5319e708743c5bb216405f77f4 (patch)
treec3bb3cc974985a79980a043a045c90dee71deb1f
parentd6c4fbb29e818aec79864d25a0d308decb0db92d (diff)
downloaduhd-380889798a9a9b5319e708743c5bb216405f77f4.tar.gz
uhd-380889798a9a9b5319e708743c5bb216405f77f4.tar.bz2
uhd-380889798a9a9b5319e708743c5bb216405f77f4.zip
Convert write to use the mmap interface.
-rw-r--r--host/apps/omap_debug/usrp-e-mm-loopback.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/host/apps/omap_debug/usrp-e-mm-loopback.c b/host/apps/omap_debug/usrp-e-mm-loopback.c
index a1da926a2..81bdb410a 100644
--- a/host/apps/omap_debug/usrp-e-mm-loopback.c
+++ b/host/apps/omap_debug/usrp-e-mm-loopback.c
@@ -137,7 +137,7 @@ static void *read_thread(void *threadid)
static void *write_thread(void *threadid)
{
- int seq_number, i, cnt;
+ int seq_number, i, cnt, rb_write;
void *tx_data;
struct pkt *p;
@@ -151,6 +151,7 @@ static void *write_thread(void *threadid)
p->data[i] = i;
seq_number = 1;
+ rb_write = 0;
while (1) {
p->seq_num = seq_number++;
@@ -162,9 +163,26 @@ static void *write_thread(void *threadid)
p->checksum = calc_checksum(p);
- cnt = write(fp, tx_data, p->len * 2 + 12);
- if (cnt < 0)
- printf("Error returned from write: %d\n", cnt);
+ if (!((*txi)[rb_write].flags & RB_KERNEL)) {
+// printf("Waiting for space\n");
+ struct pollfd pfd;
+ pfd.fd = fp;
+ pfd.events = POLLOUT;
+ ssize_t ret = poll(&pfd, 1, -1);
+ }
+
+ memcpy(&(*tx_buf)[rb_write], tx_data, p->len * 2 + 12);
+
+ (*txi)[rb_write].len = p->len * 2 + 12;
+ (*txi)[rb_write].flags = RB_USER;
+
+ rb_write++;
+ if (rb_write == 100)
+ rb_write = 0;
+
+// cnt = write(fp, tx_data, p->len * 2 + 12);
+// if (cnt < 0)
+// printf("Error returned from write: %d\n", cnt);
// sleep(1);
}
}