• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscaphegui翻訳comegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

hardware/gps


コミットメタ情報

リビジョンbe8caf448e1e8b3d4cc794e959a93217922a2e14 (tree)
日時2015-04-07 15:40:38
作者Keith Conger <keith.conger@gmai...>
コミッターChih-Wei Huang

ログメッセージ

Fix satellite reporting and some cleanup

変更サマリ

差分

--- a/gps.c
+++ b/gps.c
@@ -40,14 +40,14 @@ typedef struct {
4040 int init;
4141 int fd;
4242 GpsCallbacks *callbacks;
43- GpsStatus status;
43+ GpsStatus status;
4444 pthread_t thread;
4545 int control[2];
4646 } GpsState;
4747
4848 static GpsState _gps_state[1];
4949 static int id_in_fixed[12];
50-#define GPS_DEBUG 0
50+#define GPS_DEBUG 1
5151
5252 #define DFR(...) ALOGD(__VA_ARGS__)
5353
@@ -62,10 +62,11 @@ static int id_in_fixed[12];
6262
6363 #define GPS_DEV_LOW_BAUD (B4800)
6464 #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);
6970
7071 /*****************************************************************/
7172 /*****************************************************************/
@@ -80,7 +81,7 @@ typedef struct {
8081 const char* end;
8182 } Token;
8283
83-#define MAX_NMEA_TOKENS 16
84+#define MAX_NMEA_TOKENS 32
8485
8586 typedef struct {
8687 int count;
@@ -116,13 +117,11 @@ nmea_tokenizer_init( NmeaTokenizer* t, const char* p, const char* end )
116117 if (q == NULL)
117118 q = end;
118119
119- if (q > p) {
120120 if (count < MAX_NMEA_TOKENS) {
121121 t->tokens[count].p = p;
122122 t->tokens[count].end = q;
123123 count += 1;
124124 }
125- }
126125 if (q < end)
127126 q += 1;
128127
@@ -475,9 +474,13 @@ nmea_reader_update_svs( NmeaReader* r, int inview, int num, int i, Token prn, T
475474 r->sv_status.sv_list[i].elevation=str2int(elevation.p,elevation.end);
476475 r->sv_status.sv_list[i].azimuth=str2int(azimuth.p,azimuth.end);
477476 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+ }
481484 }
482485 return 0;
483486 }
@@ -564,13 +567,31 @@ nmea_reader_parse( NmeaReader* r )
564567 Token tok_hdop = nmea_tokenizer_get(tzer,16);
565568 Token tok_vdop = nmea_tokenizer_get(tzer,17);
566569
570+ nmea_reader_update_accuracy(r, tok_hdop);
571+
567572 int i;
568573 for ( i=0; i<12; i++ ) {
569574 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+ }
572580 }
573581 } 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+
574595 //Satellites are handled by RPC-side code.
575596 Token tok_num_messages = nmea_tokenizer_get(tzer,1);
576597 Token tok_msg_number = nmea_tokenizer_get(tzer,2);
@@ -595,8 +616,10 @@ nmea_reader_parse( NmeaReader* r )
595616 int msg_number = str2int(tok_msg_number.p,tok_msg_number.end);
596617 int svs_inview = str2int(tok_svs_inview.p,tok_svs_inview.end);
597618 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+
600623 nmea_reader_update_svs( r, svs_inview, msg_number, 0, tok_sv1_prn_num, tok_sv1_elevation, tok_sv1_azimuth, tok_sv1_snr );
601624 nmea_reader_update_svs( r, svs_inview, msg_number, 1, tok_sv2_prn_num, tok_sv2_elevation, tok_sv2_azimuth, tok_sv2_snr );
602625 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 )
605628
606629 if (num_messages==msg_number)
607630 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+
633632 } else if ( !memcmp(tok.p, "RMC", 3) ) {
634633 Token tok_time = nmea_tokenizer_get(tzer,1);
635634 Token tok_fixStatus = nmea_tokenizer_get(tzer,2);
@@ -1332,6 +1331,6 @@ struct hw_module_t HAL_MODULE_INFO_SYM = {
13321331 .version_minor = 0,
13331332 .id = GPS_HARDWARE_MODULE_ID,
13341333 .name = "Serial GPS Module",
1335- .author = "The Android-x86 Open Source Project",
1334+ .author = "Keith Conger",
13361335 .methods = &gps_module_methods,
13371336 };