Esempio n. 1
0
def conf_wizard_net(config):
    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        features_menu_content = """

                            {rmh}NETWORKING MENU{endc}{bold}

                        
                        1 - Setup hotspot - always on

                        2 - Setup automatic hotspot/wifi 

                {yellow}e - Exit to main menu {endc}

                 """.format(rmh=Bcolors.RED_MENU_HEADER,
                            yellow=Bcolors.YELLOW_S,
                            bold=Bcolors.BOLD,
                            endc=Bcolors.ENDC)
        print(features_menu_content)
        selection = input()
        if selection == '1':
            net_and_ap_conf(config)
        elif selection == '2':
            confirm_auto_hotspot(config)
        elif selection == 'e':
            break
    pass
Esempio n. 2
0
def updated_check(config):
    user = config.user
    if os.path.exists("/home/" + user + "/.ota_markers/.was_updated"):
        clear_the_screen()
        logo_top(config.debug_mode)
        print(""" {bold}
        Software was updated recently to the new version.

        You can read update notes now or check them later.


         {endc}  {green} 
        'r' - read update notes {endc}

        's' - skip and don't show again
            """.format(bold=Bcolors.BOLD_S,
                       underline=Bcolors.UNDERLINE,
                       endc=Bcolors.ENDC,
                       green=Bcolors.GREEN,
                       blue=Bcolors.BLUE,
                       yellow=Bcolors.YELLOW_S,
                       red=Bcolors.RED_S,
                       orange=Bcolors.ORANGE_S))
        selection = input()
        if selection == 'r':
            os.system("less ./docs/update-notes.txt")
        if selection == 's':
            pass
        else:
            updated_check(config)
        os.system("rm /home/" + user +
                  "/.ota_markers/.was_updated >/dev/null 2>&1")
Esempio n. 3
0
def avr_dude(config):
    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        avrdude_menu = """
                {red}{bold}
                            AVRDUDE MENU
                            
                {blue}    
                        'i' - Install avrdude {endc}{yellow}
                {bold}
                        'e' - Go back {endc}
                """.format(bold=Bcolors.BOLD,
                           endc=Bcolors.ENDC,
                           blue=Bcolors.BLUE,
                           yellow=Bcolors.YELLOW_S,
                           red=Bcolors.RED_S)
        print(avrdude_menu)
        selection = input()
        if selection == 'i':
            os.system("sudo apt-get update")
            os.system("sudo apt-get install avrdude -y")
            print("\nDone\n")
            sleep(2)
        if selection == 'e':
            break
Esempio n. 4
0
    def node_menu():
        clear_the_screen()
        logo_top()
        sleep(0.05)
        flash_node_menu = """
                            {red}{bold}NODES MENU{endc}
                        {bold}
                1 - Flash node 1        5 - Flash node 5

                2 - Flash node 2        6 - Flash node 6

                3 - Flash node 3        7 - Flash node 7

                4 - Flash node 4        8 - Flash node 8
                        {yellow}
                    'e'- Exit to main menu{endc}
        """.format(bold=Bcolors.BOLD,
                   red=Bcolors.RED,
                   yellow=Bcolors.YELLOW,
                   endc=Bcolors.ENDC)
        print(flash_node_menu)
        selection = input("\n\n\t\t" + Bcolors.BOLD +
                          "Which node do you want to program:" + Bcolors.ENDC +
                          " ")
        print("\n\n")
        if selection.isdigit() and int(selection) <= 8:
            x = selection
            sleep(0.5)
            node_x_menu()
        if selection == 'e':
            nodes_update()
        else:
            node_menu()
Esempio n. 5
0
def updated_check(config):
    user = config.user
    while True:
        if os.path.exists(f"/home/{user}/.ota_markers/.was_updated"):
            clear_the_screen()
            logo_top(config.debug_mode)
            print(""" {bold}
            Software was updated recently to the new version.
    
            You can read update notes now or check them later.
    
    
             {endc}  {green} 
            'r' - read update notes {endc}
    
            's' - skip and don't show again
                """.format(bold=Bcolors.BOLD_S,
                           endc=Bcolors.ENDC,
                           green=Bcolors.GREEN))
            selection = input()
            if selection == 'r':
                os.system("less ./docs/update-notes.txt")
                break
            if selection == 's':
                break
        else:
            break

    os.system(f"rm /home/{user}/.ota_markers/.was_updated >/dev/null 2>&1")
