Newsletter
October 29, 2019 - 10:23am, 4831 views
Using AT^SGPSC="Engine","3"I get data through ASC0, but, how do I read the data in my java app?br
Hello,
In your Java app you can use Java API for location. Please see this example: https://iot-developer.thalesgroup.com/showcase/cinterion-ehs8-gps-locati...
If you want to see NMEA data under Java you can additionally try this on the Location object:
String mimeTypes = "application/X-jsr179-location-nmea";
System.out.println(location.getExtraInfo(mimeTypes));
Best regards,
Bartłomiej
Thank's, and it is works running its own thread.
But I do have my old GeoCoding using U-Blox serial connection.
Here I extract
$GPGGA,hhmmss.ss,Latitude,N,Longitude,E,FS,NoSV,HDOP,msl,m,Altref,m,DiffAge,DiffStation*cs<CR><LF>
$GPGGA,122333.02,5548.8177,N,01222.4063,E,1,04,2.25,11.45,M,,M,,*45
The output is a Map coordinates.
These are sent to my computer if any deviation occur.
Configuring the Nmea output interface.
AT^SGPSC="Nmea/Interface","local"(D),"asc0","usb0","usb3","usb4","usb5"
So, I would like to know, how do I get hold on the output of any of the abowe interfaces,
using:
AT^SGPSC="Engine","3"
Br Morten, Farum, DK
Hello,
To read NMEA data from the interface configured with this AT command you need to connect an external phisical device to this inteface. You can't do it from the Java MIDlet. In Java you can control GPS with Java classes as in the example app and can read NMEA with getExtraInfo() method.
Regards,
Bartłomiej
I have done it again, locked myself out.
I wrote a gps.java using AT-commands.
It finally worked using ASC0.
But I also added an serial COM0 wich did't work.
I thought that I could read GPS from ASC0 using a serial connection using COM0.
The result is now, that the ASC0 is blocked, saying:
^SYSLOADING
NMEA.OUT STARTED
The USB1 is saying:
MIDlet:com.cinterion.jrc.JRC_Midlet autostart
What to do?
In all of my app, I have written an backdor for this occation.
In pure panic I deleted the installed Midlet, thereby locking myself out.
I should have installed a simple Midlet, before deleting it.
Br
Hello,
It is not possible to catch ASC0 or any other hardware interface output inside Java MIDlet. When you open ASC0 in Java any external app connected to ASC0 communicates with your MIDlet instead of AT commands interpreter. And from Java you also don't have access to the same AT commands interpreter as from outswide when Java is not running. You can communicate with the external application then.
You'd probably have to add some hardware workaround, for example connecting ASC0 with ASC1. Then you should be able to connect to ASC0 as an external application.
Each hardware interface on which you can execute AT command has an AT commands interpretes assigned. In Java AT commands interpreters are not bound to the hardware interfaces. You can access them by ATCommand class.
So one thing you could try (I'm not sure about that - I didn't test it) would be to set "Nmea/Output" to local and start GPS engine on the same ATCommand instance. Then you could catch URCs for that instance with ATCommandListener. But I suppose that it won't be possible in Java.
If you see NMEA.OUT STARTED on ASC0 and you have access to some other interface you can switch it off with the same command it was activated with.
Best regards,
Bartłomiej
I just thought You should se my self destructive code:
I am not sure if a change from ASC0 to LOCAL would do a differense BR
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public boolean AT_CMD_GPS(){
System.out.println("AT_CMD_GPS begin");
try{
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
String query_gps =
parent.SendCommand("AT^SGPSC?");
System.out.println("query_gps = " +query_gps);
if(query_gps.indexOf("OK") != -1) parent.NOP();
// parent.NOP() is just a return doing nothing
/*---------------------------------------------------------------------------*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// string.indexOf(...) returns:
// if the string argument occurs as a substring within this object, then
// the index of the first character of the first such substring is returned;
// if it does not occur as a substring, -1 is returned.
// Or in plain words: if string contain OK, it returns none -1
// or in other word's, return a value >= greater than or equal to 0
// In above example, the string DO contain OK and return true
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*---------------------------------------------------------------------------*/
if(query_gps.indexOf("\"Engine\",\"3\"") != -1) parent.NOP();
else{
result = parent.SendCommand("AT^SGPSC=\"Engine\",\"3\"");
}
System.out.println("result = " +result);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(result.indexOf("OK") != -1) parent.NOP();
else{
System.out.println("Restart Module");
parent.SendCommand("AT+CFUN=1,1");
parent.Delay(100);
}
/*---------------------------------------------------------------------------*/
if(query_gps.indexOf("\"Nmea/Output\",\"off\"") != -1) parent.NOP();
else{
result = parent.SendCommand("AT^SGPSC=\"Nmea/Output\",\"off\"");
}
System.out.println("result = " +result);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(result.indexOf("OK") != -1) parent.NOP();
else{
System.out.println("Restart Module");
parent.SendCommand("AT+CFUN=1,1");
parent.Delay(100);
}
/*---------------------------------------------------------------------------*/
if(query_gps.indexOf("\"Mode/Antenna\",\"1\"") != -1) parent.NOP();
else{
result = parent.SendCommand("AT^SGPSC=\"Mode/Antenna\",\"1\"");
}
System.out.println("result = " +result);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(result.indexOf("OK") != -1) parent.NOP();
else{
System.out.println("Restart Module");
parent.SendCommand("AT+CFUN=1,1");
parent.Delay(100);
}
/*---------------------------------------------------------------------------*/
if(query_gps.indexOf("\"Power/Antenna\",\"auto\"") != -1) parent.NOP();
else{
result = parent.SendCommand("AT^SGPSC=\"Power/Antenna\",\"auto\"");
}
System.out.println("result = " +result);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(result.indexOf("OK") != -1) parent.NOP();
else{
System.out.println("Restart Module");
parent.SendCommand("AT+CFUN=1,1");
parent.Delay(100);
}
/*---------------------------------------------------------------------------*/
// local
if(query_gps.indexOf("AT^SGPSC=\"Nmea/Interface\",\"asc0\"") != -1) parent.NOP();
else{
result = parent.SendCommand("AT^SGPSC=\"Nmea/Interface\",\"asc0\"");
}
System.out.println("result = " +result);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(result.indexOf("OK") != -1) parent.NOP();
else{
System.out.println("Restart Module");
parent.SendCommand("AT+CFUN=1,1");
parent.Delay(100);
}
/*---------------------------------------------------------------------------*/
if(query_gps.indexOf("\"Nmea/Freq\",\"1\"") != -1) parent.NOP();
else{
result = parent.SendCommand("AT^SGPSC=\"Nmea/Freq\",\"1\"");
}
System.out.println("result = " +result);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(result.indexOf("OK") != -1) parent.NOP();
else{
System.out.println("Restart Module");
parent.SendCommand("AT+CFUN=1,1");
parent.Delay(100);
}
/*---------------------------------------------------------------------------*/
if(query_gps.indexOf("\"Nmea/Data\",\"GGA\"") != -1) parent.NOP();
else{
result = parent.SendCommand("AT^SGPSC=\"Nmea/Data\",\"GGA\",\"on\"");
}
System.out.println("result = " +result);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(result.indexOf("OK") != -1) parent.NOP();
else{
System.out.println("Restart Module");
parent.SendCommand("AT+CFUN=1,1");
parent.Delay(100);
}
/*---------------------------------------------------------------------------*/
}catch(Exception in){
System.out.println("Exception in \"Java_CFG\" AT_CMD_GPS " + in);}
//-----------------------------------------------------------------------------
System.out.println("return true");
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
When "local" is set the NMEA sentences will be printed on the interface on which the GPS engine was activated with 'AT^SGPSC="Engine",' command.
If you set "Nmea/Interface" to a specific hardware interface like ASC0 the NMEA output will be always printed to this interface.
But I'm not sure what is your goal - to catch NMEA sentences inside the MIDlet ot to print them all to a hardware interface.
If you want to read it inside MIDlet I recommend you to use Java classes for this.
If you need NMEA to be printed on a hardware interface you either need to use AT commands and configure "Nmea/Interface" to some interface like ASC0 or you can use Java classes to catch NMEA but then your application ***** to open an inteface with CommConnection and then print out what is needed.
Regards,
Bartłomiej
Just in order to close this.
I am not sure if there is room/space for any rethinking in these exellent java-modules.
But in order to be able to use both COM-port or hwatever, my Motorola G24 and my bluetooth module, has an "autorun" pin, by wich the modules distinguish between command-mode and ececute-mode.
It is only a suggestion.
Br Morten