请问pyb中can.send函数怎么发送8个字节?发送了一个列表提示错误。
-
# Untitled - By: Administrator - 周五 九月 20 2019 import time from pyb import Pin, Timer from pyb import CAN can2 = CAN(2,CAN.NORMAL,extframe=False,prescaler=9,sjw=1,bs1=8,bs2=3) can2.setfilter(0,CAN.LIST16,0,(0,1,123,124)) ID=0x111 MSG=123 Data=[1,2,3,4,5,6,7,8] def tick(timer): # we will receive the timer object when being called print("Timer callback") tim = Timer(4, freq=1) # create a timer object using timer 4 - trigger at 1Hz tim.callback(tick) # set the callback to our tick function while(True): time.sleep(1000) print("wait") can2.send(MSG,ID,timeout=3000) can2.send(Data,ID,timeout=3000)
-
-
非常感谢!能通过,但是我想知道原因,为什么需要用bytes()来将数组转换才能传入数组?
-
@z1sk 数组不是字节。你要考虑大小端的问题。