Esempio n. 6
0
def specific_node_menu(config, selected_node_number):
    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        node_selected_menu = f"""
        {Bcolors.BOLD}\n\t\t\tNode {str(selected_node_number)}  selected{Bcolors.ENDC}\n
                Choose flashing type:\n{Bcolors.ENDC}
        1 - {Bcolors.GREEN}Node ground-auto selection firmware - recommended{Bcolors.ENDC}{Bcolors.BOLD}

        2 - Flash custom firmware on the node
        
        3 - Flash 'blink' on the node - only for test purposes

        4 - Check UART connection with a node

        e - Exit{Bcolors.ENDC}"""
        print(node_selected_menu)
        selection = input()
        if selection == '1':
            flash_firmware_on_a_specific_node(config, selected_node_number)
        elif selection == '2':
            flash_custom_firmware_on_a_specific_node(config,
                                                     selected_node_number)
        elif selection == '3':
            flash_blink_on_a_specific_node(config, selected_node_number)
        elif selection == '4':
            check_uart_con_with_a_node(config, selected_node_number)
        elif selection == 'e':
            break
        else:
            continue
        break
Esempio n. 7
0
def ota_update_available_check(config):
    # no config.user usage due to order of operations
    if os.path.exists("./.new_ota_version_diff_file") and os.path.exists("./updater-config.json"):
        if os.path.getsize("./.new_ota_version_diff_file"):
            ota_update_available_flag = True
        else:
            ota_update_available_flag = False  # done this way due to development purposes and weird edge cases
    else:
        ota_update_available_flag = False

    if ota_update_available_flag and config.beta_tester is False:  # don't show update prompt to beta-testers
        clear_the_screen()
        logo_top(config.debug_mode)
        print("""\n\n {bold}

                New OTA software release is available.
                
                Consider updating now (takes ~20 secs).



             {endc}  {green} 
                    u - Update now {endc}{yellow}

                    s - Skip{endc}
            """.format(bold=Bcolors.BOLD_S, endc=Bcolors.ENDC, red=Bcolors.RED,
                       green=Bcolors.GREEN, yellow=Bcolors.YELLOW))
        while True:
            selection = input()
            if selection == 'u':
                self_updater(config)
                break
            elif selection == 's':
                break
Esempio n. 8
0
def welcome_screen(config):
    welcome_message = """{bold}
    Welcome to OTA! With our software you can easily install, update and manage 
    your RotorHazard installation. You can also flash the firmware onto nodes, 
    without the need to open the timer ever again. You have to use official PCB 
    or have 'hardware mod" done for that functionality. You may also check 
    features like smart-hotspot or adding aliases to your system, etc.


    This program has ability to perform 'self-updates' - see "Features Menu".    

    If you found any bug - please report it via GitHub or Facebook. {endc}{bold}        


    Wish you good experience. Enjoy!


                                                            Pawel F.                                                
    {endc}""".format(bold=Bcolors.BOLD, red=Bcolors.RED, green=Bcolors.GREEN, endc=Bcolors.ENDC)

    first_time_flag = os.path.exists("./.first_time_here")
    while first_time_flag and not updated_check(config):
        clear_the_screen()
        logo_top(config.debug_mode)
        print(welcome_message)
        selection = input(f"\n\t\t\t{Bcolors.GREEN}Open next page by typing 'n'{Bcolors.ENDC}\n\n").lower()
        if selection == 'n':
            os.system("rm ./.first_time_here")
            first_time_flag = False  # done that way so after configuration user won't be redirected back here
            show_about(config)
        if selection == 'f':  # helpful when troubleshooting, going further without changing the folder contents
            first_time_flag = False
            show_about(config)
Esempio n. 9
0
 def node_menu():
     while True:
         clear_the_screen()
         logo_top(config.debug_mode)
         sleep(0.05)
         flash_node_menu = """
                     {red}{bold}NODES MENU{endc}
                         {bold}
                 1 - Flash node 1        5 - Flash node 5
             
                 2 - Flash node 2        6 - Flash node 6
             
                 3 - Flash node 3        7 - Flash node 7
             
                 4 - Flash node 4        8 - Flash node 8
                         {yellow}
                     'e'- Exit to main menu{endc}
         """.format(bold=Bcolors.BOLD_S, red=Bcolors.RED_S, yellow=Bcolors.YELLOW, endc=Bcolors.ENDC)
         print(flash_node_menu)
         selection = input("""
                 {bold}Which node do you want to program:{endc} """.format(bold=Bcolors.BOLD, endc=Bcolors.ENDC))
         if selection.isnumeric() and 1 <= int(selection) <= 8:
             specific_node_menu(int(selection))
         elif selection == 'e':
             break
Esempio n. 10
0
def reset_gpio_state():
    clear_the_screen()
    logo_top()
    print("\n\n\n")
    os.system("echo {gpio_reset_pin}  > /sys/class/GPIO/unexport")
    print("\n\n        DONE\n\n")
    sleep(0.3)
Esempio n. 11
0
def nodes_update():
    clear_the_screen()
    logo_top()
    sleep(0.05)
    print("\n\n\t\t\t " + Bcolors.BOLD + Bcolors.UNDERLINE + "CHOOSE FLASHING TYPE:\n" + Bcolors.ENDC)
    print("\t\t " + Bcolors.GREEN + Bcolors.BOLD + "1 - Every Node gets own dedicated firmware - recommended\n"
          + Bcolors.ENDC)
    print("\t\t " + Bcolors.BOLD + "2 - Nodes will use ground-auto selection firmware\n" + Bcolors.ENDC)
    print("\t\t " + Bcolors.BOLD + "3 - Flash 'Blink' on every node\n" + Bcolors.ENDC)
    print("\t\t " + Bcolors.BOLD + "4 - Flash each node individually\n" + Bcolors.ENDC)
    print("\t\t " + Bcolors.BOLD + "5 - Fix GPIO pins state - obsolete\n" + Bcolors.ENDC)
    print("\t\t " + Bcolors.YELLOW + Bcolors.BOLD + "e - Exit to main menu\n" + Bcolors.ENDC)
    sleep(0.3)
    selection = input()
    if selection == '1':
        #  todo dedicated node - redundant?
        logo_update()
        sleep(3)
    if selection == '2':
        flash_firmware_onto_all_gnd_nodes()
        logo_update()
        sleep(3)
    if selection == '3':
        flash_blink_onto_all_gnd_nodes()
        logo_update()
        sleep(3)
    if selection == '4':
        flash_each_node()
    if selection == '5':
        reset_gpio_state()
    if selection == 'e':
        sys.exit()
    else:
        nodes_update()
Esempio n. 12
0
    def node_selection_menu():
        clear_the_screen()
        logo_top(linux_testing)
        sleep(0.05)
        flash_node_menu = """
                            {red}{bold}NODES MENU{endc}
                        {bold}
                1 - Flash node 1        5 - Flash node 5

                2 - Flash node 2        6 - Flash node 6

                3 - Flash node 3        7 - Flash node 7

                4 - Flash node 4        8 - Flash node 8
                        {yellow}
                    'e'- Exit to main menu{endc}
        """.format(bold=Bcolors.BOLD, red=Bcolors.RED, yellow=Bcolors.YELLOW, endc=Bcolors.ENDC)
        print(flash_node_menu)
        selection = input("""
                {bold}Which node do you want to program:{endc} """.format(bold=Bcolors.BOLD, endc=Bcolors.ENDC))
        if int(selection) in range(8):
            selected_node_number = selection
            return selected_node_number
        if selection == 'e':
            main()
        else:
            node_selection_menu()
Esempio n. 13
0
 def first_page():
     clear_the_screen()
     logo_top()
     sleep(0.05)
     print("""\n
 Right now you have your Access Point configured. However,
 there is still an option to maintain internet connection.
 You will be able to connect the Pi via ethernet to the router 
 or PC - with internet sharing option enbled. It requires chages
 in configuration file. Those will be performed automatically,
 after entering 'netcfg' or 'apcfg' in command line.
 Remember to reboot the timer after every change. Instruction
 can be also found in 'apconf.txt' file in net_ap folder.\n
 Remember that regardless how you have your Raspberry configured
 in a given moment, you can always connect to it using WiFi.
 It can be helpful if you don't remember how your timer was configured
 when you left it or when some troubleshooting is required.\n
 Open second page, for detailed explanation.\n\n""")
     selection = input("\t\t" + Bcolors.GREEN + "'s' - second page'" + Bcolors.ENDC + "\t\t" + Bcolors.YELLOW +
                       "'b' - go back" + Bcolors.ENDC + "\n")
     if selection == 's':
         second_page()
     if selection == 'b':
         main()
     else:
         first_page()
Esempio n. 14
0
def main_menu(parser, config):
    clear_the_screen()
    logo_top(config.debug_mode)
    config_check()
    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        main_menu = """
        
                    {red}{bold}{underline}MAIN MENU{endc}
                    
        {blue}{bold}
                        1 - RotorHazard Manager
                            
                        2 - Nodes flash and update {endc} 
                            {bold}
                        3 - Start the server now
                            
                        4 - Additional features
                            
                        5 - Info + first time here
                            
                        6 - Configuration wizard {endc}
                            {yellow}
                        e - Exit {endc}
                            
                """.format(bold=Bcolors.BOLD_S,
                           underline=Bcolors.UNDERLINE,
                           endc=Bcolors.ENDC,
                           blue=Bcolors.BLUE,
                           yellow=Bcolors.YELLOW_S,
                           red=Bcolors.RED_S,
                           orange=Bcolors.ORANGE_S)
        print(main_menu)
        selection = input()
        if selection == '1':
            os.system(
                "python3 ./rpi_update.py")  # opens raspberry updating file
        if selection == '2':
            os.system("python3 ./nodes_update.py")  # opens nodes updating file
        if selection == '3':
            clear_the_screen()
            os.system(". ./open_scripts.sh; server_start")
        if selection == '4':
            features_menu(parser, config)
        if selection == '5':
            first_time(parser, config)
        if selection == '6':
            os.system(". ./open_scripts.sh; ota_configuration_start")
        if selection == 'logme':
            log_to_dev(parser, config)
        if selection == 'e':
            end(parser, config)
        if selection == '2dev':
            os.system("python3 ./.dev/done_nodes_update_dev.py"
                      )  # opens nodes updating file
