行空板初始化引脚失败
本帖最后由 流光辐白 于 2024-9-29 12:58 编辑行空板初始化引脚失败重复多次,报错如下
Traceback (most recent call last):
File "/root/mindplus/cache/getpins.py", line 8, in <module>
Board().begin()
File "/usr/local/lib/python3.7/dist-packages/pinpong/board.py", line 1369, in begin
self.board = pymata4.Pymata4(com_port=self.serial, arduino_wait=2, baud_rate=115200, name = self.boardname)
File "/usr/local/lib/python3.7/dist-packages/pinpong/base/pymata4.py", line 396, in __init__
raise RuntimeError('*** Analog map retrieval timed out. ***'
RuntimeError: *** Analog map retrieval timed out. ***
Do you have Arduino connectivity and do you have the correct Firmata sketch uploaded to the board?
我做了一个读写引脚的程序
getpin.py==================================================
import sys
sys.path.append("/root/mindplus/.lib/thirdExtension/nick-chatglm-thirdex")
import siot
import time
from pinpong.board import Board, Pin
Board().begin()
siot.init(server='10.1.2.3', port=1883, user='siot', password='dfrobot')
siot.connect()
siot.loop()
while True:
Pins = [Pin(Pin.P0, Pin.ANALOG).read_analog(), Pin(Pin.P0, Pin.IN).read_digital(),
Pin(Pin.P1, Pin.ANALOG).read_analog(), Pin(Pin.P1, Pin.IN).read_digital(),
Pin(Pin.P2, Pin.ANALOG).read_analog(), Pin(Pin.P2, Pin.IN).read_digital(),
Pin(Pin.P3, Pin.ANALOG).read_analog(), Pin(Pin.P3, Pin.IN).read_digital(),
Pin(Pin.P4, Pin.ANALOG).read_analog(), Pin(Pin.P4, Pin.IN).read_digital(),
None, Pin(Pin.P5, Pin.IN).read_digital(),
None, Pin(Pin.P6, Pin.IN).read_digital(),
None, Pin(Pin.P7, Pin.IN).read_digital(),
None, Pin(Pin.P8, Pin.IN).read_digital(),
None, Pin(Pin.P9, Pin.IN).read_digital(),
Pin(Pin.P10, Pin.ANALOG).read_analog(), Pin(Pin.P10, Pin.IN).read_digital(),
None, Pin(Pin.P11, Pin.IN).read_digital(),
None, Pin(Pin.P12, Pin.IN).read_digital(),
None, Pin(Pin.P13, Pin.IN).read_digital(),
None, Pin(Pin.P14, Pin.IN).read_digital(),
None, Pin(Pin.P15, Pin.IN).read_digital(),
None, Pin(Pin.P16, Pin.IN).read_digital(),
Pin(Pin.P21, Pin.ANALOG).read_analog(), Pin(Pin.P21, Pin.IN).read_digital(),
Pin(Pin.P22, Pin.ANALOG).read_analog(), Pin(Pin.P22, Pin.IN).read_digital(),
None, Pin(Pin.P23, Pin.IN).read_digital(),
None, Pin(Pin.P24, Pin.IN).read_digital()]
siot.publish(topic='Pins/In', data=Pins)
time.sleep(1)
==================================================
setpins.py
==================================================
import sys
sys.path.append("/root/mindplus/.lib/thirdExtension/nick-chatglm-thirdex")
import siot
import time
from pinpong.board import Board, Pin
from ast import literal_eval
Board().begin()
def siot_callback(client, userdata, msg):
Pins = literal_eval(msg.payload.decode())
Pin(Pin.P0, Pin.PWM).write_analog(Pins)
Pin(Pin.P0, Pin.OUT).write_digital(Pins)
Pin(Pin.P1, Pin.PWM).write_analog(Pins)
Pin(Pin.P1, Pin.OUT).write_digital(Pins)
Pin(Pin.P2, Pin.PWM).write_analog(Pins)
Pin(Pin.P2, Pin.OUT).write_digital(Pins)
Pin(Pin.P3, Pin.PWM).write_analog(Pins)
Pin(Pin.P3, Pin.OUT).write_digital(Pins)
Pin(Pin.P4, Pin.PWM).write_analog(Pins)
Pin(Pin.P4, Pin.OUT).write_digital(Pins)
Pin(Pin.P5, Pin.PWM).write_analog(Pins)
Pin(Pin.P5, Pin.OUT).write_digital(Pins)
Pin(Pin.P6, Pin.PWM).write_analog(Pins)
Pin(Pin.P6, Pin.OUT).write_digital(Pins)
Pin(Pin.P7, Pin.PWM).write_analog(Pins)
Pin(Pin.P7, Pin.OUT).write_digital(Pins)
Pin(Pin.P8, Pin.PWM).write_analog(Pins)
Pin(Pin.P8, Pin.OUT).write_digital(Pins)
Pin(Pin.P9, Pin.PWM).write_analog(Pins)
Pin(Pin.P9, Pin.OUT).write_digital(Pins)
Pin(Pin.P10, Pin.PWM).write_analog(Pins)
Pin(Pin.P10, Pin.OUT).write_digital(Pins)
Pin(Pin.P11, Pin.PWM).write_analog(Pins)
Pin(Pin.P11, Pin.OUT).write_digital(Pins)
Pin(Pin.P12, Pin.PWM).write_analog(Pins)
Pin(Pin.P12, Pin.OUT).write_digital(Pins)
Pin(Pin.P13, Pin.PWM).write_analog(Pins)
Pin(Pin.P13, Pin.OUT).write_digital(Pins)
Pin(Pin.P14, Pin.PWM).write_analog(Pins)
Pin(Pin.P14, Pin.OUT).write_digital(Pins)
Pin(Pin.P15, Pin.PWM).write_analog(Pins)
Pin(Pin.P15, Pin.OUT).write_digital(Pins)
Pin(Pin.P16, Pin.PWM).write_analog(Pins)
Pin(Pin.P16, Pin.OUT).write_digital(Pins)
Pin(Pin.P21, Pin.PWM).write_analog(Pins)
Pin(Pin.P21, Pin.OUT).write_digital(Pins)
Pin(Pin.P22, Pin.PWM).write_analog(Pins)
Pin(Pin.P22, Pin.OUT).write_digital(Pins)
Pin(Pin.P23, Pin.PWM).write_analog(Pins)
Pin(Pin.P23, Pin.OUT).write_digital(Pins)
Pin(Pin.P24, Pin.PWM).write_analog(Pins)
Pin(Pin.P24, Pin.OUT).write_digital(Pins)
siot.init(server="10.1.2.3", port=1883, user="siot", password="dfrobot")
siot.connect()
siot.loop()
siot.getsubscribe(topic="Pins/Out")
siot.set_callback(siot_callback)
==================================================
引脚测试.mp
==================================================
#-*- coding: UTF-8 -*-
# MindPlus
# Python
import siot
from os import system
from unihiker import GUI
from pinpong.board import Board
from pinpong.board import Board,Pin
from pinpong.extension.unihiker import *
# 事件回调函数
def u_getpins_function():
system('python /root/mindplus/cache/getpins.py')
def u_setpins_function():
system('python /root/mindplus/cache/setpins.py')
siot.init(client_id="36404553610466306",server="10.1.2.3",port=1883,user="siot",password="dfrobot")
Board().begin()
u_gui=GUI()
siot.connect()
siot.loop()
p_p1_in=Pin(Pin.P1, Pin.IN)
print("行空板对象初始化")
print("行空板对象初始化完成")
getpins=u_gui.start_thread(u_getpins_function)
setpins=u_gui.start_thread(u_setpins_function)
print("行空板引脚初始化完成")
while not (False):
pass
u_gui.stop_thread(getpins)
u_gui.stop_thread(setpins)
==================================================
行空板引脚.py(本地运行)
# import sys
# sys.path.append("/root/mindplus/.lib/thirdExtension/nick-chatglm-thirdex")
# import siot
# import time
# from unihiker import GUI
# from pinpong.board import Board
# from pinpong.board import Pin
# from pinpong.extension.unihiker import *
import time
import tkinter as tk
import siot
from ast import literal_eval
def siot_callback(client, userdata, msg):
global 变量列表
变量列表 = literal_eval(msg.payload.decode())
更新变量(-1)
def 更新变量(ii):
if ii == -1:
for iii in range(len(变量列表)):
显示列表.config(text=f"值: {变量列表}")
else:
try:
变量值 = int(输入列表.get())
变量列表 = 变量值
显示列表.config(text=f"值: {变量列表}")
siot.publish(topic="Pins/Out", data=变量列表)
except ValueError:
print(f"引脚{ii + 1}的输入不是有效的整数!")
# 初始化变量
# 变量索引表 = ['0A', '0D', '1A', '1D', '2A', '2D', '3A', '3D', '4A', '4D', '5D', '6D', '7D', '8D', '9D', '10A', '10D',
# '11D', '12D', '13D', '14D', '15D', '16D', '21A', '21D', '22A', '22D', '23D', '24D', '25D']# 您的变量索引表
变量索引表 = []
for i in :
变量索引表.append(str(i) + 'A')
变量索引表.append(str(i) + 'D')
变量列表 = * len(变量索引表)
显示列表 = []
输入列表 = []
main = tk.Tk()
main.title("变量显示与更新")
每列 = 14
for i in range(len(变量列表)):
列 = i // 每列 * 4
行 = i % 每列
label = tk.Label(main, text=f"引脚{变量索引表}")
label.grid(row=行, column=列, sticky='w', padx=5, pady=2)
label = tk.Label(main, text=f"值:{变量列表}")
label.grid(row=行, column=列 + 1, sticky='w', padx=5, pady=2)
显示列表.append(label)
entry = tk.Entry(main, width=10)
entry.grid(row=行, column=列 + 2, sticky='ew', padx=5, pady=2)
输入列表.append(entry)
# 创建设置按钮
button = tk.Button(main, text="设置", command=lambda idx=i: 更新变量(idx))
button.grid(row=行, column=列 + 3, sticky='e', padx=5, pady=2)
# 如果变量总数不是每列数量的整数倍,需要处理最后一行
# 这里假设我们不需要对最后一行进行特殊处理,因为它会自然对齐
siot.init(server="10.1.2.3", port=1883, user="siot", password="dfrobot")
siot.connect()
siot.loop()
siot.getsubscribe(topic="Pins/In")
siot.set_callback(siot_callback)
# 启动事件循环
main.mainloop()
发现只要同时运行的程序中包含Board().begin()就会稳定复现
但有时只运行一个程序也会出现这样的错误
行空板前几天刷入了最新的固件
尝试运行
Board().begin(1)
reboot
都不能解决问题
使用resetunihikerpinpong.py
==================================================
#coding:utf-8
#burner unihiker firmware
from pinpong.base.avrdude import *
cwdpath = '/usr/local/lib/python3.7/dist-packages/pinpong/base/'
filename_ls = os.listdir(cwdpath)
filename=''
for name in filename_ls:
#print(name)
if not name.find("FirmataExpress.UNIHIKER.") == -1:
filename = name
break
print("Find unihiker firmware: "+filename)
print("burner firmware...")
pgm = Burner("UNIHIKER", "/dev/ttyS3")
pgm.burn(cwdpath + filename)
print("%s烧录成功!"%filename)
==================================================
返回内容
==================================================
root@unihiker:~/mindplus/cache# python resetunihikerpinpong.py
Find unihiker firmware: FirmataExpress.UNIHIKER.3.8.bin
burner firmware...
initialize
/usr/local/lib/python3.7/dist-packages/pinpong/base/FirmataExpress.UNIHIKER.3.8.bin
stm32flash -w /usr/local/lib/python3.7/dist-packages/pinpong/base/FirmataExpress.UNIHIKER.3.8.bin -v -g 0x08000000 /dev/ttyS3
stm32flash 0.5
http://stm32flash.sourceforge.net/
Using Parser : Raw BINARY
Interface serial_posix: 57600 8E1
Failed to init device.
FirmataExpress.UNIHIKER.3.8.bin烧录成功!
==================================================
与应有的效果不一致。
猜测可能出现问题的原因:
初始化过多引脚
重复初始化引脚
求助!
再额外提一下
我的Windwos10 Pro For Workstation不能识别行空板
unihiiker显示在其他设备里有一个问号,错误为无法请求设备描述符(代码:1)
同时其他设备还显示”未知设备“ 问号加黄色感叹号
禁用驱动程序强制签名后安装行空板驱动依然报错
后面去网上下了个Ethernet_RNDIS_drivers_20220808就解决了(但这个驱动不是Win10预装的吗,我用的就是官方Win10呀)
页:
[1]