Python Serial Zmodem
Posted By admin On 28/06/18Editors' Note: The Download Now link will direct you to a form on the developer's site that you must fill out before download. Technics Su-a600 Manual. The rock- solid Telnet and SSH client. Python Package Index. Modem implementations for XMODEM, YMODEM and ZMODEMThis package ports the XMODEM, YMODEM and ZMODEM protocols to Python.


Modem 1.0 Modem implementations for XMODEM, YMODEM and ZMODEM This package ports the XMODEM, YMODEM and ZMODEM protocols to Python. We try to implement the protocols as minimalistic as possible without breaking the protocol specifications. The interface to most modem classes are pretty similair. Keep in mind though, that the XMODEM protocol can send one file (stream) at a time, whereas the YMODEM and ZMODEM protocols can send multiple. All modem implementations must be given a getc callback to retrieve character data from the remote end and a putc callback to send character data. Examples An example using STDIN/ STDOUT may read: >>>import select >>>import sys >>>def getc(size, timeout=5).
R, w, e = select.select([sys.stdin.fileno()], [], [], timeout). If r: return sys.stdin.read(size). >>>def putc(data, timeout). R, w, e = select.select([], [sys.stdout.fileno()], [], timeout). If w: return sys.stdout.write(data) Now we can send a stream using XMODEM: >>>from modem import XMODEM >>>xmodem = XMODEM(getc, putc) >>>stream = file(__file__) >>>xmodem.send(stream).
Or send one or more files using YMODEM or ZMODEM: >>>from modem import ZMODEM >>>zmodem = ZMODEM(getc, putc) >>>zmodem.send([__file__]).
README.rst XMODEM protocol implementation Documentation available at Python Package Index (PyPI) page is available at 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. 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,. 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,. • 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,.
0.4.2: • bugfix: documentation files missing from the release tarball. 0.4.1 • bugfix: re-transmit in send() on NAK or timeout, previously re-transmissions (wrongly) occurred only on garbage bytes.. 0.4.0 • enhancement: support for python 3. • bugfix: CRC failures in XMODEM.recv() were not renegotiated correctly.