-
大小: 15KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-06-05
- 語言: Java
- 標簽: android4.2??gps??hal??
資源簡介
android 下處理gps數(shù)據(jù)的hal層代碼,帶Android.mk 文件,只處理gps數(shù)據(jù),不處理北斗的數(shù)據(jù)。(源碼來自網(wǎng)絡)
調(diào)試中解決的問題:
1、使用gps test工具測試,能搜索到衛(wèi)星且也能夠定位,但是已使用的衛(wèi)星個數(shù)一直為零。(北斗數(shù)據(jù)覆蓋了gps數(shù)據(jù)導致)
2、信號為零的衛(wèi)星也顯示。(修改代碼邏輯,將信號大于零才加入衛(wèi)星列表)
3、只有定到位置后才顯示衛(wèi)星。(修改代碼只要有衛(wèi)星有信號,就上報android系統(tǒng))

代碼片段和文件信息
/*
?*?Copyright?(C)?2010?The?Android?Open?Source?Project
?*
?*?Licensed?under?the?Apache?License?Version?2.0?(the?“License“);
?*?you?may?not?use?this?file?except?in?compliance?with?the?License.
?*?You?may?obtain?a?copy?of?the?License?at
?*
?*??????http://www.apache.org/licenses/LICENSE-2.0
?*
?*?Unless?required?by?applicable?law?or?agreed?to?in?writing?software
?*?distributed?under?the?License?is?distributed?on?an?“AS?IS“?BASIS
?*?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY?KIND?either?express?or?implied.
?*?See?the?License?for?the?specific?language?governing?permissions?and
?*?limitations?under?the?License.
?*/
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include??
#include??
#include??
#include??
#include??
#include?
#include?
#include?
#include?
#include?
#include?
#define??LOG_TAG??“GPS“
#define??GPS_DEBUG??0
#if?GPS_DEBUG
#define??D(...)???LOGD(__VA_ARGS__)
#else
#define??D(...)???((void)0)
#endif
typedef?struct?{
????const?char*??p;
????const?char*??end;
}?Token;
#define??MAX_NMEA_TOKENS??21
typedef?struct?{
????int?????count;
????Token???tokens[?MAX_NMEA_TOKENS?];
}?NmeaTokenizer;
GpsStatus?g_status;
static?int
nmea_tokenizer_init(?NmeaTokenizer*??t?const?char*??p?const?char*??end?)
{
????int????count?=?0;
????char*??q;
????//?the?initial?‘$‘?is?optional
????if?(p?????????p?+=?1;
????//?remove?trailing?newline
????if?(end?>?p?&&?end[-1]?==?‘\n‘)?{
????????end?-=?1;
????????if?(end?>?p?&&?end[-1]?==?‘\r‘)
????????????end?-=?1;
????}
????//?get?rid?of?checksum?at?the?end?of?the?sentecne
????if?(end?>=?p+3?&&?end[-3]?==?‘*‘)?{
????????end?-=?3;
????}
????while?(p?????????const?char*??q?=?p;
????????q?=?memchr(p?‘‘?end-p);
????????if?(q?==?NULL){
????????????q?=?end;
}
????????if?(q?>=?p)?{
????????????if?(count?????????????????t->tokens[count].p???=?p;
????????????????t->tokens[count].end?=?q;
????????????????count?+=?1;
????????????}
????????}
????????if?(q?????????????q?+=?1;
}
????????p?=?q;
????}
????t->count?=?count;
????return?count;
}
static?Token
nmea_tokenizer_get(?NmeaTokenizer*??t?int??index?)
{
????Token??tok;
????static?const?char*??dummy?=?““;
????if?(index?0?||?index?>=?t->count)?{
????????tok.p?=?tok.end?=?dummy;
????}?else?{
????????tok?=?t->tokens[index];
????}
????return?tok;
}
static?int
str2int(?const?char*??p?const?char*??end?)
{
????int???result?=?0;
????int???len????=?end?-?p;
????for?(?;?len?>?0;?len--?p++?)
????{
????????int??c;
????????if?(p?>=?end)
????????????goto?Fail;
????????c?=?*p?-?‘0‘;
????????if?((unsigned)c?>=?10)
????????????goto?Fail;
????????result?=?result*10?+?c;
????}
????return??result;
Fail:
????return?-1;
}
static?double
str2float(?const?char*??p?const?char*??end?)
{
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????13652??2014-03-12?15:54??gps_hal\gps.default.so
?????文件??????30735??2014-03-12?15:54??gps_hal\gps.c
?????文件???????1045??2014-03-12?09:53??gps_hal\Android.mk
?????目錄??????????0??2014-03-12?15:54??gps_hal
-----------?---------??----------?-----??----
????????????????45432????????????????????4
評論
共有 條評論