Kvaser使用(Can总线)

1、概述

克萨:Kvaser
官网:https://www.kvaser.cn/
window版下载: 下载驱动及SDK
官网下载:https://www.kvaser.cn/downloads/
驱动下载:https://www.kvaser.cn/downloads/#?categories=driver

windows驱动:kvaser_drivers_setup.exe (根据设备编号查找,4xHs和2xHs是不同的)
Kvaser CANlib SDK:canlib.exe
python module or (pip install canlib)

2、基本使用

#include 
#include 
 
void main(void)
{
	canHandle h;
	
	canInitializeLibrary();
	h = canOpenChannel(0, canWANT_EXCLUSIVE);
	if (h < 0) {
		char msg[64];
		canGetErrorText((canStatus)h, msg, sizeof(msg));
		fprintf(stderr, "canOpenChannel failed (%s)\n", msg);
		exit(1);
	}
	canSetBusParams(h, BAUD_250K, 0, 0, 0, 0, 0);
	canSetBusOutputControl(h, canDRIVER_NORMAL);
	canBusOn(h);
	canWrite(h, 123, "HELLO!", 6, 0);
	canWriteSync(h, 500);
	canBusOff(h);
	canClose(h);
}

你可能感兴趣的:(QT,Can总线)