def transfer(self, file, channel:RawIOBase, progress:ProgressSpan):
"""
Transfers a single file to the device and closes the session, so the device places the data in the
target location.
file: the file to transfer via ymodem
channel: the ymodem endpoint
progress: notification of progress
"""
self.seq = 0
self.channel = channel
self.progress = progress
file.seek(0, os.SEEK_END)
size = file.tell()
file.seek(0, os.SEEK_SET)
progress.min = 0
progress.max = size
progress.update(0)
response = self.send_filename_header(self.default_file_name, size)
while response == LightYModemClient.ack:
response = self.send_packet(file)
file.close()
if response != LightYModemClient.eot:
raise LightYModemException("Unable to transfer the file to the device. Code=%d" % response)
self._send_close()
return True
评论列表
文章目录