Skip to content

Commit 437d4f8

Browse files
author
Fiorentino Francesco
committed
Bugfix for send() method; 'retry' parameter didn't work as specify by documentation
Previously 'retry' parameter match the absolute number of resend before failing. With the fix 'retry' match the maximum number of resend a failed packet before failing
1 parent 695aa83 commit 437d4f8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

xmodem/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def send(self, stream, retry=16, timeout=60, quiet=False, callback=None):
210210
'''
211211
Send a stream via the XMODEM protocol.
212212
213-
>>> stream = file('/etc/issue', 'rb')
213+
>>> stream = open('/etc/issue', 'rb')
214214
>>> print(modem.send(stream))
215215
True
216216
@@ -308,6 +308,7 @@ def callback(total_packets, success_count, error_count)
308308
success_count += 1
309309
if callable(callback):
310310
callback(total_packets, success_count, error_count)
311+
error_count = 0
311312
break
312313

313314
self.log.error('send error: expected ACK; got %r for block %d',
@@ -370,7 +371,7 @@ def recv(self, stream, crc_mode=1, retry=16, timeout=60, delay=1, quiet=0):
370371
'''
371372
Receive a stream via the XMODEM protocol.
372373
373-
>>> stream = file('/etc/issue', 'wb')
374+
>>> stream = open('/etc/issue', 'wb')
374375
>>> print(modem.recv(stream))
375376
2342
376377

0 commit comments

Comments
 (0)