Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | /* Copyright (C) 2010-2011 Circuits At Home, LTD. All rights reserved. |
2 | |||
3 | This software may be distributed and modified under the terms of the GNU |
||
4 | General Public License version 2 (GPL2) as published by the Free Software |
||
5 | Foundation and appearing in the file GPL2.TXT included in the packaging of |
||
6 | this file. Please note that GPL2 Section 2[b] requires that all works based |
||
7 | on this software must also be made publicly available under the terms of |
||
8 | the GPL2 ("Copyleft"). |
||
9 | |||
10 | Contact information |
||
11 | ------------------- |
||
12 | |||
13 | Circuits At Home, LTD |
||
14 | Web : http://www.circuitsathome.com |
||
15 | e-mail : support@circuitsathome.com |
||
16 | */ |
||
17 | #include "ptpdebug.h" |
||
18 | |||
19 | void HexDump::Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset) |
||
20 | { |
||
21 | for (uint16_t j=0; j<len; j++, byteCount++, byteTotal++) |
||
22 | { |
||
23 | if (!byteCount) |
||
24 | { |
||
25 | PrintHex<uint16_t>(byteTotal); |
||
26 | Serial.print(": "); |
||
27 | } |
||
28 | PrintHex<uint8_t>(pbuf[j]); |
||
29 | Serial.print(" "); |
||
30 | |||
31 | if (byteCount == 15) |
||
32 | { |
||
33 | Serial.println(""); |
||
34 | byteCount = 0xFF; |
||
35 | } |
||
36 | } |
||
37 | } |
||
38 | |||
39 | void EOSEventDump::Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset) |
||
40 | { |
||
41 | uint8_t *p = (uint8_t*)pbuf; |
||
42 | uint16_t cntdn = (uint16_t)len; |
||
43 | |||
44 | switch (parseStage) |
||
45 | { |
||
46 | case 0: |
||
47 | // Get PTP data packet size |
||
48 | ptppktSize = *((uint32_t*)p); |
||
49 | |||
50 | // Return if the packet has only one empty record |
||
51 | if (ptppktSize == 0x14) |
||
52 | return; |
||
53 | |||
54 | Serial.println("\r\n"); |
||
55 | |||
56 | for (uint8_t i=0; i<4; i++) |
||
57 | { |
||
58 | PrintHex<uint8_t>(((uint8_t*)&ptppktSize)[i]); |
||
59 | Serial.print(" "); |
||
60 | } |
||
61 | |||
62 | // Skip PTP packet header |
||
63 | p += 12; |
||
64 | cntdn -= 12; |
||
65 | parseStage ++; |
||
66 | case 1: |
||
67 | parseSubstage = 0; |
||
68 | parseStage ++; |
||
69 | case 2: |
||
70 | while (1) |
||
71 | { |
||
72 | switch (parseSubstage) |
||
73 | { |
||
74 | // CR after each event record |
||
75 | case 0: |
||
76 | Serial.println(""); |
||
77 | valueParser.Initialize(&valueBuffer); |
||
78 | parseSubstage ++; |
||
79 | |||
80 | // Parse record size value |
||
81 | case 1: |
||
82 | //Serial.println("1"); |
||
83 | if (!valueParser.Parse(&p, &cntdn)) |
||
84 | return; |
||
85 | recordSize = (uint32_t)theBuffer; |
||
86 | for (uint8_t i=0; i<4; i++) |
||
87 | { |
||
88 | PrintHex<uint8_t>(((uint8_t*)&theBuffer)[i]); |
||
89 | Serial.print(" "); |
||
90 | } |
||
91 | recordSize -= 4; |
||
92 | valueParser.Initialize(&valueBuffer); |
||
93 | parseSubstage ++; |
||
94 | |||
95 | // Parse the first uint32_t value |
||
96 | case 2: |
||
97 | //Serial.println("2"); |
||
98 | if (!valueParser.Parse(&p, &cntdn)) |
||
99 | return; |
||
100 | |||
101 | for (uint8_t i=0; i<4; i++) |
||
102 | { |
||
103 | PrintHex<uint8_t>(((uint8_t*)&theBuffer)[i]); |
||
104 | Serial.print(" "); |
||
105 | } |
||
106 | recordSize -= 4; |
||
107 | |||
108 | // Return if empty(last) record |
||
109 | if (recordSize == 0x08 && (uint32_t)theBuffer == 0) |
||
110 | { |
||
111 | parseSubstage = 0; |
||
112 | parseStage = 0; |
||
113 | return; |
||
114 | } |
||
115 | parseSubstage ++; |
||
116 | |||
117 | // Print the rest of the record |
||
118 | case 3: |
||
119 | //Serial.println("3"); |
||
120 | for (; recordSize && cntdn; recordSize--, cntdn--, p++) |
||
121 | { |
||
122 | PrintHex<uint8_t>(*p); |
||
123 | Serial.print(" "); |
||
124 | } |
||
125 | if (!recordSize) |
||
126 | parseSubstage = 0; |
||
127 | if (!cntdn) |
||
128 | return; |
||
129 | |||
130 | } // switch (parseSubstage) |
||
131 | } // while(1) |
||
132 | } // switch (parseStage) |
||
133 | } |