Skip to content

Commit

Permalink
[bebop] Version Checking Compatible with 3.10 (#1906)
Browse files Browse the repository at this point in the history
  • Loading branch information
dewagter authored and podhrmic committed Oct 25, 2016
1 parent 4e96afe commit 34b182c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sw/tools/parrot/ardrone2.py
Expand Up @@ -160,7 +160,7 @@ 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('Version:\t\t' + str(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)')

Expand Down
6 changes: 3 additions & 3 deletions sw/tools/parrot/bebop.py
Expand Up @@ -50,7 +50,7 @@ def bebop_status():
#config_ini = parrot_utils.execute_command(tn, 'cat /data/config.ini')

print('======================== Bebop Status ========================')
print('Version:\t\t' + parrot_utils.check_version(tn, ''))
print('Version:\t\t' + str(parrot_utils.check_version(tn, '')))
# Request the filesystem status
print('\n=================== Filesystem Status =======================')
print(parrot_utils.check_filesystem(tn))
Expand Down Expand Up @@ -123,9 +123,9 @@ def bebop_status():
f = parrot_utils.split_into_path_and_file(args.file)

#check firmware version
v = parrot_utils.check_version(tn, '').strip()
v = parrot_utils.check_version(tn, '')
print("Checking Bebop firmware version... " + v )
if ((v < '3.2.0') or (v > '3.9.0')):
if ((v < parrot_utils.ParrotVersion('3.2.0')) or (v > parrot_utils.ParrotVersion('3.9.0'))):
print("Error: please upgrade your Bebop firmware to version between 3.2.0 and 3.9.0!")
else:
print("Kill running " + f[1] + " and make folder " + args.folder)
Expand Down
46 changes: 45 additions & 1 deletion sw/tools/parrot/parrot_utils.py
Expand Up @@ -25,6 +25,50 @@
from ftplib import FTP
import ftplib

class ParrotVersion(object):
def __init__(self):
self.h = 0
self.m = 0
self.l = 0
self.rc = 0
self.raw = ''

def __init__(self, s):
try:
self.raw = s
ss = s.split(".")
self.h = int(ss[0])
self.m = int(ss[1])
sss=ss[2].split("-RC")
self.l = int(sss[0])
if len(sss) > 1:
self.rc = int(sss[1])
else:
self.rc = 0
except:
self.__init__()

def version(self):
return ( ( (self.h * 100 + self.m) * 100) + self.l) * 100 + self.rc

def __str__(self):
return str(self.h) + "." + str(self.m) + "." + str(self.l) + "." + str(self.rc)

def __eq__(self, other):
return self.version() == other.version()

def __lt__(self, other):
return self.version() < other.version()

def __le__(self, other):
return self.version() <= other.version()

def __gt__(self, other):
return self.version() > other.version()

def __ge__(self, other):
return self.version() >= other.version()


# Check if IP is valid
def is_ip(address):
Expand All @@ -48,7 +92,7 @@ def execute_command(tn, command):

# Check the version
def check_version(tn, directory):
return execute_command(tn, 'cat ' + directory + '/version.txt')
return ParrotVersion(execute_command(tn, 'cat ' + directory + '/version.txt').strip())

# Check what currently is running on the drone
def check_running(tn):
Expand Down

0 comments on commit 34b182c

Please sign in to comment.