2 * This file is part of u360gts, aka amv-open360tracker 32bits:
3 * https://github.com/raul-ortega/amv-open360tracker-32bits
5 * The code below is an adaptation by Raúl Ortega of the original code written by Samuel Brucksch:
6 * https://github.com/SamuelBrucksch/open360tracker
8 * u360gts is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * u360gts is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with u360gts. If not, see <http://www.gnu.org/licenses/>.
24 This code is written by Samuel Brucksch, and improved by Raul Ortega
26 it will decode the RVOSD telemetry protocol and will convert it into values the open360tracker can understand
28 $1,1,00040291,00.000000,N,000.000000,W,+00000,+00000,000,0000,0000,000,+000,000,089,089,089,089,1160,0000,00004,0004,00,000,0026,*00
29 $1,1,00194723,41.572332,N,001.973692,E,+00312,+00312,254,0021,0000,005,+000,220,000,000,000,000,1156,0002,00050,0161,06,000,0033,0,*01
31 It is sent 25 times/S, 115200, 8N1.
34 Validity (1 valid, 0 invalid)
35 Units (1 metric, 0 imperial)
36 HHMMSSmm (hour|minutes|seconds|tenth of seconds)
41 +/- altitude (relative)
42 +/- altitude (absolute)
54 Aux battery voltage (V * 100)
63 Checksum is everything XORed from "$" to "temperature".
66 #include "telemetry.h"
68 uint8_t dot_found
= 0;
70 uint16_t checksum_calculation
= 0;
71 uint16_t checksum_read
= 0;
73 //data needed to buffer
78 uint16_t rvosd_headingtemp
;
79 uint16_t rvosd_heading
=0;
83 uint32_t rvosd_lat_bp
;
84 uint32_t rvosd_lon_bp
;
85 uint32_t rvosd_lat_ap
;
86 uint32_t rvosd_lon_ap
;
92 uint8_t rvosd_data_index
= 0;
93 uint8_t frame_started
= 0;
94 uint8_t checksum_started
= 0;
96 uint8_t checksum_index
= 0;
98 void rvosd_encodeTargetData(uint8_t c
) {
99 if (c
== '$' && !frame_started
){
100 frame_started
= true;
101 checksum_started
= false;
102 checksum_calculation
= 0;
119 else if (c
== 'R' && frame_started
){
120 checksum_calculation
^= c
;
123 else if (c
== 'V' && frame_started
){
124 checksum_calculation
^= c
;
127 else if (c
== '*' && frame_started
){
128 checksum_started
= true;
131 else if (checksum_index
== 2){
132 if (checksum_read
== checksum_calculation
){
133 telemetry_lat
= ((int32_t)rvosd_lat_bp
*100000+(int32_t)(rvosd_lat_ap
/10))*(int32_t)latsign
;
134 telemetry_lon
= ((int32_t)rvosd_lon_bp
*100000+(int32_t)(rvosd_lon_ap
/10))*(int32_t)lonsign
;
135 telemetry_sats
=satstemp
;
136 telemetry_alt
=altsign
*alttemp
;
137 rvosd_heading
=rvosd_headingtemp
;
144 telemetry_failed_cs
++;
146 frame_started
= false;
150 if (checksum_started
){
153 if (c
>= '0' && c
<= '9'){
154 checksum_read
+= (c
- '0');
157 checksum_read
+= (c
-'A'+10);
162 checksum_calculation
^= c
;
175 switch (rvosd_data_index
) {
179 //frame invalid, skip...
180 frame_started
= false;
183 else if ((c
- '0') == 1){
184 //frame valid, do nothing
188 //units, 0 = imperial, 1 = metric
192 else if (c
- '0' == 1){
204 rvosd_lat_bp
+= c
-'0';
208 rvosd_lat_ap
+= c
-'0';
228 rvosd_lon_bp
+= c
-'0';
232 rvosd_lon_ap
+= c
-'0';
263 //no after comma i think
268 rvosd_headingtemp
*= 10;
269 rvosd_headingtemp
+= c
- '0';