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 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.
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 symbol indicating an error.
44 ;; All symbol's names shall begin with %error-
47 ;; ----------------------------------------------------------------
50 ;; The protocol class is defined from the client's point-of-view.
51 ;; (The client port is unconjugated, the server port is conjugated.)
53 (define-protocol-class usrp-channel
57 (cmd-allocate-channel invocation-handle capacity-reservation)
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.)
66 (cmd-deallocate-channel invocation-handle channel)
68 ;; The integer channel specifies the channel to deallocate.
75 (response-allocate-channel invocation-handle status channel)
77 ;; If successful, a channel the specified capacity was allocated.
78 ;; channel, an integer, indicates which channel was allocated.
80 (response-deallocate-channel invocation-handle status)
82 ;; If successful, the specified channel and associated interconnect
83 ;; capacity were deallocated.
88 ;; ----------------------------------------------------------------
91 ;; The protocol class is defined from the client's point-of-view.
92 ;; (The client port is unconjugated, the server port is conjugated.)
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
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.
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)
120 (define-protocol-class usrp-low-level-cs
124 (cmd-to-control-channel invocation-handle list-of-subpackets)
130 (response-from-control-channel invocation-handle status list-of-subpackets timestamp)
135 ;; ----------------------------------------------------------------
138 ;; The protocol class is defined from the client's point-of-view.
139 ;; (The client port is unconjugated, the server port is conjugated.)
141 (define-protocol-class usrp-tx
142 (:include usrp-channel)
143 (:include usrp-low-level-cs)
147 (cmd-xmit-raw-frame invocation-handle channel samples timestamp properties)
149 ;; The argument channel must be an integer. It specifies the
150 ;; channel on which the frame of samples will be be sent.
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
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
166 (response-xmit-raw-frame invocation-handle status)
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.
177 ;; ----------------------------------------------------------------
180 ;; The protocol class is defined from the client's point-of-view.
181 ;; (The client port is unconjugated, the server port is conjugated.)
183 (define-protocol-class usrp-rx
184 (:include usrp-channel)
185 (:include usrp-low-level-cs)
189 (cmd-start-recv-raw-samples invocation-handle channel)
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.
196 (cmd-stop-recv-raw-samples invocation-handle channel)
198 ;; The argument channel must be an integer. There is no reply to
205 (response-recv-raw-samples invocation-handle status samples timestamp channel properties)
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
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.
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.
228 ;; ----------------------------------------------------------------
231 ;; Control and status port for usrp-server
233 ;; The protocol class is defined from the client's point-of-view.
234 ;; (The client port is unconjugated, the server port is conjugated.)
236 (define-protocol-class usrp-server-cs
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)
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)