-
Notifications
You must be signed in to change notification settings - Fork 9
/
rbox_structure.html
395 lines (293 loc) · 11.4 KB
/
rbox_structure.html
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
<title>USBBox</title>
</head>
<body>
<h1 id="usbbox">USBBox</h1>
<p>The main object representing the response box.</p>
<h2 id="usbbox_methods">USBBox methods</h2>
<ul>
<li><p><code>send_command(command_id,bytes)</code> </p>
<blockquote>
<p>send a command to the box (command id byte and 7 data bytes as a Python string)</p>
</blockquote></li>
<li><p><code>purge_queue()</code></p>
<blockquote>
<p>purge the system buffer queue</p>
</blockquote></li>
<li><p><code>reset_clock()</code></p>
<blockquote>
<p>reset the system clock</p>
</blockquote></li>
<li><p><code>enable_loopback()</code></p>
<blockquote>
<p>enable loopback (button presses turn LEDs on/off)</p>
</blockquote></li>
<li><p><code>disable_loopback()</code></p></li>
<li><p><code>wait_for_keydown()</code> </p>
<blockquote>
<p>wait for a key down event (return None if no event received within timeout)</p>
</blockquote></li>
<li><p><code>wait_for_keyup()</code> </p>
<blockquote>
<p>wait for key up event (return None if no event received within timeout)</p>
</blockquote></li>
</ul>
<h2 id="usbbox_properties">USBBox properties</h2>
<ul>
<li><p><code>serial_num</code> </p>
<blockquote>
<p>serial number for main board (read)</p>
</blockquote></li>
<li><p><code>PAC</code> </p>
<blockquote>
<p>set product authorisation code (write)</p>
</blockquote></li>
<li><p><code>version</code> </p>
<blockquote>
<p>system firmware (read)</p>
</blockquote></li>
<li><p><code>voice_version</code> </p>
<blockquote>
<p>voice key firmware (read)</p>
</blockquote></li>
<li><p><code>clock</code> </p>
<blockquote>
<p>system clock value (read)</p>
</blockquote></li>
<li><p><code>heartbeat</code> </p>
<blockquote>
<p>set heartbeat rate (write)</p>
</blockquote></li>
<li><p><code>port0</code></p>
<blockquote>
<p>see <a href="#port0">port0, port2, leds object</a></p>
</blockquote></li>
<li><p><code>port1</code> / <code>buttons</code></p>
<blockquote>
<p>see <a href="#port1">port1, buttons object</a></p>
</blockquote></li>
<li><p><code>port2</code> / <code>leds</code></p>
<blockquote>
<p>see <a href="#port0">port0, port2, leds object</a></p>
</blockquote></li>
<li><p><code>int0</code> / <code>voice_key</code></p>
<blockquote>
<p>see <a href="#int0">int0, voice_key object</a></p>
</blockquote></li>
<li><p><code>int1</code> / <code>optic_key</code></p>
<blockquote>
<p>see <a href="#int1">int1, optic_key object</a></p>
</blockquote></li>
<li><p><code>serial</code> </p>
<blockquote>
<p>see <a href="#serial">serial object</a></p>
</blockquote></li>
<li><p><code>device</code></p>
<blockquote>
<p>the underlying USB HID device object</p>
</blockquote></li>
<li><p><code>commands</code></p>
<blockquote>
<p>see <a href="#commands">commands object</a></p>
</blockquote></li>
</ul>
<p><a name='port0'></a></p>
<h1 id="port0_port2_leds_object">port0, port2, leds object</h1>
<p><code>port0</code>, <code>port2</code> and <code>leds</code> are object properties of the main USBBox object.</p>
<h2 id="port0_port2_leds_methods">port0, port2, leds methods</h2>
<ul>
<li><p><code>and_state(and_bits)</code></p>
<blockquote>
<p>AND <code>and_bits</code> with current port state</p>
</blockquote></li>
<li><p><code>or_state(or_bits)</code></p>
<blockquote>
<p>OR <code>or_bits</code> with current port state</p>
</blockquote></li>
<li><p><code>xor_state(xor_bits)</code></p>
<blockquote>
<p>XOR <code>xor_bits</code> with current port state</p>
</blockquote></li>
</ul>
<h2 id="port0_port2_leds_properties">port0, port2, leds properties</h2>
<p><code>direction</code>, <code>logic</code> and <code>state</code> apply to all lines on the port.</p>
<ul>
<li><p><code>direction</code></p>
<blockquote>
<p>byte representing direction of port (read/write)</p>
</blockquote></li>
<li><p><code>logic</code></p>
<blockquote>
<p>byte representing logic of port (read/write)</p>
</blockquote></li>
<li><p><code>state</code></p>
<blockquote>
<p>byte representing state of port (read/write)</p>
</blockquote></li>
<li><p><code>lines</code></p>
<blockquote>
<p>collection of all 8 line objects on the port</p>
</blockquote></li>
<li><p><code>line0</code>, <code>line1</code>, <code>line2</code>, <code>line3</code>, <code>line4</code>, <code>line5</code>, <code>line6</code>, <code>line7</code></p>
<blockquote>
<p>individual line objects on the port</p>
</blockquote></li>
</ul>
<h1 id="line_objects_port0_port2_leds">line objects (port0, port2, leds)</h1>
<p>Individual lines on port0, port2 and leds objects</p>
<h2 id="line_objects_port0_port2_leds_properties">line objects (port0, port2, leds) properties</h2>
<ul>
<li><p><code>state</code></p>
<blockquote>
<p>bit representing state of line (read/write)</p>
</blockquote></li>
<li><p><code>direction</code></p>
<blockquote>
<p>bit representing direction of line (read/write)</p>
</blockquote></li>
<li><p><code>logic</code></p>
<blockquote>
<p>bit representing logic of line (read/write)</p>
</blockquote></li>
</ul>
<p><a name='port1'></a></p>
<h1 id="port1_buttons_object">port1, buttons object</h1>
<p><code>port1</code> and <code>buttons</code> are synonyms on the USBBox object.</p>
<h2 id="port1_buttons_object_properties">port1, buttons object properties</h2>
<ul>
<li><p><code>enabled</code></p>
<blockquote>
<p>byte representing enabled state of input lines (read/write)</p>
</blockquote></li>
<li><p><code>debounce_down</code></p>
<blockquote>
<p>byte representing key down debounce time (read/write)</p>
</blockquote></li>
<li><p><code>debound_up</code></p>
<blockquote>
<p>byte representing key up debounce time (read/write)</p>
</blockquote></li>
<li><p><code>state</code></p>
<blockquote>
<p>byte representing state of all input lines (read)</p>
</blockquote></li>
<li><p><code>lines</code></p>
<blockquote>
<p>all 8 input lines of the port</p>
</blockquote></li>
<li><p><code>line0</code>, <code>line1</code>, <code>line2</code>, <code>line3</code>, <code>line4</code>, <code>line5</code>, <code>line6</code>, <code>line7</code></p>
<blockquote>
<p>individual line objects on the port</p>
</blockquote></li>
</ul>
<h1 id="line_objects_port1_buttons">line objects (port1, buttons)</h1>
<p>Object representing a single line on port1/buttons.</p>
<h2 id="line_objects_port1_buttons_properties">line objects (port1, buttons) properties</h2>
<ul>
<li><p><code>state</code></p>
<blockquote>
<p>bit representing state of line (read)</p>
</blockquote></li>
<li><p><code>enabled</code></p>
<blockquote>
<p>bit representing whether line is enabled (read/write)</p>
</blockquote></li>
</ul>
<p><a name='int0'></a></p>
<h1 id="int0_voice_key_object">int0, voice_key object</h1>
<p>Interrupt 0 / voice key object</p>
<h2 id="int0_voice_key_object_properties">int0, voice_key object properties</h2>
<ul>
<li><p><code>enabled</code></p>
<blockquote>
<p>bit representing whether port is enabled (read/write)</p>
</blockquote></li>
<li><p><code>debounce_down</code></p>
<blockquote>
<p>byte representing key down debounce time (read/write)</p>
</blockquote></li>
<li><p><code>debound_up</code></p>
<blockquote>
<p>byte representing key up debounce time (read/write)</p>
</blockquote></li>
<li><p><code>primary_gain</code></p>
<blockquote>
<p>byte representing primary gain (read/write)</p>
</blockquote></li>
<li><p><code>secondary_gain</code></p>
<blockquote>
<p>byte representing secondary gain (read/write)</p>
</blockquote></li>
<li><p><code>min_duration</code></p>
<blockquote>
<p>byte representing minimum duration (read/write)</p>
</blockquote></li>
<li><p><code>min_silence</code></p>
<blockquote>
<p>byte representing minimum silence (read/write)</p>
</blockquote></li>
<li><p><code>trigger_level</code></p>
<blockquote>
<p>byte representing trigger level (threshold) (read/write)</p>
</blockquote></li>
<li><p><code>mic_pass_thru</code></p>
<blockquote>
<p>bit representing microphone pass through state.
note value is not read from the box, so value will only
be valid after it is first written (read/write)</p>
</blockquote></li>
</ul>
<p><a name='int1'></a></p>
<h1 id="int1_optic_key_object">int1, optic_key object</h1>
<p>Interrupt 1 / optic key object</p>
<h1 id="int1_optic_key_object_properties">int1, optic_key object properties</h1>
<ul>
<li><p><code>enabled</code></p>
<blockquote>
<p>bit representing whether port is enabled (read/write)</p>
</blockquote></li>
<li><p><code>debounce_down</code></p>
<blockquote>
<p>byte representing key down debounce time (read/write)</p>
</blockquote></li>
<li><p><code>debound_up</code></p>
<blockquote>
<p>byte representing key up debounce time (read/write)</p>
</blockquote></li>
</ul>
<p><a name='serial'></a></p>
<h1 id="serial_object">serial object</h1>
<p>Object representing the serial port on the USBBox. Operates at 9600 baud.</p>
<h2 id="serial_object_methods">serial object methods</h2>
<ul>
<li><p><code>read()</code></p>
<blockquote>
<p>read bytes from the serial port. returns bytes as a Python string
(as a file object would). returns an empty string ” if no bytes were received
after timing out. bytes sent to the serial port will be stored on this object
until <code>read()</code> is called.</p>
</blockquote></li>
<li><p><code>write(bytes)</code></p>
<blockquote>
<p>write bytes to the serial port. blocks until all bytes written. bytes should
be a Python string.</p>
</blockquote></li>
</ul>
<p><a name='commands'></a></p>
<h1 id="commands_object">commands object</h1>
<p>The <code>commmands</code> object is intended to be a fairly low-level interface to the response box.
It is mainly concerned with sending and receiving reports and therefore closely mimics the
underlying protocol of the response box.</p>
<h2 id="commands_object_methods">commands object methods</h2>
<p>There exists one method for each command report specified in the response box manual. They
are names are lowercase (and - to _) versions of the IDs specified in the manual. These methods
are used to send commands to the HID device.
e.g.</p>
<pre><code>usbbox.commands.verget() # send a VERGET command to the box
usbbox.commands.dirset(1,0,0) # send a DIRGET command (enable loopback)
</code></pre>
</body>
</html>