示例#1
0
// Sends the GPS Position by serial com
function sendGPSPosition()
{ 
	console.log("Sent " + "/" + GPSPosition.lat + "," + GPSPosition.lon + "!");
	sp.write("/" + GPSPosition.lat + "," + GPSPosition.lon + "!\n");
}
示例#2
0
		GPSPosition.lat = navdata.gps.latitude;
		GPSPosition.lon = navdata.gps.longitude;
		GPSPosition.nSat = navdata.gps.nbSatellites;
	}

	if (navdata.demo)
		battery_percentage = navdata.demo.batteryPercentage;
});

// ******************************************************************
// *************** SERIAL COMMUNICATION *****************************
// ******************************************************************
var serialport = require('node-serialport');

var sp = new serialport.SerialPort("/dev/ttyO3", {
	parser: serialport.parsers.readline('\n'),
	baud: 9600
});

sp.on('data', function(msg) {

	msg = msg.toString();
	msg = msg.substr(0, msg.length - 1);
	console.log("Received: " + msg);

  // External sensing system asks for GPS location
  if (msg.search("\\*GPS!") != -1)
  	processGPS(true);

  else if (msg.search("\\*GPS_ACK!") != -1)
  	processGPS(false);
});