openmv H7 plus 使用CAN模块通信,一直不通报错ETIMEOUT???
-
import time
from pyb import CAN,LED
led = LED(3)
#can = CAN(2, CAN.LOOPBACK)
#can = CAN(2, CAN.SILENT_LOOPBACK)
can = CAN(2, CAN.NORMAL,prescaler=8, sjw=1, bs1=8, bs2=3) # 500Kbps#can.setfilter(0, CAN.RANGE|CAN.DUAL, 0, (0x701, 0x708))
can.setfilter(0, CAN.RANGE, 0, (0x701, 0x708))
#can.restart()time.sleep_ms(2000)
led.on()
time.sleep_ms(100)
led.off()
time.sleep_ms(100)cnt = 0
while True:
time.sleep_ms(100)
try:
cnt+=1
can.send(b'\x00\x00\x00\x00', 0x701,timeout=500) #发送 ID 为 123 的消息
#print(can.info())
#print(cnt,can.recv(0,timeout=200)) # 在FIFO 0上接收消息
except Exception as e:
print("error",e)
led.on()
time.sleep_ms(100)
led.off()
time.sleep_ms(100)
-