windows上的Rshell在通过rsync或cp向运行micropython的ESP32发送文件时会随机冻结

windows上的Rshell在通过rsync或cp向运行micropython的ESP32发送文件时会随机冻结,windows,esp32,micropython,Windows,Esp32,Micropython,我无法通过rshell(远程MicropythonShell)将文件复制到运行micropython的ESP32设备。这个问题似乎是随机发生的。有时我用rsync成功地发送了所有文件(比如20个),有时甚至无法用cp复制一个文件。没有错误消息,脚本也不会崩溃,它只是停止工作并冻结控制台。我尝试过使用和不使用-a参数(我只发送.py文件)。最后一件用调试打印的东西是要在下面的微控制器上运行的代码,它就停在那里。我没有找到任何模式。我试过使用其他一些esp32设备和其他windows PC。同样的结

我无法通过rshell(远程MicropythonShell)将文件复制到运行micropython的ESP32设备。这个问题似乎是随机发生的。有时我用
rsync
成功地发送了所有文件(比如20个),有时甚至无法用
cp
复制一个文件。没有错误消息,脚本也不会崩溃,它只是停止工作并冻结控制台。我尝试过使用和不使用-a参数(我只发送.py文件)。最后一件用调试打印的东西是要在下面的微控制器上运行的代码,它就停在那里。我没有找到任何模式。我试过使用其他一些esp32设备和其他windows PC。同样的结果。我甚至尝试将默认的32缓冲区降低到16,但没有任何改进。最糟糕的是,它有时工作得很好,而我无法得到持续的结果(甚至是坏的)。它在随机文件上停止,不总是相同的文件

Rsync命令(带--mirror参数)非常有用,我不能手工复制所有文件

编辑:刚刚在mac上测试过,效果很好。我想这只是windows上的问题

Adding /pyboard/protocol/parser.py
----- About to send 2269 bytes of code to the pyboard -----
def recv_file_from_host(src_file, dst_filename, filesize, dst_mode='wb'):
"""Function which runs on the pyboard. Matches up with send_file_to_remote."""
import sys
import ubinascii
import os
if False:
    try:
        import pyb
        usb = pyb.USB_VCP()
    except:
        try:
            import machine
            usb = machine.USB_VCP()
        except:
            usb = None
    if usb and usb.isconnected():
        # We don't want 0x03 bytes in the data to be interpreted as a Control-C
        # This gets reset each time the REPL runs a line, so we don't need to
        # worry about resetting it ourselves
        usb.setinterrupt(-1)
try:
    with open(dst_filename, dst_mode) as dst_file:
        bytes_remaining = filesize
        if not False:
            bytes_remaining *= 2  # hexlify makes each byte into 2
        buf_size = 32
        write_buf = bytearray(buf_size)
        read_buf = bytearray(buf_size)
        while bytes_remaining > 0:
            # Send back an ack as a form of flow control
            sys.stdout.write('\x06')
            read_size = min(bytes_remaining, buf_size)
            buf_remaining = read_size
            buf_index = 0
            while buf_remaining > 0:
                if False:
                    bytes_read = sys.stdin.buffer.readinto(read_buf, read_size)
                else:
                    bytes_read = sys.stdin.readinto(read_buf, read_size)
                if bytes_read > 0:
                    write_buf[buf_index:bytes_read] = read_buf[0:bytes_read]
                    buf_index += bytes_read
                    buf_remaining -= bytes_read
            if False:
                dst_file.write(write_buf[0:read_size])
            else:
                dst_file.write(ubinascii.unhexlify(write_buf[0:read_size]))
            if hasattr(os, 'sync'):
                os.sync()
            bytes_remaining -= read_size
    return True
except:
    return False
output = recv_file_from_host(None, '/protocol/parser.py', 1467)
if output is None:
print("None")
else:
print(output)

-----
我也有同样的问题, 尝试时

    C:\> cp src\main.py /pyboard/
冰箱冻结了。 当我使用以下命令复制时

    C:\> cp src/main.py /pyboard/
没有问题,所以当路径中有“\”时,rshell可能会有一些问题