[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r6260 - gnuradio/branches/features/inband-usb/usrp/hos
From: |
gnychis |
Subject: |
[Commit-gnuradio] r6260 - gnuradio/branches/features/inband-usb/usrp/host/lib/inband |
Date: |
Sat, 1 Sep 2007 14:08:03 -0600 (MDT) |
Author: gnychis
Date: 2007-09-01 14:08:03 -0600 (Sat, 01 Sep 2007)
New Revision: 6260
Modified:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_channel.h
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_rx.h
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_server_cs.h
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.h
Log:
Merging from -r6240:6258 gnychis/inband to have complete up to date features
branch
Modified:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
===================================================================
---
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-09-01 19:26:38 UTC (rev 6259)
+++
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-09-01 20:08:03 UTC (rev 6260)
@@ -105,11 +105,13 @@
{
// Allocations should fail before open
d_tx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel, PMT_F),
+ pmt_list2(pmt_list2(s_response_allocate_channel,
+ s_err_usrp_not_opened),
pmt_from_long(1)));
d_rx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_list2(s_response_allocate_channel,PMT_F),
+ pmt_list2(pmt_list2(s_response_allocate_channel,
+ s_err_usrp_not_opened),
pmt_from_long(1)));
// Retrieve information about the USRP, then run tests
@@ -139,7 +141,7 @@
// should not be able to allocate max capacity after 100 bytes were allocated
d_tx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_from_long(usrp_server::RQSTD_CAPACITY_UNAVAIL),
+ pmt_list2(s_err_requested_capacity_unavailable,
pmt_from_long(d_max_capacity)));
// keep allocating a little more until all of the channels are used and test
@@ -156,14 +158,14 @@
// No more channels after allocating all of them is expected
d_tx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_from_long(usrp_server::CHANNEL_UNAVAIL),
+ pmt_list2(s_err_channel_unavailable,
pmt_from_long(1)));
// test out the same on the RX side
d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
d_rx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_from_long(usrp_server::RQSTD_CAPACITY_UNAVAIL),
+ pmt_list2(s_err_requested_capacity_unavailable,
pmt_from_long(d_max_capacity)));
for(int i=1; i < d_nrx_chan; i++) {
@@ -174,7 +176,7 @@
}
d_rx->send(s_cmd_allocate_channel,
- pmt_list2(pmt_from_long(usrp_server::CHANNEL_UNAVAIL),
+ pmt_list2(s_err_channel_unavailable,
pmt_from_long(1)));
// when all is said and done, there should be d_ntx_chan+d_ntx_chan bytes
@@ -403,7 +405,7 @@
d_tx->send(s_cmd_deallocate_channel,
pmt_list2(pmt_list2(s_response_deallocate_channel,
- pmt_from_long(usrp_server::PERMISSION_DENIED)),
+ s_err_channel_permission_denied),
pmt_from_long(d_tx_chans[i])));
d_ndealloc_to_recv++;
@@ -414,7 +416,7 @@
d_rx->send(s_cmd_deallocate_channel,
pmt_list2(pmt_list2(s_response_deallocate_channel,
- pmt_from_long(usrp_server::PERMISSION_DENIED)),
+ s_err_channel_permission_denied),
pmt_from_long(d_rx_chans[i])));
d_ndealloc_to_recv++;
@@ -426,12 +428,12 @@
d_ndealloc_to_recv+=2;
d_tx->send(s_cmd_deallocate_channel,
pmt_list2(pmt_list2(s_response_deallocate_channel,
- pmt_from_long(usrp_server::CHANNEL_INVALID)),
+ s_err_channel_invalid),
pmt_from_long(d_rx_chans.back()+1)));
d_rx->send(s_cmd_deallocate_channel,
pmt_list2(pmt_list2(s_response_deallocate_channel,
- pmt_from_long(usrp_server::CHANNEL_INVALID)),
+ s_err_channel_invalid),
pmt_from_long(d_rx_chans.back()+1)));
@@ -608,7 +610,8 @@
// std::cout << "[qa_open_close_top] Starting tests\n";
// A close before an open should fail
- d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_F)));
+ d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,
+ s_err_usrp_already_closed)));
// Perform an open, and a second open which should fail
d_cs->send(s_cmd_open,
@@ -616,14 +619,16 @@
pmt_from_long(0)));
d_cs->send(s_cmd_open,
- pmt_list2(pmt_list2(s_response_open,PMT_F),
+ pmt_list2(pmt_list2(s_response_open,
+ s_err_usrp_already_opened),
pmt_from_long(0)));
// A close should now be successful since the interface is open
d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T)));
// But, a second close should fail
- d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_F)));
+ d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,
+ s_err_usrp_already_closed)));
// Just to be thorough, try an open and close again
d_cs->send(s_cmd_open,
@@ -749,7 +754,8 @@
// A transmit before an open should fail
d_tx->send(s_cmd_xmit_raw_frame,
- pmt_list4(pmt_list2(s_response_xmit_raw_frame, PMT_F),
+ pmt_list4(pmt_list2(s_response_xmit_raw_frame,
+ s_err_usrp_not_opened),
pmt_from_long(0),
pmt_make_u32vector(transport_pkt::max_payload()/4, 0),
pmt_from_long(0)));
@@ -762,7 +768,7 @@
// Try to transmit on a channel that we have no allocation for
d_tx->send(s_cmd_xmit_raw_frame,
pmt_list4(pmt_list2(s_response_xmit_raw_frame,
-
pmt_from_long(usrp_server::PERMISSION_DENIED)),
+ s_err_channel_permission_denied),
pmt_from_long(0),
pmt_make_u32vector(transport_pkt::max_payload()/4, 0),
pmt_from_long(0)));
@@ -784,7 +790,8 @@
// After closing, a new transmit raw frame should fail again
d_tx->send(s_cmd_xmit_raw_frame,
- pmt_list4(pmt_list2(s_response_xmit_raw_frame, PMT_F),
+ pmt_list4(pmt_list2(s_response_xmit_raw_frame,
+ s_err_usrp_not_opened),
pmt_from_long(0),
pmt_make_u32vector(transport_pkt::max_payload()/4, 0),
pmt_from_long(0)));
@@ -797,7 +804,7 @@
d_tx->send(s_cmd_xmit_raw_frame,
pmt_list4(pmt_list2(s_response_xmit_raw_frame,
-
pmt_from_long(usrp_server::PERMISSION_DENIED)),
+ s_err_channel_permission_denied),
pmt_from_long(0),
pmt_make_u32vector(transport_pkt::max_payload()/4, 0),
pmt_from_long(0)));
Modified:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_channel.h
===================================================================
---
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_channel.h
2007-09-01 19:26:38 UTC (rev 6259)
+++
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_channel.h
2007-09-01 20:08:03 UTC (rev 6260)
@@ -31,4 +31,10 @@
static pmt_t s_response_allocate_channel =
pmt_intern("response-allocate-channel");
static pmt_t s_response_deallocate_channel =
pmt_intern("response-deallocate-channel");
+// Errors
+static pmt_t s_err_requested_capacity_unavailable =
pmt_intern("err-requested-capacity-unavailable");
+static pmt_t s_err_channel_unavailable = pmt_intern("err-channel-unavailable");
+static pmt_t s_err_channel_invalid = pmt_intern("err-channel-invalid");
+static pmt_t s_err_channel_permission_denied =
pmt_intern("err-channel-permission-denied");
+
#endif /* INCLUDED_SYMBOLS_USRP_CHANNEL_H */
Modified:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_rx.h
===================================================================
---
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_rx.h
2007-09-01 19:26:38 UTC (rev 6259)
+++
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_rx.h
2007-09-01 20:08:03 UTC (rev 6260)
@@ -30,4 +30,7 @@
// Incoming
static pmt_t s_response_recv_raw_samples =
pmt_intern("response-recv-raw-samples");
+// Errors
+static pmt_t s_err_already_receiving = pmt_intern("err-already-receiving");
+
#endif /* INCLUDED_SYMBOLS_USRP_RX_H */
Modified:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_server_cs.h
===================================================================
---
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_server_cs.h
2007-09-01 19:26:38 UTC (rev 6259)
+++
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/symbols_usrp_server_cs.h
2007-09-01 20:08:03 UTC (rev 6260)
@@ -39,4 +39,9 @@
static pmt_t s_response_nrx_chan = pmt_intern("response-nrx-chan");
static pmt_t s_response_current_capacity_allocation =
pmt_intern("response-current-capacity-allocation");
+// Errors
+static pmt_t s_err_usrp_not_opened = pmt_intern("err-usrp-not-opened");
+static pmt_t s_err_usrp_already_opened = pmt_intern("err-usrp-already-opened");
+static pmt_t s_err_usrp_already_closed = pmt_intern("err-usrp-already-closed");
+
#endif /* INCLUDED_SYMBOLS_USRP_SERVER_CS_H */
Modified:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc
2007-09-01 19:26:38 UTC (rev 6259)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.cc
2007-09-01 20:08:03 UTC (rev 6260)
@@ -97,24 +97,9 @@
d_rx_chan_mask = 0;
- // Initialize request ID's to 0
- d_op_ping_fixed_rid = 0;
- d_op_read_reg_rid = 0;
- d_op_i2c_read_rid = 0;
- d_op_spi_read_rid = 0;
+ for(int i=0; i < D_MAX_RID; i++)
+ d_rids.push_back(rid_info());
- for(int i=0; i < D_OP_PING_FIXED_MAX_RID; i++)
- d_op_ping_fixed_owners.push_back(PMT_NIL);
-
- for(int i=0; i < D_OP_READ_REG_MAX_RID; i++)
- d_op_read_reg_owners.push_back(PMT_NIL);
-
- for(int i=0; i < D_OP_I2C_READ_MAX_RID; i++)
- d_op_i2c_read_owners.push_back(PMT_NIL);
-
- for(int i=0; i < D_OP_SPI_READ_MAX_RID; i++)
- d_op_spi_read_owners.push_back(PMT_NIL);
-
//d_fake_rx=true;
}
@@ -262,7 +247,7 @@
// Reject if already open
if(d_opened) {
- d_cs->send(s_response_open, pmt_list2(invocation_handle, PMT_F));
+ d_cs->send(s_response_open, pmt_list2(invocation_handle,
s_err_usrp_already_opened));
return;
}
@@ -277,7 +262,7 @@
else if (pmt_eq(event, s_cmd_close)){
if(!d_opened) {
- d_cs->send(s_response_close, pmt_list2(invocation_handle, PMT_F));
+ d_cs->send(s_response_close, pmt_list2(invocation_handle,
s_err_usrp_already_closed));
return;
}
@@ -291,7 +276,7 @@
if(!d_opened) {
d_cs->send(s_response_max_capacity,
- pmt_list3(invocation_handle, PMT_F, pmt_from_long(0)));
+ pmt_list3(invocation_handle, s_err_usrp_not_opened,
pmt_from_long(0)));
return;
}
@@ -306,7 +291,7 @@
if(!d_opened) {
d_cs->send(s_response_ntx_chan,
- pmt_list3(invocation_handle, PMT_F, pmt_from_long(0)));
+ pmt_list3(invocation_handle, s_err_usrp_not_opened,
pmt_from_long(0)));
return;
}
@@ -321,7 +306,7 @@
if(!d_opened) {
d_cs->send(s_response_nrx_chan,
- pmt_list3(invocation_handle, PMT_F, pmt_from_long(0)));
+ pmt_list3(invocation_handle, s_err_usrp_not_opened,
pmt_from_long(0)));
return;
}
@@ -337,7 +322,7 @@
if(!d_opened) {
d_cs->send(s_response_current_capacity_allocation,
pmt_list3(invocation_handle,
- PMT_F,
+ s_err_usrp_not_opened,
pmt_from_long(0)));
return;
}
@@ -360,7 +345,7 @@
if(!d_opened) {
d_tx[port]->send(s_response_allocate_channel,
pmt_list3(invocation_handle,
- PMT_F,
+ s_err_usrp_not_opened,
pmt_from_long(0)));
return;
}
@@ -375,7 +360,7 @@
if(!d_opened) {
d_tx[port]->send(s_response_deallocate_channel,
pmt_list3(invocation_handle,
- PMT_F,
+ s_err_usrp_not_opened,
pmt_from_long(0)));
return;
}
@@ -389,7 +374,7 @@
if(!d_opened) {
d_tx[port]->send(s_response_xmit_raw_frame,
- pmt_list2(invocation_handle, PMT_F));
+ pmt_list2(invocation_handle, s_err_usrp_not_opened));
return;
}
@@ -402,7 +387,7 @@
if(!d_opened) {
d_tx[port]->send(s_response_xmit_raw_frame,
- pmt_list2(invocation_handle, PMT_F));
+ pmt_list2(invocation_handle, s_err_usrp_not_opened));
return;
}
@@ -423,7 +408,7 @@
if(!d_opened) {
d_rx[port]->send(s_response_allocate_channel,
pmt_list3(invocation_handle,
- PMT_F,
+ s_err_usrp_not_opened,
pmt_from_long(0)));
return;
}
@@ -438,7 +423,7 @@
if(!d_opened) {
d_rx[port]->send(s_response_deallocate_channel,
pmt_list3(invocation_handle,
- PMT_F,
+ s_err_usrp_not_opened,
pmt_from_long(0)));
return;
}
@@ -452,7 +437,7 @@
if(!d_opened) {
d_rx[port]->send(s_response_recv_raw_samples,
- pmt_list2(invocation_handle, PMT_F));
+ pmt_list2(invocation_handle, s_err_usrp_not_opened));
return;
}
@@ -529,7 +514,7 @@
// no capacity available
port->send(s_response_allocate_channel,
pmt_list3(invocation_handle,
- pmt_from_long(RQSTD_CAPACITY_UNAVAIL),
+ s_err_requested_capacity_unavailable,
PMT_NIL));
return;
}
@@ -568,7 +553,7 @@
// no free TX chan found
port->send(s_response_allocate_channel,
pmt_list3(invocation_handle,
- pmt_from_long(CHANNEL_UNAVAIL),
+ s_err_channel_unavailable,
PMT_NIL));
return;
}
@@ -712,22 +697,20 @@
long pingval = pmt_to_long(pmt_nth(1, subp_data));
// USRP server sets request ID's to keep track of which application gets
- // what response back. We do not handle wrap around, if we wrap before
we
- // got responses then they will be lost. The higher 3 bits will be the
- // user specified RID value, and the lower 3 bits will be the USRP server
- // marking.
- long srid = d_op_ping_fixed_rid++ % D_OP_PING_FIXED_MAX_RID;
- long rid = (
- ((urid & 0x07) << 3)
- | ((srid & 0x07)));
+ // what response back. To allow a full 6-bits for an RID to the user, we
+ // keep a mapping and replace the RID's as the packets go in and out. If
+ // there are no RID's available, the command is thrown away silently.
+ long srid;
+ if((srid = next_rid()) == -1)
+ goto subpkt_bail;
// We use a vector to store the owner of the ping request and will use it
- // to send the request on any RX port they own. There is currently no
way
- // for the requester to specify the RX port to receive the response on.
- d_op_ping_fixed_owners[srid] = port->port_symbol();
-
+ // to send the request on any RX port they own.
+ d_rids[srid].owner = port->port_symbol();
+ d_rids[srid].user_rid = urid;
+
// Adds a ping after the previous command in the pkt
- if(!pkt->cs_ping(rid, pingval))
+ if(!pkt->cs_ping(srid, pingval))
{
d_cs_usrp->send(s_cmd_usrp_write,
pmt_list3(invocation_handle,
@@ -735,8 +718,7 @@
v_packet));
// Return the RID
- d_op_ping_fixed_owners[srid] = PMT_NIL;
- d_op_ping_fixed_rid--;
+ d_rids[srid].owner = PMT_NIL;
goto new_packet;
}
@@ -798,14 +780,14 @@
long urid = pmt_to_long(pmt_nth(0, subp_data));
long reg_num = pmt_to_long(pmt_nth(1, subp_data));
- long srid = d_op_read_reg_rid++ % D_OP_READ_REG_MAX_RID;
- long rid = (
- ((urid & 0x07) << 3)
- | ((srid & 0x07)));
+ long srid;
+ if((srid = next_rid()) == -1)
+ goto subpkt_bail;
- d_op_read_reg_owners[srid] = port->port_symbol();
+ d_rids[srid].owner = port->port_symbol();
+ d_rids[srid].user_rid = urid;
- if(!pkt->cs_read_reg(rid, reg_num))
+ if(!pkt->cs_read_reg(srid, reg_num))
{
d_cs_usrp->send(s_cmd_usrp_write,
pmt_list3(invocation_handle,
@@ -813,8 +795,7 @@
v_packet));
// Return the rid
- d_op_read_reg_owners[srid] = PMT_NIL;
- d_op_read_reg_rid--;
+ d_rids[srid].owner = PMT_NIL;
goto new_packet;
}
@@ -878,14 +859,14 @@
long i2c_addr = pmt_to_long(pmt_nth(1, subp_data));
long i2c_bytes = pmt_to_long(pmt_nth(2, subp_data));
- long srid = d_op_i2c_read_rid++ % D_OP_I2C_READ_MAX_RID;
- long rid = (
- ((urid & 0x07) << 3)
- | ((srid & 0x07)));
+ long srid;
+ if((srid = next_rid()) == -1)
+ goto subpkt_bail;
+
+ d_rids[srid].owner = port->port_symbol();
+ d_rids[srid].user_rid = urid;
- d_op_i2c_read_owners[srid] = port->port_symbol();
-
- if(!pkt->cs_i2c_read(rid, i2c_addr, i2c_bytes))
+ if(!pkt->cs_i2c_read(srid, i2c_addr, i2c_bytes))
{
d_cs_usrp->send(s_cmd_usrp_write,
@@ -893,8 +874,7 @@
pmt_from_long(channel),
v_packet));
- d_op_i2c_read_owners[srid] = PMT_NIL;
- d_op_i2c_read_rid--;
+ d_rids[srid].owner = PMT_NIL;
goto new_packet;
}
@@ -939,16 +919,15 @@
long opt = pmt_to_long(pmt_nth(3, subp_data));
long n_bytes = pmt_to_long(pmt_nth(4, subp_data));
- // Generate an RID for the READ
- long srid = d_op_spi_read_rid % D_OP_SPI_READ_MAX_RID;
- long rid = (
- ((urid & 0x07) << 3)
- | ((srid & 0x07)));
-
- d_op_spi_read_owners[srid] = port->port_symbol();
+ long srid;
+ if((srid = next_rid()) == -1)
+ goto subpkt_bail;
+ d_rids[srid].owner = port->port_symbol();
+ d_rids[srid].user_rid = urid;
+
// Make the USB packet
- if(!pkt->cs_spi_read(rid, enables, format, opt, n_bytes))
+ if(!pkt->cs_spi_read(srid, enables, format, opt, n_bytes))
{
d_cs_usrp->send(s_cmd_usrp_write,
pmt_list3(invocation_handle,
@@ -956,8 +935,7 @@
v_packet));
// Return the rid
- d_op_spi_read_owners[srid] = PMT_NIL;
- d_op_spi_read_rid--;
+ d_rids[srid].owner = PMT_NIL;
goto new_packet;
}
@@ -966,6 +944,7 @@
std::cout << "[USRP_SERVER] Received SPI read\n";
}
+ subpkt_bail:
curr_subpkt++;
}
@@ -998,7 +977,7 @@
if(d_rx_chan_mask & (1 << channel)) {
port->send(s_response_recv_raw_samples,
pmt_list5(invocation_handle,
- pmt_from_long(ALREADY_RECV),
+ s_err_already_receiving,
PMT_NIL,
PMT_NIL,
PMT_NIL));
@@ -1118,6 +1097,16 @@
pmt_intern("rssi"),
pmt_from_long(pkt->rssi()));
+ if(pkt->overrun())
+ pmt_dict_set(properties,
+ pmt_intern("overrun"),
+ PMT_T);
+
+ if(pkt->underrun())
+ pmt_dict_set(properties,
+ pmt_intern("underrun"),
+ PMT_T);
+
d_rx[port]->send(s_response_recv_raw_samples,
pmt_list5(invocation_handle,
status,
@@ -1154,11 +1143,10 @@
//----------------- PING RESPONSE ------------------//
if(pmt_eq(op_symbol, s_op_ping_fixed_reply)) {
- long rid = pmt_to_long(pmt_nth(1, sub_packet));
+ long srid = pmt_to_long(pmt_nth(1, sub_packet));
pmt_t pingval = pmt_nth(2, sub_packet);
- long urid = (rid >> 3) & 0x7;
- long srid = rid & 0x7;
+ long urid = d_rids[srid].user_rid;
if(verbose)
std::cout << "[USRP_SERVER] Found ping response "
@@ -1169,10 +1157,10 @@
<< ")\n";
// Do some bounds checking incase of bogus/corrupt responses
- if(srid > D_OP_PING_FIXED_MAX_RID)
+ if(srid > D_MAX_RID)
return;
- pmt_t owner = d_op_ping_fixed_owners[srid];
+ pmt_t owner = d_rids[srid].owner;
// FIXME: should be 1 response for all subpackets here ?
if((port = tx_port_index(owner)) != -1)
@@ -1188,12 +1176,11 @@
//----------------- READ REG RESPONSE ------------------//
else if(pmt_eq(op_symbol, s_op_read_reg_reply)) {
- long rid = pmt_to_long(pmt_nth(1, sub_packet));
+ long srid = pmt_to_long(pmt_nth(1, sub_packet));
pmt_t reg_num = pmt_nth(2, sub_packet);
pmt_t reg_val = pmt_nth(3, sub_packet);
- long urid = (rid >> 3) & 0x7;
- long srid = rid & 0x7;
+ long urid = d_rids[srid].user_rid;
if(verbose)
std::cout << "[USRP_SERVER] Found read register response "
@@ -1205,10 +1192,10 @@
<< ")\n";
// Do some bounds checking to avoid seg faults
- if(srid > D_OP_READ_REG_MAX_RID)
+ if(srid > D_MAX_RID)
return;
- pmt_t owner = d_op_read_reg_owners[srid];
+ pmt_t owner = d_rids[srid].owner;
// FIXME: should be 1 response for all subpackets here ?
if((port = tx_port_index(owner)) != -1)
@@ -1225,12 +1212,11 @@
//------------------ I2C READ REPLY -------------------//
else if(pmt_eq(op_symbol, s_op_i2c_read_reply)) {
- long rid = pmt_to_long(pmt_nth(1, sub_packet));
+ long srid = pmt_to_long(pmt_nth(1, sub_packet));
pmt_t i2c_addr = pmt_nth(2, sub_packet);
pmt_t i2c_data = pmt_nth(3, sub_packet);
- long urid = (rid >> 3) & 0x7;
- long srid = rid & 0x7;
+ long urid = d_rids[srid].user_rid;
if(verbose)
std::cout << "[USRP_SERVER] Found i2c read reply "
@@ -1242,10 +1228,10 @@
<< ")\n";
// Do some bounds checking to avoid seg faults
- if(srid > D_OP_I2C_READ_MAX_RID)
+ if(srid > D_MAX_RID)
return;
- pmt_t owner = d_op_i2c_read_owners[srid];
+ pmt_t owner = d_rids[srid].owner;
if((port = tx_port_index(owner)) != -1)
d_tx[port]->send(s_response_from_control_channel,
@@ -1261,11 +1247,10 @@
//------------------ SPI READ REPLY -------------------//
else if(pmt_eq(op_symbol, s_op_spi_read_reply)) {
- long rid = pmt_to_long(pmt_nth(1, sub_packet));
+ long srid = pmt_to_long(pmt_nth(1, sub_packet));
pmt_t spi_data = pmt_nth(2, sub_packet);
- long urid = (rid >> 3) & 0x7;
- long srid = rid & 0x7;
+ long urid = d_rids[srid].user_rid;
if(verbose)
std::cout << "[USRP_SERVER] Found SPI read reply "
@@ -1276,10 +1261,10 @@
<< ")\n";
// Bounds check the RID
- if(srid > D_OP_SPI_READ_MAX_RID)
+ if(srid > D_MAX_RID)
return;
- pmt_t owner = d_op_spi_read_owners[srid];
+ pmt_t owner = d_rids[srid].owner;
if((port = tx_port_index(owner)) != -1)
d_tx[port]->send(s_response_from_control_channel,
@@ -1335,7 +1320,7 @@
if(channel >= (long)chan_info.size() && channel != 0x1f) {
port->send(response_signal,
pmt_list2(invocation_handle,
- pmt_from_long(CHANNEL_INVALID)));
+ s_err_channel_invalid));
if(verbose)
std::cout << "[USRP_SERVER] Invalid channel number for event "
@@ -1347,7 +1332,7 @@
if(chan_info[channel].owner != port->port_symbol()) {
port->send(response_signal,
pmt_list2(invocation_handle,
- pmt_from_long(PERMISSION_DENIED)));
+ s_err_channel_permission_denied));
if(verbose)
std::cout << "[USRP_SERVER] Invalid permissions"
@@ -1363,4 +1348,16 @@
return true;
}
+// Goes through the vector of RIDs and retreieves an
+// available one for use
+long
+usrp_server::next_rid()
+{
+ for(int i = 0; i < D_MAX_RID; i++)
+ if(pmt_eqv(d_rids[i].owner, PMT_NIL))
+ return i;
+
+ return -1;
+}
+
REGISTER_MBLOCK_CLASS(usrp_server);
Modified:
gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.h
===================================================================
--- gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.h
2007-09-01 19:26:38 UTC (rev 6259)
+++ gnuradio/branches/features/inband-usb/usrp/host/lib/inband/usrp_server.h
2007-09-01 20:08:03 UTC (rev 6260)
@@ -35,13 +35,6 @@
class usrp_server : public mb_mblock
{
public:
- enum error_codes {
- RQSTD_CAPACITY_UNAVAIL = 0,
- CHANNEL_UNAVAIL = 1,
- CHANNEL_INVALID = 2,
- PERMISSION_DENIED = 3,
- ALREADY_RECV = 4
- };
// our ports
enum port_types {
@@ -58,23 +51,20 @@
long d_ntx_chan;
long d_nrx_chan;
- // USRP server assigns and keeps track of request IDs.
- long d_op_ping_fixed_rid;
- static const long D_OP_PING_FIXED_MAX_RID = 8;
- std::vector<pmt_t> d_op_ping_fixed_owners;
-
- long d_op_read_reg_rid;
- static const long D_OP_READ_REG_MAX_RID = 8;
- std::vector<pmt_t> d_op_read_reg_owners;
+ // Keep track of the request IDs
+ struct rid_info {
+ pmt_t owner;
+ long user_rid;
- long d_op_i2c_read_rid;
- static const long D_OP_I2C_READ_MAX_RID = 8;
- std::vector<pmt_t> d_op_i2c_read_owners;
+ rid_info() {
+ owner = PMT_NIL;
+ user_rid = 0;
+ }
+ };
- long d_op_spi_read_rid;
- static const long D_OP_SPI_READ_MAX_RID = 8;
- std::vector<pmt_t> d_op_spi_read_owners;
-
+ static const long D_MAX_RID = 64;
+ std::vector<rid_info> d_rids;
+
struct channel_info {
long assigned_capacity; // the capacity currently assignedby the channel
pmt_t owner; // port ID of the owner of the channel
@@ -123,6 +113,7 @@
void handle_response_usrp_read(pmt_t data);
bool check_valid(mb_port_sptr port, long channel, std::vector<struct
channel_info> &chan_info, pmt_t signal_info);
void parse_control_pkt(pmt_t invocation_handle, transport_pkt *pkt);
+ long next_rid();
};
#endif /* INCLUDED_USRP_SERVER_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r6260 - gnuradio/branches/features/inband-usb/usrp/host/lib/inband,
gnychis <=