You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.6 KiB
99 lines
2.6 KiB
//ControlCAN.h for matlab
|
|
//20200613
|
|
|
|
#ifndef CONTROLCAN_H
|
|
#define CONTROLCAN_H
|
|
|
|
#define VCI_USBCAN1 3
|
|
#define VCI_USBCAN2 4
|
|
#define VCI_USBCAN2A 4
|
|
|
|
#define VCI_USBCAN_E_U 20
|
|
#define VCI_USBCAN_2E_U 21
|
|
|
|
#define STATUS_OK 1
|
|
#define STATUS_ERR 0
|
|
|
|
//for matlab
|
|
typedef unsigned char BYTE;
|
|
typedef char CHAR;
|
|
typedef unsigned char UCHAR;
|
|
typedef int INT;
|
|
typedef unsigned int UINT;
|
|
typedef unsigned short USHORT;
|
|
typedef unsigned long ULONG;
|
|
typedef unsigned long DWORD;
|
|
|
|
|
|
typedef struct _VCI_BOARD_INFO{
|
|
USHORT hw_Version;
|
|
USHORT fw_Version;
|
|
USHORT dr_Version;
|
|
USHORT in_Version;
|
|
USHORT irq_Num;
|
|
BYTE can_Num;
|
|
CHAR str_Serial_Num[20];
|
|
CHAR str_hw_Type[40];
|
|
USHORT Reserved[4];
|
|
} VCI_BOARD_INFO,*PVCI_BOARD_INFO;
|
|
|
|
|
|
typedef struct _VCI_CAN_OBJ{
|
|
UINT ID;
|
|
UINT TimeStamp;
|
|
BYTE TimeFlag;
|
|
BYTE SendType;
|
|
BYTE RemoteFlag;
|
|
BYTE ExternFlag;
|
|
BYTE DataLen;
|
|
BYTE Data[8];
|
|
BYTE Reserved[3];
|
|
}VCI_CAN_OBJ,*PVCI_CAN_OBJ;
|
|
|
|
|
|
typedef struct _VCI_INIT_CONFIG{
|
|
DWORD AccCode;
|
|
DWORD AccMask;
|
|
DWORD Reserved;
|
|
UCHAR Filter;
|
|
UCHAR Timing0;
|
|
UCHAR Timing1;
|
|
UCHAR Mode;
|
|
}VCI_INIT_CONFIG,*PVCI_INIT_CONFIG;
|
|
|
|
|
|
typedef struct _VCI_FILTER_RECORD{
|
|
DWORD ExtFrame;
|
|
DWORD Start;
|
|
DWORD End;
|
|
}VCI_FILTER_RECORD,*PVCI_FILTER_RECORD;
|
|
|
|
#define EXTERNC extern "C"
|
|
|
|
EXTERNC DWORD __stdcall VCI_OpenDevice(DWORD DeviceType,DWORD DeviceInd,DWORD Reserved);
|
|
EXTERNC DWORD __stdcall VCI_CloseDevice(DWORD DeviceType,DWORD DeviceInd);
|
|
EXTERNC DWORD __stdcall VCI_InitCAN(DWORD DeviceType, DWORD DeviceInd, DWORD CANInd, PVCI_INIT_CONFIG pInitConfig);
|
|
|
|
EXTERNC DWORD __stdcall VCI_ReadBoardInfo(DWORD DeviceType,DWORD DeviceInd,PVCI_BOARD_INFO pInfo);
|
|
|
|
//EXTERNC DWORD __stdcall VCI_SetReference(DWORD DeviceType,DWORD DeviceInd,DWORD CANInd,DWORD RefType,PVOID pData);
|
|
|
|
EXTERNC DWORD __stdcall VCI_SetReference(DWORD DeviceType,DWORD DeviceInd,DWORD CANInd,DWORD RefType,void *pData);
|
|
|
|
EXTERNC ULONG __stdcall VCI_GetReceiveNum(DWORD DeviceType,DWORD DeviceInd,DWORD CANInd);
|
|
EXTERNC DWORD __stdcall VCI_ClearBuffer(DWORD DeviceType,DWORD DeviceInd,DWORD CANInd);
|
|
|
|
EXTERNC DWORD __stdcall VCI_StartCAN(DWORD DeviceType,DWORD DeviceInd,DWORD CANInd);
|
|
EXTERNC DWORD __stdcall VCI_ResetCAN(DWORD DeviceType,DWORD DeviceInd,DWORD CANInd);
|
|
|
|
EXTERNC ULONG __stdcall VCI_Transmit(DWORD DeviceType,DWORD DeviceInd,DWORD CANInd,PVCI_CAN_OBJ pSend,ULONG Len);
|
|
EXTERNC ULONG __stdcall VCI_Receive(DWORD DeviceType,DWORD DeviceInd,DWORD CANInd,PVCI_CAN_OBJ pReceive,ULONG Len,INT WaitTime);
|
|
|
|
|
|
|
|
#define EXTERNC extern "C"
|
|
|
|
EXTERNC DWORD __stdcall VCI_UsbDeviceReset(DWORD DevType,DWORD DevIndex,DWORD Reserved);
|
|
EXTERNC DWORD __stdcall VCI_FindUsbDevice2(PVCI_BOARD_INFO pInfo);
|
|
|
|
#endif
|