java: Added java examples for some sensors

Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Stefan Andritoiu
2015-10-02 17:31:43 +03:00
committed by Mihai Tudor Panu
parent 9d63545d44
commit 5ff625eaf4
24 changed files with 1187 additions and 28 deletions

View File

@ -22,7 +22,6 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//NOT TESTED!!!
public class Ublox6Sample {
private static final int BUFFERLENGTH = 256;
@ -45,11 +44,11 @@ public class Ublox6Sample {
throw new RuntimeException("Failed to setup tty port parameters");
}
// Collect and output NMEA data. There are various libraries out on
// the Internet, such as tinyGPS or tinyGPS++ that can handle
// decoding NMEA data and presenting it in a more easily accessible
// format. This example will just check for, and read raw NMEA data
// from the device and output it on standard output.
// Collect and output NMEA data. There are various libraries out on
// the Internet, that can handle decoding NMEA data and presenting
// it in a more easily accessible format. This example will just
// check for, and read raw NMEA data from the device and output it
// on standard output.
// This device also supports numerous configuration options, which
// you can set with writeData(). Please refer to the Ublox-6 data
@ -65,10 +64,10 @@ public class Ublox6Sample {
int rv = nmea.readData(nmeaBuffer);
if(rv > 0)
for (int i = 0; i < nmeaBuffer.length; i++)
System.out.print(nmeaBuffer[i]);
for (int i = 0; i < rv; i++)
System.out.print((char)nmeaBuffer[i]);
if (rv < 0){ // some sort of read error occured
if (rv < 0){ // some sort of read error occurred
System.err.println("Port read error.") ;
break;
}