I'm trying to transfer a file using the XMODEM protocol.
I saw and did not understand the solution provided in: Can I use the xmodem protocol with PySerial?
I saw xmodem package link.
- What is the value of
size
to be provided for thegetc
method? It is not assigned with any value given in the first link. - When I use simple method as explained in the second link, I end up getting the error:
No handlers could be found for logger "xmodem"
.
Here is my code to send the file.
import serial
from xmodem import XMODEM, CRC
from time import sleep
def getc(size, timeout=1):
return port.read(size)
def putc(data, timeout=1):
port.write(data)
sleep(0.001) # give device time to send ACK
port = serial.Serial(port='COM10',parity=serial.PARITY_NONE,bytesize=serial.EIGHTBITS,stopbits=serial.STOPBITS_ONE,timeout=0,xonxoff=0,rtscts=0,dsrdtr=0,baudrate=9600)
sleep(2) # give device time to handle command
stream = open('..\\stream\\myfile.bin','rb')
modem = XMODEM(getc, putc)
modem.send(stream, quiet = 0)
I get the error: No handlers could be found for logger "xmodem"
.