Esempio n. 15
0
def serial_menu(config):
    ota_status = load_ota_config(config.user)

    def serial_content():
        # TODO Make this repeatable without adding multiple copies at the end of config.txt.
        os.system("echo 'enable_uart=1'| sudo tee -a /boot/config.txt")
        os.system(
            "sudo sed -i 's/console=serial0,115200//g' /boot/cmdline.txt")
        ota_status.serial_added = True
        write_ota_config(ota_status, config.user)
        print("""
        
        Serial port enabled successfully
        You have to reboot Raspberry now. Ok?
        
        r - Reboot now{yellow}
        b - Go back{endc}
            """.format(endc=Bcolors.ENDC, yellow=Bcolors.YELLOW_S))
        selection_2 = input()
        if selection_2 == 'r':
            os.system("sudo reboot")
        if selection_2 == 'b':
            return

    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        menu = """
            Serial port has to be enabled. 
            Without it Arduinos cannot be programmed.
            Do you want to enable it now?
            
            {yellow}
            y - for yes 
            a - for abort{endc}
            """.format(endc=Bcolors.ENDC, yellow=Bcolors.YELLOW)
        selection = input(menu)
        if selection == 'y':
            if ota_status.serial_added:
                print(
                    "\n\n\t\tLooks like you already enabled Serial port. \n\t\tDo you want to continue anyway?\n"
                )
                selection = input(
                    f"\t\t\t{Bcolors.YELLOW}Press 'y' for yes or 'a' for abort{Bcolors.ENDC}\n"
                )
                if selection == 'y':
                    serial_content()
                    break
                if selection == 'a':
                    break
            else:
                serial_content()
                break
        if selection == 'a':
            break
Esempio n. 16
0
def serial_menu(config):
    ota_status = load_ota_sys_markers(config.user)

    def uart_enabling():  # UART enabling prompt is also being shown when entering nodes flash menu for the first time
        # TODO Make this repeatable without adding multiple copies at the end of config.txt.
        os.system("./scripts/sys_conf.sh uart")
        ota_status.uart_support_added = True
        write_ota_sys_markers(ota_status, config.user)
        print("""

        Serial port enabled successfully.
        You have to reboot Raspberry now,
        so changes would be implemented. Ok?



        r - Reboot now{yellow}

        e - Exit{endc}
            """.format(endc=Bcolors.ENDC, yellow=Bcolors.YELLOW_S))
        selection = input()
        if selection == 'r':
            os.system("sudo reboot")
        elif selection == 'e':
            return

    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        serial_adding_menu = """
            Serial port (UART) has to be enabled. 
            Without it Arduino-nodes cannot be programmed.
            Do you want to enable it now?


     {green}y - for yes {endc}

    {yellow}a - for abort{endc}
            """.format(yellow=Bcolors.YELLOW_S, green=Bcolors.GREEN_S, endc=Bcolors.ENDC)
        selection = input(serial_adding_menu)
        if selection == 'y':
            if ota_status.uart_support_added:
                print("\n\n\t\tLooks like you already enabled Serial port. \n\t\tDo you want to continue anyway?\n")
                selection = input(f"\t\t\t{Bcolors.YELLOW}Press 'y' for yes or 'a' for abort{Bcolors.ENDC}\n")
                if selection == 'y':
                    uart_enabling()
                    break
                elif selection == 'a':
                    break
            else:
                uart_enabling()
                break
        elif selection == 'a':
            break
Esempio n. 17
0
 def node_menu():
     global x
     clear_the_screen()
     logo_top(linux_testing)
     sleep(0.05)
     flash_node_menu = """
                         {red}{bold}NODES MENU{endc}
                     {bold}
             1 - Flash node 1        5 - Flash node 5
         
             2 - Flash node 2        6 - Flash node 6
         
             3 - Flash node 3        7 - Flash node 7
         
             4 - Flash node 4        8 - Flash node 8
                     {yellow}
                 'e'- Exit to main menu{endc}
     """.format(bold=Bcolors.BOLD,
                red=Bcolors.RED,
                yellow=Bcolors.YELLOW,
                endc=Bcolors.ENDC)
     print(flash_node_menu)
     selection = input("""
             {bold}Which node do you want to program:{endc} """.format(
         bold=Bcolors.BOLD, endc=Bcolors.ENDC))
     if selection == '1':
         x = 1
         node_x_menu()
     if selection == '2':
         x = 2
         node_x_menu()
     if selection == '3':
         x = 3
         node_x_menu()
     if selection == '4':
         x = 4
         node_x_menu()
     if selection == '5':
         x = 5
         node_x_menu()
     if selection == '6':
         x = 6
         node_x_menu()
     if selection == '7':
         x = 7
         node_x_menu()
     if selection == '8':
         x = 8
         node_x_menu()
     if selection == 'e':
         nodes_update()
     else:
         node_menu()
Esempio n. 18
0
def node_selection_menu(config):
    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        flash_node_menu = """\n
        
                    {red}{bold}NODES MENU{endc}{bold}
                        
                1 - Flash node 1        5 - Flash node 5

                2 - Flash node 2        6 - Flash node 6

                3 - Flash node 3        7 - Flash node 7

                4 - Flash node 4        8 - Flash node 8 
                            
                   {yellow}e - Exit to main menu{endc}
                    
        """.format(bold=Bcolors.BOLD_S,
                   red=Bcolors.RED_S,
                   yellow=Bcolors.YELLOW_S,
                   endc=Bcolors.ENDC)
        print(flash_node_menu)
        selection = input(
            f"\t\t{Bcolors.BOLD}Which node do you want to program: {Bcolors.ENDC}"
        )
        if selection.isdigit():
            if odd_number_of_nodes_check(config):
                if int(selection) in range(config.nodes_number + 1) and int(
                        selection) != config.nodes_number:
                    selected_node_number = selection
                    specific_node_menu(config, int(selected_node_number))
                elif int(selection) in range(config.nodes_number + 1) and int(
                        selection) == config.nodes_number:
                    odd_node_menu(config)
                elif int(selection) in range(8) and int(
                        selection) not in range(config.nodes_number):
                    print(
                        "\n\n\tNode number higher than configured amount of nodes."
                    )
                    sleep(1.5)
            elif not odd_number_of_nodes_check(config):
                if int(selection) in range(config.nodes_number + 1):
                    selected_node_number = selection
                    specific_node_menu(config, int(selected_node_number))
                elif int(selection) in range(8) and int(
                        selection) not in range(config.nodes_number):
                    print(
                        "\n\n\tNode number higher than configured amount of nodes."
                    )
                    sleep(1.5)
        elif selection == 'e':
            break
Esempio n. 19
0
def main_menu(config):
    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        config_check()
        main_menu_content = """
        
                    {red}{bold}{underline}MAIN MENU{endc}{blue}{bold}
                    
                             
                        1 - RotorHazard Manager
                            
                        2 - Nodes flash and update {endc}{bold}
                            
                        3 - Start the server now
                            
                        4 - Additional features
                            
                        5 - Info + first time here
                            
                        6 - Configuration wizard {endc}{yellow}
                            
                        e - Exit {endc}
                            
                """.format(bold=Bcolors.BOLD_S,
                           underline=Bcolors.UNDERLINE,
                           endc=Bcolors.ENDC,
                           blue=Bcolors.BLUE,
                           yellow=Bcolors.YELLOW_S,
                           red=Bcolors.RED_S)
        print(main_menu_content)
        selection = input()
        if selection == '1':
            print("todo: call rpi_update")
            # rpi_update(config) #TODO modulalize rpi-update
            # os.system("python3 ./rpi_update.py")  # opens raspberry updating file
        if selection == '2':
            print("todo: call node_update")
            # nodes_update(config) #TODO modulalize node-update (i2c_ !)
            # os.system("python3 ./nodes_update.py")  # opens nodes updating file
        if selection == '3':
            clear_the_screen()
            os.system(". ./scripts/server_start.sh")
        if selection == '4':
            features_menu(config)
        if selection == '5':
            first_time()
        if selection == '6':
            config = conf_ota(config)
        if selection == 'logme':
            log_to_dev(config)
        if selection == 'e':
            end()
Esempio n. 20
0
def self_updater(parser, config):
    def add_updater():
        clear_the_screen()
        logo_top(config.debug_mode)
        print("""
    Permissions required so 'zip' and 'unzip' program can be downloaded.
    Performed only during first instance of entering this sub-menu\n""")
        sleep(2)
        os.system("sudo echo")
        os.system("sudo apt install zip unzip")
        os.system(
            "echo 'alias updateupdater=\"cd ~ && cp ~/RH-ota/self.py ~/.ota_markers/self.py && \
         python ~/.ota_markers/self.py \"  # part of self updater' | tee -a ~/.bashrc >/dev/null"
        )
        os.system(
            "echo 'alias uu=\"cd ~ && cp ~/RH-ota/self.py ~/.ota_markers/self.py && python \
         ~/.ota_markers/self.py \"  # part of self updater' | tee -a ~/.bashrc >/dev/null"
        )
        parser.set('added_functions', 'updater_planted', '1')
        parser_write(parser, config)

    if not parser.getint('added_functions', 'updater_planted'):
        add_updater()
    clear_the_screen()
    logo_top(config.debug_mode)
    updater = """{bold}
    If you want to update this program and download new firmware, 
    prepared for Arduino nodes - so you can next flash them 
    - you can just hit 'u' now. You can also type 'updateupdater'
    or 'uu' in the terminal window.
    Version of the updater is related to {blue}nodes firmware API number{endc},
          {bold}
    so you always know what firmware version updater contains.
    For example "2.2.5c" contains nodes firmware with "API level 22".
    Self-updater will test your internet connection during every update.
    Updating script is currently set to mode: {green}{update_mode}{endc}.\n\n
    """.format(green=Bcolors.GREEN,
               endc=Bcolors.ENDC,
               bold=Bcolors.BOLD,
               blue=Bcolors.BLUE,
               update_mode=config.update_mode)
    print(updater)
    print(Bcolors.GREEN + """\t\tUpdate now by pressing 'u'""" + Bcolors.ENDC +
          """\n""")
    print(Bcolors.YELLOW + """\t\tGo back by pressing 'b'""" + Bcolors.ENDC +
          """\n\n""")
    selection = input()
    if selection == 'b':
        features_menu(parser, config)
    if selection == 'u':
        os.system(". ./open_scripts.sh; updater_from_ota")
    else:
        self_updater(parser, config)
Esempio n. 21
0
def serial_menu(parser, config):
    def serial_content():
        os.system("echo 'enable_uart=1'| sudo tee -a /boot/config.txt")
        os.system(
            "sudo sed -i 's/console=serial0,115200//g' /boot/cmdline.txt")
        parser.set('added_functions', 'serial_added', '1')
        parser_write(parser, config)
        print("""
        
        Serial port enabled successfully
        You have to reboot Raspberry now. Ok?
        
        r - Reboot now{yellow}
        b - Go back{endc}
            """.format(endc=Bcolors.ENDC, yellow=Bcolors.YELLOW_S))
        selection_2 = input()
        if selection_2 == 'r':
            os.system("sudo reboot")
        if selection_2 == 'b':
            return

    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        menu = """
            Serial port has to be enabled. 
            Without it Arduinos cannot be programmed.
            Do you want to enable it now?
            
            {yellow}
            y - for yes 
            a - for abort{endc}
            """.format(endc=Bcolors.ENDC, yellow=Bcolors.YELLOW)
        selection = input(menu)
        if selection == 'y':
            if parser.getint('added_functions', 'serial_added'):
                print(
                    "\n\n\t\tLooks like you already enabled Serial port. \n\t\tDo you want to continue anyway?\n"
                )
                selection = input("\t\t\t" + Bcolors.YELLOW +
                                  "Press 'y' for yes or 'a' for abort" +
                                  Bcolors.ENDC + "\n")
                if selection == 'y':
                    serial_content()
                    break
                if selection == 'a':
                    break
            else:
                serial_content()
                break
        if selection == 'a':
            break
Esempio n. 22
0
def nodes_update():
    clear_the_screen()
    logo_top(linux_testing)
    sleep(0.05)
    node_menu = """\n
                    {bold}{underline}CHOOSE FLASHING TYPE:{endc}
    
            {green}{bold}1 - Every Node gets own dedicated firmware - rec.{endc}
            
            {bold}2 - Nodes using ground-auto numbering firmware
            
            3 - Flash 'Blink' on every node
            
            4 - Flash each node individually
            
            5 - I2C programming - NEW (beta)
            
            6 - Fix GPIO pins state - obsolete
            
            {yellow}e - Exit to main menu{endc}
    """.format(bold=Bcolors.BOLD,
               green=Bcolors.GREEN,
               yellow=Bcolors.YELLOW,
               endc=Bcolors.ENDC,
               underline=Bcolors.UNDERLINE)
    print(node_menu)
    sleep(0.1)
    selection = input()
    if selection == '1':
        flash_all_nodes()
        logo_update()
        sleep(3)
    if selection == '2':
        flash_all_gnd()
        logo_update()
        sleep(3)
    if selection == '3':
        flash_all_blink()
        logo_update()
        sleep(3)
    if selection == '4':
        flash_each_node()
    if selection == '5':
        os.system("python3 ./i2c_nodes_flash.py")
    if selection == '6':
        gpio_state()
    if selection == 'e':
        sys.exit()
    else:
        nodes_update()
