def main(): logger = app_api.logging_setup("payload-image-transfer") # parse arguments for config file and run type parser = argparse.ArgumentParser() parser.add_argument('--run', '-r', nargs=1) parser.add_argument('--config', '-c', nargs=1) args = parser.parse_args() if args.config is not None: # use user config file if specified in command line SERVICES = app_api.Services(args.config[0]) else: # else use default global config file SERVICES = app_api.Services("/home/kubos/kubos/local_config.toml") # run app onboot or oncommand logic if args.run is not None: if args.run[0] == 'OnBoot': on_boot(logger, SERVICES) elif args.run[0] == 'OnCommand': on_command(logger, SERVICES) else: on_command(logger, SERVICES)
def main(): logger = "sunpoint " #change to appropriate loggin name / Probably need to remove this entirely parser = argparse.ArgumentParser() #Add argument for csv file list parser.add_argument('--config', '-c', nargs=1) args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services(CONFIG_PATH) sys.stdout.flush() print(f"{logger} info: Adjusting to sunpoint...") _, time_set = set_sunpoint_value() time.sleep(1) sys.stdout.flush() print( f'{logger} info: [{time_set.strftime("%Y-%m-%d %H:%M:%S")}] Sunpoint panels: SUCCESS' ) sys.stdout.flush() print('')
def main(): logger = app_api.logging_setup("imu-read-qua") # parse arguments for config file and run type parser = argparse.ArgumentParser() parser.add_argument('--run', '-r', nargs=1) parser.add_argument('--config', '-c', nargs=1) parser.add_argument('cmd_args', nargs='*') args = parser.parse_args() if args.config is not None: # use user config file if specified in command line SERVICES = app_api.Services(args.config[0]) else: # else use default global config file SERVICES = app_api.Services() # run app onboot or oncommand logic if args.run is not None: if args.run[0] == 'OnBoot': on_boot(logger, SERVICES) elif args.run[0] == 'OnCommand': on_command(logger, SERVICES) else: on_command(logger, SERVICES)
def main(): logger = "groundpoint " #change to appropriate loggin name / Probably need to remove this entirely parser = argparse.ArgumentParser() #Add argument for csv file list parser.add_argument('--config', '-c', nargs=1) args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services(CONFIG_PATH) print(f"{logger} info: Adjusting to groundpoint...") sys.stdout.flush() time_set = noSun() time.sleep(1) print( f'{logger} info: [{time_set.strftime("%Y-%m-%d %H:%M:%S")}] Groundpoint panels: SUCCESS' ) sys.stdout.flush() run_list = [ '/challenge/mission-apps/stage_two/win_check/win_check.py', '--lose', '--ground' ] p = subprocess.Popen(run_list) p.communicate() print('')
def main(): logger = app_api.logging_setup("kubos-linux-makeLED") logger.info("Entering main LED logic BLINKER!!! ") parser = argparse.ArgumentParser() parser.add_argument( '-c', '--config', nargs=1, help='Specifies the location of a non-default configuration file') parser.add_argument('-s', '--subcommand', help='on, off, flash') args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services() logger.info("Command to LED Blinker is " + str(args.subcommand)) if args.subcommand == 'flash': on_command(logger, 'flash') elif args.subcommand == 'off': on_command(logger, 'off') elif args.subcommand == 'on': on_command(logger, 'on') else: logger.error("Bad command to led blinker " + args.subcommand)
def main(): logger = app_api.logging_setup("keep_alive") parser = argparse.ArgumentParser() parser.add_argument('--config', '-c', nargs=1) parser.add_argument('--stop', '-s', action='store_true') args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services() if args.stop is not None: sys.exit(0) ######### START ######### app_name = "leon3_i2c" if check_app_running(logger, app_name) == False: logger.warning("I2C application not running. Starting...") start_app(logger)
def main(): logger = "low_power " parser = argparse.ArgumentParser() #Add argument for csv file list parser.add_argument('--config', '-c', nargs=1) args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services(CONFIG_PATH) print(f"{logger} info: Temporarily stopping all comms until mode change") print(f"{logger} info: Low power: TRUE") sys.stdout.flush() run_list = [ '/challenge/mission-apps/stage_two/win_check/win_check.py', '--lose', '--low' ] p = subprocess.Popen(run_list) p.communicate() print('')
def main(): logger = app_api.logging_setup("mission-framework") parser = argparse.ArgumentParser() parser.add_argument('--run', '-r', nargs=1) parser.add_argument('--config', '-c', nargs=1) parser.add_argument('cmd_args', nargs='*') args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services() if args.run[0] == 'OnBoot': on_boot(logger) elif args.run[0] == 'OnCommand': on_command(logger) else: logger.error("Unknown run level specified") sys.exit(1)
def main(): parser = argparse.ArgumentParser() parser.add_argument( '-r', '--run', nargs=1, help='Determines run behavior. Either "OnBoot" or "OnCommand"', required=True) parser.add_argument( '-c', '--config', nargs=1, help='Specifies the location of a non-default configuration file') parser.add_argument('cmd_args', nargs='*') args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services() if args.run[0] == 'OnBoot': on_boot() elif args.run[0] == 'OnCommand': on_command(args.cmd_args) else: print("Unknown run level specified") sys.exit(1)
def main(): logger = "disable_downlink " parser = argparse.ArgumentParser() #Add argument for csv file list parser.add_argument('--config', '-c', nargs=1) args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services(CONFIG_PATH) print(f"{logger} warn: Downlink not running") sys.stdout.flush() # print(f"{logger} warn: Beginning downlink...") run_list = ['/challenge/mission-apps/stage_two/win_check/win_check.py', '--lose'] p = subprocess.Popen(run_list) p.communicate() print('')
def main(): logger = app_api.logging_setup("change-app-version") # parse arguments for config file and run type parser = argparse.ArgumentParser() parser.add_argument('--run', '-r', nargs=1) parser.add_argument('--config', '-c', nargs=1) parser.add_argument('name') parser.add_argument('version') args = parser.parse_args() if args.config is not None: # use user config file if specified in command line SERVICES = app_api.Services(args.config[0]) else: # else use default global config file SERVICES = app_api.Services("/etc/kubos-config.toml") # run app onboot or oncommand logic if args.run is not None: if args.run[0] == 'OnBoot': on_boot(logger, SERVICES) elif args.run[0] == 'OnCommand': on_command(logger, SERVICES, args.name, args.version) else: on_command(logger, SERVICES, args.name, args.version)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--config', '-c') args = parser.parse_args() if args.config is not None: SERVICES = app_api.Services(args.config) else: SERVICES = app_api.Services() # setting up query to send and request the monitor service and making sure it works request = ' {ping} ' try: response = SERVICES.query(service="monitor-service", query=request) #parse out the result to get our response string data = response["ping"] if data == "pong": print("Successfully pinged monitor service") status = "Okay" else: print("Unexpected monitor service response: %s" % data) status = "Unexpected" except Exception as e: print("Something went wrong: " + str(e)) status = "Error" request = ''' mutation { insert(subsystem: "OBC", parameter: "status", value: "%s") { success, errors } } ''' % (status) # if monitor is okay and try: response = SERVICES.query(service="telemetry-service", query=request) except Exception as e: print("Something went wrong: " + str(e)) sys.exit(1) # inside 'response' is the data for the specific request which returns success (ok/not) and specific errors # in this case it's a mutation request for the database service data = response["insert"] success = data["success"] errors = data["errors"] if success == False: print("Telemetry insert encountered errors: " + str(errors)) sys.exit(1) else: print("Telemetry insert completed successfully")
def main(): parser = argparse.ArgumentParser() parser.add_argument('--config', '-c') args = parser.parse_args() if args.config is not None: SERVICES = app_api.Services(args.config) else: SERVICES = app_api.Services() request = '{ ping }' try: response = SERVICES.query(service="monitor-service", query=request) data = response["ping"] if data == "pong": print("Successfully pinged monitor service") status = "Okay" else: print("Unexpected monitor service response: %s" % data) status = "Unexpected" except Exception as e: print("Something went wrong: " + str(e)) status = "Error" request = ''' mutation { insert(subsystem: "OBC", parameter: "status", value: "%s") { success, errors } } ''' % (status) try: response = SERVICES.query(service="telemetry-service", query=request) except Exception as e: print("Something went wrong: " + str(e)) sys.exit(1) data = response["insert"] success = data["success"] errors = data["errors"] if success == False: print("Telemetry insert encountered errors: " + str(errors)) sys.exit(1) else: print("Telemetry insert completed successfully")
def main(): logger = app_api.logging_setup("initchallenge") parser = argparse.ArgumentParser() parser.add_argument('--config', '-c', nargs=1) parser.add_argument('--mode', '-m', nargs=1) parser.add_argument('--schedule', '-s', nargs=1) args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services() ######### START ######### logger.info("Initializing system. This will only run once.") if args.mode is None: mode_name = "nominal" # Name of mode to create else: mode_name = args.mode if args.schedule is None: schedule_name = "imager" # Name of schedule to insert into mode else: schedule_name = args.schedule # Apps to register i2c_app = "/home/microsd/mission-apps/leon3_i2c" # alive_app = "/home/microsd/mission-apps/keep_alive" ### Alive app was removed in order to speed up i2c. ### # apps_registrar = [i2c_app, alive_app] apps_registrar = [i2c_app] register_all_apps(logger, apps_registrar) create_mode(logger, mode_name) create_mode_schedule(logger, mode_name, schedule_name) activate_mode(logger, mode_name) logger.info("Initialized successfully.")
def main(): logger = app_api.logging_setup("mission-framework") parser = argparse.ArgumentParser() parser.add_argument('--config', '-c', nargs=1) args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services() logger.info("Starting mission logic")
def main(): logger = app_api.logging_setup("python-proj") parser = argparse.ArgumentParser() parser.add_argument( '-c', '--config', nargs=1, help='Specifies the location of a non-default configuration file') parser.add_argument('-t', '--test', nargs=1) parser.add_argument('-e', '--error', action='store_true') parser.add_argument('-f', '--flag', action='store_true') parser.add_argument('positional', nargs='?') matches = parser.parse_args() if matches.config is not None: global SERVICES SERVICES = app_api.Services(matches.config[0]) else: SERVICES = app_api.Services() success = False sub.test_func() if matches.error: sys.exit(123) if matches.flag: success = True if matches.test is not None and matches.test[0] == "test": success = True if matches.positional is not None and matches.positional == "pos": success = True if success: sys.exit(0) else: logging.error("No valid arguments were found") sys.exit(1)
def main(): logger = "start_stage_one " parser = argparse.ArgumentParser() parser.add_argument('--config', '-c', nargs=1) parser.add_argument('--delete', '-d', help='Deletes all app and service data', action='store_true') args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services(CONFIG_PATH) #print(f"{logger} info: Begining stage_one") if args.delete: #print(f"{logger} info: Deleting app and service data.") delete_all_info(logger) else: register_all_apps(logger) init_tel(logger) create_mode(logger, "transmission") low_power_time_str = store_transmission_json(logger) create_mode_schedule(logger, "transmission") create_mode(logger, "low_power") store_low_power_json(logger, low_power_time_str) create_mode_schedule(logger, "low_power") create_mode(logger, "station-keeping") create_mode_schedule(logger, "station-keeping") activate_mode(logger, "station-keeping") store_latest_json(logger) print("\n** Welcome to spaceDB **\n" + '-' * 25)
def main(): logger = "critical-tel-check " parser = argparse.ArgumentParser() # The -c argument should be present if you would like to be able to specify a non-default # configuration file parser.add_argument( '-c', '--config', nargs=1, help='Specifies the location of a non-default configuration file') args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: # SERVICES = app_api.Services() SERVICES = app_api.Services(CONFIG_PATH) if not check_tel_change(logger): return print(f"{logger} info: Detected new telemetry values.") print(f"{logger} info: Checking recently inserted telemetry values.") sys.stdout.flush() check_gps_val(logger) sys.stdout.flush() check_wheel_val(logger) sys.stdout.flush() if (check_eps_val(logger)): set_critval_and_start(logger, False) sys.stdout.flush() else: set_critval_and_start(logger, True) sys.stdout.flush() print("")
def main(): logger = app_api.logging_setup("mission-app") parser = argparse.ArgumentParser() # The -r argument is required to be present by the applications service parser.add_argument( '-r', '--run', nargs=1, help='Determines run behavior. Either "OnBoot" or "OnCommand"', required=True) # The -c argument should be present if you would like to be able to specify a non-default # configuration file parser.add_argument( '-c', '--config', nargs=1, help='Specifies the location of a non-default configuration file') # Other optional arguments which will be passed through to the underlying logic parser.add_argument('cmd_args', nargs='*') args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services() if args.run[0] == 'OnBoot': on_boot(logger) elif args.run[0] == 'OnCommand': on_command(logger, args.cmd_args) else: logger.error("Unknown run level specified") sys.exit(1)
def main(): logger = app_api.logging_setup("mission-app") parser = argparse.ArgumentParser() # The -c argument should be present if you would like to be able to specify a non-default # configuration file parser.add_argument( '-c', '--config', nargs=1, help='Specifies the location of a non-default configuration file') # Arguments specific to this application parser.add_argument('-a', '--apps', action='store_true', help='Get list of installed apps') parser.add_argument('-m', '--mode', nargs=1, help='System mode') parser.add_argument('-t', '--time', type=int, help='Safemode time (in seconds)') args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services() if args.mode == 'safemode': safe_mode(logger, args.time) elif args.apps is not None: get_apps(logger) else: get_telemetry(logger)
def main(): logger = "update_tel " #change to appropriate loggin name / Probably need to remove this entirely parser = argparse.ArgumentParser() #Add argument for csv file list parser.add_argument('--config', '-c', nargs=1) args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services(CONFIG_PATH) ins_wheel_tel(logger) ins_gps_tel(logger) ins_eps_tel(logger) print("")
def main(): logger = "initalize_telemetry " #change to appropriate loggin name / Probably need to remove this entirely parser = argparse.ArgumentParser() #Add argument for csv file list parser.add_argument('--config', '-c', nargs=1) parser.add_argument('--files', '-f', help='Telemetry files to parse', nargs='*') parser.add_argument('--delete', '-d', help='Deletes all telemetry entries', action='store_true') args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services(CONFIG_PATH) if args.files is not None: for f in args.files: if os.path.exists(f): if 'gps' in f.lower(): parse_csv(f, True, logger) continue parse_csv(f, False, logger) else: error_msg = "Could not find initial tlm files." #print(error_msg) sys.stderr.write(error_msg + " Quitting...") sys.exit(-20) #print(f"{logger} info: Inserted initial telemetry.") if args.delete: del_all_telemetry(logger)
def __init__(self): ''' Initialize the hardware and logging ''' # Get the configuration parser = argparse.ArgumentParser() parser.add_argument('--config', '-c') args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config) else: SERVICES = app_api.Services() # Setup logging self.logger = app_api.logging_setup(self.app_name) # Connect to tracking motor self.motor = scmd(1) print('I2C bus: ', self.motor.bus) print('I2C slave address: ', self.motor.addr) print('SCMD ID: ', self.motor.begin()) self.motor.ready() self.motor.disable() time.sleep(0.25) self.motor.set_drive(0, 0, 0) self.motor.set_drive(1, 0, 0) self.motor.enable() time.sleep(0.25) # Make sure DORA is ready to go self.powerOnSensors()
def main(): logger = "enable_downlink " #change to appropriate loggin name / Probably need to remove this entirely parser = argparse.ArgumentParser() #Add argument for csv file list parser.add_argument('--config', '-c', nargs=1) args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services(CONFIG_PATH) run_list = [ '/challenge/mission-apps/stage_two/win_check/win_check.py', '--lose' ] subprocess.Popen(run_list) print('')
def main(): logger = "print_all_apps " #change to appropriate loggin name / Probably need to remove this entirely parser = argparse.ArgumentParser() #Add argument for csv file list parser.add_argument('--config', '-c', nargs=1) args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config[0]) else: SERVICES = app_api.Services(CONFIG_PATH) if(not check_sys_critical(logger)): get_apps(logger) else: print(f"{logger} warn: System critical.") print('')
def main(): logger = app_api.logging_setup("set-adcs-idle") # parse arguments for config file and run type parser = argparse.ArgumentParser() parser.add_argument('--run', '-r', nargs=1) args = parser.parse_args() SERVICES = app_api.Services("/etc/kubos-config.toml") # run app onboot or oncommand logic if args.run is not None: if args.run[0] == 'OnBoot': on_boot(logger, SERVICES) elif args.run[0] == 'OnCommand': on_command(logger, SERVICES) else: on_command(logger, SERVICES)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--run', '-r') parser.add_argument('--config', '-c') args = parser.parse_args() if args.config is not None: global SERVICES SERVICES = app_api.Services(args.config) else: SERVICES = app_api.services() if args.run == 'OnBoot': on_boot() elif args.run == 'OnCommand': on_command() else: print("Unknown run level specified") sys.exit(1)
#!/usr/bin/env python3 from i2c import I2C import argparse import app_api import sys # choose i2c bus i2c_device = I2C(bus = 1) # get services from api SERVICES = app_api.Services() def on_boot(logger): print("OnBoot logic") def on_command(logger): print("OnBoot logic") slave_address = 0x51 num_read = 20 data = def main(): logger = app_api.logging_setup("i2c-app") parser = argparse.ArgumentParser()
def __init__(self, config_filepath=DEFAULT_CONFIG_PATH): self.api = app_api.Services(config_filepath)
def setUp(self): self.api = app_api.Services("test_config.toml")