[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4942 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r4942 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband |
Date: |
Tue, 10 Apr 2007 14:17:36 -0600 (MDT) |
Author: gnychis
Date: 2007-04-10 14:17:35 -0600 (Tue, 10 Apr 2007)
New Revision: 4942
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
Log:
define the usb packet class in usrp_inband_usb_packet.h, and now define the
methods only in usrp_inband_usb_packet.cc
implemented the basics of cmd-xmit-raw-frame, create the USB packet, but have
no interface to send it over the USB bus yet
'tag' is not initialized properly in transmitting the raw frame, I am not sure
what to set it to
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.cc
2007-04-10 07:18:59 UTC (rev 4941)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.cc
2007-04-10 20:17:35 UTC (rev 4942)
@@ -20,113 +20,70 @@
*/
#include <usrp_bytesex.h>
#include <mb_mblock.h>
+#include <usrp_inband_usb_packet.h>
-static const int USB_PKT_SIZE = 512; // bytes
+void usrp_inband_usb_packet::set_timestamp(uint32_t timestamp){
+ d_timestamp = host_to_usrp_u32(timestamp);
+}
-class usrp_inband_usb_packet {
- //
- // keep raw packet in USRP-endian order
- //
- uint32_t d_word0;
- uint32_t d_timestamp;
- unsigned char d_payload[USB_PKT_SIZE-2*sizeof(uint32_t)];
+void usrp_inband_usb_packet::set_header(int flags, int chan, int tag, int
payload_len){
+ uint32_t word0 = ((flags & FL_ALL_FLAGS)
+ | ((chan & CHAN_MASK) << CHAN_SHIFT)
+ | ((tag & TAG_MASK) << TAG_SHIFT)
+ | ((payload_len & PAYLOAD_LEN_MASK) <<
PAYLOAD_LEN_SHIFT));
+ d_word0 = host_to_usrp_u32(word0);
+}
-public:
+uint32_t usrp_inband_usb_packet::timestamp() const {
+ return usrp_to_host_u32(d_timestamp);
+}
- enum flags {
- FL_OVERRUN = 0x80000000,
- FL_UNDERRUN = 0x40000000,
- FL_DROPPED = 0x20000000,
- FL_END_OF_BURST = 0x10000000,
- FL_START_OF_BURST = 0x08000000,
+int usrp_inband_usb_packet::rssi() const {
+ uint32_t word0 = usrp_to_host_u32(d_word0);
+ return (word0 >> RSSI_SHIFT) & RSSI_MASK;
+}
- FL_ALL_FLAGS = 0xf8000000
- };
+int usrp_inband_usb_packet::chan() const {
+ uint32_t word0 = usrp_to_host_u32(d_word0);
+ return (word0 >> CHAN_SHIFT) & CHAN_MASK;
+}
- static const int FL_OVERRUN_SHIFT = 31;
- static const int FL_UNDERRUN_SHIFT = 30;
- static const int FL_DROPPED_SHIFT = 29;
- static const int FL_END_OF_BURST_SHIFT = 28;
- static const int FL_START_OF_BURST_SHIFT = 27;
-
- static const int RSSI_MASK = 0x3f;
- static const int RSSI_SHIFT = 21;
+int usrp_inband_usb_packet::tag() const {
+ uint32_t word0 = usrp_to_host_u32(d_word0);
+ return (word0 >> TAG_SHIFT) & TAG_MASK;
+}
- static const int CHAN_MASK = 0x1f;
- static const int CHAN_SHIFT = 16;
+int usrp_inband_usb_packet::payload_len() const {
+ uint32_t word0 = usrp_to_host_u32(d_word0);
+ return (word0 >> PAYLOAD_LEN_SHIFT) & PAYLOAD_LEN_MASK;
+}
- static const int TAG_MASK = 0xf;
- static const int TAG_SHIFT = 9;
+int usrp_inband_usb_packet::flags() const {
+ return usrp_to_host_u32(d_word0) & FL_ALL_FLAGS;
+}
- static const int PAYLOAD_LEN_MASK = 0x1ff;
- static const int PAYLOAD_LEN_SHIFT = 0;
+int usrp_inband_usb_packet::overrun() const {
+ return (usrp_to_host_u32(d_word0) & FL_OVERRUN) >> FL_OVERRUN_SHIFT;
+}
-public:
-
- void set_timestamp(uint32_t timestamp){
- d_timestamp = host_to_usrp_u32(timestamp);
- }
- void set_header(int flags, int chan, int tag, int payload_len){
- uint32_t word0 = ((flags & FL_ALL_FLAGS)
- | ((chan & CHAN_MASK) << CHAN_SHIFT)
- | ((tag & TAG_MASK) << TAG_SHIFT)
- | ((payload_len & PAYLOAD_LEN_MASK) <<
PAYLOAD_LEN_SHIFT));
- d_word0 = host_to_usrp_u32(word0);
- }
-
- uint32_t timestamp() const {
- return usrp_to_host_u32(d_timestamp);
- }
+int usrp_inband_usb_packet::underrun() const {
+ return (usrp_to_host_u32(d_word0) & FL_UNDERRUN) >> FL_UNDERRUN_SHIFT;
+}
- int rssi() const {
- uint32_t word0 = usrp_to_host_u32(d_word0);
- return (word0 >> RSSI_SHIFT) & RSSI_MASK;
- }
- int chan() const {
- uint32_t word0 = usrp_to_host_u32(d_word0);
- return (word0 >> CHAN_SHIFT) & CHAN_MASK;
- }
+int usrp_inband_usb_packet::start_of_burst() const {
+ return (usrp_to_host_u32(d_word0) & FL_START_OF_BURST) >>
FL_START_OF_BURST_SHIFT;
+}
- int tag() const {
- uint32_t word0 = usrp_to_host_u32(d_word0);
- return (word0 >> TAG_SHIFT) & TAG_MASK;
- }
+int usrp_inband_usb_packet::end_of_burst() const {
+ return (usrp_to_host_u32(d_word0) & FL_END_OF_BURST) >>
FL_END_OF_BURST_SHIFT;
+}
- int payload_len() const {
- uint32_t word0 = usrp_to_host_u32(d_word0);
- return (word0 >> PAYLOAD_LEN_SHIFT) & PAYLOAD_LEN_MASK;
- }
-
- int flags() const {
- return usrp_to_host_u32(d_word0) & FL_ALL_FLAGS;
- }
+int usrp_inband_usb_packet::dropped() const {
+ return (usrp_to_host_u32(d_word0) & FL_DROPPED) >> FL_DROPPED_SHIFT;
+}
- int overrun() const {
- return (usrp_to_host_u32(d_word0) & FL_OVERRUN) >> FL_OVERRUN_SHIFT;
- }
-
-
- int underrun() const {
- return (usrp_to_host_u32(d_word0) & FL_UNDERRUN) >> FL_UNDERRUN_SHIFT;
- }
-
-
- int start_of_burst() const {
- return (usrp_to_host_u32(d_word0) & FL_START_OF_BURST) >>
FL_START_OF_BURST_SHIFT;
- }
-
- int end_of_burst() const {
- return (usrp_to_host_u32(d_word0) & FL_END_OF_BURST) >>
FL_END_OF_BURST_SHIFT;
- }
-
- int dropped() const {
- return (usrp_to_host_u32(d_word0) & FL_DROPPED) >> FL_DROPPED_SHIFT;
- }
-
- unsigned char *payload() {
- return d_payload;
- }
-
-};
+unsigned char *usrp_inband_usb_packet::payload() {
+ return d_payload;
+}
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
2007-04-10 07:18:59 UTC (rev 4941)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
2007-04-10 20:17:35 UTC (rev 4942)
@@ -19,3 +19,60 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+static const int USB_PKT_SIZE = 512; // bytes
+
+class usrp_inband_usb_packet {
+ //
+ // keep raw packet in USRP-endian order
+ //
+ uint32_t d_word0;
+ uint32_t d_timestamp;
+ unsigned char d_payload[USB_PKT_SIZE-2*sizeof(uint32_t)];
+
+public:
+
+ enum flags {
+ FL_OVERRUN = 0x80000000,
+ FL_UNDERRUN = 0x40000000,
+ FL_DROPPED = 0x20000000,
+ FL_END_OF_BURST = 0x10000000,
+ FL_START_OF_BURST = 0x08000000,
+
+ FL_ALL_FLAGS = 0xf8000000
+ };
+
+ static const int FL_OVERRUN_SHIFT = 31;
+ static const int FL_UNDERRUN_SHIFT = 30;
+ static const int FL_DROPPED_SHIFT = 29;
+ static const int FL_END_OF_BURST_SHIFT = 28;
+ static const int FL_START_OF_BURST_SHIFT = 27;
+
+ static const int RSSI_MASK = 0x3f;
+ static const int RSSI_SHIFT = 21;
+
+ static const int CHAN_MASK = 0x1f;
+ static const int CHAN_SHIFT = 16;
+
+ static const int TAG_MASK = 0xf;
+ static const int TAG_SHIFT = 9;
+
+ static const int PAYLOAD_LEN_MASK = 0x1ff;
+ static const int PAYLOAD_LEN_SHIFT = 0;
+
+public:
+
+ void set_timestamp(uint32_t timestamp);
+ void set_header(int flags, int chan, int tag, int payload_len);
+ uint32_t timestamp() const;
+ int rssi() const;
+ int chan() const;
+ int tag() const;
+ int payload_len() const;
+ int flags() const;
+ int overrun() const;
+ int underrun() const;
+ int start_of_burst() const;
+ int end_of_burst() const;
+ int dropped() const;
+ unsigned char *payload();
+};
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-04-10 07:18:59 UTC (rev 4941)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-04-10 20:17:35 UTC (rev 4942)
@@ -23,6 +23,7 @@
#include <config.h>
#endif
#include <usrp_server.h>
+#include <usrp_inband_usb_packet.h>
// FIXME We should machine generate these by a simple preprocessor run over
this file
@@ -197,7 +198,32 @@
d_cs->send(s_response_deallocate_channel, reply_data); // respond
return;
}
+
+ if (pmt_eq(event, s_cmd_xmit_raw_frame)){
+ invocation_handle = pmt_nth(0, data); // get the
invocation handle to pass back to client
+ long channel_number = pmt_to_long(pmt_nth(1, data)); // the channel to
deallocate
+ // Read the samples, which are in a uniform numeric vector and find the
number of samples
+ size_t num_samples;
+ uint32_t *samples = (uint32_t *) pmt_uniform_vector_elements(pmt_nth(2,
data), num_samples);
+ long payload_len = num_samples * sizeof(uint32_t);
+
+ long timestamp = pmt_to_long(pmt_nth(3, data)); // the timestamp to
send the samples to the D/A converter
+
+ usrp_inband_usb_packet usb_packet; // lets make a
packet!
+
+ // Set the header of the packet... what should 'tag' be set to here?
+ usb_packet.set_header(0, channel_number, 0, payload_len);
+ usb_packet.set_timestamp(timestamp);
+ memcpy(usb_packet.payload(), samples, payload_len);
+
+ // interface with the USRP to send the USB packet
+
+ reply_data = pmt_list2(invocation_handle, PMT_T);
+ d_cs->send(s_response_xmit_raw_frame, reply_data); // respond
+ return;
+ }
+
unhandled:
std::cout << "unhandled msg: " << msg << std::endl;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4942 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband,
gnychis <=