示例#1
0
def check_autoboot():
    check_update = parrot_utils.execute_command(tn,'grep "START_PAPARAZZI" /bin/check_update.sh')
    wifi_setup = parrot_utils.execute_command(tn,'grep "BASE_ADRESS" /bin/wifi_setup.sh')
    if "START_PAPARAZZI" in check_update and "BASE_ADRESS" in wifi_setup:
        return True
    else:
        return False
示例#2
0
def ardrone2_install_vision():
    print('Uploading GST')
    parrot_utils.uploadfile(ftp, "arm_light.tgz", file("bin/arm_light.tgz", "rb"))
    print(parrot_utils.execute_command(tn,"cd /data/video && tar -xzf arm_light.tgz"))
    print(parrot_utils.execute_command(tn,"rm -rf /data/video/arm_light.tgz"))
    print('Now Starting Vision')
    ardrone2_start_vision()
示例#3
0
def ardrone2_install_olsrd():
    print('Uploading olsr deamon')
    parrot_utils.uploadfile(ftp, "olsrd", file("ardrone2/olsrd", "rb"))
    parrot_utils.uploadfile(ftp, "olsrd.conf", file("ardrone2/olsrd.conf", "rb"))
    print(parrot_utils.execute_command(tn,"mv /data/video/olsrd /bin/olsrd"))
    print(parrot_utils.execute_command(tn,"chmod 777 /bin/olsrd"))
    print(parrot_utils.execute_command(tn,"mkdir -p /etc/olsrd"))
    print(parrot_utils.execute_command(tn,"mv /data/video/olsrd.conf /etc/olsrd"))
    print(parrot_utils.execute_command(tn,"rm -f /var/run && ln -s /tmp /var/run")) # olsrd needs /var/run folder, symlinked to /tmp
示例#4
0
def ardrone2_status():
    config_ini = parrot_utils.execute_command(tn,'cat /data/config.ini')

    print('======================== ARDrone 2 Status ========================')
    print('Version:\t\t' + parrot_utils.check_version(tn, '/firmware'))
    print('Host:\t\t\t' + args.host + ' (' + read_from_config('static_ip_address_base', config_ini) +
          read_from_config('static_ip_address_probe', config_ini) + ' after boot)')
    print('Currently running:\t' + parrot_utils.check_running(tn))
    print('Serial number:\t\t' + read_from_config('drone_serial', config_ini))
    print('Network id:\t\t' + read_from_config('ssid_single_player', config_ini))
    print('Motor software:\t\t' +
          read_from_config('motor1_soft', config_ini) + '\t' + read_from_config('motor2_soft', config_ini) + '\t' +
          read_from_config('motor3_soft', config_ini) + '\t' + read_from_config('motor4_soft', config_ini))
    print('Motor hardware:\t\t' +
          read_from_config('motor1_hard', config_ini) + '\t' + read_from_config('motor2_hard', config_ini) + '\t' +
          read_from_config('motor3_hard', config_ini) + '\t' + read_from_config('motor4_hard', config_ini))

    autorun = {'': 'Native', '0': 'Native', '1': 'Paparazzi RAW', '2': 'Paparazzi SDK'}
    if check_autoboot():
        print('Autorun at start:\tInstalled booting ' + autorun[read_from_config('start_paparazzi', config_ini)])
    else:
        print('Autorun at start:\tNot installed')

    # Check if the vision framework is installed and running
    vision_framework = ""
    if check_vision_installed():
        vision_framework += "Installed"
    if check_vision_running():
        vision_framework += " and running"
    print('Vision framework:\t' + vision_framework)

    # Request the filesystem status
    print('\n======================== Filesystem Status ========================')
    print(parrot_utils.check_filesystem(tn))
示例#5
0
def read_from_config(name, config=''):
    if config == '':
        config = parrot_utils.execute_command('cat /data/config.ini')
    search = re.search(name + '[^=]+=[\r\n\t ]([^\r\n\t ]+)', config)
    if search is None:
        return ''
    else:
        return search.group(1)
示例#6
0
def read_from_config(name, config=""):
    if config == "":
        config = parrot_utils.execute_command("cat /data/config.ini")
    search = re.search(name + "[^=]+=[\r\n\t ]([^\r\n\t ]+)", config)
    if search is None:
        return ""
    else:
        return search.group(1)
