PEAK CAN自动发送CAN报文的python程序from PCANBasic import *import timefrom sys import *from threading import *temp10ms = 0temp20ms = 0temp100ms = 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 > 8: temp20ms = 0 msg = TPCANMsg() msg.ID = 0x002 msg.MSGTYPE = PCAN_MODE_STANDARD msg.LEN = 8 for i in range(8): msg.DATA[i] = 0x00 temp20ms global pd pd.Write(PCAN_USBBUS1, msg) print(20) global thread20ms thread20ms = Timer(0.02, send20ms) thread20ms.start()def send100ms(): global temp100ms temp100ms = 1 if temp100ms > 8: temp100ms = 0 msg = TPCANMsg() msg.ID = 0x003 msg.MSGTYPE = PCAN_MODE_STANDARD msg.LEN = 8 for i in range(8): msg.DATA[i] = 0x40 temp100ms global pd pd.Write(PCAN_USBBUS1, msg) print(100) global thread100ms thread100ms = Timer(0.1, send100ms) thread100ms.start()def send250ms(): global temp250ms temp250ms = 1 if temp250ms > 8: temp250ms = 0 msg = TPCANMsg() msg.ID = 0x004 msg.MSGTYPE = PCAN_MODE_STANDARD msg.LEN = 8 for i in range(8): msg.DATA[i] = 0x50 temp250ms global pd pd.Write(PCAN_USBBUS1, msg) print(250) global thread250ms thread250ms = Timer(0.25, send250ms) thread250ms.start()def send1000ms(): global temp1000ms temp1000ms = 1 if temp1000ms > 8: temp1000ms = 0 msg = TPCANMsg() msg.ID = 0x005 msg.MSGTYPE = PCAN_MODE_STANDARD msg.LEN = 8 for i in range(8): msg.DATA[i] = 0x20 temp1000ms global pd pd.Write(PCAN_USBBUS1, msg) msg.ID = 0x006 for i in range(8): msg.DATA[i] = 0x30 temp1000ms pd.Write(PCAN_USBBUS1, msg) msg.ID = 0x007 for i in range(8): msg.DATA[i] = 0x60 temp1000ms pd.Write(PCAN_USBBUS1, msg) msg.ID = 0x008 for i in range(8): msg.DATA[i] = 0x70 temp1000ms pd.Write(PCAN_USBBUS1, msg) msg.ID = 0x009 msg.DATA[0] = 0x00 msg.DATA[1] = 0x00 msg.DATA[2] = 0x00 msg.DATA[3] = 0x00 msg.DATA[4] = 0x00 msg.DATA[5] = 0x00 msg.DATA[6] = 0x00 msg.DATA[7] = 0x00 pd.Write(PCAN_USBBUS1, msg) print(1000) global thread1000ms thread1000ms = Timer(1, send1000ms) thread1000ms.start()if __name__ == "__main__": global pd pd = PCANBasic() pd.Initialize(PCAN_USBBUS1,PCAN_BAUD_500K) thread10ms = Timer(0.01, send10ms) thread100ms = Timer(0.1, send100ms) thread250ms = Timer(0.25, send250ms) thread1000ms = Timer(1, send1000ms) # thread5000ms = Timer(5, send5000ms) thread20ms = Timer(0.02, send20ms) thread10ms.start() thread20ms.start() thread100ms.start() thread250ms.start() thread1000ms.start() # thread5000ms.start()
下载利用Python发送UDS报文(UDS诊断实例)用户还喜欢
- 18480 文章数
- 500万+ 热度
作者专栏
编辑推荐
- 淡抹u2引擎,修复内容较多,物有所值
- 界域传说·经典巨作=传世单机(一键安装)
- 丸子版本(175个传世版本大集合)
- GS版本:神话公益服务端+客户端
- 图片放大工具(放大图片不模糊)
- 剪映无限制VIP版
- 传奇世界客户端下载器,史上最全传世客户端
- 传世GS20220920商业引擎注册+登录配置器 解压密码是1
- U2官方排行榜游戏网关 支持元神,支持传家宝
- GS开战传世客户端+服务端
- (淡漠夕阳)u2引擎合区工具
- 传世GS引擎消除“你的游戏客户端版本号过旧,请及时更新”提示
- 传世一机多区双线路配置器--免密码版本
- 传世凤凰登陆器劫持修复软件
- SQLite3 for Navicat
- 传奇世界npc对话框编辑工具
- 传世GS落霞铭文服务器端
- gs_20210409引擎包+注册机(无限制)
- 传奇世界NPC对话封包查看器[支持时长版和极速版]
- 彩虹引擎传世脚本编辑工具1.7版来了,支持函数脚本翻译
评论