Skip to content

Commit

Permalink
Tools: ardupilotwaf: allow automatic upload to BlueOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed Aug 22, 2024
1 parent 32cee97 commit 9d929a3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Tools/ardupilotwaf/ap_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,22 @@ def dynamic_post(self):
self.source = Utils.to_list(self.source)
self.source.extend(self.bld.bldnode.ant_glob(self.dynamic_source))


class upload_fw_blueos(Task.Task):
def run(self):
import requests
bld = self.generator.bld
board = bld.bldnode.name.capitalize()
# there must be a better way to do this
binary_name = bld.bldnode.find_dir('bin').listdir()[0]
binary_path = bld.bldnode.find_dir('bin').abspath() + '/' + binary_name
url = f'{bld.options.upload_blueos}/ardupilot-manager/v1.0/install_firmware_from_file?board_name={board}'
files = {
'binary': open(binary_path, 'rb')
}
response = requests.post(url, files=files, verify=False)


class ap_library_check_headers(Task.Task):
color = 'PINK'
before = 'cxx c'
Expand Down
11 changes: 11 additions & 0 deletions Tools/ardupilotwaf/ardupilotwaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ def post_link(self):

check_elf_task = self.create_task('check_elf_symbols', src=link_output)
check_elf_task.set_run_after(self.link_task)
if self.bld.options.upload_blueos:
_upload_task = self.create_task('upload_fw_blueos')
_upload_task.set_run_after(self.link_task)


@conf
def ap_program(bld,
Expand Down Expand Up @@ -641,6 +645,13 @@ def options(opt):
help='''Specify the port to be used with the --upload option. For example a port of /dev/ttyS10 indicates that serial port 10 shuld be used.
''')

g.add_option('--upload-blueos',
action='store',
dest='upload_blueos',
default=None,
help='''Automatically upload to a BlueOS device. The argument is the url for the device. http://blueos.local for example.
''')

g.add_option('--upload-force',
action='store_true',
help='''Override board type check and continue loading. Same as using uploader.py --force.
Expand Down

0 comments on commit 9d929a3

Please sign in to comment.