tehmaze / xmodem

XMODEM protocol implementation for Python
https://pypi.org/project/xmodem/
MIT License
97 stars 57 forks source link

.. image:: https://travis-ci.org/tehmaze/xmodem.png?branch=master :target: https://travis-ci.org/tehmaze/xmodem

.. image:: https://coveralls.io/repos/tehmaze/xmodem/badge.png :target: https://coveralls.io/r/tehmaze/xmodem

================================ 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

xmodem has been tested with python 2.7 through python 3.11

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_.

.. _documentation: http://packages.python.org/xmodem/xmodem.html

Changes

0.4.7:

0.4.6:

0.4.5:

0.4.4:

0.4.3:

0.4.2:

0.4.1

0.4.0