summaryrefslogtreecommitdiff
path: root/usrp/host/lib/inband/usrp_server.mbh
blob: ed7943fc377751981634131181438fc8ea63f351 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
;; -*- scheme -*- ; not really, but tells emacs how to format this
;;
;; Copyright 2007 Free Software Foundation, Inc.
;; 
;; This file is part of GNU Radio
;; 
;; GNU Radio is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; 
;; GNU Radio is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;; 
;; You should have received a copy of the GNU General Public License along
;; with this program; if not, write to the Free Software Foundation, Inc.,
;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
;;

;; ----------------------------------------------------------------
;;              This is an mblock header file
;;
;; The format is very much a work-in-progress.
;; It'll be compiled to C++.
;; ----------------------------------------------------------------

;; In the outgoing messages described below, invocation-handle is an
;; identifier provided by the client to tag the method invocation.
;; The identifier will be returned with the response, to provide the
;; client with a mechanism to match asynchronous responses with the
;; commands that generate them.  The value of the invocation-handle is
;; opaque the the server, and is not required by the server to be
;; unique.
;;
;; In the incoming messages described below, invocation-handle is the
;; identifier provided by the client in the prompting invocation.  The
;; identifier is returned with the response, so that the client has a
;; mechanism to match asynchronous responses with the commands that
;; generated them.
;;
;; status is either #t, indicating success, or a symbol indicating an error.
;; All symbol's names shall begin with %error-


;; ----------------------------------------------------------------
;; usrp-channel
;;
;; The protocol class is defined from the client's point-of-view.
;; (The client port is unconjugated, the server port is conjugated.)

(define-protocol-class usrp-channel

  (:outgoing

   (cmd-allocate-channel invocation-handle capacity-reservation)

   ;; The cmd-allocate-channel message requests that the server
   ;; allocates a logical channel in the FPGA for use.
   ;; capacity-reservation specifies the number of bytes/s of
   ;; interconnect capacity (USB or ethernet) to reserve for this
   ;; channel.  (The reservation is just a sanity check, no OS
   ;; specific mechanism is used.)

   (cmd-deallocate-channel invocation-handle channel)

   ;; The integer channel specifies the channel to deallocate.

   )

  (:incoming


   (response-allocate-channel invocation-handle status channel)

   ;; If successful, a channel the specified capacity was allocated.
   ;; channel, an integer, indicates which channel was allocated.

   (response-deallocate-channel invocation-handle status)

   ;; If successful, the specified channel and associated interconnect
   ;; capacity were deallocated.

   )
  )

;; ----------------------------------------------------------------
;; usrp-low-level-cs
;;
;; The protocol class is defined from the client's point-of-view.
;; (The client port is unconjugated, the server port is conjugated.)
;;
;; This defines a low level control and status interface to the usrp.
;; This will probably be replaced (or at least augmented) with a
;; higher level interface.  For now, this will allow us to get on
;; the air.
;;
;; The subpackets are lists containing the relevant parameters.  The
;; server will marshall them appropriately.  Below is a list of
;; subpackets.  See inband-signaling-usb for details.  The opcodes are
;; symbols; unless otherwise indicated the remaining parameters are
;; integers.  rid values are limited to 3-bits.
;;
;;   (op-ping-fixed rid ping-value)
;;   (op-ping-fixed-reply rid ping-value)
;;   (op-write-reg reg-number reg-value)
;;   (op-write-reg-masked reg-number reg-value mask-value)
;;   (op-read-reg rid reg-number)
;;   (op-read-reg-reply rid reg-number reg-value)
;;   (op-i2c-write i2c-addr u8-vec)
;;   (op-i2c-read rid i2c-addr nbytes)
;;   (op-i2c-read-reply rid i2c-addr u8-vec)
;;   (op-spi-write enables format opt-header-bytes u8-vec)
;;   (op-spi-read rid enables format opt-header-bytes nbytes)
;;   (op-spi-read-reply rid u8-vec)
;;   (op-delay ticks)


