【实例简介】PEAK CAN自动发送CAN报文的python程序
【实例截图】
【核心代码】
from PCANBasic import *
import time
from sys import *
from threading import *
temp10ms = 0
temp20ms = 0
temp100ms = 0;
temp250ms = 0;
temp1000ms = 0;
def send10ms():
global temp10ms
temp10ms = 1
if temp10ms > 7:
temp10ms = 0
msg = TPCANMsg()
msg.ID = 0x001
msg.MSGTYPE = PCAN_MODE_STANDARD
msg.LEN = 8
for i in range(8):
msg.DATA[i] = 0x10 temp10ms
global pd
pd.Write(PCAN_USBBUS1, msg)
print(10)
global thread10ms
thread10ms = Timer(0.01, send10ms)
thread10ms.start()
def send20ms():
global temp20ms
temp20ms = 1
if temp20ms