Esempio n. 23
0
def main_menu(config):
    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        rh_install_or_update_prompt = rh_update_check(config)
        conf_color = Bcolors.GREEN if config_check() is False else ''
        main_menu_content = """

                                {rmf}MAIN MENU{endc}

                            {blue}{bold}  
                        1 - RotorHazard Manager {rh_prompt} 
                            {blue}{bold}
                        2 - Nodes flash and update {endc}{bold}
                            
                        3 - Additional features{configured}

                        4 - Configuration wizard{endc}{bold}{yellow}

                        e - Exit to Raspberry OS{endc}

                """.format(bold=Bcolors.BOLD_S, underline=Bcolors.UNDERLINE, endc=Bcolors.ENDC, green=Bcolors.GREEN,
                           blue=Bcolors.BLUE, yellow=Bcolors.YELLOW_S, red=Bcolors.RED, configured=conf_color,
                           rmf=Bcolors.RED_MENU_HEADER, rh_prompt=rh_install_or_update_prompt)
        print(main_menu_content)
        selection = input()
        if selection == '1':
            try:
                rpi_update(config)
            except AttributeError:
                attribute_error_handling()
        elif selection == '2':
            try:
                ota_status = load_ota_sys_markers(config.user)
                if ota_status.uart_support_added:
                    old_flash_gpio(config) if config.old_hw_mod else flashing_menu(config)
                # enters "old" flashing menu only when "old_hw_mod" is confirmed
                else:
                    serial_menu(config)
            except AttributeError:
                attribute_error_handling()
        elif selection == '3':
            features_menu(config)
        elif selection == '4':
            config = show_about(config)
        elif selection == 'e':
            end()
Esempio n. 24
0
def gpio_state():
    clear_the_screen()
    logo_top(linux_testing)
    print("\n\n\n")
    os.system(f"echo {reset_1} > /sys/class/GPIO/unexport")
    os.system(f"echo {reset_2} > /sys/class/GPIO/unexport")
    os.system(f"echo {reset_3} > /sys/class/GPIO/unexport")
    os.system(f"echo {reset_4} > /sys/class/GPIO/unexport")
    os.system(f"echo {reset_5} > /sys/class/GPIO/unexport")
    os.system(f"echo {reset_6} > /sys/class/GPIO/unexport")
    os.system(f"echo {reset_7} > /sys/class/GPIO/unexport")
    os.system(f"echo {reset_8} > /sys/class/GPIO/unexport")
    os.system("echo 19 > /sys/class/GPIO/unexport")
    os.system("echo 20 > /sys/class/GPIO/unexport")
    os.system("echo 21 > /sys/class/GPIO/unexport")
    print("\n\n        DONE\n\n")
    sleep(0.3)
Esempio n. 25
0
def gpio_state():
    clear_the_screen()
    logo_top()        # todo inspection shows error Parameter 'linux_testing' unfilled and points to this line
    print("\n\n\n")   # todo end every other line with logo_top()
    os.system("echo " + str(reset_1) + " > /sys/class/GPIO/unexport")
    os.system("echo " + str(reset_2) + " > /sys/class/GPIO/unexport")
    os.system("echo " + str(reset_3) + " > /sys/class/GPIO/unexport")
    os.system("echo " + str(reset_4) + " > /sys/class/GPIO/unexport")
    os.system("echo " + str(reset_5) + " > /sys/class/GPIO/unexport")
    os.system("echo " + str(reset_6) + " > /sys/class/GPIO/unexport")
    os.system("echo " + str(reset_7) + " > /sys/class/GPIO/unexport")
    os.system("echo " + str(reset_8) + " > /sys/class/GPIO/unexport")
    os.system("echo 19 > /sys/class/GPIO/unexport")
    os.system("echo 20 > /sys/class/GPIO/unexport")
    os.system("echo 21 > /sys/class/GPIO/unexport")
    print("\n\n        DONE\n\n")
    sleep(0.3)
Esempio n. 26
0
def gpio_state(config):
    clear_the_screen()
    logo_top(config.debug_mode)
    print("\n\n\n")
    os.system(f"echo {pins_assignment(config)[0]} > /sys/class/GPIO/unexport")
    os.system(f"echo {pins_assignment(config)[1]} > /sys/class/GPIO/unexport")
    os.system(f"echo {pins_assignment(config)[2]} > /sys/class/GPIO/unexport")
    os.system(f"echo {pins_assignment(config)[3]} > /sys/class/GPIO/unexport")
    os.system(f"echo {pins_assignment(config)[4]} > /sys/class/GPIO/unexport")
    os.system(f"echo {pins_assignment(config)[5]} > /sys/class/GPIO/unexport")
    os.system(f"echo {pins_assignment(config)[6]} > /sys/class/GPIO/unexport")
    os.system(f"echo {pins_assignment(config)[7]} > /sys/class/GPIO/unexport")
    os.system("echo 19 > /sys/class/GPIO/unexport")
    os.system("echo 20 > /sys/class/GPIO/unexport")
    os.system("echo 21 > /sys/class/GPIO/unexport")
    print("\n\n\t\tDONE\n\n")
    sleep(0.3)
