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