forked from pfalcon/blutunode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand_parse.c
1470 lines (1385 loc) · 29 KB
/
command_parse.c
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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Warning - this file was autogenerated by genparse
DO NOT EDIT - any changes will be lost
*/
#include "command_parse.h"
#include <ctype.h>
#include <panic.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <util.h> /* hash and compare */
#if (defined TEST_HARNESS || defined DISPLAY_AT_CMDS)
#include <stdio.h>
#endif
typedef const uint8 *ptr;
static __inline__ char my_toupper(char c)
{ return 'a' <= c && c <= 'z' ? c +'A'-'a' : c; }
static ptr skip1(ptr s, ptr e)
{
if(s)
while(s != e && (*s == ' ' || *s == '\t'))
++s;
return s;
}
static ptr skip2(ptr s, ptr e)
{
if(s)
while(s != e && (*s == '?'))
++s;
return s;
}
static ptr match1(ptr s, ptr e)
{ return s && s != e && (*s == '\r' || *s == '\n') ? s+1 : 0; }
static ptr match2(ptr s, ptr e)
{ return s && s != e && (*s == '=' || *s == ':') ? s+1 : 0; }
static ptr skipOnce1(ptr s, ptr e)
{
if(s)
{
if(s != e && (*s == ',' || *s == ';'))
++s;
}
return s;
}
static __inline__ ptr skipQuote(ptr p, ptr e)
{ return p && p != e && *p == '"' ? p+1 : p; }
#ifdef TEST_HARNESS
static void printString(const char *name, const struct sequence *s)
{
uint16 i;
printf(" %s='", name);
for(i = 0; i < s->length; ++i) putchar(s->data[i]);
printf("'");
}
#endif
static const int isStringTable[] =
{
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,0,1,0,0,0,0,0,0,1,1,0,1,0,1,
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0
};
static __inline__ int isString(char c)
{
return (c & ~0x7F) == 0 && isStringTable[(int)c];
}
static ptr getString(ptr p, ptr e, struct sequence *res)
{
p = skipQuote(p, e);
if(p)
{
ptr s = p;
while(p != e && isString(*p)) ++p;
if(p != s)
{
res->data = s;
res->length = p - s;
return skipQuote(p, e);
}
else
{
p = skipQuote(p, e);
if (*p==',' || *p == '\r')
{
res->data = 0;
res->length = 0;
return p;
}
}
}
res->data = 0;
res->length = 0;
return 0;
}
static ptr matchChar(ptr s, ptr e, uint8 c)
{ return s && s != e && my_toupper((char) *s) == (char) c ? s+1 : 0; }
static ptr findEndOfPacket(ptr s, ptr e)
{
/*
Returns
0 if the buffer holds an incomplete packet
s+1 if the buffer holds an invalid packet
end of the first packet otherwise
*/
if(s == e) return 0;
if(*s == '\r')
{
/* expecting <cr> <lf> ... <cr> <lf> */
if(e-s >= 4)
{
if(s[1] == '\n' && s[2] != '\r')
{
ptr p = s+2;
if(*p != '\r')
{
#ifndef TEST_HARNESS
p = (const uint8*)UtilFind(0xFFFF, '\r', (const uint16*)p, 0, 1, (uint16)(e-p));
#endif
#ifdef TEST_HARNESS
while(p != e && *p != '\r') p++;
#endif
return p == 0 || p + 1 == e ? 0 /* no terminator yet */
: p[1] == '\n' ? p+2 /* valid */
: s+1 ; /* invalid terminator */
}
else
return s+1;
}
else
{
return s+1;
}
}
else
{
/* Can't tell yet */
return 0;
}
}
else
{
/* expecting ... <cr> */
ptr p = s;
while(p != e && (*p == ' ' || *p == '\n' || *p == '\0' || *p == '\t')) ++p;
if(p != e && *p == '\r') return s+1;
while(p != e && *p != '\r') ++p;
return p == e ? 0 : p+1;
}
}
#ifndef TEST_HARNESS
#ifdef __XAP__
uint16 parseSource(Source rfcDataIn, Task task)
{
ptr s = SourceMap(rfcDataIn);
ptr e = s + SourceSize(rfcDataIn);
ptr p = parseData(s, e, task);
if(p != s)
{
SourceDrop(rfcDataIn, (uint16) (p - s));
return 1;
}
else
{
return 0;
}
}
#endif
#endif
typedef struct {
char c;
int to;
} Arc;
static const Arc arcs[] = {
{ '\t', 0 },
{ ' ', 0 },
{ 'A', 1 },
{ 'T', 2 },
{ '\t', 2 },
{ '\n', -1 },
{ '\r', -1 },
{ ' ', 2 },
{ '+', 3 },
{ '\t', 3 },
{ ' ', 3 },
{ 'A', 4 },
{ 'B', 5 },
{ 'C', 6 },
{ 'G', 7 },
{ 'L', 8 },
{ 'P', 9 },
{ 'R', 10 },
{ 'S', 11 },
{ 'T', 12 },
{ 'V', 13 },
{ 'D', 14 },
{ 'L', 15 },
{ 'T', 16 },
{ 'L', 17 },
{ 'T', 18 },
{ 'P', 19 },
{ 'O', 20 },
{ 'O', 21 },
{ 'S', 22 },
{ 'T', 23 },
{ 'L', 24 },
{ 'E', 25 },
{ 'E', 26 },
{ 'C', -2 },
{ 'L', 27 },
{ 'V', 28 },
{ 'K', 29 },
{ 'S', 30 },
{ 'I', 31 },
{ 'C', 32 },
{ 'L', 33 },
{ 'K', 34 },
{ 'S', 35 },
{ 'E', 36 },
{ 'M', 37 },
{ 'R', 38 },
{ 'O', 39 },
{ 'E', 40 },
{ '\t', 29 },
{ '\n', -3 },
{ '\r', -3 },
{ ' ', 29 },
{ '?', 41 },
{ '\t', 30 },
{ '\n', -4 },
{ '\r', -4 },
{ ' ', 30 },
{ '?', 42 },
{ 'O', -5 },
{ 'A', 43 },
{ 'L', 44 },
{ 'E', 45 },
{ '\t', 35 },
{ ' ', 35 },
{ ':', -6 },
{ '=', -6 },
{ 'E', 46 },
{ 'P', 47 },
{ '\t', 48 },
{ '\n', -7 },
{ '\r', -7 },
{ ' ', 48 },
{ '?', 49 },
{ 'S', 50 },
{ 'C', 51 },
{ 'R', 52 },
{ '\t', 53 },
{ '\n', -3 },
{ '\r', -3 },
{ ' ', 53 },
{ '?', 41 },
{ '\t', 54 },
{ '\n', -4 },
{ '\r', -4 },
{ ' ', 54 },
{ '?', 42 },
{ 'L', 55 },
{ '\t', 44 },
{ ' ', 44 },
{ ':', -8 },
{ '=', -8 },
{ 'Y', -9 },
{ 'P', 56 },
{ '\t', 47 },
{ '\n', -10 },
{ '\r', -10 },
{ ' ', 47 },
{ '?', 57 },
{ '\t', 48 },
{ '\n', -7 },
{ '\r', -7 },
{ ' ', 48 },
{ '?', 49 },
{ '\t', 58 },
{ '\n', -7 },
{ '\r', -7 },
{ ' ', 58 },
{ '?', 49 },
{ 'I', 59 },
{ '\t', 51 },
{ '\n', -11 },
{ '\r', -11 },
{ ' ', 51 },
{ '?', 60 },
{ '\t', 52 },
{ '\n', -12 },
{ '\r', -12 },
{ ' ', 52 },
{ '?', 61 },
{ '\t', 53 },
{ '\n', -3 },
{ '\r', -3 },
{ ' ', 53 },
{ '\t', 54 },
{ '\n', -4 },
{ '\r', -4 },
{ ' ', 54 },
{ 'V', 62 },
{ '\t', 56 },
{ ' ', 56 },
{ ':', -13 },
{ '=', -13 },
{ '\t', 63 },
{ '\n', -10 },
{ '\r', -10 },
{ ' ', 63 },
{ '?', 57 },
{ '\t', 58 },
{ '\n', -7 },
{ '\r', -7 },
{ ' ', 58 },
{ 'O', 64 },
{ '\t', 65 },
{ '\n', -11 },
{ '\r', -11 },
{ ' ', 65 },
{ '?', 60 },
{ '\t', 66 },
{ '\n', -12 },
{ '\r', -12 },
{ ' ', 66 },
{ '?', 61 },
{ 'E', 67 },
{ '\t', 63 },
{ '\n', -10 },
{ '\r', -10 },
{ ' ', 63 },
{ 'N', 48 },
{ '\t', 65 },
{ '\n', -11 },
{ '\r', -11 },
{ ' ', 65 },
{ '\t', 66 },
{ '\n', -12 },
{ '\r', -12 },
{ ' ', 66 },
{ 'R', 68 },
{ '\t', 68 },
{ '\n', -14 },
{ '\r', -14 },
{ ' ', 68 },
{ '?', 69 },
{ '\t', 70 },
{ '\n', -14 },
{ '\r', -14 },
{ ' ', 70 },
{ '?', 69 },
{ '\t', 70 },
{ '\n', -14 },
{ '\r', -14 },
{ ' ', 70 },
};
static const Arc *const states[72] = {
&arcs[0],
&arcs[3],
&arcs[4],
&arcs[9],
&arcs[21],
&arcs[23],
&arcs[24],
&arcs[26],
&arcs[27],
&arcs[28],
&arcs[30],
&arcs[31],
&arcs[32],
&arcs[33],
&arcs[34],
&arcs[35],
&arcs[36],
&arcs[37],
&arcs[38],
&arcs[39],
&arcs[40],
&arcs[41],
&arcs[42],
&arcs[43],
&arcs[44],
&arcs[45],
&arcs[46],
&arcs[47],
&arcs[48],
&arcs[49],
&arcs[54],
&arcs[59],
&arcs[60],
&arcs[61],
&arcs[62],
&arcs[63],
&arcs[67],
&arcs[68],
&arcs[69],
&arcs[75],
&arcs[76],
&arcs[77],
&arcs[82],
&arcs[87],
&arcs[88],
&arcs[92],
&arcs[93],
&arcs[94],
&arcs[99],
&arcs[104],
&arcs[109],
&arcs[110],
&arcs[115],
&arcs[120],
&arcs[124],
&arcs[128],
&arcs[129],
&arcs[133],
&arcs[138],
&arcs[142],
&arcs[143],
&arcs[148],
&arcs[153],
&arcs[154],
&arcs[158],
&arcs[159],
&arcs[163],
&arcs[167],
&arcs[168],
&arcs[173],
&arcs[178],
&arcs[182],
};
static uint16 matchLiteral(ptr s, ptr e, Task task)
{ s=s; e=e; task=task; return 0; }
ptr parseData(ptr s, ptr e, Task task)
{
ptr p;
#ifdef DISPLAY_AT_CMDS
{
ptr c = s;
printf("\nreceived: ");
while (c != e)
{
if (*c == '\r') printf("\\r");
else if (*c == '\n') printf("\\n");
else putchar(*c);
c++;
}
}
#endif
#ifdef TEST_HARNESS
task = task;
#endif
for(; (p = findEndOfPacket(s, e)) != 0; s = p)
{
if(p == s+1)
{
/* Silently discard one character; no packets are that short */
continue;
}
else if(matchLiteral(s, p, task))
{
continue;
}
else
{
union {
struct command_adc_get command_adc_get;
struct command_gpio_pin_get command_gpio_pin_get;
struct command_gpio_set command_gpio_set;
struct command_gpio_pin_set command_gpio_pin_set;
struct command_gpiodir_pin_get command_gpiodir_pin_get;
struct command_gpiodir_set command_gpiodir_set;
struct command_gpiodir_pin_set command_gpiodir_pin_set;
struct command_gpiosbias_pin_get command_gpiosbias_pin_get;
struct command_gpiosbias_set command_gpiosbias_set;
struct command_gpiosbias_pin_set command_gpiosbias_pin_set;
struct command_gpio_watch_set command_gpio_watch_set;
struct command_rts_set command_rts_set;
struct command_poll_set command_poll_set;
struct command_pskey_get command_pskey_get;
struct command_sleep_set command_sleep_set;
} u, *uu = &u;
int state = 0;
ptr t = s;
while(t != e && state >= 0)
{
char m = my_toupper((char) *t);
const Arc *a = states[state];
const Arc *const last_a = states[state+1];
#ifndef TEST_HARNESS
a = (const Arc *) (void *) UtilFind(0xFFFF, (uint16) m, (const uint16 *) (void *) &a[0].c, 0, sizeof(Arc), (uint16) (last_a - a));
#endif
#ifdef TEST_HARNESS
while(a != last_a && a->c != m) a++;
#endif
/*lint -e{801} suppress goto is deprecated */
if(!a) goto unrecognised;
state = a->to;
++t;
}
switch(-state)
{
case 1:
if(t)
{
#ifndef TEST_HARNESS
command_ok(task);
#endif
#ifdef TEST_HARNESS
printf("Called command_ok");
putchar('\n');
#endif
continue;
}
break;
case 2:
if(match1(skip1(skip2(skip1(UtilGetNumber(t, e, &uu->command_adc_get.channel), e), e), e), e))
{
#ifndef TEST_HARNESS
command_adc_get(task, &uu->command_adc_get);
#endif
#ifdef TEST_HARNESS
printf("Called command_adc_get");
printf(" channel=%d", uu->command_adc_get.channel);
putchar('\n');
#endif
continue;
}
break;
case 3:
if(t)
{
#ifndef TEST_HARNESS
command_clk_get(task);
#endif
#ifdef TEST_HARNESS
printf("Called command_clk_get");
putchar('\n');
#endif
continue;
}
break;
case 4:
if(t)
{
#ifndef TEST_HARNESS
command_cts_get(task);
#endif
#ifdef TEST_HARNESS
printf("Called command_cts_get");
putchar('\n');
#endif
continue;
}
break;
case 5:
if(match1(skip1(skip2(skip1(t, e), e), e), e))
{
#ifndef TEST_HARNESS
command_gpio_get(task);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpio_get");
putchar('\n');
#endif
continue;
}
if(match1(skip1(skip2(skip1(UtilGetNumber(skip1(t, e), e, &uu->command_gpio_pin_get.pin), e), e), e), e))
{
#ifndef TEST_HARNESS
command_gpio_pin_get(task, &uu->command_gpio_pin_get);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpio_pin_get");
printf(" pin=%d", uu->command_gpio_pin_get.pin);
putchar('\n');
#endif
continue;
}
if(match1(skip1(UtilGetNumber(skip1(skipOnce1(UtilGetNumber(skip1(match2(skip1(t, e), e), e), e, &uu->command_gpio_set.mask), e), e), e, &uu->command_gpio_set.bits), e), e))
{
#ifndef TEST_HARNESS
command_gpio_set(task, &uu->command_gpio_set);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpio_set");
printf(" mask=%d", uu->command_gpio_set.mask);
printf(" bits=%d", uu->command_gpio_set.bits);
putchar('\n');
#endif
continue;
}
if(match1(skip1(skip2(skip1(getString(skip1(match2(skip1(UtilGetNumber(skip1(t, e), e, &uu->command_gpio_pin_set.pin), e), e), e), e, &uu->command_gpio_pin_set.value), e), e), e), e))
{
#ifndef TEST_HARNESS
command_gpio_pin_set(task, &uu->command_gpio_pin_set);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpio_pin_set");
printf(" pin=%d", uu->command_gpio_pin_set.pin);
printString("value", &uu->command_gpio_pin_set.value);
putchar('\n');
#endif
continue;
}
if(match1(skip1(skip2(skip1(matchChar(matchChar(matchChar(t, e, 'D'), e, 'I'), e, 'R'), e), e), e), e))
{
#ifndef TEST_HARNESS
command_gpiodir_get(task);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpiodir_get");
putchar('\n');
#endif
continue;
}
if(match1(skip1(skip2(skip1(UtilGetNumber(skip1(matchChar(matchChar(matchChar(t, e, 'D'), e, 'I'), e, 'R'), e), e, &uu->command_gpiodir_pin_get.pin), e), e), e), e))
{
#ifndef TEST_HARNESS
command_gpiodir_pin_get(task, &uu->command_gpiodir_pin_get);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpiodir_pin_get");
printf(" pin=%d", uu->command_gpiodir_pin_get.pin);
putchar('\n');
#endif
continue;
}
if(match1(skip1(UtilGetNumber(skip1(skipOnce1(UtilGetNumber(skip1(match2(skip1(matchChar(matchChar(matchChar(t, e, 'D'), e, 'I'), e, 'R'), e), e), e), e, &uu->command_gpiodir_set.mask), e), e), e, &uu->command_gpiodir_set.bits), e), e))
{
#ifndef TEST_HARNESS
command_gpiodir_set(task, &uu->command_gpiodir_set);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpiodir_set");
printf(" mask=%d", uu->command_gpiodir_set.mask);
printf(" bits=%d", uu->command_gpiodir_set.bits);
putchar('\n');
#endif
continue;
}
if(match1(skip1(UtilGetNumber(skip1(match2(skip1(UtilGetNumber(skip1(matchChar(matchChar(matchChar(t, e, 'D'), e, 'I'), e, 'R'), e), e, &uu->command_gpiodir_pin_set.pin), e), e), e), e, &uu->command_gpiodir_pin_set.value), e), e))
{
#ifndef TEST_HARNESS
command_gpiodir_pin_set(task, &uu->command_gpiodir_pin_set);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpiodir_pin_set");
printf(" pin=%d", uu->command_gpiodir_pin_set.pin);
printf(" value=%d", uu->command_gpiodir_pin_set.value);
putchar('\n');
#endif
continue;
}
if(match1(skip1(skip2(skip1(matchChar(matchChar(matchChar(matchChar(matchChar(t, e, 'S'), e, 'B'), e, 'I'), e, 'A'), e, 'S'), e), e), e), e))
{
#ifndef TEST_HARNESS
command_gpiosbias_get(task);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpiosbias_get");
putchar('\n');
#endif
continue;
}
if(match1(skip1(skip2(skip1(UtilGetNumber(skip1(matchChar(matchChar(matchChar(matchChar(matchChar(t, e, 'S'), e, 'B'), e, 'I'), e, 'A'), e, 'S'), e), e, &uu->command_gpiosbias_pin_get.pin), e), e), e), e))
{
#ifndef TEST_HARNESS
command_gpiosbias_pin_get(task, &uu->command_gpiosbias_pin_get);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpiosbias_pin_get");
printf(" pin=%d", uu->command_gpiosbias_pin_get.pin);
putchar('\n');
#endif
continue;
}
if(match1(skip1(UtilGetNumber(skip1(skipOnce1(UtilGetNumber(skip1(match2(skip1(matchChar(matchChar(matchChar(matchChar(matchChar(t, e, 'S'), e, 'B'), e, 'I'), e, 'A'), e, 'S'), e), e), e), e, &uu->command_gpiosbias_set.mask), e), e), e, &uu->command_gpiosbias_set.bits), e), e))
{
#ifndef TEST_HARNESS
command_gpiosbias_set(task, &uu->command_gpiosbias_set);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpiosbias_set");
printf(" mask=%d", uu->command_gpiosbias_set.mask);
printf(" bits=%d", uu->command_gpiosbias_set.bits);
putchar('\n');
#endif
continue;
}
if(match1(skip1(UtilGetNumber(skip1(match2(skip1(UtilGetNumber(skip1(matchChar(matchChar(matchChar(matchChar(matchChar(t, e, 'S'), e, 'B'), e, 'I'), e, 'A'), e, 'S'), e), e, &uu->command_gpiosbias_pin_set.pin), e), e), e), e, &uu->command_gpiosbias_pin_set.value), e), e))
{
#ifndef TEST_HARNESS
command_gpiosbias_pin_set(task, &uu->command_gpiosbias_pin_set);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpiosbias_pin_set");
printf(" pin=%d", uu->command_gpiosbias_pin_set.pin);
printf(" value=%d", uu->command_gpiosbias_pin_set.value);
putchar('\n');
#endif
continue;
}
if(match1(skip1(UtilGetNumber(skip1(skipOnce1(UtilGetNumber(skip1(skipOnce1(UtilGetNumber(skip1(match2(skip1(matchChar(matchChar(matchChar(matchChar(matchChar(t, e, 'W'), e, 'A'), e, 'T'), e, 'C'), e, 'H'), e), e), e), e, &uu->command_gpio_watch_set.mask), e), e), e, &uu->command_gpio_watch_set.count), e), e), e, &uu->command_gpio_watch_set.period), e), e))
{
#ifndef TEST_HARNESS
command_gpio_watch_set(task, &uu->command_gpio_watch_set);
#endif
#ifdef TEST_HARNESS
printf("Called command_gpio_watch_set");
printf(" mask=%d", uu->command_gpio_watch_set.mask);
printf(" count=%d", uu->command_gpio_watch_set.count);
printf(" period=%d", uu->command_gpio_watch_set.period);
putchar('\n');
#endif
continue;
}
break;
case 6:
if(match1(skip1(skip2(skip1(UtilGetNumber(skip1(t, e), e, &uu->command_rts_set.value), e), e), e), e))
{
#ifndef TEST_HARNESS
command_rts_set(task, &uu->command_rts_set);
#endif
#ifdef TEST_HARNESS
printf("Called command_rts_set");
printf(" value=%d", uu->command_rts_set.value);
putchar('\n');
#endif
continue;
}
break;
case 7:
if(t)
{
#ifndef TEST_HARNESS
command_software_version(task);
#endif
#ifdef TEST_HARNESS
printf("Called command_software_version");
putchar('\n');
#endif
continue;
}
break;
case 8:
if(match1(skip1(t, e), e))
{
#ifndef TEST_HARNESS
command_poll_reset(task);
#endif
#ifdef TEST_HARNESS
printf("Called command_poll_reset");
putchar('\n');
#endif
continue;
}
if(match1(skip1(getString(skip1(skipOnce1(UtilGetNumber(skip1(t, e), e, &uu->command_poll_set.period), e), e), e, &uu->command_poll_set.input), e), e))
{
#ifndef TEST_HARNESS
command_poll_set(task, &uu->command_poll_set);
#endif
#ifdef TEST_HARNESS
printf("Called command_poll_set");
printf(" period=%d", uu->command_poll_set.period);
printString("input", &uu->command_poll_set.input);
putchar('\n');
#endif
continue;
}
break;
case 9:
if(match1(skip1(skip2(skip1(UtilGetNumber(skip1(t, e), e, &uu->command_pskey_get.pskey), e), e), e), e))
{
#ifndef TEST_HARNESS
command_pskey_get(task, &uu->command_pskey_get);
#endif
#ifdef TEST_HARNESS
printf("Called command_pskey_get");
printf(" pskey=%d", uu->command_pskey_get.pskey);
putchar('\n');
#endif
continue;
}
break;
case 10:
if(t)
{
#ifndef TEST_HARNESS
command_temp_get(task);
#endif
#ifdef TEST_HARNESS
printf("Called command_temp_get");
putchar('\n');
#endif
continue;
}
break;
case 11:
if(t)
{
#ifndef TEST_HARNESS
command_alloc_get(task);
#endif
#ifdef TEST_HARNESS
printf("Called command_alloc_get");
putchar('\n');
#endif
continue;
}
break;
case 12:
if(t)
{
#ifndef TEST_HARNESS
command_bt_version_get(task);
#endif
#ifdef TEST_HARNESS
printf("Called command_bt_version_get");
putchar('\n');
#endif
continue;
}
break;
case 13:
if(match1(skip1(UtilGetNumber(skip1(t, e), e, &uu->command_sleep_set.state), e), e))
{
#ifndef TEST_HARNESS
command_sleep_set(task, &uu->command_sleep_set);
#endif
#ifdef TEST_HARNESS
printf("Called command_sleep_set");
printf(" state=%d", uu->command_sleep_set.state);
putchar('\n');
#endif
continue;
}
break;
case 14:
if(t)
{
#ifndef TEST_HARNESS
command_local_version_get(task);
#endif
#ifdef TEST_HARNESS
printf("Called command_local_version_get");
putchar('\n');
#endif
continue;
}
break;
default:
break;
}
/*
The message does not contain a recognised AT command or response.
Pass the data on to the application to have a go at
*/
unrecognised:
#ifndef TEST_HARNESS
handleUnrecognised(s, (uint16) (p-s), task);
#endif
#ifdef TEST_HARNESS
printf("Called handleUnrecognised\n");
#endif
}
}
return s;
}
/*
command_ok
Skip " \t"
MatchChar A
MatchChar T
Skip " \t"
Match "\r\n"
command_gpio_get
Skip " \t"
MatchChar A
MatchChar T
Skip " \t"
MatchChar +
Skip " \t"
MatchChar G
MatchChar P
MatchChar I
MatchChar O
Skip " \t"
Skip "?"
Skip " \t"
Match "\r\n"
command_gpio_pin_get
Skip " \t"
MatchChar A
MatchChar T
Skip " \t"
MatchChar +
Skip " \t"
MatchChar G
MatchChar P
MatchChar I
MatchChar O
Skip " \t"
GetNumber pin
Skip " \t"
Skip "?"
Skip " \t"
Match "\r\n"
command_gpio_set
Skip " \t"
MatchChar A
MatchChar T
Skip " \t"
MatchChar +
Skip " \t"
MatchChar G
MatchChar P
MatchChar I
MatchChar O
Skip " \t"
Match "=:"
Skip " \t"
GetNumber mask
SkipOnce ",;"
Skip " \t"
GetNumber bits
Skip " \t"
Match "\r\n"
command_gpio_pin_set
Skip " \t"
MatchChar A
MatchChar T
Skip " \t"
MatchChar +
Skip " \t"
MatchChar G
MatchChar P
MatchChar I
MatchChar O
Skip " \t"
GetNumber pin
Skip " \t"
Match "=:"
Skip " \t"
GetString value
Skip " \t"
Skip "?"
Skip " \t"
Match "\r\n"
command_gpiodir_get
Skip " \t"
MatchChar A
MatchChar T
Skip " \t"
MatchChar +
Skip " \t"
MatchChar G
MatchChar P