Change default bandwidth to 25 MHz to match maximum USRP2 bandwidth
[debian/gnuradio] / usrp / limbo / inband / usrp_server.mbh
1 ;; -*- scheme -*- ; not really, but tells emacs how to format this
2 ;;
3 ;; Copyright 2007 Free Software Foundation, Inc.
4 ;; 
5 ;; This file is part of GNU Radio
6 ;; 
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)
10 ;; any later version.
11 ;; 
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.
16 ;; 
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.
20 ;;
21
22 ;; ----------------------------------------------------------------
23 ;;              This is an mblock header file
24 ;;
25 ;; The format is very much a work-in-progress.
26 ;; It'll be compiled to C++.
27 ;; ----------------------------------------------------------------
28
29 ;; In the outgoing messages described below, invocation-handle is an
30 ;; identifier provided by the client to tag the method invocation.
31 ;; The identifier will be returned with the response, to provide the
32 ;; client with a mechanism to match asynchronous responses with the
33 ;; commands that generate them.  The value of the invocation-handle is
34 ;; opaque the the server, and is not required by the server to be
35 ;; unique.
36 ;;
37 ;; In the incoming messages described below, invocation-handle is the
38 ;; identifier provided by the client in the prompting invocation.  The
39 ;; identifier is returned with the response, so that the client has a
40 ;; mechanism to match asynchronous responses with the commands that
41 ;; generated them.
42 ;;
43 ;; status is either #t, indicating success, or a symbol indicating an error.
44 ;; All symbol's names shall begin with %error-
45
46
47 ;; ----------------------------------------------------------------
48 ;; usrp-channel
49 ;;
50 ;; The protocol class is defined from the client's point-of-view.
51 ;; (The client port is unconjugated, the server port is conjugated.)
52
53 (define-protocol-class usrp-channel
54
55   (:outgoing
56
57    (cmd-allocate-channel invocation-handle capacity-reservation)
58
59    ;; The cmd-allocate-channel message requests that the server
60    ;; allocates a logical channel in the FPGA for use.
61    ;; capacity-reservation specifies the number of bytes/s of
62    ;; interconnect capacity (USB or ethernet) to reserve for this
63    ;; channel.  (The reservation is just a sanity check, no OS
64    ;; specific mechanism is used.)
65
66    (cmd-deallocate-channel invocation-handle channel)
67
68    ;; The integer channel specifies the channel to deallocate.
69
70    )
71
72   (:incoming
73
74
75    (response-allocate-channel invocation-handle status channel)
76
77    ;; If successful, a channel the specified capacity was allocated.
78    ;; channel, an integer, indicates which channel was allocated.
79
80    (response-deallocate-channel invocation-handle status)
81
82    ;; If successful, the specified channel and associated interconnect
83    ;; capacity were deallocated.
84
85    )
86   )
87
88 ;; ----------------------------------------------------------------
89 ;; usrp-low-level-cs
90 ;;
91 ;; The protocol class is defined from the client's point-of-view.
92 ;; (The client port is unconjugated, the server port is conjugated.)
93 ;;
94 ;; This defines a low level control and status interface to the usrp.
95 ;; This will probably be replaced (or at least augmented) with a
96 ;; higher level interface.  For now, this will allow us to get on
97 ;; the air.
98 ;;
99 ;; The subpackets are lists containing the relevant parameters.  The
100 ;; server will marshall them appropriately.  Below is a list of
101 ;; subpackets.  See inband-signaling-usb for details.  The opcodes are
102 ;; symbols; unless otherwise indicated the remaining parameters are
103 ;; integers.  rid values are limited to 3-bits.
104 ;;
105 ;;   (op-ping-fixed rid ping-value)
106 ;;   (op-ping-fixed-reply rid ping-value)
107 ;;   (op-write-reg reg-number reg-value)
108 ;;   (op-write-reg-masked reg-number reg-value mask-value)
109 ;;   (op-read-reg rid reg-number)
110 ;;   (op-read-reg-reply rid reg-number reg-value)
111 ;;   (op-i2c-write i2c-addr u8-vec)
112 ;;   (op-i2c-read rid i2c-addr nbytes)
113 ;;   (op-i2c-read-reply rid i2c-addr u8-vec)
114 ;;   (op-spi-write enables format opt-header-bytes u8-vec)
115 ;;   (op-spi-read rid enables format opt-header-bytes nbytes)
116 ;;   (op-spi-read-reply rid u8-vec)
117 ;;   (op-delay ticks)
118
119
120 (define-protocol-class usrp-low-level-cs
121
122   (:outgoing
123
124    (cmd-to-control-channel invocation-handle list-of-subpackets)
125
126    )
127
128   (:incoming
129
130    (response-from-control-channel invocation-handle status list-of-subpackets timestamp)
131
132    )
133   )
134
135 ;; ----------------------------------------------------------------
136 ;; usrp-tx
137 ;;
138 ;; The protocol class is defined from the client's point-of-view.
139 ;; (The client port is unconjugated, the server port is conjugated.)
140
141 (define-protocol-class usrp-tx
142   (:include usrp-channel)
143   (:include usrp-low-level-cs)
144
145   (:outgoing
146
147    (cmd-xmit-raw-frame invocation-handle channel samples timestamp properties)
148
149    ;; The argument channel must be an integer.  It specifies the
150    ;; channel on which the frame of samples will be be sent.
151    ;;
152    ;; samples must be a uniform numeric vector.  The contents of the
153    ;; sample vector is treated as opaque and is passed on to the FPGA
154    ;; unmodified.  It is the responsibility of the sender to ensure
155    ;; that the binary format is sensible for the current FPGA
156    ;; configuration.
157    ;;
158    ;; timestamp is a 32-bit integer that specifies the time at which
159    ;; the first sample in samples shall be sent to the D/A converter.
160    ;; The format and interpration of time is specified in the file
161    ;; inband-signaling-usb
162    )
163
164   (:incoming
165
166    (response-xmit-raw-frame invocation-handle status)
167
168    ;; If successful, the samples of the associated frame have been
169    ;; transmitted to the USRP.  This message may be used to implement
170    ;; Tx flow control.  The client could for example implement a
171    ;; policy of never having more than 4 unacknowledged
172    ;; cmd-xmit-raw-frame's outstanding.
173
174    )
175   )
176
177 ;; ----------------------------------------------------------------
178 ;; usrp-rx
179 ;;
180 ;; The protocol class is defined from the client's point-of-view.
181 ;; (The client port is unconjugated, the server port is conjugated.)
182
183 (define-protocol-class usrp-rx
184   (:include usrp-channel)
185   (:include usrp-low-level-cs)
186
187   (:outgoing
188
189    (cmd-start-recv-raw-samples invocation-handle channel)
190
191    ;; The argument channel must be an integer.  It specifies the
192    ;; channel from which frames of samples will be be received.  The
193    ;; server will return response-recv-raw-samples messages until a
194    ;; cmd-stop-recv-raw-samples message is received.
195
196    (cmd-stop-recv-raw-samples invocation-handle channel)
197
198    ;; The argument channel must be an integer.  There is no reply to
199    ;; this message.
200    
201    )
202
203   (:incoming
204
205    (response-recv-raw-samples invocation-handle status samples timestamp channel properties)
206
207    ;; samples is a uniform numeric vector.  The contents of the sample
208    ;; vector is treated as opaque and is passed from the FPGA
209    ;; unmodified.  It is the responsibility of the receiver to decode
210    ;; the binary format as appropriate for the current FPGA
211    ;; configuration.
212    ;;
213    ;; timestamp is a 32-bit integer that specifies the time at which
214    ;; the first sample in samples was received from the A/D converter.
215    ;; The format and interpretation of time is as specified in the
216    ;; file inband-signaling-usb.
217    ;;
218    ;; properties is a dictionary containing additional (key, value)
219    ;; pairs associated with the reception of these samples.  In
220    ;; particular, the map may contain the Received Signal Strength
221    ;; Indication (RSSI) reported by the front end at the time the
222    ;; first sample was received from the A/D.
223
224    )
225   )
226
227
228 ;; ----------------------------------------------------------------
229 ;; usrp-server-cs
230 ;;
231 ;; Control and status port for usrp-server
232 ;;
233 ;; The protocol class is defined from the client's point-of-view.
234 ;; (The client port is unconjugated, the server port is conjugated.)
235
236 (define-protocol-class usrp-server-cs
237
238   (:outgoing
239    (cmd-open invocation-handle which-usrp)
240    (cmd-close invocation-handle)
241    (cmd-max-capacity invocation-handle)
242    (cmd-ntx-chan invocation-handle)
243    (cmd-nrx-chan invocation-handle)
244    (cmd-current-capacity-allocation invocation-handle)
245    )
246
247   (:incoming
248    (response-open invocation-handle status)
249    (response-close invocation-handle status)
250    (response-max-capacity invocation-handle status capacity)
251    (response-ntx-chan invocation-handle status ntx-chan)
252    (response-nrx-chan invocation-handle status nrx-chan)
253    (response-current-capacity-allocation invocation-handle status capacity)
254    )
255   )