1 ;; -*- scheme -*- ; not really, but tells emacs how to format this
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 2, 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.
22 ;; ----------------------------------------------------------------
23 ;; This is an mblock header file
25 ;; The format is very much a work-in-progress.
26 ;; It'll be compiled to C++.
27 ;; ----------------------------------------------------------------
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
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
43 ;; status is either #t, indicating success, or a pair containing
44 ;; (status-code . message), where status-code is a symbol and message
48 ;; ----------------------------------------------------------------
51 ;; The protocol class is defined from the client's point-of-view.
52 ;; (The client port is unconjugated, the server port is conjugated.)
54 (define-protocol-class usrp-channel
58 (cmd-allocate-channel invocation-handle capacity-reservation)
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.)
67 (cmd-deallocate-channel invocation-handle channel)
69 ;; The integer channel specifies the channel to deallocate.
76 (response-allocate-channel invocation-handle status channel)
78 ;; If successful, a channel the specified capacity was allocated.
79 ;; channel, an integer, indicates which channel was allocated.
81 (response-deallocate-channel invocation-handle status)
83 ;; If successful, the specified channel and associated interconnect
84 ;; capacity were deallocated.
89 ;; ----------------------------------------------------------------
92 ;; The protocol class is defined from the client's point-of-view.
93 ;; (The client port is unconjugated, the server port is conjugated.)
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
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.
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)
121 (define-protocol-class usrp-low-level-cs
125 (cmd-to-control-channel invocation-handle list-of-subpackets)
131 (response-from-control-channel invocation-handle status list-of-subpackets)
136 ;; ----------------------------------------------------------------
139 ;; The protocol class is defined from the client's point-of-view.
140 ;; (The client port is unconjugated, the server port is conjugated.)
142 (define-protocol-class usrp-tx
143 (:include usrp-channel)
144 (:include usrp-low-level-cs)
148 (cmd-xmit-raw-frame invocation-handle channel samples timestamp)
150 ;; The argument channel must be an integer. It specifies the
151 ;; channel on which the frame of samples will be be sent.
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
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
167 (response-xmit-raw-frame invocation-handle status)
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.
178 ;; ----------------------------------------------------------------
181 ;; The protocol class is defined from the client's point-of-view.
182 ;; (The client port is unconjugated, the server port is conjugated.)
184 (define-protocol-class usrp-rx
185 (:include usrp-channel)
186 (:include usrp-low-level-cs)
190 (cmd-start-recv-raw-samples invocation-handle channel)
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.
197 (cmd-stop-recv-raw-samples invocation-handle channel)
199 ;; The argument channel must be an integer. There is no reply to
206 (response-recv-raw-samples invocation-handle status samples timestamp properties)
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
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.
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.
229 ;; ----------------------------------------------------------------
232 ;; Control and status port for usrp-server
234 ;; The protocol class is defined from the client's point-of-view.
235 ;; (The client port is unconjugated, the server port is conjugated.)
237 (define-protocol-class usrp-server-cs
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)
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)