Download SimSat Educational Program Development
Transcript
GPSstring = readSerial(serial2Name, serial2Link);
GPS
// Get data from
GPSstring.resize(GPSstring.find_first_of("*",0)+3);
tempGPS = parseGPS(GPSstring); // Parse the GPS string into
partial SAARP
}
else // No relevant data in GPS, so don't sample
tempGPS = ",,,,,"; // Use blank GPS data
if ((loopCounter % 2) == 0) { // If it is time to sample the EZCompass
tempEZ = readSerial(serial1Name, serial1Link); // Get data from
EZ-Compass
tempEZ.resize(tempEZ.find_first_of("*",0)+3);
compassTemp = getCompassTemp(tempEZ); // Get the EZ-Compass
temperature
tempEZ = parseEZCompass(tempEZ); // Parse EZ-Compass string into
partial SAARP
}
else { // EZ-Compass has not refreshed, so don't sample
tempEZ = ",,"; // Use blank EZ-Compass data
compassTemp = ""; // Use blank compass temperature
}
t1 = getTemperature("T1"); // Get the first temperature
t2 = getTemperature("T2"); // Get the second temperature
t3 = getTemperature("T3"); // Get the third temperature
t4 = getTemperature("T4"); // Get the fourth temperature
spinRate = getSpinRate(); // Calculate the spin rate
hk1 = getHousekeeping("HK1"); // Get the first housekeeping voltage
hk2 = getHousekeeping("HK2"); // Get the second housekeeping voltage
/* FORMAT SAARP STRING */
SAARP = "$" + tempTS + "," + tempGPS + "," + tempEZ + "," + spinRate +
"," + compassTemp + "," + t1 + "," + t2 + "," + t3 + "," + t4 + "," + hk1 +
"," + hk2 + "\r\n";
/* OUTPUT SAARP */
if (shouldEcho) // We want to echo the output
cout << SAARP; // Print out SAARP to the screen
write(fdLog, SAARP.c_str(), SAARP.length()); // Write SAARP to the
specified file
}
}
loopCounter++;
// end while
// Increment loop counter
/* CLOSE FILE | TERMINATE CONNECTIONS WITH I/O PORTS | EXIT PROGRAM */
close(fdLog); // Close the file
close(serial1Link); // Close the EZ-Compass port
close(serial2Link); // Close the GPS port
exit(0); // Exit the program succesfully
int open_port(string name) {
/* This function will open the specified port to begin communication.
successful completion, the function returns the file descriptor
associated
Upon
93