GithubHelp home page GithubHelp logo

jiuzhuaxiong / xmodem Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tehmaze/xmodem

0.0 2.0 0.0 135 KB

*MODEM protocol implementation for Python (XMODEM/YMODEM/ZMODEM)

Makefile 0.29% Python 99.71%

xmodem's Introduction

image

image

XMODEM protocol implementation

Documentation available at http://packages.python.org/xmodem/

Python Package Index (PyPI) page is available at https://pypi.python.org/pypi/xmodem

Usage

Create a function to get and put character data (to a serial line for example):

>>> import serial
>>> from xmodem import XMODEM
>>> ser = serial.Serial('/dev/ttyUSB0', timeout=0) # or whatever port you need
>>> def getc(size, timeout=1):
...     return ser.read(size) or None
...
>>> def putc(data, timeout=1):
...     return ser.write(data)  # note that this ignores the timeout
...
>>> modem = XMODEM(getc, putc)

Now, to upload a file, use the send method:

>>> stream = open('/etc/fstab', 'rb')
>>> modem.send(stream)

To download a file, use the recv method:

>>> stream = open('output', 'wb')
>>> modem.recv(stream)

For more information, take a look at the documentation.

Changes

0.4.5:
  • bugfix: Remove bogus assert False code in recv() that resulted in AssertionError introduced in version 0.4.0 commit-id 9b03fc20, PR #29.
0.4.4:
  • bugfix: Large file transfers in send() were more likely to fail for small values of retry: This value should be the maximum failures per block transfer as documented, but was improperly implemented as the number of failures allowed for the total duration of the transfer, PR #21.
  • bugfix: send(retry=n) and recv(retry=n) should retry n times as documented, was retrying n - 1.
0.4.3:
  • bugfix: putc() callback was called in series, 3 times for each part of xmodem block header, data, and checksum during block transfer. Now all three data blocks are sent by single putc() call. This resolves issues when integrating with microcontrollers or equipment sensitive to timing issues at stream boundaries, PR #19.
0.4.2:
  • bugfix: documentation files missing from the release tarball Issue #16.
0.4.1
  • bugfix: re-transmit in send() on NAK or timeout, previously re-transmissions (wrongly) occurred only on garbage bytes. PR #12.
0.4.0
  • enhancement: support for python 3 PR #8.
  • bugfix: CRC failures in XMODEM.recv() were not renegotiated correctly PR #11.

xmodem's People

Contributors

tehmaze avatar jquast avatar krishardy avatar rohieb avatar znog77 avatar jkflying avatar powertomato avatar

Watchers

James Cloos avatar rick.zhang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.