I have given up on my original idea to stream NMEA into Google Earth.. and found a better solution!
I was able to solve this by programmatically generating KML file for each position and attitude change and then opening up an instance of Google Earth with the generated KML file as parameter. This is happening in 250ms loop which makes the transitions smooth. Also, Google Earth detects that another instance is already running and therefore it only loads the KML file.
Here is a capture:
I was able to accomplish generating of KML using C# and SharpKml software library. Here is a code example:
private void GenerateKML()
{
SharpKml.Dom.Location loc = new SharpKml.Dom.Location();
loc.Latitude = currentLat;
loc.Longitude = currentLon;
loc.Altitude = currentAlt;
SharpKml.Dom.Model model = new SharpKml.Dom.Model();
model.Location = loc;
model.AltitudeMode = SharpKml.Dom.AltitudeMode.Absolute;
SharpKml.Dom.Orientation ori = new SharpKml.Dom.Orientation();
ori.Roll = currentRoll;
ori.Tilt = currentPitch;
ori.Heading = (currentTrack + 180) % 360;
model.Orientation = ori;
SharpKml.Dom.Link link = new SharpKml.Dom.Link();
link.Href = new Uri("model.dae", UriKind.Relative);
model.Link = link;
SharpKml.Dom.Placemark pmplane = new SharpKml.Dom.Placemark();
pmplane.Geometry = model;
File.Delete(AppDomain.CurrentDomain.BaseDirectory + kmlFileName);
SharpKml.Engine.KmlFile kml = SharpKml.Engine.KmlFile.Create(pmplane, false);
using (var stream = System.IO.File.OpenWrite(kmlFileName))
kml.Save(stream);
}
If you also want custom viewpoint of the model in Google Earth, instantiate LookAt object and assign it to model.Viewpoint
.
Without knowing much about how you're dealing with the incoming data, but if it's overflowing then its probably because the previous/current data is or has not been dealt with in a timely fashion.
With ublox7's; NEMA sentences are enabled via:
$PUBX,40,msgType,0,1,0,0*checksum
and disabled via:
$PUBX,40,msgType,0,0,0,0*checksum
You have 6 variables after the msgType whereas only 4 are expected. Other modules may require 6.
Checksum is calculated by XOR'ing all characters between the $ and the *, and is a 2 char HEX value.
eg;
// test string
const char *msg = "PUBX,40,GSV,0,0,0,0";
// find checksum
int checksum = 0;
for (int i = 0; msg[i]; i++)
checksum ^= (unsigned char)msg[i];
// convert and create checksum HEX string
char checkTmp[8];
snprintf(checkTmp, sizeof(checkTmp)-1, F("*%.2X"), checksum);
// send to module
module.print("$");
module.print(msg);
module.println(checkTmp);
and to put this in to something [re]usable:
inline int calculateChecksum (const char *msg)
{
int checksum = 0;
for (int i = 0; msg[i] && i < 32; i++)
checksum ^= (unsigned char)msg[i];
return checksum;
}
INLINE int nemaMsgSend (const char *msg)
{
char checksum[8];
snprintf(checksum, sizeof(checksum)-1, F("*%.2X"), calculateChecksum(msg));
module.print("$");
module.print(msg);
module.println(checksum);
}
inline int nemaMsgDisable (const char *nema)
{
if (strlen(nema) != 3) return 0;
char tmp[32];
snprintf(tmp, sizeof(tmp)-1, F("PUBX,40,%s,0,0,0,0"), nema);
//snprintf(tmp, sizeof(tmp)-1, F("PUBX,40,%s,0,0,0,0,0,0"), nema);
nemaMsgSend(tmp);
return 1;
}
inline int nemaMsgEnable (const char *nema)
{
if (strlen(nema) != 3) return 0;
char tmp[32];
snprintf(tmp, sizeof(tmp)-1, F("PUBX,40,%s,0,1,0,0"), nema);
//snprintf(tmp, sizeof(tmp)-1, F("PUBX,40,%s,0,1,0,0,0,0"), nema);
nemaMsgSend(tmp);
return 1;
}
and then to disable a message:
nemaMsgDisable("GSV");
to enable a message:
nemaMsgEnable("GSV");
Hope this helps.
Michael
Best Answer
NMEA is the abbreviated name of the organisation. Presumably you are looking for NMEA 0183 interface specification, which you can buy from the organisation - see http://www.nmea.org/.
Garmin (and other manufacturers) have proprietary extensions (which is the meaning of "P" in the label). The Garmin ones can be found at http://www8.garmin.com/support/pdf/NMEA_0183.pdf (thanks to Where can I find documentation on the NMEA sentences supported by the Garmin GLO?), but yours look like another manufacturer (since Garmin ones have "GRM"). A partial list is provided as part of the GPSD documentation at http://catb.org/gpsd/NMEA.html#_vendor_extensions.