summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/apps/omap_debug/usrp-e-crc-rw.c37
-rw-r--r--host/apps/omap_debug/usrp-e-mm-loopback.c29
2 files changed, 45 insertions, 21 deletions
diff --git a/host/apps/omap_debug/usrp-e-crc-rw.c b/host/apps/omap_debug/usrp-e-crc-rw.c
index f91c4fa85..7f4ff0023 100644
--- a/host/apps/omap_debug/usrp-e-crc-rw.c
+++ b/host/apps/omap_debug/usrp-e-crc-rw.c
@@ -97,7 +97,7 @@ static void *read_thread(void *threadid)
struct pollfd pfd;
pfd.fd = fp;
pfd.events = POLLIN;
- ssize_t ret = poll(&pfd, 1, -1);
+ poll(&pfd, 1, -1);
}
(*rxi)[rb_read].flags = RB_USER_PROCESS;
@@ -136,7 +136,7 @@ static void *read_thread(void *threadid)
}
(*rxi)[rb_read].flags = RB_KERNEL;
-
+ write(fp, NULL, 1);
if (rx_crc != ck_sum)
printf("Ck_sum eror, calc ck_sum = %lX, rx ck_sum = %X\n",
@@ -176,6 +176,7 @@ static void *read_thread(void *threadid)
bytes_transfered = 0;
}
}
+ return NULL;
}
static void *write_thread(void *threadid)
@@ -185,6 +186,7 @@ static void *write_thread(void *threadid)
unsigned long crc;
unsigned long bytes_transfered;
struct timeval start_time;
+ unsigned int pkt_seq = 0;
__u8 *p;
printf("Greetings from the write thread!\n");
@@ -228,19 +230,27 @@ static void *write_thread(void *threadid)
struct pollfd pfd;
pfd.fd = fp;
pfd.events = POLLOUT;
- ssize_t ret = poll(&pfd, 1, -1);
+ poll(&pfd, 1, -1);
}
// printf("Got space\n");
+ for (i=8; i < tx_len-4; i++) {
+ p[i] = i & 0xFF;
+ }
+
+ *(unsigned int *) &p[0] = tx_len-4;
+ *(unsigned int *) &p[4] = pkt_seq;
+
+ pkt_seq++;
+
crc = 0xFFFFFFFF;
for (i = 0; i < tx_len-4; i++) {
- p[i] = i & 0xFF;
// printf("%X ", p[i]);
crc = ((crc >> 8) & 0x00FFFFFF) ^
crc_tab[(crc ^ p[i]) & 0xFF];
}
- *(int *) &p[tx_len-4] = crc;
+ *(unsigned int *) &p[tx_len-4] = crc;
// printf("\n crc = %lX\n", crc);
(*txi)[rb_write].len = tx_len;
@@ -273,13 +283,14 @@ static void *write_thread(void *threadid)
// sleep(1);
}
+ return NULL;
}
int main(int argc, char *argv[])
{
pthread_t tx, rx;
- long int t;
+ long int t=0;
int fpga_config_flag ,decimation;
int ret, map_size, page_size;
void *rb;
@@ -315,7 +326,7 @@ int main(int argc, char *argv[])
return -1;
}
- printf("rb = %X\n", rb);
+ printf("rb = %p\n", rb);
rxi = rb;
rx_buf = rb + (rb_size.num_pages_rx_flags * page_size);
@@ -325,13 +336,13 @@ int main(int argc, char *argv[])
(rb_size.num_rx_frames * page_size >> 1) +
(rb_size.num_pages_tx_flags * page_size);
- fpga_config_flag = 0;
+ fpga_config_flag = (1<<8);
if (strcmp(argv[1], "w") == 0)
- fpga_config_flag |= (1 << 15);
+ fpga_config_flag |= (1 << 11);
else if (strcmp(argv[1], "r") == 0)
- fpga_config_flag |= (1 << 14);
+ fpga_config_flag |= (1 << 10);
else if (strcmp(argv[1], "rw") == 0)
- fpga_config_flag |= ((1 << 15) | (1 << 14));
+ fpga_config_flag |= ((1 << 10) | (1 << 11));
fpga_config_flag |= decimation;
@@ -344,7 +355,7 @@ int main(int argc, char *argv[])
sched_setscheduler(0, SCHED_RR, &s);
- if (fpga_config_flag & (1 << 14)) {
+ if (fpga_config_flag & (1 << 10)) {
if (pthread_create(&rx, NULL, read_thread, (void *) t)) {
printf("Failed to create rx thread\n");
exit(-1);
@@ -353,7 +364,7 @@ int main(int argc, char *argv[])
sleep(1);
- if (fpga_config_flag & (1 << 15)) {
+ if (fpga_config_flag & (1 << 11)) {
if (pthread_create(&tx, NULL, write_thread, (void *) t)) {
printf("Failed to create tx thread\n");
exit(-1);
diff --git a/host/apps/omap_debug/usrp-e-mm-loopback.c b/host/apps/omap_debug/usrp-e-mm-loopback.c
index b67eecd21..14f68a5c3 100644
--- a/host/apps/omap_debug/usrp-e-mm-loopback.c
+++ b/host/apps/omap_debug/usrp-e-mm-loopback.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
@@ -7,6 +8,7 @@
#include <unistd.h>
#include <stddef.h>
#include <sys/mman.h>
+#include <sys/time.h>
#include <poll.h>
#include "usrp_e.h"
@@ -72,7 +74,7 @@ static void *read_thread(void *threadid)
struct pollfd pfd;
pfd.fd = fp;
pfd.events = POLLIN;
- ssize_t ret = poll(&pfd, 1, -1);
+ poll(&pfd, 1, -1);
}
(*rxi)[rb_read].flags = RB_USER_PROCESS;
@@ -95,7 +97,7 @@ static void *read_thread(void *threadid)
printf("Sequence number fail, current = %d, previous = %d, pkt_count = %d\n",
p->seq_num, prev_seq_num, pkt_count);
printf("pkt received, rb_read = %d\n", rb_read);
- printf("p = %X, p->seq_num = %d p->len = %d\n", p, p->seq_num, p->len);
+ printf("p = %p, p->seq_num = %d p->len = %d\n", p, p->seq_num, p->len);
seq_num_failure ++;
if (seq_num_failure > 2)
@@ -135,7 +137,7 @@ static void *read_thread(void *threadid)
// fflush(stdout);
// printf("\n");
}
-
+ return NULL;
}
static void *write_thread(void *threadid)
@@ -171,7 +173,7 @@ static void *write_thread(void *threadid)
struct pollfd pfd;
pfd.fd = fp;
pfd.events = POLLOUT;
- ssize_t ret = poll(&pfd, 1, -1);
+ poll(&pfd, 1, -1);
}
memcpy(&(*tx_buf)[rb_write], tx_data, p->len * 2 + 12);
@@ -188,18 +190,20 @@ static void *write_thread(void *threadid)
// printf("Error returned from write: %d\n", cnt);
// sleep(1);
}
+ return NULL;
}
int main(int argc, char *argv[])
{
pthread_t tx, rx;
- long int t;
+ long int t = 0;
struct sched_param s = {
.sched_priority = 1
};
int ret, map_size, page_size;
void *rb;
+ struct usrp_e_ctl16 d;
if (argc < 2) {
printf("%s data_size\n", argv[0]);
@@ -211,6 +215,11 @@ int main(int argc, char *argv[])
fp = open("/dev/usrp_e0", O_RDWR);
printf("fp = %d\n", fp);
+ d.offset = 14;
+ d.count = 1;
+ d.buf[0] = (1<<8) | (1<<9);
+ ioctl(fp, USRP_E_WRITE_CTL16, &d);
+
page_size = getpagesize();
ret = ioctl(fp, USRP_E_GET_RB_INFO, &rb_size);
@@ -224,7 +233,7 @@ int main(int argc, char *argv[])
return -1;
}
- printf("rb = %X\n", rb);
+ printf("rb = %p\n", rb);
rxi = rb;
rx_buf = rb + (rb_size.num_pages_rx_flags * page_size);
@@ -234,9 +243,11 @@ int main(int argc, char *argv[])
(rb_size.num_rx_frames * page_size >> 1) +
(rb_size.num_pages_tx_flags * page_size);
- printf("rxi = %X, rx_buf = %X, txi = %X, tx_buf = %X\n", rxi, rx_buf, txi, tx_buf);
+ printf("rxi = %p, rx_buf = %p, txi = %p, tx_buf = %p\n", rxi, rx_buf, txi, tx_buf);
+
+ if ((ret = sched_setscheduler(0, SCHED_RR, &s)))
+ perror("sched_setscheduler");
- sched_setscheduler(0, SCHED_RR, &s);
error = 0;
#if 1
@@ -257,4 +268,6 @@ int main(int argc, char *argv[])
sleep(1000000000);
printf("Done sleeping\n");
+
+ return 0;
}