No Description

kmpm 6a9d9281c3 Chunked download of files. 8 years ago
lib 8a61d17b68 Chunked download of files. 8 years ago
tests 6c2da40c76 Some files to test 8 years ago
.gitignore 7dea7291b3 Error handling and flushing/clearing buffers 8 years ago
.pylintrc 6b505d4f29 restructure the project 8 years ago
.travis.yml 2a17b2b787 build status. removed python 3.5 8 years ago
LICENSE 6b505d4f29 restructure the project 8 years ago
README.md 8a61d17b68 Chunked download of files. 8 years ago
nodemcu-uploader.py f32e8a6d99 unicode and LF 8 years ago
setup.cfg 71f1d34c76 make setup more complete for pypi 8 years ago
setup.py 5fc5df41c3 Documenting verify and windows notes 8 years ago
test_requirements.txt d48462c403 need to install coverage before running CI tests 8 years ago

README.md

nodemcu-uploader.py

A simple tool for uploading files to the filesystem of an ESP8266 running NodeMCU as well as some other useful commands.

master next
Build Status Build Status

Please note that these tests is not complete and it might be the tests themselves that are having issues.

It should work on Linux, and OS X; and with any type of file that fits the filesystem, binary or text. For windows see the notes below.

Installation

Should be installable by PyPI (prefered) but there might be packaging issues still.

pip install nodemcu-uploader
nodemcu-uploader

Otherwise clone from github and run directly from there

git clone https://github.com/kmpm/nodemcu-uploader
cd nodemcu-uploader
python ./nodemcu-uploader.py

Note that pip would install pyserial >= 2.7. The terminal command (using miniterm from pyserial) might not work depending on version used. This is a known issue.

Notes for Windows

There might be some significant issues with Windows.

Issues

Create a issue in github, https://github.com/kmpm/nodemcu-uploader/issues

Disclaimer

THE SOFTWARE IS PROVIDED «AS IS», WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Usage (part of it)

  • –baud are set at a default of 9600
  • –port is by default /dev/ttyUSB0, /dev/tty.SLAB_USBtoUART if on Mac and COM1 on Windows

###Upload Uploading a number of files. Supports multiple files. If you want an alternate destination name, just add a colon «:» and the new destination filename.

./nodemcu-uploader.py upload init.lua README.md nodemcu-uploader.py [--compile] [--restart]

Uploading a number of files, but saving with a different file name.

./nodemcu-uploader.py upload init.lua:new_init.lua README.md:new_README.md [--compile] [--restart]

Uploading a number of files and verify successful uploading by downloading the file and comparing contents.

./nodemcu-uploader.py upload init.lua README.md nodemcu-uploader.py --verify=raw

Uploading a number of files and verify successful uploading by doing a sha1 checksum. Requires crypto module on the device and currently files not to big (~1000 bytes)

./nodemcu-uploader.py upload init.lua README.md nodemcu-uploader.py --verify=sha1

###Download Downloading a number of files. Supports multiple files. If you want an alternate destination name, just add a colon «:» and the new destination filename.

./nodemcu-uploader.py download init.lua README.md nodemcu-uploader.py

Downloading a number of files, but saving with a different file name.

./nodemcu-uploader.py download init.lua:new_init.lua README.md:new_README.md

###List files

./nodemcu-uploader.py --port com1 file list

###Format filesystem

./nodemcu-uploader.py file format

###Remove specific files

./nodemcu-uploader.py file remove foo.lua

OS X Python serial module

To solve «ImportError: No module named serial», install the pyserial module:

python easy_install pyserial

Todo

  • Speed up the initial step of uploading the script to NodeMCU
  • Implement a change of baudrate for the actual transfer and go back when done
  • Documentation
  • –help should show full usage

Details

This is almost an implementation of xmodem protocol for the upload part.

  1. Client calls the function recv()
  2. NodeMCU disables echo and send a ‘C’ to tell that it’s ready to receive data
  3. Client sends a filename terminated with 0x00
  4. NodeMCU sends ACK
  5. Client send block of data according to the definition.
  6. Client sends ACK
  7. Step 5 and 6 are repeated until NodeMCU receives a block with 0 as size.
  8. NodeMCU enables normal terminal again with echo

Data Block Definition

SOH, size, data[128]

  • SOH = 0x01
  • Single byte telling how much of the 128 bytes data that are actually used.
  • Data padded with random bytes to fill out the 128 bytes frame.

This gives a total 130 bytes per block.

The block size was decided for…

  1. Being close to xmodem from where the inspiration came
  2. A fixed size allow the use of the uart.on(‘data’) event very easy.
  3. 130 bytes would fit in the receive buffer buffer.
  4. It would not waste that much traffic if the total size uploaded was not a multiple of the allowed datasize.