程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Call Python can library and use zhouligong can interface card to send data suggestions collection

編輯:Python

Hello everyone , I meet you again , I'm your friend, Quan Jun .

Look up python-can file , Know the supporting part zhouligong CAN Interface card , So write routine verification data Sending of . in addition , The use of python Version is 3.4, In the installation python-can The prompt cannot be found windows-curses The installation package of the corresponding version , Therefore, in python-can Of setup.py in , To cancel the windows-curses The installation of depends on . The code is as follows (ControlCAN.dll To be placed in the same path ):

from __future__ import print_function
import platform
import can
def send_one():
bus = can.interface.Bus(bustype='canalystii', channel=0, baud=500000)
msg = can.Message(arbitration_id=0xc0ffee,
data=[0, 25, 0, 1, 3, 1, 4, 1],
is_extended_id=True)
try:
bus.send(msg)
print("Message sent on {}".format(bus.channel_info))
except can.CanError:
print("Message NOT sent")
if __name__ == '__main__':
send_one()

Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/151788.html Link to the original text :https://javaforall.cn


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved