问题描述
所以我有 2 个 python 脚本,一个是读取串行端口数据,另一个是从该数据接收列表,但是一旦我运行第二个脚本,我就会收到权限错误并且无法再从串行端口读取。这些是我的 2 个脚本,我正在用 Arduino 做一些事情,我知道我可以将所有这些放在 1 个文件中,但出于延迟目的,我将逻辑与读取分开。这是我的脚本:
read.py:
FontFace
do.py:
import serial
from time import sleep
ser = serial.Serial('COM7',9600)
while True:
ser_bytes = ser.readline()
decoded_bytes = ser_bytes[0:len(ser_bytes)-2].decode('utf-8')
if len(decoded_bytes) == 0:
ser.flushinput()
if len(decoded_bytes) != 0:
find1 = decoded_bytes.find('&')
find2 = decoded_bytes.find('|')
find3 = decoded_bytes.find('/')
left = decoded_bytes[0:find1]
right = decoded_bytes[find1+1:find2]
fire = decoded_bytes[find2+1: find3]
jump = decoded_bytes[find3+1:]
keypresses = [left,right,fire,jump]
ser.flushinput()
如果你能帮忙就好了,谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)