hardware/gps
リビジョン | be8caf448e1e8b3d4cc794e959a93217922a2e14 (tree) |
---|---|
日時 | 2015-04-07 15:40:38 |
作者 | Keith Conger <keith.conger@gmai...> |
コミッター | Chih-Wei Huang |
Fix satellite reporting and some cleanup
@@ -40,14 +40,14 @@ typedef struct { | ||
40 | 40 | int init; |
41 | 41 | int fd; |
42 | 42 | GpsCallbacks *callbacks; |
43 | - GpsStatus status; | |
43 | + GpsStatus status; | |
44 | 44 | pthread_t thread; |
45 | 45 | int control[2]; |
46 | 46 | } GpsState; |
47 | 47 | |
48 | 48 | static GpsState _gps_state[1]; |
49 | 49 | static int id_in_fixed[12]; |
50 | -#define GPS_DEBUG 0 | |
50 | +#define GPS_DEBUG 1 | |
51 | 51 | |
52 | 52 | #define DFR(...) ALOGD(__VA_ARGS__) |
53 | 53 |
@@ -62,10 +62,11 @@ static int id_in_fixed[12]; | ||
62 | 62 | |
63 | 63 | #define GPS_DEV_LOW_BAUD (B4800) |
64 | 64 | #define GPS_DEV_HIGH_BAUD (B115200) |
65 | - static void gps_dev_init(int fd); | |
66 | - static void gps_dev_deinit(int fd); | |
67 | - static void gps_dev_start(int fd); | |
68 | - static void gps_dev_stop(int fd); | |
65 | + | |
66 | +static void gps_dev_init(int fd); | |
67 | +static void gps_dev_deinit(int fd); | |
68 | +static void gps_dev_start(int fd); | |
69 | +static void gps_dev_stop(int fd); | |
69 | 70 | |
70 | 71 | /*****************************************************************/ |
71 | 72 | /*****************************************************************/ |
@@ -80,7 +81,7 @@ typedef struct { | ||
80 | 81 | const char* end; |
81 | 82 | } Token; |
82 | 83 | |
83 | -#define MAX_NMEA_TOKENS 16 | |
84 | +#define MAX_NMEA_TOKENS 32 | |
84 | 85 | |
85 | 86 | typedef struct { |
86 | 87 | int count; |
@@ -116,13 +117,11 @@ nmea_tokenizer_init( NmeaTokenizer* t, const char* p, const char* end ) | ||
116 | 117 | if (q == NULL) |
117 | 118 | q = end; |
118 | 119 | |
119 | - if (q > p) { | |
120 | 120 | if (count < MAX_NMEA_TOKENS) { |
121 | 121 | t->tokens[count].p = p; |
122 | 122 | t->tokens[count].end = q; |
123 | 123 | count += 1; |
124 | 124 | } |
125 | - } | |
126 | 125 | if (q < end) |
127 | 126 | q += 1; |
128 | 127 |
@@ -475,9 +474,13 @@ nmea_reader_update_svs( NmeaReader* r, int inview, int num, int i, Token prn, T | ||
475 | 474 | r->sv_status.sv_list[i].elevation=str2int(elevation.p,elevation.end); |
476 | 475 | r->sv_status.sv_list[i].azimuth=str2int(azimuth.p,azimuth.end); |
477 | 476 | r->sv_status.sv_list[i].snr=str2int(snr.p,snr.end); |
478 | - for (o=0;o<12;o++) | |
479 | - if (id_in_fixed[o]==str2int(prn.p,prn.end)) | |
480 | - r->sv_status.used_in_fix_mask |= 1<i ; | |
477 | + for (o=0;o<12;o++){ | |
478 | + if (id_in_fixed[o]==str2int(prn.p,prn.end)){ | |
479 | + int prni = str2int(prn.p, prn.end); | |
480 | + r->sv_status.used_in_fix_mask |= (1ul << (prni-1)); | |
481 | + D("sv_status.used_in_fix_mask: '%i'", r->sv_status.used_in_fix_mask); | |
482 | + } | |
483 | + } | |
481 | 484 | } |
482 | 485 | return 0; |
483 | 486 | } |
@@ -564,13 +567,31 @@ nmea_reader_parse( NmeaReader* r ) | ||
564 | 567 | Token tok_hdop = nmea_tokenizer_get(tzer,16); |
565 | 568 | Token tok_vdop = nmea_tokenizer_get(tzer,17); |
566 | 569 | |
570 | + nmea_reader_update_accuracy(r, tok_hdop); | |
571 | + | |
567 | 572 | int i; |
568 | 573 | for ( i=0; i<12; i++ ) { |
569 | 574 | Token tok_id = nmea_tokenizer_get(tzer,3+i); |
570 | - if ( tok_id.end > tok_id.p ) | |
571 | - id_in_fixed[i]=str2int(tok_id.end, tok_id.p); | |
575 | + if ( tok_id.end > tok_id.p ){ | |
576 | + id_in_fixed[i]=str2int(tok_id.p,tok_id.end); | |
577 | + D("id='%i' satellite='%i'",i, id_in_fixed[i]); | |
578 | + D("Satellite used '%.*s'", tok_id.end-tok_id.p, tok_id.p); | |
579 | + } | |
572 | 580 | } |
573 | 581 | } else if ( !memcmp(tok.p, "GSV", 3) ) { |
582 | + /* | |
583 | + 1 = Total number of messages of this type in this cycle | |
584 | + 2 = Message number | |
585 | + 3 = Total number of SVs in view | |
586 | + 4 = SV PRN number | |
587 | + 5 = Elevation in degrees, 90 maximum | |
588 | + 6 = Azimuth, degrees from true north, 000 to 359 | |
589 | + 7 = SNR, 00-99 dB (null when not tracking) | |
590 | + 8-11 = Information about second SV, same as field 4-7 | |
591 | + 12-15= Information about third SV, same as field 4-7 | |
592 | + 16-19= Information about fourth SV, same as field 4-7 | |
593 | + */ | |
594 | + | |
574 | 595 | //Satellites are handled by RPC-side code. |
575 | 596 | Token tok_num_messages = nmea_tokenizer_get(tzer,1); |
576 | 597 | Token tok_msg_number = nmea_tokenizer_get(tzer,2); |
@@ -595,8 +616,10 @@ nmea_reader_parse( NmeaReader* r ) | ||
595 | 616 | int msg_number = str2int(tok_msg_number.p,tok_msg_number.end); |
596 | 617 | int svs_inview = str2int(tok_svs_inview.p,tok_svs_inview.end); |
597 | 618 | D("GSV %d %d %d", num_messages, msg_number, svs_inview ); |
598 | - if (msg_number==1) | |
599 | - r->sv_status.used_in_fix_mask=0; | |
619 | + if (msg_number==1) { | |
620 | + r->sv_status.used_in_fix_mask = 0ul; | |
621 | + } | |
622 | + | |
600 | 623 | nmea_reader_update_svs( r, svs_inview, msg_number, 0, tok_sv1_prn_num, tok_sv1_elevation, tok_sv1_azimuth, tok_sv1_snr ); |
601 | 624 | nmea_reader_update_svs( r, svs_inview, msg_number, 1, tok_sv2_prn_num, tok_sv2_elevation, tok_sv2_azimuth, tok_sv2_snr ); |
602 | 625 | nmea_reader_update_svs( r, svs_inview, msg_number, 2, tok_sv3_prn_num, tok_sv3_elevation, tok_sv3_azimuth, tok_sv3_snr ); |
@@ -605,31 +628,7 @@ nmea_reader_parse( NmeaReader* r ) | ||
605 | 628 | |
606 | 629 | if (num_messages==msg_number) |
607 | 630 | update_gps_svstatus(&r->sv_status); |
608 | - /* | |
609 | - 1 = Total number of messages of this type in this cycle | |
610 | - 2 = Message number | |
611 | - 3 = Total number of SVs in view | |
612 | - 4 = SV PRN number | |
613 | - 5 = Elevation in degrees, 90 maximum | |
614 | - 6 = Azimuth, degrees from true north, 000 to 359 | |
615 | - 7 = SNR, 00-99 dB (null when not tracking) | |
616 | - 8-11 = Information about second SV, same as field 4-7 | |
617 | - 12-15= Information about third SV, same as field 4-7 | |
618 | - 16-19= Information about fourth SV, same as field 4-7 | |
619 | - */ | |
620 | -/* | |
621 | - int i; | |
622 | - _gps_state.sv_status.num_svs=ntohl(data[82]) & 0x1F; | |
623 | - for(i=0;i<ret.num_svs;++i) { | |
624 | - _gps_state.sv_status.sv_list[i].prn=ntohl(data[83+3*i]); | |
625 | - _gps_state.sv_status.sv_list[i].elevation=ntohl(data[83+3*i+1]); | |
626 | - _gps_state.sv_status.sv_list[i].azimuth=ntohl(data[83+3*i+2])/100; | |
627 | - _gps_state.sv_status.sv_list[i].snr=ntohl(data[83+3*i+2])%100; | |
628 | - } | |
629 | - _gps_state.sv_status.used_in_fix_mask=ntohl(data[77]); | |
630 | - update_gps_svstatus(&_gps_state. | |
631 | - | |
632 | -*/ | |
631 | + | |
633 | 632 | } else if ( !memcmp(tok.p, "RMC", 3) ) { |
634 | 633 | Token tok_time = nmea_tokenizer_get(tzer,1); |
635 | 634 | Token tok_fixStatus = nmea_tokenizer_get(tzer,2); |
@@ -1332,6 +1331,6 @@ struct hw_module_t HAL_MODULE_INFO_SYM = { | ||
1332 | 1331 | .version_minor = 0, |
1333 | 1332 | .id = GPS_HARDWARE_MODULE_ID, |
1334 | 1333 | .name = "Serial GPS Module", |
1335 | - .author = "The Android-x86 Open Source Project", | |
1334 | + .author = "Keith Conger", | |
1336 | 1335 | .methods = &gps_module_methods, |
1337 | 1336 | }; |