Copy BIN to Board automatically use a simple Python-script
mbed's online compiler is easy for environment-setup.
But it's very annoying to copy the BIN file from Download directory to board manually.
Note: USB-IAP will detect the BIN file automatically.
Put the Python-script below to anywhere you like(https://gist.github.com/mintisan/e4ac4593c7f47f63bfc9bf23a8b85f9c),
Note: you may modify the directory slightly for your system.
import os from shutil import copyfile # `sudo pip install walkdir` if you don't install walkdir import walkdir as wd import time src_dir = os.environ['HOME']+'/Downloads/' dst_dir = '/Volumes/NUCLEO/' pattern = "*_NUCLEO_F401RE.bin" while True: time.sleep(1) bin_file = wd.file_paths(wd.filtered_walk(src_dir, depth=0,included_files=[pattern])) fn_l = list(bin_file) if len(fn_l) == 0: print("no bin file is exits!") continue fn = str(fn_l[0]).split('/')[-1] print(fn, "is coped to " + dst_dir) copyfile(src_dir+fn,dst_dir+fn) os.remove(src_dir+fn)
and execute it(copy_bin_2_nucleo.py):
python copy_bin_2_nucleo.py
If you press compile button on online-compiler, it will generate a BIN file to $HOME/Downloads directory.
And the below Python-script will check any BIN files exit or not, and copy it to board per second.
It's very easy, ha.
If you want to stop the script, just press "CTRL+C".
1 comment on Copy BIN to Board automatically use a simple Python-script:
Please log in to post comments.
This is a great idea. I am thinking about making a Chrome extension to do the same thing. For your code, you might consider using https://pypi.python.org/pypi/watchdog to watch the filesystem instead of polling.