我试图使用XMODEM协议传输文件。在
我看到但不理解中提供的解决方案:Can I use the xmodem protocol with PySerial?
我看到了xmodem package link。在
getc
方法提供的size
值是多少?它没有被赋予first link中给定的任何值。在No handlers could be found for logger "xmodem"
。在这是我发送文件的代码。在
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)
我得到错误:No handlers could be found for logger "xmodem"
。在
这是第一个问题的解决方案,getc和putc分别从端口读取大小字节数,并将数据写入端口。它们需要由用户定义并提供给XMODEM对象。XMODEM内部使用size调用getc。在
相关问题 更多 >
编程相关推荐