Rev 262 | Rev 265 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 262 | Rev 264 | ||
---|---|---|---|
Line 34... | Line 34... | ||
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 37... | Line 37... | ||
37 | 37 | ||
38 | public byte lib_version_major=0; |
38 | public byte lib_version_major=0; |
Line 39... | Line 39... | ||
39 | public byte lib_version_minor=5; |
39 | public byte lib_version_minor=6; |
40 | 40 | ||
41 | public String lib_version_str() |
41 | public String lib_version_str() |
42 | { |
42 | { |
Line -... | Line 43... | ||
- | 43 | return "V"+lib_version_major+"."+lib_version_minor; |
|
- | 44 | } |
|
- | 45 | ||
- | 46 | ||
- | 47 | public int AngleNick() |
|
- | 48 | { |
|
- | 49 | if (ufo_prober.is_mk()) |
|
- | 50 | return angle_nick; |
|
- | 51 | else if (ufo_prober.is_navi()) |
|
- | 52 | return debug_data.analog[0]; |
|
- | 53 | return -1; |
|
- | 54 | ||
- | 55 | } |
|
- | 56 | ||
- | 57 | ||
- | 58 | public int AngleRoll() |
|
- | 59 | { |
|
- | 60 | if (ufo_prober.is_mk()) |
|
- | 61 | return angle_roll; |
|
- | 62 | else if (ufo_prober.is_navi()) |
|
- | 63 | ||
- | 64 | return debug_data.analog[1]; |
|
- | 65 | return -1; |
|
43 | return "V"+lib_version_major+"."+lib_version_minor; |
66 | |
44 | } |
67 | } |
Line 45... | Line 68... | ||
45 | 68 | ||
Line 56... | Line 79... | ||
56 | // boolean do_log=false; |
79 | // boolean do_log=false; |
57 | boolean do_log=true; |
80 | boolean do_log=true; |
Line 58... | Line 81... | ||
58 | 81 | ||
Line -... | Line 82... | ||
- | 82 | int data_buff_pos=0; |
|
- | 83 | ||
- | 84 | ||
- | 85 | // public final static int DATA_IN_BUFF_SIZE=512; |
|
- | 86 | public final static int DATA_IN_BUFF_SIZE=2048; |
|
59 | int data_buff_pos=0; |
87 | // public final static int DATA_IN_BUFF_SIZE=4096; |
60 | 88 | ||
61 | public byte user_intent=0; |
89 | public byte user_intent=0; |
62 | public final static int[] crc16_table = { |
90 | public final static int[] crc16_table = { |
63 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, |
91 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, |
Line 97... | Line 125... | ||
97 | public void log(String str) |
125 | public void log(String str) |
98 | { |
126 | { |
99 | //#ifdef android |
127 | //#ifdef android |
100 | if (do_log) Log.d("MK-Comm",str); |
128 | if (do_log) Log.d("MK-Comm",str); |
101 | //#endif |
129 | //#endif |
- | 130 | // canvas.debug.log(str); |
|
102 | System.out.println(str); |
131 | // System.out.println(str); |
103 | } |
132 | } |
Line 104... | Line 133... | ||
104 | 133 | ||
105 | public int CRC16(int ch, int crc) |
134 | public int CRC16(int ch, int crc) |
106 | { |
135 | { |
Line 411... | Line 440... | ||
411 | } |
440 | } |
Line 412... | Line 441... | ||
412 | 441 | ||
413 | 442 | ||
414 | public void switch_todo() |
443 | public void switch_todo() |
415 | { |
444 | { |
416 | sleep(50); |
445 | sleep(150); |
417 | version=new MKVersion(); |
446 | version=new MKVersion(); |
Line 418... | Line 447... | ||
418 | LCD= new MKLCD(this); |
447 | LCD= new MKLCD(this); |
Line 532... | Line 561... | ||
532 | 561 | ||
Line 533... | Line 562... | ||
533 | } |
562 | } |
534 | 563 | ||
535 | public void set_debug_interval(int interval) |
564 | public void set_debug_interval(int interval) |
536 | { |
565 | { |
- | 566 | send_command(2,'d',interval); |
|
- | 567 | } |
|
- | 568 | ||
- | 569 | ||
- | 570 | public void set_gpsosd_interval(int interval) |
|
- | 571 | { |
|
- | 572 | send_command(NAVI_SLAVE_ADDR,'o',interval); |
|
537 | send_command(FC_SLAVE_ADDR,'d',interval); |
573 | } |
538 | } |
574 | |
539 | public void send_command(int modul,char cmd) |
575 | public void send_command(int modul,char cmd) |
540 | { |
576 | { |
Line 652... | Line 688... | ||
652 | { |
688 | { |
653 | debug_buff=new int[len][targets.length]; |
689 | debug_buff=new int[len][targets.length]; |
Line 654... | Line 690... | ||
654 | 690 | ||
655 | debug_buff_off=0; |
691 | debug_buff_off=0; |
- | 692 | debug_buff_len=len; |
|
656 | debug_buff_len=len; |
693 | |
- | 694 | debug_buff_interval=interval; |
|
657 | debug_buff_interval=interval; |
695 | if (debug_buff_interval<2)debug_buff_interval=2; |
658 | debug_buff_targets=targets; |
696 | debug_buff_targets=targets; |
659 | debug_buff_max=1; |
697 | debug_buff_max=1; |
660 | debug_buff_lastset=0; |
698 | debug_buff_lastset=0; |
Line 675... | Line 713... | ||
675 | } |
713 | } |
Line 676... | Line 714... | ||
676 | 714 | ||
677 | public void process_data(byte[] data,int len) |
715 | public void process_data(byte[] data,int len) |
Line 678... | Line -... | ||
678 | { |
- | |
- | 716 | { |
|
679 | 717 | ||
680 | 718 | slave_addr=data[1]; |
|
681 | log("command " +(char)data[2] ); |
719 | log("command " +(char)data[2] ); |
Line 682... | Line 720... | ||
682 | switch((char)data[2]) |
720 | switch((char)data[2]) |
Line 1115... | Line 1153... | ||
1115 | } |
1153 | } |
Line 1116... | Line 1154... | ||
1116 | 1154 | ||
1117 | 1155 | ||
- | 1156 | byte[] data_set=new byte[1024]; |
|
- | 1157 | int data_set_pos=0; |
|
- | 1158 | ||
- | 1159 | ||
1118 | byte[] data_set=new byte[1024]; |
1160 | |
Line 1119... | Line 1161... | ||
1119 | int data_set_pos=0; |
1161 | |
1120 | byte[] data_in_buff=new byte[2048]; |
1162 | byte[] data_in_buff=new byte[DATA_IN_BUFF_SIZE]; |
Line 1127... | Line 1169... | ||
1127 | 1169 | ||
1128 | 1170 | ||
1129 | log("Thread started"); |
1171 | log("Thread started"); |
- | 1172 | while(true) |
|
- | 1173 | { |
|
- | 1174 | ||
- | 1175 | data_buff[data_buff_pos]="ct-l" +data_buff_pos + "" + connected ; |
|
Line 1130... | Line 1176... | ||
1130 | while(true) |
1176 | data_buff_pos++; |
1131 | { |
1177 | data_buff_pos%=DATA_BUFF_LEN; |
1132 | 1178 | ||
1133 | if (!connected) |
1179 | if (!connected) |
Line 1144... | Line 1190... | ||
1144 | catch (Exception e) { } |
1190 | catch (Exception e) { } |
1145 | } |
1191 | } |
1146 | */ |
1192 | */ |
Line 1147... | Line 1193... | ||
1147 | 1193 | ||
- | 1194 | recieving=true; |
|
- | 1195 | int read_count ; |
|
- | 1196 | ||
- | 1197 | ||
- | 1198 | ||
1148 | recieving=true; |
1199 | if (reader.available()<DATA_IN_BUFF_SIZE) |
- | 1200 | read_count =reader.read(data_in_buff,0,reader.available()); |
|
- | 1201 | else |
|
- | 1202 | read_count =reader.read(data_in_buff,0,DATA_IN_BUFF_SIZE); |
|
- | 1203 | ||
- | 1204 | ||
- | 1205 | if ( read_count!=0) |
|
- | 1206 | { |
|
- | 1207 | data_buff[data_buff_pos]="avail:" + reader.available(); |
|
- | 1208 | data_buff_pos++; |
|
- | 1209 | data_buff_pos%=DATA_BUFF_LEN; |
|
1149 | int read_count =reader.read(data_in_buff,0,reader.available()); |
1210 | } |
1150 | // log("Connected - reading data " + read_count); |
1211 | // log("Connected - reading data " + read_count); |
1151 | // pos=0; |
1212 | // pos=0; |
1152 | input=0; |
1213 | input=0; |
1153 | //data_buff[data_buff_pos]=""; |
1214 | //data_buff[data_buff_pos]=""; |
1154 | // recieve data-set |
1215 | // recieve data-set |
Line 1155... | Line 1216... | ||
1155 | if (read_count==0) sleep(50); |
1216 | if (read_count==0) sleep(20); |
1156 | 1217 | ||
1157 | // int read_count =reader.read(data_in_buff,0,reader.available()); |
1218 | // int read_count =reader.read(data_in_buff,0,reader.available()); |
1158 | stats.bytes_in+=read_count; |
1219 | stats.bytes_in+=read_count; |
Line 1211... | Line 1272... | ||
1211 | } |
1272 | } |
Line 1212... | Line 1273... | ||
1212 | 1273 | ||
1213 | 1274 | ||
1214 | } |
1275 | } |
1215 | else |
1276 | else |
1216 | sleep(50); |
1277 | sleep(5); |
1217 | /* |
1278 | /* |
1218 | while ((input != 13)) //&&(input!=-1)) |
1279 | while ((input != 13)) //&&(input!=-1)) |
1219 | { |
1280 | { |