(define-protocol-class usrp-low-level-cs

  (:outgoing

   (cmd-to-control-channel invocation-handle list-of-subpackets)

   )

  (:incoming

   (response-from-control-channel invocation-handle status list-of-subpackets timestamp)

   )
  )

;; ----------------------------------------------------------------
;; usrp-tx
;;
;; The protocol class is defined from the client's point-of-view.
;; (The client port is unconjugated, the server port is conjugated.)

(define-protocol-class usrp-tx
  (:include usrp-channel)
  (:include usrp-low-level-cs)

  (:outgoing

   (cmd-xmit-raw-frame invocation-handle channel samples timestamp properties)

   ;; The argument channel must be an integer.  It specifies the
   ;; channel on which the frame of samples will be be sent.
   ;;
   ;; samples must be a uniform numeric vector.  The contents of the
   ;; sample vector is treated as opaque and is passed on to the FPGA
   ;; unmodified.  It is the responsibility of the sender to ensure
   ;; that the binary format is sensible for the current FPGA
   ;; configuration.
   ;;
   ;; timestamp is a 32-bit integer that specifies the time at which
   ;; the first sample in samples shall be sent to the D/A converter.
   ;; The format and interpration of time is specified in the file
   ;; inband-signaling-usb
   )

  (:incoming

   (response-xmit-raw-frame invocation-handle status)

   ;; If successful, the samples of the associated frame have been
   ;; transmitted to the USRP.  This message may be used to implement
   ;; Tx flow control.  The client could for example implement a
   ;; policy of never having more than 4 unacknowledged
   ;; cmd-xmit-raw-frame's outstanding.

   )
  )

;; ----------------------------------------------------------------
;; usrp-rx
;;
;; The protocol class is defined from the client's point-of-view.
;; (The client port is unconjugated, the server port is conjugated.)

(define-protocol-class usrp-rx
  (:include usrp-channel)
  (:include usrp-low-level-cs)

  (:outgoing

   (cmd-start-recv-raw-samples invocation-handle channel)

   ;; The argument channel must be an integer.  It specifies the
   ;; channel from which frames of samples will be be received.  The
   ;; server will return response-recv-raw-samples messages until a
   ;; cmd-stop-recv-raw-samples message is received.

   (cmd-stop-recv-raw-samples invocation-handle channel)

   ;; The argument channel must be an integer.  There is no reply to
   ;; this message.
   
   )

  (:incoming

   (response-recv-raw-samples invocation-handle status samples timestamp channel properties)

   ;; samples is a uniform numeric vector.  The contents of the sample
   ;; vector is treated as opaque and is passed from the FPGA
   ;; unmodified.  It is the responsibility of the receiver to decode
   ;; the binary format as appropriate for the current FPGA
   ;; configuration.
   ;;
   ;; timestamp is a 32-bit integer that specifies the time at which
   ;; the first sample in samples was received from the A/D converter.
   ;; The format and interpretation of time is as specified in the
   ;; file inband-signaling-usb.
   ;;
   ;; properties is a dictionary containing additional (key, value)
   ;; pairs associated with the reception of these samples.  In
   ;; particular, the map may contain the Received Signal Strength
   ;; Indication (RSSI) reported by the front end at the time the
   ;; first sample was received from the A/D.

   )
  )


;; ----------------------------------------------------------------
;; usrp-server-cs
;;
;; Control and status port for usrp-server
;;
;; The protocol class is defined from the client's point-of-view.
;; (The client port is unconjugated, the server port is conjugated.)

(define-protocol-class usrp-server-cs

  (:outgoing
   (cmd-open invocation-handle which-usrp)
   (cmd-close invocation-handle)
   (cmd-max-capacity invocation-handle)
   (cmd-ntx-chan invocation-handle)
   (cmd-nrx-chan invocation-handle)
   (cmd-current-capacity-allocation invocation-handle)
   )

  (:incoming
   (response-open invocation-handle status)
   (response-close invocation-handle status)
   (response-max-capacity invocation-handle status capacity)
   (response-ntx-chan invocation-handle status ntx-chan)
   (response-nrx-chan invocation-handle status nrx-chan)
   (response-current-capacity-allocation invocation-handle status capacity)
   )
  )