Rev 4 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4 | Rev 5 | ||
---|---|---|---|
Line 110... | Line 110... | ||
110 | } |
110 | } |
111 | 111 | ||
112 | uint8_t |
112 | uint8_t |
113 | decodePacket (char *linebuff, int linePos, Location *loc) |
113 | decodePacket (char *linebuff, int linePos, Location *loc) |
114 | { |
114 | { |
115 | uint8_t checksum; |
115 | uint8_t checksum = 0; |
116 | for (int i = 0; i < linePos - 3; i++) |
116 | for (int i = 0; i < linePos - 3; i++) |
117 | checksum ^= linebuff[i]; |
117 | checksum ^= linebuff[i]; |
118 | uint8_t givenSum = (decodeHex (linebuff[linePos - 2]) << 4) |
118 | uint8_t givenSum = (decodeHex (linebuff[linePos - 2]) << 4) |
119 | + decodeHex (linebuff[linePos - 1]); |
119 | + decodeHex (linebuff[linePos - 1]); |
120 | if (givenSum != checksum) |
120 | if (givenSum != checksum) |
Line 143... | Line 143... | ||
143 | loc->ew = *fieldPos[5]; |
143 | loc->ew = *fieldPos[5]; |
144 | loc->speed = decodeFP (fieldPos[6]); |
144 | loc->speed = decodeFP (fieldPos[6]); |
145 | loc->heading = decodeFP (fieldPos[7]); |
145 | loc->heading = decodeFP (fieldPos[7]); |
146 | 146 | ||
147 | } |
147 | } |
148 | 148 | return linePos; |
|
149 | } |
149 | } |