示例#7
0
def ardrone2_remove_vision():
    parrot_utils.execute_command(tn,"rm -rf /opt/arm")
    parrot_utils.execute_command(tn,"rm -rf /lib/dsp")
    parrot_utils.execute_command(tn,"rm -rf /data/video/opt")
示例#8
0
def check_wifi_setup():
    check_wifi = parrot_utils.execute_command(tn,'grep "static_ip_address_base" /bin/wifi_setup.sh')
    if "static_ip_address_base" in check_wifi:
        return True
    else:
        return False
示例#9
0
def check_vision_running():
    du_opt = parrot_utils.execute_command(tn,'du -d 2 /opt')
    return '/opt/arm/gst' in du_opt and '/opt/arm/lib' in du_opt and '/opt/arm/tidsp-binaries-23.i3.8' in du_opt
示例#10
0
def ardrone2_remove_vision():
    parrot_utils.execute_command(tn, "rm -rf /opt/arm")
    parrot_utils.execute_command(tn, "rm -rf /lib/dsp")
    parrot_utils.execute_command(tn, "rm -rf /data/video/opt")
示例#11
0
def ardrone2_install_network_script():
    print('Uploading Wifi script')
    parrot_utils.uploadfile(ftp, "wifi_setup.sh", file("ardrone2/wifi_setup.sh", "rb"))
    print(parrot_utils.execute_command(tn,"mv /data/video/wifi_setup.sh /bin/wifi_setup.sh"))
    print(parrot_utils.execute_command(tn,"chmod 777 /bin/wifi_setup.sh"))
示例#12
0
def ardrone2_install_autoboot():
    print('Uploading autoboot script')
    parrot_utils.uploadfile(ftp, "check_update.sh", file("ardrone2/check_update.sh", "rb"))
    print(parrot_utils.execute_command(tn,"mv /data/video/check_update.sh /bin/check_update.sh"))
    print(parrot_utils.execute_command(tn,"chmod 777 /bin/check_update.sh"))
示例#13
0
# Connect with telnet and ftp
tn, ftp = parrot_utils.connect(args.host)

# Check the ARDrone 2 status
if args.command == 'status':
    ardrone2_status()

# Reboot the drone
elif args.command == 'reboot':
    parrot_utils.reboot(tn)
    print('The ARDrone 2 is rebooting...')

# Kill a program
elif args.command == 'kill':
    parrot_utils.execute_command(tn,'killall -9 ' + args.program + ' &')
    print('Program "' + args.program + '" is now killed')

# Start a program
elif args.command == 'start':
    parrot_utils.execute_command(tn,args.start + ' &')
    print('Program "' + args.start + '" is now started')

# Change the network ID
elif args.command == 'networkid':
    ardrone2_set_ssid(args.name)

    if raw_input("Shall I restart the ARDrone 2? (y/N) ").lower() == 'y':
        parrot_utils.reboot(tn)

# Change the IP address
示例#14
0
def check_vision_installed():
    du_opt = parrot_utils.execute_command(tn, 'du -d 2 /data/video/opt')
    return '/data/video/opt/arm/gst' in du_opt or '/data/video/opt/arm/lib' in du_opt or '/data/video/opt/arm/tidsp-binaries-23.i3.8' in du_opt
示例#15
0
def ardrone2_start_vision():
    # Mount the directories
    parrot_utils.execute_command(tn, "mkdir -p /opt/arm")
    parrot_utils.execute_command(tn, "mkdir -p /lib/dsp")
    parrot_utils.execute_command(tn,
                                 "mount --bind /data/video/opt/arm /opt/arm")
    parrot_utils.execute_command(
        tn, "mount --bind /data/video/opt/arm/lib/dsp /lib/dsp")
    # Start The DSP programs
    parrot_utils.execute_command(tn, "kill -9 `pidof program.elf`")
    parrot_utils.execute_command(tn, "kill -9 `pidof gst-launch-0.10`")
    parrot_utils.execute_command(tn, "export PATH=/opt/arm/gst/bin:$PATH")
    parrot_utils.execute_command(
        tn, "export DSP_PATH=/opt/arm/tidsp-binaries-23.i3.8/")
    parrot_utils.execute_command(
        tn,
        "/bin/dspbridge/cexec.out -T /opt/arm/tidsp-binaries-23.i3.8/baseimage.dof -v"
    )
    parrot_utils.execute_command(
        tn,
        "/bin/dspbridge/dynreg.out -r /opt/arm/tidsp-binaries-23.i3.8/m4venc_sn.dll64P -v"
    )
    # Show result
    parrot_utils.execute_command(tn, "ls -altr /opt/arm/gst/bin")
