-
Notifications
You must be signed in to change notification settings - Fork 412
/
x_pipe
executable file
·425 lines (373 loc) · 13.9 KB
/
x_pipe
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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
#!/bin/bash
GPIO=25
#
# This script serves as a confidence check that the pipe interface to
# the pigpio library is ok.
#
# The script uses gpio 25 (pin 22). Make sure that nothing (or only a LED)
# is connected to gpio 25 before running the script.
#
# To run the script
# sudo pigpiod # if not already running
# ./x_pipe # on the Pi running pigpiod
#
# Some tests are statistical in nature and so may on occasion fail.
# Repeated failures on the same test or many failures in a group
# of tests indicate a problem.
#
echo
echo "Testing pigpio pipe I/F"
echo "pigpv" >/dev/pigpio
read -t 1 s </dev/pigout
echo "pigpio version $s"
echo "bc1 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "BC1 ok"; else echo "BC1 fail ($s)"; fi
echo "bc2 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "BC2 ok"; else echo "BC2 fail ($s)"; fi
echo "br1" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ ${#s} = 8 ]]
then echo "BR1 ok"
else echo "BR1 fail ($s)"
fi
echo "br2" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ ${#s} = 8 ]]
then echo "BR2 ok"
else echo "BR2 fail ($s)"
fi
echo "bs1 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "BS1 ok"; else echo "BS1 fail ($s)"; fi
echo "bs2 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "BS2 ok"; else echo "BS2 fail ($s)"; fi
echo "h" >/dev/pigpio
read -t 1 s </dev/pigout
read -t 1 s </dev/pigout
if [[ $s = "BC1 bits Clear GPIO in bank 1" ]]
then echo "HELP-a ok"
else echo "HELP-a fail ($s)"
fi
read -t 1 -N 9000 </dev/pigout # dump rest of help
echo "help" >/dev/pigpio
read -t 1 s </dev/pigout
read -t 1 s </dev/pigout
if [[ $s = "BC1 bits Clear GPIO in bank 1" ]]
then echo "HELP-b ok"
else echo "HELP-b fail ($s)"
fi
read -t 1 -N 9000 </dev/pigout # dump rest of help
echo "hwver" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s -ne 0 ]]; then echo "HWVER ok"; else echo "HWVER fail ($s)"; fi
echo "mics 1000" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "MICS ok"; else echo "MICS fail ($s)"; fi
echo "mils 10" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "MILS ok"; else echo "MILS fail ($s)"; fi
echo "modes $GPIO 0" >/dev/pigpio
read -t 1 s </dev/pigout
echo "modeg $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 4 ]]; then echo "MODEG ok"; else echo "MODEG fail ($s)"; fi
echo "m $GPIO r" >/dev/pigpio
read -t 1 s </dev/pigout
echo "mg $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "MODES ok"; else echo "MODES fail ($s)"; fi
echo "no" >/dev/pigpio
read -t 1 h </dev/pigout
if [[ $h -ge 0 && $h -le 31 ]]
then echo "NO($h) ok"
else echo "NO fail ($s)"
fi
echo "nb $h 0xabcd" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "NB($h) ok"; else echo "NB fail ($s)"; fi
echo "np $h" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "NP($h) ok"; else echo "NP fail ($s)"; fi
echo "nc $h" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "NC($h) ok"; else echo "NC fail ($s)"; fi
echo "pfs $GPIO 800" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 800 ]]; then echo "PFG-a ok"; else echo "PFG-a fail ($s)"; fi
echo "pfg $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 800 ]]; then echo "PFG-b ok"; else echo "PFG-b fail ($s)"; fi
echo "pfs $GPIO 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 10 ]]; then echo "PFS-a ok"; else echo "PFS-a fail ($s)"; fi
echo "pfs $GPIO 800" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 800 ]]; then echo "PFS-b ok"; else echo "PFS-b fail ($s)"; fi
echo "prs $GPIO 255" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 250 ]]; then echo "PRG-a ok"; else echo "PRG-a fail ($s)"; fi
echo "prg $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 255 ]]; then echo "PRG-b ok"; else echo "PRG-b fail ($s)"; fi
echo "proc ld p1 p0 ld p0 29 tag 9 mils 1000 jmp 9" >/dev/pigpio
read -t 1 p </dev/pigout
if [[ $p -ge 0 && $p -le 31 ]]
then echo "PROC($p) ok"
else echo "PROC($p) fail ($s)"
fi
sleep 0.1 # Make sure script has time to intialise.
echo "procr $p 9876" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "PROCR($p) ok"; else echo "PROCR($p) fail ($s)"; fi
echo "procp $p" >/dev/pigpio
read -t 1 -a v </dev/pigout
if [[ ${v[0]} = 2 && ${v[1]} = 29 && ${v[2]} = 9876 ]]
then echo "PROCP($p) ok"
else echo "PROCP($p) fail ($s)"
fi
echo "procs $p" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "PROCS($p) ok"; else echo "PROCS($p) fail ($s)"; fi
echo "procd $p" >/dev/pigpio
sleep 0.1
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "PROCD($p) ok"; else echo "PROCD($p) fail ($s)"; fi
echo "prrg $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 250 ]]; then echo "PRRG ok"; else echo "PRRG fail ($s)"; fi
echo "prs $GPIO 1000" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 250 ]]; then echo "PRS-a ok"; else echo "PRS-a fail ($s)"; fi
echo "prg $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1000 ]]; then echo "PRS-b ok"; else echo "PRS-b fail ($s)"; fi
echo "prs $GPIO 255" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 250 ]]; then echo "PRS-c ok"; else echo "PRS-c fail ($s)"; fi
echo "prg $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 255 ]]; then echo "PRS-d ok"; else echo "PRS-d fail ($s)"; fi
echo "pud $GPIO u" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "PUD-a ok"; else echo "PUD-a fail ($s)"; fi
echo "r $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "PUD-b ok"; else echo "PUD-b fail ($s)"; fi
echo "pud $GPIO d" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "PUD-c ok"; else echo "PUD-c fail ($s)"; fi
echo "r $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "PUD-d ok"; else echo "PUD-d fail ($s)"; fi
echo "pud $GPIO o" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "PUD-e ok"; else echo "PUD-e fail ($s)"; fi
echo "p $GPIO 128" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "PWM-a ok"; else echo "PWM-a fail ($s)"; fi
echo "gdc $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 128 ]]; then echo "GDC-a ok"; else echo "GDC-a fail ($s)"; fi
echo "pwm $GPIO 64" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "PWM-b ok"; else echo "PWM-b fail ($s)"; fi
echo "GDC $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 64 ]]; then echo "GDC-b ok"; else echo "GDC-b fail ($s)"; fi
echo "pwm $GPIO 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "PWM-c ok"; else echo "PWM-c fail ($s)"; fi
echo "gdc $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "GDC-c ok"; else echo "GDC-c fail ($s)"; fi
echo "m $GPIO r" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "PWM-d ok"; else echo "PWM-d fail ($s)"; fi
echo "pud $GPIO u" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "READ-a ok"; else echo "READ-a fail ($s)"; fi
echo "r $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "READ-b ok"; else echo "READ-b fail ($s)"; fi
echo "pud $GPIO d" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "READ-c ok"; else echo "READ-c fail ($s)"; fi
echo "read $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "READ-d ok"; else echo "READ-d fail ($s)"; fi
echo "pud $GPIO o" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "READ-e ok"; else echo "READ-e fail ($s)"; fi
echo "s $GPIO 500" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "SERVO-a ok"; else echo "SERVO-a fail ($s)"; fi
echo "gpw $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 500 ]]; then echo "GPW-a ok"; else echo "GPW-a fail ($s)"; fi
echo "servo $GPIO 2500" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "SERVO-b ok"; else echo "SERVO-b fail ($s)"; fi
echo "GPW $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 2500 ]]; then echo "GPW-b ok"; else echo "GPW-b fail ($s)"; fi
echo "servo $GPIO 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "SERVO-c ok"; else echo "SERVO-c fail ($s)"; fi
echo "gpw $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "GPW-c ok"; else echo "GPW-c fail ($s)"; fi
echo "w $GPIO 1" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "SERVO-d ok"; else echo "SERVO-d fail ($s)"; fi
echo "wvclr" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "SLR-a ok"; else echo "SLR-a fail ($s)"; fi
echo "slro $GPIO 4800 8" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "SLR-b ok"; else echo "SLR-b fail ($s)"; fi
echo "wvas $GPIO 4800 8 2 0 0x6d 0x79 0x20 0x6e 0x61 0x6d 0x65 0x20 0x69 0x73 0x20 0x6a 0x6f 0x61 0x6e" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 95 ]]; then echo "SLR-c ok"; else echo "SLR-c fail ($s)"; fi
echo "m $GPIO w" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "SLR-d ok"; else echo "SLR-d fail ($s)"; fi
echo "wvcre" >/dev/pigpio
read -t 1 w </dev/pigout
if [[ $w -ge 0 ]]; then echo "WVCRE ok"; else echo "WVCRE fail ($w)"; fi
echo "wvtx $w" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 191 ]]; then echo "SLR-e ok"; else echo "SLR-e fail ($s)"; fi
sleep 0.4
echo "slr $GPIO 100" >/dev/pigpio
read -t 1 s </dev/pigout
e="15 109 121 32 110 97 109 101 32 105 115 32 106 111 97 110"
if [[ $s = $e ]]
then echo "SLR-f ok"
else echo "SLR-f fail with ($s)"
fi
read -t 1 s </dev/pigout # dump any junk
echo "slrc $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "SLR-g ok"; else echo "SLR-g fail ($s)"; fi
echo "t" >/dev/pigpio
echo "tick" >/dev/pigpio
read -t 1 t1 </dev/pigout
read -t 1 t2 </dev/pigout
s=$((t2-t1))
if [[ $s -gt 0 && $s -lt 5000 ]]
then echo "TICK ok"
else echo "TICK fail ($s)"
fi
pigs w $GPIO 1 # put in known state
echo "trig $GPIO 10 1" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "TRIG-a ok"; else echo "TRIG-a fail ($s)"; fi
echo "r $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "TRIG-b ok"; else echo "TRIG-b fail ($s)"; fi
echo "trig $GPIO 10 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "TRIG-c ok"; else echo "TRIG-c fail ($s)"; fi
echo "r $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "TRIG-d ok"; else echo "TRIG-d fail ($s)"; fi
echo "wdog $GPIO 1000" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "WDOG-a ok"; else echo "WDOG-a fail ($s)"; fi
echo "wdog $GPIO 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "WDOG-b ok"; else echo "WDOG-b fail ($s)"; fi
echo "w $GPIO 1" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "WRITE-a ok"; else echo "WRITE-a fail ($s)"; fi
echo "r $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "WRITE-b ok"; else echo "WRITE-b fail ($s)"; fi
echo "write $GPIO 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "WRITE-c ok"; else echo "WRITE-c fail ($s)"; fi
echo "r $GPIO" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "WRITE-d ok"; else echo "WRITE-d fail ($s)"; fi
echo "wvclr" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "WVCLR ok"; else echo "WVCLR fail ($s)"; fi
echo "wvas $GPIO 300 8 2 0 0x74 0x68 0x69 0x73 0x20 0x69 0x73 0x20 0x74 0x68 0x65 0x20 0x77 0x69 0x6e 0x74 0x65 0x72 0x20 0x6f 0x66 0x20 0x6d 0x79 0x20 0x64 0x69 0x73 0x63 0x6f 0x6e 0x74 0x65 0x6e 0x74" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 215 ]]; then echo "WVAS ok"; else echo "WVAS fail ($s)"; fi
echo "wvag 16 0 5000000 0 16 5000000" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 216 ]]; then echo "WVAG ok"; else echo "WVAG fail ($s)"; fi
echo "wvcre" >/dev/pigpio
read -t 1 w </dev/pigout
if [[ $w -ge 0 ]]; then echo "WVCRE ok"; else echo "WVCRE fail ($s)"; fi
echo "wvtx $w" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ ($s = 433) || ($s = 977) ]]
then echo "WVTX ok"
else echo "WVTX fail ($s)"
fi
echo "wvbsy" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "WVBSY-a ok"; else echo "WVBSY-a fail ($s)"; fi
sleep 1
echo "wvbsy" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "WVBSY-b ok"; else echo "WVBSY-b fail ($s)"; fi
echo "wvhlt" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "WVHLT ok"; else echo "WVHLT fail ($s)"; fi
echo "wvbsy" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "WVBSY-c ok"; else echo "WVBSY-c fail ($s)"; fi
echo "wvtxr $w" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ ($s = 433) || ($s = 977) ]]
then echo "WVTXR ok"
else echo "WVTXR fail ($s)"
fi
echo "wvbsy" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "WVBSY-d ok"; else echo "WVBSY-d fail ($s)"; fi
echo "wvhlt" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "WVHLT ok"; else echo "WVHLT fail ($s)"; fi
echo "wvbsy" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "WVBSY-e ok"; else echo "WVBSY-e fail ($s)"; fi
echo "wvsc 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ ($s = 432) || ($s = 743) ]]
then echo "WVSC-a ok"
else echo "WVSC-a fail ($s)"
fi
echo "wvsc 1" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s -ge 432 ]]; then echo "WVSC-b ok"; else echo "WVSC-b fail ($s)"; fi
echo "wvsc 2" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 25016 ]]; then echo "WVSC-c ok"; else echo "WVSC-c fail ($s)"; fi
echo "wvsm 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 10000000 ]]; then echo "WVSM-a ok"; else echo "WVSM-a fail ($s)"; fi
echo "wvsm 1" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s -ge 10000000 ]]; then echo "WVSM-b ok"; else echo "WVSM-b fail ($s)"; fi
echo "wvsm 2" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1800000000 ]]
then echo "WVSM-c ok"
else echo "WVSM-c fail ($s)"
fi
echo "wvsp 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 216 ]]; then echo "WVSP-a ok"; else echo "WVSP-a fail ($s)"; fi
echo "wvsp 1" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s -ge 216 ]]; then echo "WVSP-b ok"; else echo "WVSP-b fail ($s)"; fi
echo "wvsp 2" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 12000 ]]; then echo "WVSP-c ok"; else echo "WVSP-c fail ($s)"; fi