Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | #include "pseventparser.h" |
2 | |||
3 | void PSEventParser::Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset) |
||
4 | { |
||
5 | uint16_t cntdn = (uint16_t)len; |
||
6 | uint8_t *p = (uint8_t*)pbuf; |
||
7 | |||
8 | switch (nStage) |
||
9 | { |
||
10 | case 0: |
||
11 | p += 12; |
||
12 | cntdn -= 12; |
||
13 | |||
14 | if (!cntdn) |
||
15 | return; |
||
16 | nStage ++; |
||
17 | |||
18 | case 1: |
||
19 | theBuffer.valueSize = 4; |
||
20 | valueParser.Initialize(&theBuffer); |
||
21 | nStage ++; |
||
22 | case 2: |
||
23 | if (!valueParser.Parse(&p, &cntdn)) |
||
24 | return; |
||
25 | |||
26 | //PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
27 | nStage ++; |
||
28 | case 3: |
||
29 | //Notify(PSTR("\r\nNumber of Fields:\t")); |
||
30 | theBuffer.valueSize = 2; |
||
31 | valueParser.Initialize(&theBuffer); |
||
32 | nStage ++; |
||
33 | case 4: |
||
34 | if (!valueParser.Parse(&p, &cntdn)) |
||
35 | return; |
||
36 | |||
37 | //PrintHex<uint16_t>(*((uint16_t*)theBuffer.pValue)); |
||
38 | nStage ++; |
||
39 | case 5: |
||
40 | //Notify(PSTR("\r\nEvent Code:\t")); |
||
41 | theBuffer.valueSize = 2; |
||
42 | valueParser.Initialize(&theBuffer); |
||
43 | nStage ++; |
||
44 | case 6: |
||
45 | if (!valueParser.Parse(&p, &cntdn)) |
||
46 | return; |
||
47 | |||
48 | eventCode = *((uint16_t*)theBuffer.pValue); |
||
49 | //PrintHex<uint16_t>(*((uint16_t*)theBuffer.pValue)); |
||
50 | nStage ++; |
||
51 | case 7: |
||
52 | //Notify(PSTR("\r\nTransaction ID:\t")); |
||
53 | theBuffer.valueSize = 4; |
||
54 | valueParser.Initialize(&theBuffer); |
||
55 | nStage ++; |
||
56 | case 8: |
||
57 | if (!valueParser.Parse(&p, &cntdn)) |
||
58 | return; |
||
59 | |||
60 | //PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
61 | nStage ++; |
||
62 | case 9: |
||
63 | if (eventCode == PTP_EC_ObjectAdded) |
||
64 | Notify(PSTR("\r\nObject Added:\t\t")); |
||
65 | |||
66 | theBuffer.valueSize = 4; |
||
67 | valueParser.Initialize(&theBuffer); |
||
68 | nStage ++; |
||
69 | case 10: |
||
70 | if (eventCode == PTP_EC_ObjectAdded) |
||
71 | { |
||
72 | if (!valueParser.Parse(&p, &cntdn)) |
||
73 | return; |
||
74 | |||
75 | objHandle = *((uint32_t*)theBuffer.pValue); |
||
76 | PrintHex<uint32_t>(*((uint32_t*)theBuffer.pValue)); |
||
77 | Notify(PSTR("\r\n")); |
||
78 | } |
||
79 | if (eventCode == PTP_EC_CaptureComplete) |
||
80 | Notify(PSTR("\r\nCapture complete.\r\n")); |
||
81 | nStage ++; |
||
82 | case 11: |
||
83 | nStage = 0; |
||
84 | } |
||
85 | } |