示例#16
0
def ardrone2_start_vision():
    # Mount the directories
    parrot_utils.execute_command(tn,"mkdir -p /opt/arm")
    parrot_utils.execute_command(tn,"mkdir -p /lib/dsp")
    parrot_utils.execute_command(tn,"mount --bind /data/video/opt/arm /opt/arm")
    parrot_utils.execute_command(tn,"mount --bind /data/video/opt/arm/lib/dsp /lib/dsp")
    # Start The DSP programs
    parrot_utils.execute_command(tn,"kill -9 `pidof program.elf`")
    parrot_utils.execute_command(tn,"kill -9 `pidof gst-launch-0.10`")
    parrot_utils.execute_command(tn,"export PATH=/opt/arm/gst/bin:$PATH")
    parrot_utils.execute_command(tn,"export DSP_PATH=/opt/arm/tidsp-binaries-23.i3.8/")
    parrot_utils.execute_command(tn,"/bin/dspbridge/cexec.out -T /opt/arm/tidsp-binaries-23.i3.8/baseimage.dof -v")
    parrot_utils.execute_command(tn,"/bin/dspbridge/dynreg.out -r /opt/arm/tidsp-binaries-23.i3.8/m4venc_sn.dll64P -v")
    # Show result
    parrot_utils.execute_command(tn,"ls -altr /opt/arm/gst/bin")
示例#17
0
# Connect with telnet and ftp
tn, ftp = parrot_utils.connect(args.host)

# Check the Bebop status
if args.command == 'status':
    print("Connected to Bebop at " + args.host)
    bebop_status()

# Reboot the drone
elif args.command == 'reboot':
    parrot_utils.reboot(tn)
    print('The Bebop is rebooting...')

# Kill a program
elif args.command == 'kill':
    parrot_utils.execute_command(tn, 'killall -9 ' + args.program)
    print('Program "' + args.program + '" is now killed')

# Start a program
elif args.command == 'start':
    parrot_utils.execute_command(tn, args.start + ' &')
    print('Program "' + args.start + '" is now started')


elif args.command == 'insmod':
    modfile = parrot_utils.split_into_path_and_file(args.file)
    print('Uploading \'' + modfile[1])
    parrot_utils.uploadfile(ftp, modfile[1], file(args.file, "rb"))
    print(parrot_utils.execute_command(tn, "insmod /data/ftp/" + modfile[1]))

elif args.command == 'upload_file_and_run':
示例#18
0
def check_vision_installed():
    du_opt = parrot_utils.execute_command(tn,'du -d 2 /data/video/opt')
    return '/data/video/opt/arm/gst' in du_opt or '/data/video/opt/arm/lib' in du_opt or '/data/video/opt/arm/tidsp-binaries-23.i3.8' in du_opt
示例#19
0
def write_to_config(name, value):
    if read_from_config(name) == '':
        parrot_utils.execute_command('echo "' + name + ' = ' + value + '\" >> /data/config.ini')
    else:
        parrot_utils.execute_command('sed -i "s/\(' + name + ' *= *\).*/\\1' + value + '/g" /data/config.ini')
示例#20
0
# Connect with telnet and ftp
tn, ftp = parrot_utils.connect(args.host)

# Check the ARDrone 2 status
if args.command == 'status':
    ardrone2_status()

# Reboot the drone
elif args.command == 'reboot':
    parrot_utils.reboot(tn)
    print('The ARDrone 2 is rebooting...')

# Kill a program
elif args.command == 'kill':
    parrot_utils.execute_command(tn, 'killall -9 ' + args.program + ' &')
    print('Program "' + args.program + '" is now killed')

# Start a program
elif args.command == 'start':
    parrot_utils.execute_command(tn, args.start + ' &')
    print('Program "' + args.start + '" is now started')

# Change the network ID
elif args.command == 'networkid':
    ardrone2_set_ssid(args.name)

    if raw_input("Shall I restart the ARDrone 2? (y/N) ").lower() == 'y':
        parrot_utils.reboot(tn)

# Change the IP address