Bem, estou fazendo testes no emulador de um sisteminha que pega uma mensagem do GPS e extrai as coordenadas geográficas.
Eia o código em questão…
public String gpsmsg(){
String msg = null;
try{
CommConnection cc = (CommConnection)Connector.open("comm:com1;baudrate=4800");
InputStream is = cc.openInputStream();
OutputStream os = cc.openOutputStream();
int newdata = 0;
boolean inicio = false;
while (newdata!=-1 && !inicio){
if (newdata=='$'){
StringBuffer sb = new StringBuffer();
inicio = true;
for (int i=0; i<=5;i++){
sb.append((char)newdata);
newdata = is.read();
if (newdata==-1){
break;
}
}
if (sb.toString().startsWith("$GPGLL")){
boolean fim = false;
inicio = true;
while (newdata!=-1 && !fim){
sb.append((char)newdata);
newdata = is.read();
if (newdata=='*' || newdata==0x0D){
fim = true;
}
}
System.out.println(new String(sb));
}
else {
inicio = false;
} }
newdata = is.read();
}
} catch (IOException e){
System.out.println(e.getMessage());
}
return msg;
}
O meu problema é q a mensagem encontrada é desse tipo $GPGLL,N, (Os parametros da latitude e longitude nao aparecem)
Seria porq eu estou testando dentro d ksa e o gps está sem sinal? ou tem algum erro no meu código… O meu GPS é o Garmin Summit da eTrex e eu já configurei pra ele mandar mensagem no formato NMEA a uma taxa d 4800… Alguém já teve um problema parecido?
