Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
1eda1f81
Commit
1eda1f81
authored
10 years ago
by
Johan Jansen
Browse files
Options
Downloads
Patches
Plain Diff
px_uploader: Minor code cleanup
parent
2aa7b303
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tools/px_uploader.py
+26
-25
26 additions, 25 deletions
Tools/px_uploader.py
with
26 additions
and
25 deletions
Tools/px_uploader.py
+
26
−
25
View file @
1eda1f81
#!/usr/bin/env python
############################################################################
#
# Copyright (C) 2012
,
201
3
PX4 Development Team. All rights reserved.
# Copyright (C) 2012
-
201
5
PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
...
...
@@ -227,16 +227,21 @@ class uploader(object):
+
uploader
.
EOC
)
self
.
__getSync
()
# def __trySync(self):
# c = self.__recv()
# if (c != self.INSYNC):
# #print("unexpected 0x%x instead of INSYNC" % ord(c))
# return False;
# c = self.__recv()
# if (c != self.OK):
# #print("unexpected 0x%x instead of OK" % ord(c))
# return False
# return True
def
__trySync
(
self
):
try
:
self
.
port
.
flush
()
if
(
self
.
__recv
()
!=
self
.
INSYNC
):
#print("unexpected 0x%x instead of INSYNC" % ord(c))
return
False
;
if
(
self
.
__recv
()
!=
self
.
OK
):
#print("unexpected 0x%x instead of OK" % ord(c))
return
False
return
True
except
RuntimeError
:
#timeout, no response yet
return
False
# send the GET_DEVICE command and wait for an info parameter
def
__getInfo
(
self
,
param
):
...
...
@@ -275,26 +280,23 @@ class uploader(object):
def
__erase
(
self
):
self
.
__send
(
uploader
.
CHIP_ERASE
+
uploader
.
EOC
)
# erase is very slow, give it 20s
deadline
=
time
.
time
()
+
20
deadline
=
time
.
time
()
+
20
.0
while
time
.
time
()
<
deadline
:
#Draw progress bar (erase usually takes about 9 seconds to complete)
estimatedTimeRemaining
=
deadline
-
time
.
time
()
-
11.0
estimatedTimeRemaining
=
deadline
-
time
.
time
()
if
estimatedTimeRemaining
>
0
:
self
.
__drawProgressBar
(
1
0.0
-
estimatedTimeRemaining
,
10
.0
)
self
.
__drawProgressBar
(
2
0.0
-
estimatedTimeRemaining
,
9
.0
)
else
:
self
.
__drawProgressBar
(
10.0
,
10.0
)
sys
.
stdout
.
write
(
"
(timeout: %d seconds)
"
%
int
(
time
.
time
()
-
deadline
)
)
try
:
self
.
__getSync
()
self
.
__drawProgressBar
(
10.0
,
10.0
)
sys
.
stdout
.
write
(
"
\n
erase complete!
\n
"
)
return
except
RuntimeError
:
# we timed out, that's OK
continue
if
self
.
__trySync
():
self
.
__drawProgressBar
(
10.0
,
10.0
)
sys
.
stdout
.
write
(
"
\n
erase complete!
\n
"
)
return
;
raise
RuntimeError
(
"
timed out waiting for erase
"
)
...
...
@@ -464,8 +466,7 @@ class uploader(object):
self
.
__send
(
uploader
.
MAVLINK_REBOOT_ID0
)
except
:
return
# Detect python version
if
sys
.
version_info
[
0
]
<
3
:
...
...
@@ -508,7 +509,7 @@ while True:
for
port
in
portlist
:
#print("Trying %s" % port)
# create an uploader attached to the port
try
:
if
"
linux
"
in
_platform
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment