intern-space-program / avionics

Avionics software to be developed and passed down over multiple tours.
http://internspaceprogram.com/
MIT License
9 stars 8 forks source link

teensy_main.ino will always think GPS is connected #22

Closed mdbernard closed 4 years ago

mdbernard commented 4 years ago

In avionics/teensy/teensy_main/teensy_main.ino, line 282, the following code is written:

GPS_CONNECTED = true;
if (GPS_CONNECTED) {

As-is, this code will cause a failure if the GPS is not actually connected by this point. This must have been added for testing purposes at some point and never removed. It's possible this is what caused the downlink failure in the Fall 2019 flight.

xxEoD2242 commented 4 years ago

This was only put there as there is a GPS flag that gets checked every time data is pulled.

The Flag being set there honestly wouldn't have an effect, as the line before it gps.begin(9600) would cause the script to fail before ever getting to this point, as it's the first time that the GPS is actually queried.

This flag was checked every time the data was pulled and would set true or false based upon whether the proper data was pulled when the GPS was connected. As I remember Ronnie writing it, the GPS couldn't cause the failure, as the Teensy would never say it was "ready" until all of the flags were true.

It's not so much a bug as just unclear code that definitely needs to be changed.

xxEoD2242 commented 4 years ago

As such, I don't remember who actually wrote that whole thing but the whole file needs to be rewritten, as I never had time to rewrite it and it was changed a bunch after I stopped working on it.

mdbernard commented 4 years ago

If that is the case, it ought to be documented, since it is unclear. Additionally, the if check should be removed, since that block is always going to run if gps.begin(9600) is successful.