180| 0
|
[求助] 行空板初始化引脚失败 |
本帖最后由 流光辐白 于 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[0]) Pin(Pin.P0, Pin.OUT).write_digital(Pins[1]) Pin(Pin.P1, Pin.PWM).write_analog(Pins[2]) Pin(Pin.P1, Pin.OUT).write_digital(Pins[3]) Pin(Pin.P2, Pin.PWM).write_analog(Pins[4]) Pin(Pin.P2, Pin.OUT).write_digital(Pins[5]) Pin(Pin.P3, Pin.PWM).write_analog(Pins[6]) Pin(Pin.P3, Pin.OUT).write_digital(Pins[7]) Pin(Pin.P4, Pin.PWM).write_analog(Pins[8]) Pin(Pin.P4, Pin.OUT).write_digital(Pins[9]) Pin(Pin.P5, Pin.PWM).write_analog(Pins[10]) Pin(Pin.P5, Pin.OUT).write_digital(Pins[11]) Pin(Pin.P6, Pin.PWM).write_analog(Pins[12]) Pin(Pin.P6, Pin.OUT).write_digital(Pins[13]) Pin(Pin.P7, Pin.PWM).write_analog(Pins[14]) Pin(Pin.P7, Pin.OUT).write_digital(Pins[15]) Pin(Pin.P8, Pin.PWM).write_analog(Pins[16]) Pin(Pin.P8, Pin.OUT).write_digital(Pins[17]) Pin(Pin.P9, Pin.PWM).write_analog(Pins[18]) Pin(Pin.P9, Pin.OUT).write_digital(Pins[19]) Pin(Pin.P10, Pin.PWM).write_analog(Pins[20]) Pin(Pin.P10, Pin.OUT).write_digital(Pins[21]) Pin(Pin.P11, Pin.PWM).write_analog(Pins[22]) Pin(Pin.P11, Pin.OUT).write_digital(Pins[23]) Pin(Pin.P12, Pin.PWM).write_analog(Pins[24]) Pin(Pin.P12, Pin.OUT).write_digital(Pins[25]) Pin(Pin.P13, Pin.PWM).write_analog(Pins[26]) Pin(Pin.P13, Pin.OUT).write_digital(Pins[27]) Pin(Pin.P14, Pin.PWM).write_analog(Pins[28]) Pin(Pin.P14, Pin.OUT).write_digital(Pins[29]) Pin(Pin.P15, Pin.PWM).write_analog(Pins[30]) Pin(Pin.P15, Pin.OUT).write_digital(Pins[31]) Pin(Pin.P16, Pin.PWM).write_analog(Pins[32]) Pin(Pin.P16, Pin.OUT).write_digital(Pins[33]) Pin(Pin.P21, Pin.PWM).write_analog(Pins[34]) Pin(Pin.P21, Pin.OUT).write_digital(Pins[35]) Pin(Pin.P22, Pin.PWM).write_analog(Pins[36]) Pin(Pin.P22, Pin.OUT).write_digital(Pins[37]) Pin(Pin.P23, Pin.PWM).write_analog(Pins[38]) Pin(Pin.P23, Pin.OUT).write_digital(Pins[39]) Pin(Pin.P24, Pin.PWM).write_analog(Pins[40]) Pin(Pin.P24, Pin.OUT).write_digital(Pins[41]) 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(本地运行) 发现只要同时运行的程序中包含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呀) |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed