在下面的脚本中,我将数据 [0x01, 0x0a] 发送到地址 0x0050000b,然后在地址 0x0790000b 处搜索答案“01 0a”。消息需要每 100 毫秒发送一次。
问题是由于某种原因,我发送的消息被移动了~1.3ms,这导致我的 CAN 设备无法接收它。
我在下面添加了 CAN 消息的屏幕截图,
任何帮助表示赞赏!
import can
import time
enable_use_server = True
bus = can.interface.Bus(bustype='neovi', channel='1', bitrate=500000)
# Set Control Mode = Buck and Control Type = V_LOW_I_LIM (new mode)
#send(can_id=0x00500000, ext_id=1, dlc=2, one_shot=1, rtr=0, data=[0x01, 0x0A], wait=100)
msg = can.Message(arbitration_id=0x0050000b, data=[0x01, 0x0a], extended_id=True)
bus.send(msg)
time.sleep(.1)
print('Enter Vlow Ilim Mode sent')
#Verifv
SearchID = str(hex(0x0790000b))
SearchID = SearchID.strip('0x')
found = False
while not found:
mg = str(bus.recv(0.05))
if re.search(SearchID, mg):
print('rcv: ' + mg)
if re.search("01 0a", mg):
print(msg)
print("Vlow Ilim Mode was Successful")
found = True
else:
print("Vlow Ilim Mode was NOT Successful")
msg = can.Message(arbitration_id=0x0050000b, data=[0x01, 0x0a], extended_id=True)
bus.send(msg)
time.sleep(0.1)