Esempio n. 27
0
def main():
    clear_the_screen()
    logo_top(linux_testing)
    sleep(0.05)
    node_menu = """\n
                        {bold}{underline}CHOOSE FLASHING TYPE:{endc}

                {green}{bold}1 - Flash each node automatically - rec.{endc}

                2 - Flash each node individually

                3 - Flash first time

                4 - Show I2C connected devices

                5 - Flash using GPIO reset pins - obsolete

                6 - Fix GPIO pin state

                {yellow}'e' - Exit to main menu{endc}
        """.format(bold=Bcolors.BOLD, green=Bcolors.GREEN, yellow=Bcolors.YELLOW,
                   endc=Bcolors.ENDC, underline=Bcolors.UNDERLINE)
    print(node_menu)
    sleep(0.1)
    selection = input()
    if selection == '1':
        flash_firmware_onto_all_gnd_nodes()
        logo_update()
    if selection == '2':
        flash_nodes_individually()
        logo_update()
    if selection == '3':
        first_flashing(nodes_number)
        logo_update()
    if selection == '4':
        logo_top()
        os.system("i2cdetect - y 1")
    if selection == '5':
        os.system("python3 ./nodes_update_old.py")
    if selection == '6':
        reset_gpio_state()
    if selection == 'e':
        sys.exit()
    else:
        main()
Esempio n. 28
0
def features_menu(config):
    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        features_menu_content = """

                                {rmf}FEATURES MENU{endc}{blue}{bold}


                        1 - Enable serial protocol {endc}{bold}

                        2 - Access Point and Internet 

                        3 - Show actual Pi's GPIO

                        4 - Add useful aliases

                        5 - Update OTA software {endc}{bold}

                        6 - Create a log file{yellow}

                        e - Exit to main menu {endc}

                 """.format(bold=Bcolors.BOLD_S, underline=Bcolors.UNDERLINE, endc=Bcolors.ENDC,
                            blue=Bcolors.BLUE, yellow=Bcolors.YELLOW_S, red=Bcolors.RED_S, rmf=Bcolors.RED_MENU_HEADER)
        print(features_menu_content)
        selection = input()
        if selection == '1':
            serial_menu(config)
        elif selection == '2':
            conf_wizard_net(config)
        elif selection == '3':
            os.system("pinout")
            input("\nDone? Hit 'Enter'\n")
        elif selection == '4':
            try:
                aliases_menu(config)
            except AttributeError:
                attribute_error_handling()
        elif selection == '5':
            self_updater(config)  # todo better "wrong user name" handling and added here too
        elif selection == '6':  # maybe add a general checking if username is setup right?
            log_to_dev(config)
        elif selection == 'e':
            break
Esempio n. 29
0
def flashing_menu(config):
    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        node_menu = """\n
        
                          {rmh}FLASHING MENU{endc}
            
            
       {green}{bold}1 - Flash each node automatically{endc}{bold}
    
                    2 - Flash nodes individually
    
                    3 - First time flashing
    
                    4 - Show I2C connected devices
                    
                    5 - Check connection with nodes
            
            {yellow}e - Exit to main menu{endc}\n
            """.format(bold=Bcolors.BOLD_S,
                       green=Bcolors.GREEN_S,
                       yellow=Bcolors.YELLOW_S,
                       endc=Bcolors.ENDC,
                       red=Bcolors.RED_S,
                       underline=Bcolors.UNDERLINE_S,
                       rmh=Bcolors.RED_MENU_HEADER)
        print(node_menu)
        sleep(0.1)
        selection = input("")
        if selection == '1':
            flash_firmware_onto_all_nodes(config)
        elif selection == '2':
            node_selection_menu(config)
        elif selection == '3':
            first_flashing(config)
        elif selection == '4':
            show_i2c_devices(config)
        elif selection == '5':
            check_uart_devices(config)
        elif selection == 'custom':
            flash_custom_firmware_onto_all_nodes(config)
        elif selection == 'e':
            break
Esempio n. 30
0
 def add_updater():
     clear_the_screen()
     logo_top(config.debug_mode)
     print("""
 Permissions required so 'zip' and 'unzip' program can be downloaded.
 Performed only during first instance of entering this sub-menu\n""")
     sleep(2)
     os.system("sudo echo")
     os.system("sudo apt install zip unzip")
     os.system(
         "echo 'alias updateupdater=\"cd ~ && cp ~/RH-ota/self.py ~/.ota_markers/self.py && \
      python ~/.ota_markers/self.py \"  # part of self updater' | tee -a ~/.bashrc >/dev/null"
     )
     os.system(
         "echo 'alias uu=\"cd ~ && cp ~/RH-ota/self.py ~/.ota_markers/self.py && python \
      ~/.ota_markers/self.py \"  # part of self updater' | tee -a ~/.bashrc >/dev/null"
     )
     ota_status.updater_planted = True
     write_ota_config(ota_status, config.user)