3 * Copyright 2007 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef INCLUDED_USRP_SERVER_H
22 #define INCLUDED_USRP_SERVER_H
24 #include <mb_mblock.h>
28 #include <usrp_inband_usb_packet.h>
30 typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit easy
33 * \brief Implements the lowest-level mblock usb_interface to the USRP
35 class usrp_server : public mb_mblock
44 static const int N_PORTS = 4;
45 std::vector<mb_port_sptr> d_tx, d_rx;
47 mb_port_sptr d_cs_usrp;
49 static const int D_USB_CAPACITY = 32 * 1024 * 1024;
50 static const int D_MAX_CHANNELS = 16;
54 // Keep track of the request IDs
65 static const long D_MAX_RID = 64;
66 std::vector<rid_info> d_rids;
69 long assigned_capacity; // the capacity currently assignedby the channel
70 pmt_t owner; // port ID of the owner of the channel
73 assigned_capacity = 0;
78 long d_rx_chan_mask; // A bitmask representing the channels in the
81 std::vector<struct channel_info> d_chaninfo_tx;
82 std::vector<struct channel_info> d_chaninfo_rx;
84 std::queue<mb_message_sptr> d_defer_queue;
92 usrp_server(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg);
95 void initial_transition();
96 void handle_message(mb_message_sptr msg);
99 static int max_capacity() { return D_USB_CAPACITY; }
102 void handle_cmd_allocate_channel(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data);
103 void handle_cmd_deallocate_channel(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data);
104 void handle_cmd_xmit_raw_frame(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data);
105 void handle_cmd_to_control_channel(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data);
106 void handle_cmd_start_recv_raw_samples(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data);
107 void handle_cmd_stop_recv_raw_samples(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data);
108 int rx_port_index(pmt_t port_id);
109 int tx_port_index(pmt_t port_id);
110 long current_capacity_allocation();
111 void recall_defer_queue();
112 void reset_channels();
113 void handle_response_usrp_read(pmt_t data);
114 bool check_valid(mb_port_sptr port, long channel, std::vector<struct channel_info> &chan_info, pmt_t signal_info);
115 void parse_control_pkt(pmt_t invocation_handle, transport_pkt *pkt);
119 #endif /* INCLUDED_USRP_SERVER_H */