/* /* RESCUE ROBOTICS WORKSHOP ReadGPSFromFile Read GPS Data From File Ron Kessler Created 8/17/2018 Updated: 8/17/2018 Did final compile/test. PURPOSE: This project is based on 5-2-3 (ReadFromFile) but shows how to read GPS data. SETUP: Use the companion project called SaveGPS2File to store your readings first. As before, we will trap errors to see if everything worked. We will start by defining a function to do the reading. */ void ReadGPSData() { TFileHandle fileNumber; //internal number used to locate the file. TFileIOResult IOException; //tells us if there is an error during the IO string myFileName = "GPStest.txt"; //my file name. int fileSize = 100; //same as when we saved 2 file long longitudeFromFile = 0.0; long latitudeFromFile = 0.0; OpenRead(fileNumber, IOException, myFileName, fileSize); //---Now actually read the line of data and store it in the 'lineFromFile' variable. ReadLong(fileNumber, IOException, longitudeFromFile); ReadLong(fileNumber, IOException, latitudeFromFile); Close(fileNumber, IOException); eraseDisplay(); nxtDisplayCenteredTextLine(1, "Rescue Robotics"); nxtDisplayCenteredTextLine(2, "GPS Stored Data"); nxtDisplayTextLine(4, "Lon= %d", longitudeFromFile); nxtDisplayTextLine(5, "Lat= %d", latitudeFromFile); //---any errors? if(IOException == 0) nxtDisplayTextLine(7, "No errors!"); else nxtDisplayTextLine(7, "Error while reading...."); } task main() { ReadGPSData(); //---keep results on screen for 5 seconds so we can view it wait1Msec(5000); }