[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9017 - in usrp2/branches/features/host-ng/host-ng: ap
From: |
eb |
Subject: |
[Commit-gnuradio] r9017 - in usrp2/branches/features/host-ng/host-ng: apps lib |
Date: |
Fri, 25 Jul 2008 15:48:01 -0600 (MDT) |
Author: eb
Date: 2008-07-25 15:48:00 -0600 (Fri, 25 Jul 2008)
New Revision: 9017
Modified:
usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc
usrp2/branches/features/host-ng/host-ng/lib/control.h
usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc
usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.h
usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc
usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h
Log:
usrp2 work-in-progress
Modified: usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc 2008-07-25
21:09:39 UTC (rev 9016)
+++ usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc 2008-07-25
21:48:00 UTC (rev 9017)
@@ -111,6 +111,11 @@
usrp2::usrp2::sptr u2 = usrp2::usrp2::make(interface, mac_addr_str);
+ // FIXME in case it was left running...
+ if (!u2->stop_rx_streaming()){
+ fprintf(stderr, "stop_rx_streaming failed\n");
+ }
+
if (!u2->set_rx_gain(rx_gain)){
fprintf(stderr, "set_rx_gain(%f) failed\n", rx_gain);
exit(1);
Modified: usrp2/branches/features/host-ng/host-ng/lib/control.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/control.h 2008-07-25
21:09:39 UTC (rev 9016)
+++ usrp2/branches/features/host-ng/host-ng/lib/control.h 2008-07-25
21:48:00 UTC (rev 9017)
@@ -21,7 +21,6 @@
#include <omnithread.h>
#include <usrp2_eth_packet.h>
-#include <list>
namespace usrp2 {
/*!
Modified: usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc 2008-07-25
21:09:39 UTC (rev 9016)
+++ usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc 2008-07-25
21:48:00 UTC (rev 9017)
@@ -124,11 +124,12 @@
}
else {
d_using_tpring = true;
- d_buf = (uint8_t *)mmap(0, d_buflen, PROT_READ|PROT_WRITE, MAP_SHARED,
d_fd, 0);
- if (!d_buf) {
+ void *p = mmap(0, d_buflen, PROT_READ|PROT_WRITE, MAP_SHARED, d_fd, 0);
+ if (p == MAP_FAILED){
perror("eth_buffer: mmap");
return false;
}
+ d_buf = (uint8_t *) p;
if (ETH_BUFFER_DEBUG)
std::cerr << "eth_buffer: using kernel shared mem for buffer" <<
std::endl;
@@ -171,12 +172,12 @@
}
int
- eth_buffer::rx_frames(data_handler *f, int timeout)
+ eth_buffer::rx_frames(data_handler *f, int timeout_in_ms)
{
DEBUG_LOG("\n");
while (!frame_available()) {
- if (timeout == 0) {
+ if (timeout_in_ms == 0) {
DEBUG_LOG("w");
return 0; // would block
}
@@ -188,7 +189,7 @@
DEBUG_LOG("P");
- int pres = poll(&pfd, 1, timeout);
+ int pres = poll(&pfd, 1, timeout_in_ms);
if (pres == -1) {
perror("poll");
return -1;
@@ -240,7 +241,7 @@
eth_buffer::release_frame(void *base)
{
// Get d_frame_size aligned header
- tpacket_hdr *hdr = (tpacket_hdr *)((size_t)base & ~(d_frame_size-1));
+ tpacket_hdr *hdr = (tpacket_hdr *)((intptr_t)base & ~(d_frame_size-1));
hdr->tp_status = TP_STATUS_KERNEL; // mark it free
}
Modified: usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.h 2008-07-25
21:09:39 UTC (rev 9016)
+++ usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.h 2008-07-25
21:48:00 UTC (rev 9017)
@@ -106,7 +106,7 @@
/*!
* \brief Call \p f for each frame in the receive buffer.
* \param f is the frame data handler
- * \param timeout controls behavior when there are no frames to read
+ * \param timeout (in ms) controls behavior when there are no frames to
read
*
* If \p timeout is 0, rx_frames will not wait for frames if none are
* available, and f will not be invoked. If \p timeout is -1 (the
@@ -141,6 +141,15 @@
int rx_frames(data_handler *f, int timeout=-1);
/*
+ * \brief Release frame from buffer
+ *
+ * Call to release a frame previously held by a data_handler::KEEP.
+ * The pointer may be offset from the base of the frame up to its length.
+ */
+ void release_frame(void *p);
+
+
+ /*
* \brief Write an ethernet frame to the interface.
*
* \param base points to the beginning of the frame (the 14-byte ethernet
header).
@@ -175,14 +184,6 @@
*/
unsigned int max_frames() const { return d_frame_nr; }
- /*
- * \brief Release frame from buffer
- *
- * Call to release a frame previously held by a KEEP. The pointer
- * may be offset from the base of the frame up to its length.
- */
- void release_frame(void *p);
-
};
}; // namespace usrp2
Modified: usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc 2008-07-25
21:09:39 UTC (rev 9016)
+++ usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc 2008-07-25
21:48:00 UTC (rev 9017)
@@ -33,6 +33,7 @@
#include <stdexcept>
#include <iostream>
#include <stdio.h>
+#include <stddef.h>
#define USRP2_IMPL_DEBUG 0
#if USRP2_IMPL_DEBUG
@@ -236,7 +237,7 @@
u2_fxpt_freq_from_hilo(ntohl(reply.residual_freq_hi),
ntohl(reply.residual_freq_lo)));
- result->spectrum_inverted = (bool)(ntohs(reply.inverted) == 1);
+ result->spectrum_inverted = (bool)(ntohx(reply.inverted) == 1);
}
return success;
@@ -339,11 +340,13 @@
return false;
}
+#if 0 // don't be overzealous.
if (!d_channel_rings[channel]) {
std::cerr << "usrp2: channel " << channel
<< " not streaming" << std::endl;
return false;
}
+#endif
op_stop_rx_cmd cmd;
op_generic_t reply;
@@ -371,7 +374,7 @@
}
bool
- usrp2::impl::transmit_cmd(void *cmd, int len, pending_reply *p, double secs)
+ usrp2::impl::transmit_cmd(void *cmd, size_t len, pending_reply *p, double
secs)
{
if (p)
d_pending_replies[p->rid()] = p;
@@ -412,6 +415,7 @@
d_bg_pending_cond.wait();
}
}
+ d_bg_running = false;
}
data_handler::result
@@ -437,8 +441,7 @@
// point to beginning of payload (subpackets)
unsigned char *p = (unsigned char *)base + sizeof(u2_eth_packet_t);
- // FIXME iterate over payload, handling more than a single
- // subpacket, when (if?) the firmware starts sending them
+ // FIXME iterate over payload, handling more than a single subpacket.
//int opcode = p[0];
unsigned int oplen = p[1];
@@ -495,7 +498,7 @@
return 0; // discard packet, no channel handler
}
- size_t offset = (uint8_t *)(&pkt->samples) - (uint8_t *)base;
+ size_t offset = offsetof(u2_eth_samples_t, samples);
if (d_channel_rings[chan]->enqueue(&pkt->samples, len-offset)) {
inc_enqueued();
DEBUG_LOG("+");
@@ -548,7 +551,7 @@
DEBUG_LOG("-");
dec_enqueued();
- if (r && data_handler::DONE)
+ if (r & data_handler::DONE)
break;
}
Modified: usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h 2008-07-25
21:09:39 UTC (rev 9016)
+++ usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h 2008-07-25
21:48:00 UTC (rev 9017)
@@ -78,7 +78,7 @@
int word0_flags, int chan, uint32_t timestamp);
void stop_bg();
void init_config_rx_v2_cmd(op_config_rx_v2_cmd *cmd);
- bool transmit_cmd(void *cmd, int len, pending_reply *p, double secs=0.0);
+ bool transmit_cmd(void *cmd, size_t len, pending_reply *p, double
secs=0.0);
virtual data_handler::result operator()(const void *base, size_t len);
data_handler::result handle_control_packet(const void *base, size_t len);
data_handler::result handle_data_packet(const void *base, size_t len);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9017 - in usrp2/branches/features/host-ng/host-ng: apps lib,
eb <=