UKHAS Wiki

UK High Altitude Society

User Tools

Site Tools


code:gps_php_parser

Arduino (C-like) - transmission

int i;
char incomingByte;
boolean skip;

void setup() {
  Serial.begin(4800);
}

void loop() {
  // start: gps
  if(Serial.available()) {
    incomingByte = Serial.read();
    if(incomingByte==36) {
      i=0;
      skip=false;
    }
    if(incomingByte==86) {
      skip=true;
    }
    if((!skip)&&(i>6)) {
      Serial.print(incomingByte);
    }
    i++;
  }
  // end: gps
}

PHP - receive

<script type="text/javascript">
<!--
function get(elmnt) {
	return document.getElementById(elmnt);
}

function initialize() {
	if(GBrowserIsCompatible()) {
		var map = new GMap2(get('map'));
		var location = new GLatLng(<?php
if(isset($_GET['nmea'])&&$_GET['nmea']) {
	$nmea = split(",",$_GET['nmea']);
	$time = substr($nmea[0],0,2).":".substr($nmea[0],2,2).":".substr($nmea[0],4,2).substr($nmea[0],6);
	$lat = (($nmea[2] == "N") ? "+" : "-").substr($nmea[1],0,2)."&deg; ".substr($nmea[1],2)."'";
	$lon = (($nmea[4] == "E") ? "+" : "-").substr($nmea[3],0,3)."&deg; ".substr($nmea[3],3)."'";
	$sats = abs($nmea[6]);
	$alt = abs($nmea[8])/1000;
}
echo (($nmea[2] == "N") ? "" : "-").(substr($nmea[1],0,2)+(substr($nmea[1],2)/60)).','.(($nmea[4] == "E") ? "" : "-").(substr($nmea[3],0,3)+(substr($nmea[3],3)/60));
?>);
		map.setCenter(location, 13);
		map.addOverlay(new GMarker(location, { title: 'Current position' }));
	}
}
-->
</script>
<h1>HAVE-1 Live Tracker</h1>
<div id="map" style="width: 300px; height: 300px;">
</div>
<div id="telemetry">
<h2>Telemetry</h2>
<?php
if(isset($_GET['nmea'])&&$_GET['nmea']) {
echo "<ul>\n<li><b>Altitude:</b> $alt km</li>\n<li><b>Satellites:</b> $sats</li>\n<li><b>Coordinates:</b> $lat, $lon</li>\n<li><b>Time:</b> $time UTC</li>\n</ul>\n";
}
?>
</div>
<br class="break" />
code/gps_php_parser.txt ยท Last modified: 2009/02/08 22:54 by joshatkins