[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5539 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5539 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband |
Date: |
Fri, 25 May 2007 10:36:59 -0600 (MDT) |
Author: gnychis
Date: 2007-05-25 10:36:59 -0600 (Fri, 25 May 2007)
New Revision: 5539
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_usrp_inband.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
Log:
Misinterpreted nchan in the make of standard tx and rx as the channel number
when it is the number of active channels, since 0 is not a valid active channel
number, I though channels started at 1.
Reverted the interpretation of channels from 1,2,3... back to 0,1,2...
This also explains the FIXME, since the active channels are initialized with
one 'make' and not one for each channel. Therefore there is only 1 handle for
all TX channels, and 1 for all RX channels.
Fixed bug in computing the number of bytes to write to the bus, was using
n_bytes which represented the size of the data the caller wanted to send which
is incorrect since it does not account for header size of each USB packet. I
compensated in the test code by using max_pkt_size() for the number of bytes
for the payload, which was incorrect. This was reverted back and the
computation of bytes over the USB bus is correct now as
n_packets*max_pkt_size() (also accounts for padding).
Tested in hardware.
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-05-25 13:11:31 UTC (rev 5538)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-05-25 16:36:59 UTC (rev 5539)
@@ -551,19 +551,19 @@
d_xmit_to_recv++;
// Test 2: 1 packet, of exact size... since we are using 32-bit samples we
divide by 4
- d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(1),
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_pkt_size()/4,
0), pmt_from_long(0)));
+ d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(1),
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_payload()/4,
0), pmt_from_long(0)));
d_xmit_to_recv++;
// Test 3: 2 packets, a spill over of 1 sample into the second packet
- d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(2),
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_pkt_size()/4+1,
0), pmt_from_long(0)));
+ d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(2),
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_payload()/4+1,
0), pmt_from_long(0)));
d_xmit_to_recv++;
// Test 4: 2 packets of exact payload size
- d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(2),
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_pkt_size()/4*2,
0), pmt_from_long(0)));
+ d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(2),
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_payload()/4*2,
0), pmt_from_long(0)));
d_xmit_to_recv++;
// Test 4: 2 full packets, and 1 packet with a single sample (which is 3)
- d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(3),
pmt_from_long(d_tx_chan),
pmt_make_u32vector(transport_pkt::max_pkt_size()/4*2+1, 0), pmt_from_long(0)));
+ d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(3),
pmt_from_long(d_tx_chan),
pmt_make_u32vector(transport_pkt::max_payload()/4*2+1, 0), pmt_from_long(0)));
d_xmit_to_recv++;
}
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_usrp_inband.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_usrp_inband.cc
2007-05-25 13:11:31 UTC (rev 5538)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_usrp_inband.cc
2007-05-25 16:36:59 UTC (rev 5539)
@@ -210,7 +210,7 @@
test_usrp_inband_top::send_packets()
{
std::cout << "[TEST_USRP_INBAND_TOP] Sending single packet..\n";
- d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(1),
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_pkt_size()/4,
0), pmt_from_long(0)));
+ d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(pmt_from_long(1),
pmt_from_long(d_tx_chan), pmt_make_u32vector(transport_pkt::max_payload()/4,
0), pmt_from_long(0)));
}
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-05-25 13:11:31 UTC (rev 5538)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-05-25 16:36:59 UTC (rev 5539)
@@ -32,7 +32,7 @@
typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit
easy
-//#define FAKE_USRP_TESTS
+#define FAKE_USRP_TESTS
// FIXME We should machine generate these by a simple preprocessor run over
this file
//
@@ -141,7 +141,7 @@
// Initialize capacity on each channel to 0 and to no owner
// Also initialize the USRP standard tx/rx pointers to NULL
- for(int chan=1; chan <= d_ntx_chan; chan++) {
+ for(int chan=0; chan < d_ntx_chan; chan++) {
d_chaninfo_tx[chan].assigned_capacity = 0;
d_chaninfo_tx[chan].owner = PMT_NIL;
}
@@ -161,7 +161,7 @@
d_nrx_chan = pmt_to_long(chans);
- for(int chan=1; chan <= d_nrx_chan; chan++) {
+ for(int chan=0; chan < d_nrx_chan; chan++) {
d_chaninfo_rx[chan].assigned_capacity = 0;
d_chaninfo_rx[chan].owner = PMT_NIL;
}
@@ -367,10 +367,10 @@
long usrp_server::current_capacity_allocation() {
long capacity = 0;
- for(int chan=1; chan <= d_ntx_chan; chan++)
+ for(int chan=0; chan < d_ntx_chan; chan++)
capacity += d_chaninfo_tx[chan].assigned_capacity;
- for(int chan=1; chan <= d_nrx_chan; chan++)
+ for(int chan=0; chan < d_nrx_chan; chan++)
capacity += d_chaninfo_rx[chan].assigned_capacity;
return capacity;
@@ -395,7 +395,7 @@
}
// Find a free channel, assign the capacity and respond
- for(chan=1; chan <= d_ntx_chan; chan++) {
+ for(chan=0; chan < d_ntx_chan; chan++) {
if(d_chaninfo_tx[chan].owner == PMT_NIL) {
d_chaninfo_tx[chan].owner = port_id;
d_chaninfo_tx[chan].assigned_capacity = rqstd_capacity;
@@ -421,7 +421,7 @@
return;
}
- for(chan=1; chan <= d_nrx_chan; chan++) {
+ for(chan=0; chan < d_nrx_chan; chan++) {
if(d_chaninfo_rx[chan].owner == PMT_NIL) {
d_chaninfo_rx[chan].owner = port_id;
d_chaninfo_rx[chan].assigned_capacity = rqstd_capacity;
@@ -452,7 +452,7 @@
// of the channel, and if so remove the assigned capacity.
if((port = tx_port_index(port_id)) != -1) {
- if(channel > d_ntx_chan) {
+ if(channel >= d_ntx_chan) {
reply_data = pmt_list2(invocation_handle,
pmt_from_long(CHANNEL_INVALID)); // not a legit channel number
d_tx[port]->send(s_response_deallocate_channel, reply_data);
return;
@@ -475,7 +475,7 @@
// Repeated process on the RX side
if((port = rx_port_index(port_id)) != -1) {
- if(channel > d_nrx_chan) {
+ if(channel >= d_nrx_chan) {
reply_data = pmt_list2(invocation_handle,
pmt_from_long(CHANNEL_INVALID)); // not a legit channel number
d_rx[port]->send(s_response_deallocate_channel, reply_data);
return;
@@ -514,7 +514,7 @@
// of the channel to send the frame
if((port = tx_port_index(port_id)) != -1) {
- if(channel > d_ntx_chan) {
+ if(channel >= d_ntx_chan) {
reply_data = pmt_list2(invocation_handle,
pmt_from_long(CHANNEL_INVALID)); // not a legit channel number
d_tx[port]->send(s_response_xmit_raw_frame, reply_data);
return;
@@ -565,7 +565,7 @@
#else
// The actual response to the write will be generated by a
s_response_usrp_write
- d_cs_usrp->send(s_cmd_usrp_write, pmt_list4(PMT_NIL,
pmt_from_long(channel), v_packets, pmt_from_long(n_bytes)));
+ d_cs_usrp->send(s_cmd_usrp_write, pmt_list4(PMT_NIL,
pmt_from_long(channel), v_packets,
pmt_from_long(n_packets*transport_pkt::max_pkt_size())));
#endif
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
2007-05-25 13:11:31 UTC (rev 5538)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.cc
2007-05-25 16:36:59 UTC (rev 5539)
@@ -53,12 +53,8 @@
d_ntx_chan = 2;
d_nrx_chan = 2;
- // Initialize NULLs for the channel pointers
- for(int i=0; i < d_ntx_chan+1; i++) // +1 as the channels start at 1
- d_utx.push_back(NULL);
-
- for(int i=0; i < d_nrx_chan+1; i++)
- d_urx.push_back(NULL);
+ d_utx = NULL;
+ d_urx = NULL;
}
usrp_usb_interface::~usrp_usb_interface()
@@ -123,64 +119,56 @@
// Open up a standard RX and TX for communication with the USRP
- // I'm not sure if i should be opening up all RX and TX channels, but given
that
- // one is not specified in the signal, I am assuming so.
- //
- // FIXME: usrp_open_interface:usb_claim_interface: failed interface 1
- // ... when trying to open two channels
- for(int chan=1; chan < d_ntx_chan; chan++) {
- d_utx[chan] = usrp_standard_tx::make (which_usrp,
- 16, // interp = 32.0MB/s
- chan,
- -1, // mux
- 4096, // USB block size
- 16); // number of blocks for async transfers
+ d_utx = usrp_standard_tx::make (which_usrp,
+ 16, // interp = 32.0MB/s
+ 2,
+ -1, // mux
+ 4096, // USB block size
+ 16); // number of blocks for async transfers
- if(!d_utx[chan]) {
- std::cout << "[USRP_USB_INTERFACE] Failed to open channel " << chan <<
"\n";
- reply_data = pmt_list2(invocation_handle, PMT_F);
- d_cs->send(s_response_usrp_open, reply_data);
- return;
- }
+ if(!d_utx) {
+ std::cout << "[USRP_USB_INTERFACE] Failed to open TX\n";
+ reply_data = pmt_list2(invocation_handle, PMT_F);
+ d_cs->send(s_response_usrp_open, reply_data);
+ return;
+ }
- if(!d_utx[chan]->set_tx_freq (0,0)) { // try setting center freq to 0
- std::cout << "[USRP_USB_INTERFACE] Failed to set center frequency on
channel " << chan << "\n";
- reply_data = pmt_list2(invocation_handle, PMT_F);
- d_cs->send(s_response_usrp_open, reply_data);
- return;
- }
-
- std::cout << "[USRP_USB_INTERFACE] Setup TX channel " << chan << ",
running...";
- d_utx[chan]->start(); // not sure if this is the appropriate place to
start yet
- std::cout << "done!\n";
+ if(!d_utx->set_tx_freq (0,0)) { // try setting center freq to 0
+ std::cout << "[USRP_USB_INTERFACE] Failed to set center frequency on TX\n";
+ reply_data = pmt_list2(invocation_handle, PMT_F);
+ d_cs->send(s_response_usrp_open, reply_data);
+ return;
}
- for(int chan=1; chan < d_nrx_chan; chan++) {
- d_urx[chan] = usrp_standard_rx::make (which_usrp,
- 16, // interp = 32.0MB/s
- chan,
- -1, // mux
- 4096, // USB block size
- 16); // number of blocks for async transfers
- if(!d_urx[chan]) {
- std::cout << "[usrp_server] Failed to open channel " << chan << "\n";
- reply_data = pmt_list2(invocation_handle, PMT_F);
- d_cs->send(s_response_usrp_open, reply_data);
- return;
- }
+ std::cout << "[USRP_USB_INTERFACE] Setup TX channel running...";
+ d_utx->start(); // not sure if this is the appropriate place to start yet
+ std::cout << "done!\n";
- if(!d_urx[chan]->set_rx_freq (0,0)) { // try setting center freq to 0
- std::cout << "[usrp_server] Failed to set center frequency on channel "
<< chan << "\n";
- reply_data = pmt_list2(invocation_handle, PMT_F);
- d_cs->send(s_response_usrp_open, reply_data);
- return;
- }
+ d_urx = usrp_standard_rx::make (which_usrp,
+ 16, // interp = 32.0MB/s
+ 2,
+ -1, // mux
+ 4096, // USB block size
+ 16); // number of blocks for async transfers
- std::cout << "[USRP_USB_INTERFACE] Setup RX channel " << chan << ",
running...";
- d_urx[chan]->start(); // not sure if this is the appropriate place to
start yet
- std::cout << "done!\n";
+ if(!d_urx) {
+ std::cout << "[usrp_server] Failed to open RX\n";
+ reply_data = pmt_list2(invocation_handle, PMT_F);
+ d_cs->send(s_response_usrp_open, reply_data);
+ return;
}
+ if(!d_urx->set_rx_freq (0,0)) { // try setting center freq to 0
+ std::cout << "[usrp_server] Failed to set center frequency on RX\n";
+ reply_data = pmt_list2(invocation_handle, PMT_F);
+ d_cs->send(s_response_usrp_open, reply_data);
+ return;
+ }
+
+ std::cout << "[USRP_USB_INTERFACE] Setup RX, running...";
+ d_urx->start(); // not sure if this is the appropriate place to start yet
+ std::cout << "done!\n";
+
d_cs->send(s_response_usrp_open, pmt_list2(invocation_handle, PMT_T));
}
@@ -197,7 +185,7 @@
transport_pkt *pkts = (transport_pkt *)
pmt_u8vector_writeable_elements(v_packets, psize);
- int ret = d_utx[channel]->write (pkts, n_bytes, &underrun);
+ int ret = d_utx->write (pkts, n_bytes, &underrun);
if (ret == n_bytes) {
std::cout << "[usrp_server] Write of " << n_bytes << " successful\n";
@@ -222,15 +210,13 @@
std::cout << "[usrp_usb_interface] Handling close request for USRP\n";
- // Go through and close all of the channels by deleting them
+ delete d_utx;
- for(int chan=0; chan < d_ntx_chan; chan++)
- delete d_utx[chan];
+ delete d_urx;
- for(int chan=0; chan < d_nrx_chan; chan++)
- delete d_urx[chan];
-
d_cs->send(s_response_usrp_close, pmt_list2(invocation_handle, PMT_T));
+
+ shutdown_all(PMT_T);
}
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
2007-05-25 13:11:31 UTC (rev 5538)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_usb_interface.h
2007-05-25 16:36:59 UTC (rev 5539)
@@ -32,8 +32,8 @@
{
public:
- std::vector<usrp_standard_tx*> d_utx;
- std::vector<usrp_standard_rx*> d_urx;
+ usrp_standard_tx* d_utx;
+ usrp_standard_rx* d_urx;
mb_port_sptr d_cs;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5539 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband,
gnychis <=