在xmodem协议中为getc方法提供的大小值是多少?

2024-06-09 02:28:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用XMODEM协议传输文件。在

我看到但不理解中提供的解决方案:Can I use the xmodem protocol with PySerial?

我看到了xmodem package link。在

  1. getc方法提供的size值是多少?它没有被赋予first link中给定的任何值。在
  2. 当我使用second 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"。在


Tags: 文件方法importstreamsizetimeport错误