因此,我尝试从我的 Windows PC 向我的树莓派 Pico 发送一条字节消息。我成功地将数据从 Pico 发送到 Windows PC,但事实证明相反的方法很困难。这就是我到目前为止的过程。
Windows PC 代码
import serial
# Configure the serial connection
port = "COM5"
ser = serial.Serial(port, 9600)
message = b"Hey This is the message!!!!"
ser.write(message)
皮克代码
file = open('Results77.txt', 'wb')
while (True):
# I do not know what to do here to get the message that I sent into the variable data
data = input()
file.write(data)