scientifichackers / ampy

MicroPython Tool - Utility to interact with a MicroPython board over a serial connection.
MIT License
723 stars 157 forks source link

Downloading a binary file fails #83

Closed besi closed 3 years ago

besi commented 4 years ago

Hy there. I have a .wav file on my flash which I would like to download.

Since this should now be possible since #75 is merged I did clone the repo and run ampy in order to get that file:

python -m ampy.cli --port /dev/cu.usbserial-DN05LWXL ls

/boot.py
/mic_recording.wav

Download the file:

python -m ampy.cli --port /dev/cu.usbserial-DN05LWXL get /mic_recording.wav

Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.17/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/Cellar/python@2/2.7.17/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/besi/Documents/GitHub/ampy/ampy/cli.py", line 420, in <module>
    cli()
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/besi/Documents/GitHub/ampy/ampy/cli.py", line 126, in get
    contents = board_files.get(remote_file)
  File "ampy/files.py", line 86, in get
    return binascii.unhexlify(out)
TypeError: Non-hexadecimal digit found

I'm happy to provide more information.

curiouswala commented 3 years ago

Since the file transfer in ampy currently goes over Serial communication, it's very unreliable for binary file transfers. I would suggest you to use a TCP based file transfer to ESP which works fine in my experience. We are working on a rewrite of ampy which uses WIFI instead of USB which will solve this problem fundamentally.