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.
Changes
- 0.5.0
bugfix: retry_limit was never actually triggered during the data transfer phase because errors never accumulated, and
enhancement: replace 3x getc() calls with a single recv() call, reducing timing and failed packets when using fast serial lines without flow control. PR #61.
- 0.4.7:
bugfix: stall on some kinds of error in recv(), PR #56.
bugfix: sequence number miscalculation in send(), PR #52.
enhancement: callback function added for recv(), PR #53.
bugfix: receiving empty file and stall condition in recv(), PR #50.
bugfix: callback is now called for some kinds of errors and some CLI fixes, 8a798e8b.
bugfix: remove DepreactionWarning for logging.warn(), PR #49.
- 0.4.6:
bugfix: Abort send on EOT in startup-sequence Issue #34.
enhancement: Include LICENSE file in the source distribution.
- 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
Metadata
Release files for xmodem 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xmodem-0.5.0.tar.gz | 34.6 kB | Without provenance | Details for xmodem-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xmodem-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for xmodem-0.5.0-py3-none-any.whl |
Total release size: 70.8 kB
Release files / xmodem-0.5.0.tar.gz
| Download URL | xmodem-0.5.0.tar.gz |
|---|---|
| Size | 34.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1a818f31c29412f1cab0cd69deccd7be77bc1feb516723af990d00161f6fb6a
|
|
BLAKE2b-256 checksum How to use checksums |
c703a18c2b571266787aebb7cadc5d4c90af15ae7e949ae0ee99ed23b5ba4f3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.6
|
Release files / xmodem-0.5.0-py3-none-any.whl
| Download URL | xmodem-0.5.0-py3-none-any.whl |
|---|---|
| Size | 36.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0bb644adfc7652c15a6fa3c3a4b04693b100520e3083cb952206006e3754e89
|
|
BLAKE2b-256 checksum How to use checksums |
bbbbbb68297054e019e8fb99edde47d25608130cc2c1b2902f503a7edfe6470f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.6
|
Security for xmodem 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.