Rev 265 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 265 | Rev 266 | ||
---|---|---|---|
Line 33... | Line 33... | ||
33 | public int angle_nick=-4242; |
33 | public int angle_nick=-4242; |
34 | public int angle_roll=-4242; |
34 | public int angle_roll=-4242; |
35 | public byte bl_retrys=0; |
35 | public byte bl_retrys=0; |
36 | public boolean init_bootloader=false; |
36 | public boolean init_bootloader=false; |
Line -... | Line 37... | ||
- | 37 | ||
- | 38 | public boolean disconnect_notify=false; |
|
37 | 39 | ||
38 | public byte lib_version_major=0; |
40 | public byte lib_version_major=0; |
- | 41 | public byte lib_version_minor=7; |
|
- | 42 | ||
Line 39... | Line 43... | ||
39 | public byte lib_version_minor=6; |
43 | public byte last_navi_error=0; |
40 | 44 | ||
41 | public String lib_version_str() |
45 | public String lib_version_str() |
42 | { |
46 | { |
Line 460... | Line 464... | ||
460 | 464 | ||
461 | 465 | ||
462 | public void switch_todo() |
466 | public void switch_todo() |
463 | { |
467 | { |
464 | sleep(150); |
468 | sleep(150); |
465 | version=new MKVersion(); |
469 | version.reset(); |
Line 466... | Line 470... | ||
466 | LCD= new MKLCD(this); |
470 | // LCD= new MKLCD(this); |
Line 467... | Line 471... | ||
467 | debug_data=new MKDebugData(); |
471 | debug_data=new MKDebugData(); |
Line 758... | Line 762... | ||
758 | log("got debug data"); |
762 | log("got debug data"); |
759 | stats.debug_data_count++; |
763 | stats.debug_data_count++; |
760 | debug_data.set_by_mk_data(Decode64(data,3,len-3),version); |
764 | debug_data.set_by_mk_data(Decode64(data,3,len-3),version); |
Line 761... | Line 765... | ||
761 | 765 | ||
- | 766 | if (ufo_prober.is_mk()) |
|
762 | if (ufo_prober.is_mk()) |
767 | { |
- | 768 | stats.process_mkflags(debug_data.motor_val(0)); // TODO remove dirty hack |
|
- | 769 | stats.process_alt(Alt()); |
|
763 | stats.process_mkflags(debug_data.motor_val(0)); // TODO remove dirty hack |
770 | } |
764 | if (debug_buff_targets!=null) |
771 | if (debug_buff_targets!=null) |
765 | { |
772 | { |
766 | for (int sp=0;sp<debug_buff_targets.length;sp++) |
773 | for (int sp=0;sp<debug_buff_targets.length;sp++) |
767 | debug_buff[debug_buff_off][sp]=chg_debug_max(debug_data.analog[debug_buff_targets[sp]]); |
774 | debug_buff[debug_buff_off][sp]=chg_debug_max(debug_data.analog[debug_buff_targets[sp]]); |
768 | if (debug_buff_off>debug_buff_lastset) |
775 | if (debug_buff_off>debug_buff_lastset) |
Line 769... | Line 776... | ||
769 | debug_buff_lastset=debug_buff_off; |
776 | debug_buff_lastset=debug_buff_off; |
770 | - | ||
771 | debug_buff_off=(debug_buff_off+1)%debug_buff_len; |
- | |
Line 772... | Line 777... | ||
772 | 777 | ||
773 | 778 | debug_buff_off=(debug_buff_off+1)%debug_buff_len; |
|
774 | 779 | ||
Line 842... | Line 847... | ||
842 | 847 | ||
Line 843... | Line 848... | ||
843 | gps_position.set_by_mk_data(Decode64(data,3,len-3),version); |
848 | gps_position.set_by_mk_data(Decode64(data,3,len-3),version); |
844 | 849 | ||
- | 850 | stats.process_mkflags(gps_position.MKFlags); |
|
- | 851 | stats.process_compas(gps_position.CompasHeading); |
|
845 | stats.process_mkflags(gps_position.MKFlags); |
852 | stats.process_speed(gps_position.GroundSpeed); |
846 | stats.process_compas(gps_position.CompasHeading); |
853 | stats.process_alt(Alt()); |
Line 847... | Line 854... | ||
847 | log("long:" + gps_position.Longitude); |
854 | log("long:" + gps_position.Longitude); |
Line 865... | Line 872... | ||
865 | 872 | ||
Line 866... | Line 873... | ||
866 | public boolean force_disconnect=true; |
873 | public boolean force_disconnect=true; |
867 | 874 | ||
- | 875 | public void close_connections(boolean force) |
|
868 | public void close_connections(boolean force) |
876 | { |
869 | { |
877 | |
870 | // if ((!force)&&root.canvas.do_vibra) root.vibrate(500); |
878 | // if ((!force)&&root.canvas.do_vibra) root.vibrate(500); |
871 | force_disconnect=force; |
879 | force_disconnect=force; |
Line 880... | Line 888... | ||
880 | //# catch (Exception inner_ex) { } |
888 | //# catch (Exception inner_ex) { } |
881 | //#endif |
889 | //#endif |
882 | ufo_prober.set_to_none(); |
890 | ufo_prober.set_to_none(); |
883 | stats.reset(); |
891 | stats.reset(); |
884 | connected=false; |
892 | connected=false; |
885 | version=new MKVersion(); |
893 | version.reset(); |
- | 894 | disconnect_notify=true; |
|
886 | } |
895 | } |
Line 887... | Line 896... | ||
887 | 896 | ||
888 | // Thread to recieve data from Connection |
897 | // Thread to recieve data from Connection |
889 | public void run() |
898 | public void run() |
Line 1195... | Line 1204... | ||
1195 | 1204 | ||
1196 | log("Thread started"); |
1205 | log("Thread started"); |
1197 | while(true) |
1206 | while(true) |
Line 1198... | Line -... | ||
1198 | { |
- | |
1199 | - | ||
1200 | data_buff[data_buff_pos]="ct-l" +data_buff_pos + "" + connected ; |
- | |
1201 | data_buff_pos++; |
- | |
1202 | data_buff_pos%=DATA_BUFF_LEN; |
1207 | { |
1203 | 1208 | ||
1204 | if (!connected) |
1209 | if (!connected) |
1205 | { |
1210 | { |
1206 | if (!force_disconnect) connect(); |
1211 | if (!force_disconnect) connect(); |
Line 1213... | Line 1218... | ||
1213 | while(sending) |
1218 | while(sending) |
1214 | {try { Thread.sleep(50); } |
1219 | {try { Thread.sleep(50); } |
1215 | catch (Exception e) { } |
1220 | catch (Exception e) { } |
1216 | } |
1221 | } |
1217 | */ |
1222 | */ |
1218 | - | ||
1219 | recieving=true; |
1223 | recieving=true; |
1220 | int read_count ; |
1224 | int read_count ; |
Line 1221... | Line -... | ||
1221 | - | ||
1222 | - | ||
1223 | 1225 | ||
1224 | if (reader.available()<DATA_IN_BUFF_SIZE) |
1226 | if (reader.available()<DATA_IN_BUFF_SIZE) |
1225 | read_count =reader.read(data_in_buff,0,reader.available()); |
1227 | read_count =reader.read(data_in_buff,0,reader.available()); |
1226 | else |
1228 | else |
Line 1227... | Line -... | ||
1227 | read_count =reader.read(data_in_buff,0,DATA_IN_BUFF_SIZE); |
- | |
1228 | - | ||
1229 | - | ||
1230 | if ( read_count!=0) |
- | |
1231 | { |
- | |
1232 | data_buff[data_buff_pos]="avail:" + reader.available(); |
- | |
1233 | data_buff_pos++; |
- | |
1234 | data_buff_pos%=DATA_BUFF_LEN; |
1229 | read_count =reader.read(data_in_buff,0,DATA_IN_BUFF_SIZE); |
1235 | } |
1230 | |
1236 | // log("Connected - reading data " + read_count); |
1231 | // log("Connected - reading data " + read_count); |
1237 | // pos=0; |
1232 | // pos=0; |
1238 | input=0; |
1233 | input=0; |
1239 | //data_buff[data_buff_pos]=""; |
- | |
Line 1240... | Line 1234... | ||
1240 | // recieve data-set |
1234 | //data_buff[data_buff_pos]=""; |
1241 | if (read_count==0) sleep(20); |
1235 | // recieve data-set |
1242 | 1236 | ||
1243 | // int read_count =reader.read(data_in_buff,0,reader.available()); |
1237 | // int read_count =reader.read(data_in_buff,0,reader.available()); |
Line 1297... | Line 1291... | ||
1297 | } |
1291 | } |
Line 1298... | Line 1292... | ||
1298 | 1292 | ||
1299 | 1293 | ||
- | 1294 | } |
|
- | 1295 | else |
|
1300 | } |
1296 | { |
- | 1297 | recieving=false; |
|
1301 | else |
1298 | sleep(20); |
1302 | sleep(5); |
1299 | } |
1303 | /* |
1300 | /* |
1304 | while ((input != 13)) //&&(input!=-1)) |
1301 | while ((input != 13)) //&&(input!=-1)) |
1305 | { |
1302 | { |