Documentation available at http://packages.python.org/xmodem/
Python Package Index (PyPI) page is available at https://pypi.python.org/pypi/xmodem
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.
- 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.
- bugfix: Remove bogus assert False code in
- 0.4.4:
- bugfix: Large file transfers in
send()
were more likely to fail for small values ofretry
: 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)
andrecv(retry=n)
should retryn
times as documented, was retryingn - 1
.
- bugfix: Large file transfers in
- 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 singleputc()
call. This resolves issues when integrating with microcontrollers or equipment sensitive to timing issues at stream boundaries, PR #19.
- bugfix:
- 0.4.2:
- bugfix: documentation files missing from the release tarball Issue #16.
- 0.4.1
- bugfix: re-transmit in
send()
onNAK
or timeout, previously re-transmissions (wrongly) occurred only on garbage bytes. PR #12.
- bugfix: re-transmit in
- 0.4.0