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.
size
to be provided for the getc
method? It is not assigned with any value given in the first link.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"
.
Here is the solution for 1st question, getc and putc are used by XMODEM to read size number of bytes from port and write data to port respectively. They need to be defined by user and supplied to XMODEM object. XMODEM internally calls getc with size.