[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5665 - in gnuradio/branches/developers/gnychis/inband
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5665 - in gnuradio/branches/developers/gnychis/inband: pmt/src/lib usrp/host/lib/inband |
Date: |
Mon, 4 Jun 2007 11:02:48 -0600 (MDT) |
Author: gnychis
Date: 2007-06-04 11:02:48 -0600 (Mon, 04 Jun 2007)
New Revision: 5665
Modified:
gnuradio/branches/developers/gnychis/inband/pmt/src/lib/pmt.cc
gnuradio/branches/developers/gnychis/inband/pmt/src/lib/pmt.h
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
Log:
Checking in intermediate RX code
Added a pmt_list5() since the start receiving samples signal has 5 items which
will be used in many places.
Modified: gnuradio/branches/developers/gnychis/inband/pmt/src/lib/pmt.cc
===================================================================
--- gnuradio/branches/developers/gnychis/inband/pmt/src/lib/pmt.cc
2007-06-04 16:59:10 UTC (rev 5664)
+++ gnuradio/branches/developers/gnychis/inband/pmt/src/lib/pmt.cc
2007-06-04 17:02:48 UTC (rev 5665)
@@ -938,6 +938,12 @@
}
pmt_t
+pmt_list5(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4, pmt_t x5)
+{
+ return pmt_cons(x1, pmt_cons(x2, pmt_cons(x3, pmt_cons(x4, pmt_cons(x5,
PMT_NIL)))));
+}
+
+pmt_t
pmt_caar(pmt_t pair)
{
return (pmt_car(pmt_car(pair)));
Modified: gnuradio/branches/developers/gnychis/inband/pmt/src/lib/pmt.h
===================================================================
--- gnuradio/branches/developers/gnychis/inband/pmt/src/lib/pmt.h
2007-06-04 16:59:10 UTC (rev 5664)
+++ gnuradio/branches/developers/gnychis/inband/pmt/src/lib/pmt.h
2007-06-04 17:02:48 UTC (rev 5665)
@@ -598,6 +598,11 @@
*/
pmt_t pmt_list4(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4);
+/*!
+ * \brief Return a list of length 4 containing \p x1, \p x2, \p x3, \p x4, \p
x5
+ */
+pmt_t pmt_list5(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4, pmt_t x5);
+
/*
* ------------------------------------------------------------------------
* read / write
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-06-04 16:59:10 UTC (rev 5664)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-06-04 17:02:48 UTC (rev 5665)
@@ -149,10 +149,12 @@
for(int chan=0; chan < d_ntx_chan; chan++) {
d_chaninfo_tx[chan].assigned_capacity = 0;
d_chaninfo_tx[chan].owner = PMT_NIL;
+ d_chaninfo_tx[chan].receiving = false;
}
for(int chan=0; chan < d_nrx_chan; chan++) {
d_chaninfo_rx[chan].assigned_capacity = 0;
d_chaninfo_rx[chan].owner = PMT_NIL;
+ d_chaninfo_rx[chan].receiving = false;
}
}
@@ -427,11 +429,25 @@
//-------------- START RECV ----------------//
if (pmt_eq(event, s_cmd_start_recv_raw_samples)) {
+
+ // Ensure the user is not trying to recv on TX port
+ long port;
+ if(tx_port_index(port_id) != -1) {
+ // FIXME: should return error type
+ d_tx[port]->send(s_response_recv_raw_samples,
+ pmt_list2(invocation_handle, PMT_F));
+ return;
+ }
if(!d_opened) {
-
+ port = rx_port_index(port_id);
+ d_rx[port]->send(s_response_recv_raw_samples,
+ pmt_list2(invocation_handle, PMT_F));
+ return;
}
+ handle_cmd_start_recv_raw_samples(port_id, data);
+ return;
}
unhandled:
@@ -633,71 +649,118 @@
const void *samples = pmt_uniform_vector_elements(pmt_nth(2, data), n_bytes);
long timestamp = pmt_to_long(pmt_nth(3, data));
- long port;
+ long port = tx_port_index(port_id); // If returns -1, the port is invalid
+ // which I don't know how to handle
+ // since you can't respond on an
+ // invalid port
+
+ // Not a valid channel?
+ if(channel >= d_ntx_chan) {
+ d_tx[port]->send(s_response_xmit_raw_frame,
+ pmt_list2(invocation_handle,
+ pmt_from_long(CHANNEL_INVALID)));
+ return;
+ }
- // Check that the channel number is valid, and that the caller is the owner
of
- // the channel to send the frame
- if((port = tx_port_index(port_id)) != -1) {
+ // Not the owner of the channel?
+ if(d_chaninfo_tx[channel].owner != port_id) {
+ d_tx[port]->send(s_response_xmit_raw_frame,
+ pmt_list2(invocation_handle,
+ pmt_from_long(PERMISSION_DENIED)));
+ return;
+ }
+
+ // Determine the number of packets to allocate contiguous memory for
+ // bursting over the USB and get a pointer to the memory to be used in
+ // building the packets
+ long n_packets =
+ static_cast<long>(std::ceil(n_bytes / (double)max_payload_len));
+
+ pmt_t v_packets = pmt_make_u8vector(sizeof(transport_pkt) * n_packets, 0);
+
+ transport_pkt *pkts =
+ (transport_pkt *) pmt_u8vector_writeable_elements(v_packets, psize);
+
+ for(int n=0; n < n_packets; n++) {
+
+ long payload_len =
+ std::min((long)(n_bytes-(n*max_payload_len)), (long)max_payload_len);
- // Not a valid channel?
- if(channel >= d_ntx_chan) {
- d_tx[port]->send(s_response_xmit_raw_frame,
- pmt_list2(invocation_handle,
- pmt_from_long(CHANNEL_INVALID)));
- return;
+ if(n == 0) { // first packet gets start of burst flag and timestamp
+ pkts[n].set_header(pkts[n].FL_START_OF_BURST, channel, 0, payload_len);
+ pkts[n].set_timestamp(timestamp);
+ } else {
+ pkts[n].set_header(0, channel, 0, payload_len);
+ pkts[n].set_timestamp(0xffffffff);
}
- // Not the owner of the channel?
- if(d_chaninfo_tx[channel].owner != port_id) {
- d_tx[port]->send(s_response_xmit_raw_frame,
- pmt_list2(invocation_handle,
- pmt_from_long(PERMISSION_DENIED)));
- return;
- }
+ memcpy(pkts[n].payload(),
+ (uint8_t *)samples+(max_payload_len * n),
+ payload_len);
+ }
- // Determine the number of packets to allocate contiguous memory for
- // bursting over the USB and get a pointer to the memory to be used in
- // building the packets
- long n_packets =
- static_cast<long>(std::ceil(n_bytes / (double)max_payload_len));
+ pkts[n_packets-1].set_end_of_burst(); // set the last packet's end of burst
- pmt_t v_packets = pmt_make_u8vector(sizeof(transport_pkt) * n_packets, 0);
+ if (verbose)
+ std::cout << "[USRP_SERVER] Received raw frame invocation: "
+ << invocation_handle << std::endl;
- transport_pkt *pkts =
- (transport_pkt *) pmt_u8vector_writeable_elements(v_packets, psize);
+ // The actual response to the write will be generated by a
+ // s_response_usrp_write
+ d_cs_usrp->send(s_cmd_usrp_write,
+ pmt_list3(invocation_handle,
+ pmt_from_long(channel),
+ v_packets));
- for(int n=0; n < n_packets; n++) {
+ return;
+}
- long payload_len =
- std::min((long)(n_bytes-(n*max_payload_len)), (long)max_payload_len);
-
- if(n == 0) { // first packet gets start of burst flag and timestamp
- pkts[n].set_header(pkts[n].FL_START_OF_BURST, channel, 0, payload_len);
- pkts[n].set_timestamp(timestamp);
- } else {
- pkts[n].set_header(0, channel, 0, payload_len);
- pkts[n].set_timestamp(0xffffffff);
- }
+void
+usrp_server::handle_cmd_start_recv_raw_samples(pmt_t port_id, pmt_t data)
+{
+ pmt_t invocation_handle = pmt_nth(0, data);
+ long channel = pmt_to_long(pmt_nth(1, data));
- memcpy(pkts[n].payload(),
- (uint8_t *)samples+(max_payload_len * n),
- payload_len);
- }
+ long port = rx_port_index(port_id); // If returns -1, the port is invalid
+ // which I don't know how to handle
+ // since you can't respond on an
+ // invalid port
- pkts[n_packets-1].set_end_of_burst(); // set the last packet's end of burst
+ // Not a valid channel?
+ if(channel >= d_nrx_chan) {
+ d_rx[port]->send(s_response_recv_raw_samples,
+ pmt_list5(invocation_handle,
+ pmt_from_long(CHANNEL_INVALID),
+ PMT_NIL,
+ PMT_NIL,
+ PMT_NIL));
+ return;
+ }
- if (verbose)
- std::cout << "[USRP_SERVER] Received raw frame invocation: "
- << invocation_handle << std::endl;
+ // Not the owner of the channel?
+ if(d_chaninfo_rx[channel].owner != port_id) {
+ d_rx[port]->send(s_response_recv_raw_samples,
+ pmt_list5(invocation_handle,
+ pmt_from_long(PERMISSION_DENIED),
+ PMT_NIL,
+ PMT_NIL,
+ PMT_NIL));
+ return;
+ }
- // The actual response to the write will be generated by a
- // s_response_usrp_write
- d_cs_usrp->send(s_cmd_usrp_write,
- pmt_list3(invocation_handle,
- pmt_from_long(channel),
- v_packets));
+ // Already started receiving samples? (another start before a stop)
+ if(d_chaninfo_rx[channel].receiving) {
+ d_rx[port]->send(s_response_recv_raw_samples,
+ pmt_list5(invocation_handle,
+ pmt_from_long(ALREADY_RECV),
+ PMT_NIL,
+ PMT_NIL,
+ PMT_NIL));
+ return;
+ }
- }
+
+
}
void
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
2007-06-04 16:59:10 UTC (rev 5664)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
2007-06-04 17:02:48 UTC (rev 5665)
@@ -35,7 +35,8 @@
RQSTD_CAPACITY_UNAVAIL = 0,
CHANNEL_UNAVAIL = 1,
CHANNEL_INVALID = 2,
- PERMISSION_DENIED = 3
+ PERMISSION_DENIED = 3,
+ ALREADY_RECV = 4
};
// our ports
@@ -54,8 +55,9 @@
long d_nrx_chan;
struct channel_info {
- long assigned_capacity; // the capacity currently assignedby the channel
+ long assigned_capacity; // the capacity currently assignedby the channel
pmt_t owner; // port ID of the owner of the channel
+ bool receiving; // is a 'receieve' sample data started on this
channel?
};
struct channel_info d_chaninfo_tx[D_MAX_CHANNELS];
@@ -80,6 +82,7 @@
void handle_cmd_allocate_channel(pmt_t port_id, pmt_t data);
void handle_cmd_deallocate_channel(pmt_t port_id, pmt_t data);
void handle_cmd_xmit_raw_frame(pmt_t port_id, pmt_t data);
+ void handle_cmd_start_recv_raw_samples(pmt_t port_id, pmt_t data);
int rx_port_index(pmt_t port_id);
int tx_port_index(pmt_t port_id);
long current_capacity_allocation();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5665 - in gnuradio/branches/developers/gnychis/inband: pmt/src/lib usrp/host/lib/inband,
gnychis <=