Implementing a Supervisor request 'retries' number. Implementes
re-trying a supervisor request up to a set number of times for
supervisor responses that have bad checksums.
#include <kubos-hal-iobc/supervisor.h>
-#include <commands/errors.h>
-#include <commands/commands.h>
+#include "commands/errors.h"
+#include "commands/commands.h"
int parse_and_run(char * arg);
@@ -37,7 +37,6 @@ int main(int argc, char **argv)
}
return get_and_run_command(command_string);
-
}
@@ -50,61 +49,82 @@ int ping()
int build_info()
{
- bool result = true;
+ int retries = 0;
+ bool result = false;
supervisor_version_t version = {0};
+ while (retries < SUPERVISOR_MAX_REQUEST_RETRIES)
+ {
result = supervisor_get_version(&version);
- if (!result)
+ if (result)
{
- printf("There was an error getting the supervisor version information. Error: %i\n", result);
- return result;
+ printf("iOBC Supervisor Version: %c.%c.%c\n", version.fields.major_version, version.fields.minor_version, version.fields.patch_version);
+ return NO_ERR;
}
- printf("iOBC Supervisor Version: %u.%u.%u\n", version.fields.major_version, version.fields.minor_version, version.fields.patch_version);
- return result;
+ retries++;
}
-//TODO: I don't like having 3 nearly identical functions. I'm working on implementing the reboot type as an option
-//Theres an issue in the client that is preventing that implementation at the moment.
+ printf("Error: Exceeded the maximum number of supervisor retries. Aborting the info command.\n");
+ return GENERIC_ERR;
+}
+
+
int reboot()
{
- bool result = true;
+ int retries = 0;
+ bool result = false;
+ while (retries < SUPERVISOR_MAX_REQUEST_RETRIES)
+ {
result = supervisor_powercycle();
- if (!result)
+ if (result)
{
- printf("There was an error requesting the iOBC power cycle.\n");
- return GENERIC_ERR;
+ return NO_ERR;
+ }
+ retries++;
}
- return NO_ERR;
+ printf("Error: Exceeded the maximum number of supervisor retries. Aborting the power cycle.\n");
+ return GENERIC_ERR;
}
int reset()
{
- bool result = true;
+ int retries = 0;
+ bool result = false;
+ while (retries < SUPERVISOR_MAX_REQUEST_RETRIES)
+ {
result = supervisor_reset();
- if (!result)
+ if (result)
{
- printf("There was an error requesting the iOBC power cycle.\n");
- return GENERIC_ERR;
+ return NO_ERR;
+ }
+ retries++;
}
- return NO_ERR;
+ printf("Error: Exceeded the maximum number of supervisor retries. Aborting the reset\n");
+ return GENERIC_ERR;
}
int emergency_reset()
{
- bool result = true;
+ int retries = 0;
+ bool result = false;
+ while (retries < SUPERVISOR_MAX_REQUEST_RETRIES)
+ {
result = supervisor_emergency_reset();
- if (!result)
+ if (result)
{
- printf("There was an error requesting the iOBC power cycle.\n");
- return GENERIC_ERR;
+ return NO_ERR;
+ }
+ retries++;
}
- return NO_ERR;
+ printf("Error: Exceeded the maximum number of supervisor retries. Aborting the emergency reset\n");
+ return GENERIC_ERR;
}
+
