diff --git a/Sources/BUSMASTER/CAN_CANtact/CAN_CANtact.cpp b/Sources/BUSMASTER/CAN_CANtact/CAN_CANtact.cpp
index d3f179f48..220841d90 100644
--- a/Sources/BUSMASTER/CAN_CANtact/CAN_CANtact.cpp
+++ b/Sources/BUSMASTER/CAN_CANtact/CAN_CANtact.cpp
@@ -21,6 +21,7 @@
// CAN_CANtact.cpp : Defines the initialization routines for the DLL.
//
+#include "stdint.h"
#include "CAN_CANtact_stdafx.h"
#include "CAN_CANtact.h"
#include "BaseDIL_CAN_Controller.h"
@@ -32,8 +33,9 @@
#include "Utility\MultiLanguageSupport.h"
//#include "../Application/GettextBusmaster.h"
#include "DIL_Interface/HardwareListingCAN.h"
-#include "mhs_types.h"
+//#include "mhs_types.h"
+#include "cantact.h"
#define USAGE_EXPORT
#include "CAN_CANtact_Extern.h"
@@ -59,18 +61,6 @@ CCAN_CANtact::CCAN_CANtact()
// The one and only CCAN_CANtact object
CCAN_CANtact theApp;
-extern "C" {
- __declspec(dllimport) int32_t cantact_init();
- __declspec(dllimport) int32_t cantact_deinit();
- __declspec(dllimport) int32_t cantact_open();
- __declspec(dllimport) int32_t cantact_close();
- __declspec(dllimport) int32_t cantact_start();
- __declspec(dllimport) int32_t cantact_stop();
- __declspec(dllimport) int32_t cantact_transmit();
- __declspec(dllimport) int32_t cantact_set_bitrate();
- __declspec(dllimport) int32_t cantact_set_bitrate_user();
-}
-
/**
* CCAN_CANtact initialization
*/
@@ -177,6 +167,7 @@ static CRITICAL_SECTION sg_DIL_CriticalSection;
static HWND sg_hOwnerWnd = nullptr;
TCANtactCanCfg *sg_CANtactCanCfg = new TCANtactCanCfg("",0,0,true);
+static cantacthnd sg_CANtactHnd;
static SYSTEMTIME sg_CurrSysTime;
static UINT64 sg_TimeStamp = 0;
@@ -217,11 +208,11 @@ class CDIL_CAN_CANtact : public CBaseDIL_CAN_Controller
CDIL_CAN_CANtact* g_pouDIL_CAN_CANtact = nullptr;
-#define CALLBACK_TYPE __stdcall
+#define CALLBACK_TYPE __cdecl
static void CALLBACK_TYPE CanPnPEvent(uint32_t index, int32_t status);
static void CALLBACK_TYPE CanStatusEvent(uint32_t index, struct TDeviceStatus* status);
-static void CALLBACK_TYPE CanRxEvent(uint32_t index, struct TCanMsg* msg, int32_t count);
+static void CALLBACK_TYPE CanRxEvent(struct CantactFrame *f);
static BOOL bIsBufferExists(const SCLIENTBUFMAP& sClientObj, const CBaseCANBufFSE* pBuf);
static BOOL bRemoveClientBuffer(CBaseCANBufFSE* RootBufferArray[MAX_BUFF_ALLOWED], UINT& unCount, CBaseCANBufFSE* BufferToRemove);
@@ -505,8 +496,8 @@ HRESULT CDIL_CAN_CANtact::CAN_PerformInitOperations(void)
dwClientID = 0;
if (CAN_RegisterClient(TRUE, dwClientID, CAN_MONITOR_NODE) == S_OK)
{
- int32_t err = cantact_init();
- if (err == 0) {
+ sg_CANtactHnd = cantact_init();
+ if (sg_CANtactHnd != 0) {
// success
hResult = S_OK;
}
@@ -557,11 +548,10 @@ HRESULT CDIL_CAN_CANtact::CAN_PerformClosureOperations(void)
{
HRESULT hResult = S_OK;
- hResult = CAN_StopHardware();
// ------------------------------------
// Close driver
// ------------------------------------
- cantact_deinit();
+ cantact_deinit(sg_CANtactHnd);
#if 0
CanDownDriver();
@@ -614,21 +604,22 @@ HRESULT CDIL_CAN_CANtact::CAN_ListHwInterfaces(INTERFACE_HW_LIST& asSelHwInterfa
char str[2];
str[0] = '\0';
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if (cantact_open() == 0)
+ if (cantact_open(sg_CANtactHnd) == 0)
{
- (void)cantact_close();
-
- int pnSelList[1]={0};
- nCount = 1;
- //set the current number of channels
- sg_nNoOfChannels = 1;
- asSelHwInterface[0].m_dwIdInterface = 0;
- asSelHwInterface[0].m_acDescription = "CANtact";
- INTERFACE_HW Dummy_Interface = asSelHwInterface[0];
+ sg_nNoOfChannels = cantact_get_channel_count(sg_CANtactHnd);
+ (void)cantact_close(sg_CANtactHnd);
+
+ int pnSelList[16] = {0};
+ nCount = sg_nNoOfChannels;
+ for (int i = 0; i < sg_nNoOfChannels; i++) {
+ asSelHwInterface[i].m_dwIdInterface = i;
+ asSelHwInterface[i].m_acDescription = "CANtact";
+ }
+
sg_bCurrState = STATE_HW_INTERFACE_LISTED;
objMainWnd.Attach(sg_hOwnerWnd);
IChangeRegisters* pAdvancedSettings = new TCANtactCanCfg ("",0,0,true);
- CHardwareListingCAN HwList(&Dummy_Interface, 1, pnSelList, CAN, CHANNEL_ALLOWED, &objMainWnd, InitData, pAdvancedSettings);
+ CHardwareListingCAN HwList(&asSelHwInterface[0], sg_nNoOfChannels, pnSelList, CAN, CHANNEL_ALLOWED, &objMainWnd, InitData, pAdvancedSettings);
nRet=HwList.DoModal();
objMainWnd.Detach();
if(nRet==IDOK)
@@ -706,38 +697,40 @@ HRESULT CDIL_CAN_CANtact::CAN_SetConfigData(PSCONTROLLER_DETAILS ConfigFile, int
SCONTROLLER_DETAILS* cntrl;
char* str;
- if(sg_CANtactCanCfg != nullptr)
+ if (Length > sg_nNoOfChannels) {
+ return (S_FALSE);
+ }
+
+ if (sg_CANtactCanCfg != nullptr)
{
- //VALIDATE_VALUE_RETURN_VAL(sg_bCurrState, STATE_HW_INTERFACE_SELECTED, ERR_IMPROPER_STATE);
- cntrl = (SCONTROLLER_DETAILS*)ConfigFile;
- if (cntrl[0].m_omStrBaudrate.length() > 0)
- {
- sg_CANtactCanCfg->m_CanSpeed = _tcstol(cntrl[0].m_omStrBaudrate.c_str(), &str, 0);
- sg_CANtactCanCfg->m_CanBtrValue = 0;
- }
- else
- {
- sg_CANtactCanCfg->m_CanSpeed = 0;
- sg_CANtactCanCfg->m_CanBtrValue = _tcstol(cntrl[0].m_omStrBTR0.c_str(), &str, 0);
- }
- strcpy_s(sg_CANtactCanCfg->m_CanSnrStr, sizeof(sg_CANtactCanCfg->m_CanSnrStr), cntrl[0].m_omHardwareDesc.c_str());
+ cantact_open(sg_CANtactHnd);
+ cntrl = (SCONTROLLER_DETAILS*)ConfigFile;
- // **** Übertragungsgeschwindigkeit einstellen
- if (sg_CANtactCanCfg->m_CanSpeed)
- {
- if (cantact_set_bitrate() < 0)
- {
- return(S_FALSE);
- }
- }
- else
- {
- if (cantact_set_bitrate_user() < 0)
- {
- return(S_FALSE);
+ for (int i = 0; i < Length; i++) {
+ uint32_t bitrate;
+
+ cantact_set_enabled(sg_CANtactHnd, i, true);
+
+ if (cntrl[i].m_omStrBaudrate.length() > 0)
+ {
+ bitrate = _tcstol(cntrl[i].m_omStrBaudrate.c_str(), &str, 0);
}
- }
- }
+ else
+ {
+ bitrate = 500000;
+ }
+ if (cantact_set_bitrate(sg_CANtactHnd, i, bitrate) < 0)
+ {
+ cantact_close(sg_CANtactHnd);
+ return(S_FALSE);
+ }
+ strcpy_s(sg_CANtactCanCfg->m_CanSnrStr, sizeof(sg_CANtactCanCfg->m_CanSnrStr), cntrl[0].m_omHardwareDesc.c_str());
+ }
+ } else {
+ return (S_FALSE);
+ }
+
+ cantact_close(sg_CANtactHnd);
return(S_OK);
}
@@ -759,6 +752,7 @@ static void vWriteIntoClientsBuffer(STCANDATA& can_data)
ClientId = 0;
sAckMap.m_Channel = can_data.m_uDataInfo.m_sCANMsg.m_ucChannel;
sAckMap.m_MsgID = can_data.m_uDataInfo.m_sCANMsg.m_unMsgID;
+ //sAckMap.m_ClientID = ClientId;
if (bRemoveMapEntry(sAckMap, ClientId))
{
bClientExists = bGetClientObj(ClientId, Index);
@@ -818,53 +812,46 @@ static void CALLBACK_TYPE CanStatusEvent(uint32_t /* index */, struct TDeviceSta
// RxD Event-Funktion
-static void CALLBACK_TYPE CanRxEvent(uint32_t index, struct TCanMsg* msg, int32_t count)
+static void CALLBACK_TYPE CanRxEvent(struct CantactFrame *f)
{
- (void)index;
- static STCANDATA can_data;
- can_data.m_uDataInfo.m_sCANMsg.m_bCANFD = false;
-
- for (; count; count--)
+ STCANDATA can_data;
+ EnterCriticalSection(&sg_DIL_CriticalSection);
+ GetLocalTime(&sg_CurrSysTime);
+ //Query Tick Count
+ QueryPerformanceCounter(&sg_QueryTickCount);
+ // Get frequency of the performance counter
+ QueryPerformanceFrequency(&sg_lnFrequency);
+ // Convert it to time stamp with the granularity of hundreds of microsecond
+ if ((sg_QueryTickCount.QuadPart * 10000) > sg_lnFrequency.QuadPart)
{
- EnterCriticalSection(&sg_DIL_CriticalSection);
-
- can_data.m_uDataInfo.m_sCANMsg.m_ucChannel = 1;
- can_data.m_uDataInfo.m_sCANMsg.m_unMsgID = msg->Id;
- can_data.m_uDataInfo.m_sCANMsg.m_ucDataLen = msg->MsgLen;
- can_data.m_uDataInfo.m_sCANMsg.m_ucEXTENDED = msg->MsgEFF;
- can_data.m_uDataInfo.m_sCANMsg.m_ucRTR = msg->MsgRTR;
- if (msg->MsgTxD)
- {
- can_data.m_ucDataType = TX_FLAG;
- }
- else
- {
- can_data.m_ucDataType = RX_FLAG;
- }
-
- GetLocalTime(&sg_CurrSysTime);
- //Query Tick Count
- QueryPerformanceCounter(&sg_QueryTickCount);
- // Get frequency of the performance counter
- QueryPerformanceFrequency(&sg_lnFrequency);
- // Convert it to time stamp with the granularity of hundreds of microsecond
- if ((sg_QueryTickCount.QuadPart * 10000) > sg_lnFrequency.QuadPart)
- {
- sg_TimeStamp = (sg_QueryTickCount.QuadPart * 10000) / sg_lnFrequency.QuadPart;
- }
- else
- {
- sg_TimeStamp = (sg_QueryTickCount.QuadPart / sg_lnFrequency.QuadPart) * 10000;
- }
- can_data.m_lTickCount.QuadPart = sg_TimeStamp;
-
- memcpy(can_data.m_uDataInfo.m_sCANMsg.m_ucData, msg->MsgData, 8);
-
- //Write the msg into registered client's buffer
- vWriteIntoClientsBuffer(can_data);
- LeaveCriticalSection(&sg_DIL_CriticalSection);
- msg++;
+ sg_TimeStamp = (sg_QueryTickCount.QuadPart * 10000) / sg_lnFrequency.QuadPart;
+ }
+ else
+ {
+ sg_TimeStamp = (sg_QueryTickCount.QuadPart / sg_lnFrequency.QuadPart) * 10000;
}
+ can_data.m_lTickCount.QuadPart = sg_TimeStamp;
+
+ can_data.m_uDataInfo.m_sCANMsg.m_bCANFD = f->fd;
+ // CANtact uses zero indexing for channels
+ can_data.m_uDataInfo.m_sCANMsg.m_ucChannel = f->channel + 1;
+ can_data.m_uDataInfo.m_sCANMsg.m_unMsgID = f->id;
+ can_data.m_uDataInfo.m_sCANMsg.m_ucDataLen = f->dlc;
+ can_data.m_uDataInfo.m_sCANMsg.m_ucEXTENDED = f->ext;
+ can_data.m_uDataInfo.m_sCANMsg.m_ucRTR = f->rtr;
+ if (f->loopback)
+ {
+ can_data.m_ucDataType = TX_FLAG;
+ }
+ else
+ {
+ can_data.m_ucDataType = RX_FLAG;
+ }
+ memcpy(can_data.m_uDataInfo.m_sCANMsg.m_ucData, f->data, 8);
+
+ //Write the msg into registered client's buffer
+ vWriteIntoClientsBuffer(can_data);
+ LeaveCriticalSection(&sg_DIL_CriticalSection);
}
/**
@@ -877,8 +864,9 @@ HRESULT CDIL_CAN_CANtact::CAN_StartHardware(void)
USES_CONVERSION;
HRESULT hResult;
- if (cantact_open() == 0) {
- if (cantact_start() == 0) {
+ if (cantact_open(sg_CANtactHnd) == 0) {
+ cantact_set_rx_callback(sg_CANtactHnd, &CanRxEvent);
+ if (cantact_start(sg_CANtactHnd) == 0) {
hResult = S_OK;
/* Get connection time */
GetLocalTime(&sg_CurrSysTime);
@@ -938,7 +926,8 @@ HRESULT CDIL_CAN_CANtact::CAN_StartHardware(void)
HRESULT CDIL_CAN_CANtact::CAN_StopHardware(void)
{
VALIDATE_VALUE_RETURN_VAL(sg_bCurrState, STATE_CONNECTED, ERR_IMPROPER_STATE);
- (void)cantact_close();
+ (void)cantact_stop(sg_CANtactHnd);
+ (void)cantact_close(sg_CANtactHnd);
return(S_OK);
}
@@ -984,27 +973,22 @@ HRESULT CDIL_CAN_CANtact::CAN_SendMsg(DWORD dwClientID, const STCAN_MSG& sMessag
{
if (sMessage.m_ucChannel <= sg_nNoOfChannels)
{
- // msg Variable Initialisieren
- msg.MsgFlags = 0L; // Alle Flags löschen, Stanadrt Frame Format,
- // keine RTR, Datenlänge auf 0
- if (sMessage.m_ucEXTENDED == 1)
- {
- msg.MsgEFF = 1; // Nachricht im EFF (Ext. Frame Format) versenden
- }
- if (sMessage.m_ucRTR == 1)
+ struct CantactFrame f;
+ f.id = sMessage.m_unMsgID;
+ f.dlc = sMessage.m_ucDataLen;
+ // CANtact uses zero indexing for channels
+ f.channel = sMessage.m_ucChannel - 1;
+ f.ext = sMessage.m_ucEXTENDED;
+ f.fd = sMessage.m_bCANFD;
+ f.rtr = sMessage.m_ucRTR;
+ memcpy(f.data, sMessage.m_ucData, 8);
+ if (cantact_transmit(sg_CANtactHnd, f) >= 0)
{
- msg.MsgRTR = 1; // Nachricht als RTR Frame versenden
- }
- msg.Id = sMessage.m_unMsgID;
- msg.MsgLen = sMessage.m_ucDataLen;
- memcpy(msg.MsgData, &sMessage.m_ucData, msg.MsgLen);
- sAckMap.m_ClientID = dwClientID;
- sAckMap.m_Channel = sMessage.m_ucChannel;
- sAckMap.m_MsgID = msg.Id;
- vMarkEntryIntoMap(sAckMap);
- if (cantact_transmit() >= 0)
- {
- hResult = S_OK;
+ sAckMap.m_ClientID = dwClientID;
+ sAckMap.m_Channel = sMessage.m_ucChannel;
+ sAckMap.m_MsgID = f.id;
+ vMarkEntryIntoMap(sAckMap);
+ hResult = S_OK;
}
else
{
diff --git a/Sources/BUSMASTER/CAN_CANtact/CAN_MHS.vcxproj b/Sources/BUSMASTER/CAN_CANtact/CAN_CANtact.vcxproj
similarity index 99%
rename from Sources/BUSMASTER/CAN_CANtact/CAN_MHS.vcxproj
rename to Sources/BUSMASTER/CAN_CANtact/CAN_CANtact.vcxproj
index cd754d0b6..5495d406e 100644
--- a/Sources/BUSMASTER/CAN_CANtact/CAN_MHS.vcxproj
+++ b/Sources/BUSMASTER/CAN_CANtact/CAN_CANtact.vcxproj
@@ -159,8 +159,7 @@
"$(SolutionDir)/BIN/Libs/$(OutDir)DataTypes.lib"
"$(SolutionDir)/BIN/Libs/$(OutDir)Utils.lib"
%(AdditionalOptions)
-
-
+ cantact.dll.lib
$(SolutionDir)/bin/$(OutDir)CAN_CANtact.dll
$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);%(AdditionalLibraryDirectories)
@@ -246,6 +245,7 @@
+
diff --git a/Sources/BUSMASTER/CAN_CANtact/CAN_MHS.vcxproj.filters b/Sources/BUSMASTER/CAN_CANtact/CAN_CANtact.vcxproj.filters
similarity index 95%
rename from Sources/BUSMASTER/CAN_CANtact/CAN_MHS.vcxproj.filters
rename to Sources/BUSMASTER/CAN_CANtact/CAN_CANtact.vcxproj.filters
index c51975c06..3be57c2df 100644
--- a/Sources/BUSMASTER/CAN_CANtact/CAN_MHS.vcxproj.filters
+++ b/Sources/BUSMASTER/CAN_CANtact/CAN_CANtact.vcxproj.filters
@@ -52,6 +52,9 @@
Header Files
+
+ Header Files
+
diff --git a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/can_types.h b/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/can_types.h
deleted file mode 100644
index 83e634d65..000000000
--- a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/can_types.h
+++ /dev/null
@@ -1,146 +0,0 @@
-#ifndef __CAN_TYPES_H__
-#define __CAN_TYPES_H__
-
-#ifdef WIN32
-#ifndef __WIN32__
-#define __WIN32__
-#endif
-#endif
-
-#ifdef __WIN32__
-#include
-
-#define int32_t __int32
-#define uint32_t unsigned __int32
-#define int16_t __int16
-#define uint16_t unsigned __int16
-// Linux & Mac
-#else
-//#include
-//#include
-//#include
-#include
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#define INDEX_FIFO_PUFFER_MASK 0x0000FFFF
-#define INDEX_SOFT_FLAG 0x02000000
-#define INDEX_RXD_TXT_FLAG 0x01000000
-#define INDEX_CAN_KANAL_MASK 0x000F0000
-#define INDEX_CAN_DEVICE_MASK 0x00F00000
-
-#define INDEX_CAN_KANAL_A 0x00000000
-#define INDEX_CAN_KANAL_B 0x00010000
-
- /***************************************************************/
- /* Typen */
- /***************************************************************/
-
- /******************************************/
- /* CAN Message Type */
- /******************************************/
-#define MsgFlags Flags.Long
-#define MsgLen Flags.Flag.Len
-#define MsgRTR Flags.Flag.RTR
-#define MsgEFF Flags.Flag.EFF
-#define MsgTxD Flags.Flag.TxD
-#define MsgData Data.Bytes
-
- struct TCanFlagsBits
- {
- unsigned Len:4; // Dlc
- unsigned TxD:1; // TxD -> 1 = Tx CAN Message, 0 = Rx CAN Message
- unsigned Res:1; // Reserviert
- unsigned RTR:1; // remote transmition request bit
- unsigned EFF:1; // extended frame bit
- unsigned Res2:8;
- };
-
- union TCanFlags
- {
- struct TCanFlagsBits Flag;
- uint32_t Long;
- };
-
- union TCanData
- {
- char Chars[8];
- unsigned char Bytes[8];
- uint16_t Words[4];
- uint32_t Longs[2];
- };
-
- struct TTime
- {
- uint32_t Sec;
- uint32_t USec;
- };
-
- struct TCanMsg
- {
- uint32_t Id;
- union TCanFlags Flags;
- union TCanData Data;
- struct TTime Time;
- };
-
- /******************************************/
- /* CAN Message Filter Type */
- /******************************************/
-#define FilFlags Flags.Long
-#define FilEFF Flags.Flag.EFF
-#define FilMode Flags.Flag.Mode
-#define FilIdMode Flags.Flag.IdMode
-#define FilEnable Flags.Flag.Enable
-
-
- struct TMsgFilterFlagsBits
- {
- // 1. Byte
- unsigned Len:4; // Dlc
- unsigned Res:2; // Reserviert
- unsigned RTR:1; // remote transmition request bit
- unsigned EFF:1; // extended frame bit
- // 2. Byte
- unsigned IdMode:2; // 0 = Maske & Code
- // 1 = Start & Stop
- // 2 = Single Id
- unsigned DLCCheck:1;
- unsigned DataCheck:1;
- unsigned Res1:4;
- // 3. Byte
- unsigned Res2:8;
- // 4. Byte
- unsigned Type:4; // 0 = Single Puffer
- unsigned Res3:2;
- unsigned Mode:1; // 0 = Message entfernen
- // 1 = Message nicht entfernen
- unsigned Enable:1;
- };
-
-
- union TMsgFilterFlags
- {
- struct TMsgFilterFlagsBits Flag;
- uint32_t Long;
- };
-
- struct TMsgFilter
- {
- uint32_t Maske;
- uint32_t Code;
- union TMsgFilterFlags Flags;
- union TCanData Data;
- };
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif
diff --git a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/cantact.dll b/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/cantact.dll
deleted file mode 100644
index 1b4f60af4..000000000
Binary files a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/cantact.dll and /dev/null differ
diff --git a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/cantact.dll.lib b/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/cantact.dll.lib
deleted file mode 100644
index dc93cb4b7..000000000
Binary files a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/cantact.dll.lib and /dev/null differ
diff --git a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhs_types.h b/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhs_types.h
deleted file mode 100644
index 6cb99734d..000000000
--- a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhs_types.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef __MHS_TYPES_H__
-#define __MHS_TYPES_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define MHS_STR_SIZE 255
-
-
- struct TMhsCanCfg
- {
- char CanSnrStr[MHS_STR_SIZE];
- unsigned int CanSpeed;
- unsigned int CanBtrValue;
- BOOL m_bBitRateSelected;
- };
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhsbmcfg.h b/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhsbmcfg.h
deleted file mode 100644
index 3db0de081..000000000
--- a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhsbmcfg.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __MHS_BM_CFG_H__
-#define __MHS_BM_CFG_H__
-
-#include "mhs_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- int WINAPI ShowCanSetup(HWND hwnd, struct TMhsCanCfg* setup);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
\ No newline at end of file
diff --git a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhsbmcfg.lib b/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhsbmcfg.lib
deleted file mode 100644
index 652eb4ab9..000000000
Binary files a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhsbmcfg.lib and /dev/null differ
diff --git a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhstcan.dll b/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhstcan.dll
deleted file mode 100644
index ac08e9dca..000000000
Binary files a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhstcan.dll and /dev/null differ
diff --git a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhstcan.h b/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhstcan.h
deleted file mode 100644
index 077da51e1..000000000
--- a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhstcan.h
+++ /dev/null
@@ -1,143 +0,0 @@
-#pragma once
-
-#include "can_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /***************************************************************/
- /* Define Makros */
- /***************************************************************/
- // CAN Übertragungsgeschwindigkeit
-#define CAN_10K_BIT 10 // 10 kBit/s
-#define CAN_20K_BIT 20 // 20 kBit/s
-#define CAN_50K_BIT 50 // 50 kBit/s
-#define CAN_100K_BIT 100 // 100 kBit/s
-#define CAN_125K_BIT 125 // 125 kBit/s
-#define CAN_250K_BIT 250 // 250 kBit/s
-#define CAN_500K_BIT 500 // 500 kBit/s
-#define CAN_800K_BIT 800 // 800 kBit/s
-#define CAN_1M_BIT 1000 // 1 MBit/s
-
- // CAN Bus Mode
-#define OP_CAN_NO_CHANGE 0 // Aktuellen Zustand nicht ändern
-#define OP_CAN_START 1 // Startet den CAN-Bus
-#define OP_CAN_STOP 2 // Stopt den CAN-Bus
-#define OP_CAN_RESET 3 // Reset CAN Controller (BusOff löschen)
-#define OP_CAN_START_LOM 4 // Startet den CAN-Bus im Silent Mode (Listen Only Mode)
-#define OP_CAN_START_NO_RETRANS 5 // Startet den CAN-Bus im Automatic Retransmission disable Mode
-
-
-#define CAN_CMD_NONE 0x0000
-#define CAN_CMD_RXD_OVERRUN_CLEAR 0x0001
-#define CAN_CMD_RXD_FIFOS_CLEAR 0x0002
-#define CAN_CMD_TXD_OVERRUN_CLEAR 0x0004
-#define CAN_CMD_TXD_FIFOS_CLEAR 0x0008
-#define CAN_CMD_HW_FILTER_CLEAR 0x0010
-#define CAN_CMD_SW_FILTER_CLEAR 0x0020
-#define CAN_CMD_TXD_PUFFERS_CLEAR 0x0040
-
-#define CAN_CMD_FIFOS_ERROR_CLEAR 0x000F
-#define CAN_CMD_ALL_CLEAR 0x0FFF
-
-
- // DrvStatus
-#define DRV_NOT_LOAD 0 // Die Treiber DLL wurde noch nicht geladen
-#define DRV_STATUS_NOT_INIT 1 // Treiber noch nicht Initialisiert
-#define DRV_STATUS_INIT 2 // Treiber erfolgrich Initialisiert
-#define DRV_STATUS_PORT_NOT_OPEN 3 // Die Schnittstelle wurde geöffnet
-#define DRV_STATUS_PORT_OPEN 4 // Die Schnittstelle wurde nicht geöffnet
-#define DRV_STATUS_DEVICE_FOUND 5 // Verbindung zur Hardware wurde Hergestellt
-#define DRV_STATUS_CAN_OPEN 6 // Device wurde geöffnet und erfolgreich Initialisiert
-#define DRV_STATUS_CAN_RUN_TX 7 // CAN Bus RUN nur Transmitter (wird nicht verwendet !)
-#define DRV_STATUS_CAN_RUN 8 // CAN Bus RUN
-
- // CanStatus
-#define CAN_STATUS_OK 0 // CAN-Controller: Ok
-#define CAN_STATUS_ERROR 1 // CAN-Controller: CAN Error
-#define CAN_STATUS_WARNING 2 // CAN-Controller: Error warning
-#define CAN_STATUS_PASSIV 3 // CAN-Controller: Error passiv
-#define CAN_STATUS_BUS_OFF 4 // CAN-Controller: Bus Off
-#define CAN_STATUS_UNBEKANNT 5 // CAN-Controller: Status Unbekannt
-
- // Fifo Status
-#define FIFO_OK 0 // Fifo-Status: Ok
-#define FIFO_HW_OVERRUN 1 // Fifo-Status: Hardware Fifo Überlauf
-#define FIFO_SW_OVERRUN 2 // Fifo-Status: Software Fifo Überlauf
-#define FIFO_HW_SW_OVERRUN 3 // Fifo-Status: Hardware & Software Fifo Überlauf
-#define FIFO_STATUS_UNBEKANNT 4 // Fifo-Status: Unbekannt
-
- // Makros für SetEvent
-#define EVENT_ENABLE_PNP_CHANGE 0x0001
-#define EVENT_ENABLE_STATUS_CHANGE 0x0002
-#define EVENT_ENABLE_RX_FILTER_MESSAGES 0x0004
-#define EVENT_ENABLE_RX_MESSAGES 0x0008
-#define EVENT_ENABLE_ALL 0x00FF
-
-#define EVENT_DISABLE_PNP_CHANGE 0x0100
-#define EVENT_DISABLE_STATUS_CHANGE 0x0200
-#define EVENT_DISABLE_RX_FILTER_MESSAGES 0x0400
-#define EVENT_DISABLE_RX_MESSAGES 0x0800
-#define EVENT_DISABLE_ALL 0xFF00
-
-
- /***************************************************************/
- /* Typen */
- /***************************************************************/
-
- /******************************************/
- /* Device Status */
- /******************************************/
- struct TDeviceStatus
- {
- int32_t DrvStatus;
- unsigned char CanStatus;
- unsigned char FifoStatus;
- };
-
-
- /***************************************************************/
- /* Tiny-CAN API Funktionen */
- /***************************************************************/
- __declspec(dllimport) int32_t WINAPI CanInitDriver(char* options);
- __declspec(dllimport) void WINAPI CanDownDriver(void);
- __declspec(dllimport) int32_t WINAPI CanSetOptions(char* options);
- __declspec(dllimport) int32_t WINAPI CanDeviceOpen(uint32_t index, char* parameter);
- __declspec(dllimport) int32_t WINAPI CanDeviceClose(uint32_t index);
- __declspec(dllimport) int32_t WINAPI CanApplaySettings(uint32_t index);
-
- __declspec(dllimport) int32_t WINAPI CanSetMode(uint32_t index, unsigned char can_op_mode, uint16_t can_command);
- __declspec(dllimport) int32_t WINAPI CanSet(uint32_t index, uint16_t obj_index, uint16_t obj_sub_index, void* data, int32_t size);
- __declspec(dllimport) int32_t WINAPI CanGet(uint32_t index, uint16_t obj_index, uint16_t obj_sub_index, void* data, int32_t size);
-
- __declspec(dllimport) int32_t WINAPI CanTransmit(uint32_t index, struct TCanMsg* msg, int32_t count);
- __declspec(dllimport) void WINAPI CanTransmitClear(uint32_t index);
- __declspec(dllimport) uint32_t WINAPI CanTransmitGetCount(uint32_t index);
- __declspec(dllimport) int32_t WINAPI CanTransmitSet(uint32_t index, uint16_t cmd,
- uint32_t time);
- __declspec(dllimport) int32_t WINAPI CanReceive(uint32_t index, struct TCanMsg* msg, int32_t count);
- __declspec(dllimport) void WINAPI CanReceiveClear(uint32_t index);
- __declspec(dllimport) uint32_t WINAPI CanReceiveGetCount(uint32_t index);
-
- __declspec(dllimport) int32_t WINAPI CanSetSpeed(uint32_t index, uint16_t speed);
- __declspec(dllimport) int32_t WINAPI CanSetSpeedUser(uint32_t index, uint32_t value);
- __declspec(dllimport) char* WINAPI CanDrvInfo(void);
- __declspec(dllimport) char* WINAPI CanDrvHwInfo(uint32_t index);
- __declspec(dllimport) int32_t WINAPI CanSetFilter(uint32_t index, struct TMsgFilter* msg_filter);
-
- __declspec(dllimport) int32_t WINAPI CanGetDeviceStatus(uint32_t index, struct TDeviceStatus* status);
-
- __declspec(dllimport) void WINAPI CanSetPnPEventCallback(void (__stdcall* event)(uint32_t index, int32_t status));
- __declspec(dllimport) void WINAPI CanSetStatusEventCallback(void (__stdcall* event)
- (uint32_t index, struct TDeviceStatus* device_status));
- __declspec(dllimport) void WINAPI CanSetRxEventCallback(void (__stdcall* event)
- (uint32_t index, struct TCanMsg* msg, int32_t count));
-
- __declspec(dllimport) void WINAPI CanSetEvents(uint16_t events);
- __declspec(dllimport) uint32_t WINAPI CanEventStatus(void);
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhstcan.lib b/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhstcan.lib
deleted file mode 100644
index b01314b40..000000000
Binary files a/Sources/BUSMASTER/CAN_CANtact/EXTERNAL/mhstcan.lib and /dev/null differ
diff --git a/Sources/BUSMASTER/CAN_CANtact/cantact.dll.lib b/Sources/BUSMASTER/CAN_CANtact/cantact.dll.lib
new file mode 100644
index 000000000..ee9cc5e23
Binary files /dev/null and b/Sources/BUSMASTER/CAN_CANtact/cantact.dll.lib differ
diff --git a/Sources/BUSMASTER/CAN_CANtact/cantact.h b/Sources/BUSMASTER/CAN_CANtact/cantact.h
new file mode 100644
index 000000000..8c1620b62
--- /dev/null
+++ b/Sources/BUSMASTER/CAN_CANtact/cantact.h
@@ -0,0 +1,41 @@
+#ifndef CANTACT_H_
+#define CANTACT_H_
+
+#include
+
+typedef void* cantacthnd;
+
+struct CantactFrame {
+ uint8_t channel;
+ uint32_t id;
+ uint8_t dlc;
+ uint8_t data[8];
+ uint8_t ext;
+ uint8_t fd;
+ uint8_t loopback;
+ uint8_t rtr;
+};
+
+extern "C" {
+ __declspec(dllimport) cantacthnd cantact_init();
+ __declspec(dllimport) int32_t cantact_deinit(cantacthnd hnd);
+
+ __declspec(dllimport) int32_t cantact_open(cantacthnd hnd);
+ __declspec(dllimport) int32_t cantact_close(cantacthnd hnd);
+
+ __declspec(dllimport) int32_t cantact_set_rx_callback(cantacthnd hnd, void(__cdecl* callback)(CantactFrame* f));
+
+ __declspec(dllimport) int32_t cantact_start(cantacthnd hnd);
+ __declspec(dllimport) int32_t cantact_stop(cantacthnd hnd);
+
+ __declspec(dllimport) int32_t cantact_transmit(cantacthnd hnd, const struct CantactFrame f);
+
+ __declspec(dllimport) int32_t cantact_set_bitrate(cantacthnd hnd, uint8_t channel, uint32_t bitrate);
+ __declspec(dllimport) int32_t cantact_set_enabled(cantacthnd hnd, uint8_t channel, uint8_t enabled);
+ __declspec(dllimport) int32_t cantact_set_monitor(cantacthnd hnd, uint8_t channel, uint8_t enabled);
+ __declspec(dllimport) int32_t cantact_set_hw_loopback(cantacthnd hnd, uint8_t channel, uint8_t enabled);
+
+ __declspec(dllimport) int32_t cantact_get_channel_count(cantacthnd hnd);
+}
+
+#endif
\ No newline at end of file
diff --git a/Sources/Kernel/BusmasterDriverInterface/DIL_CAN.cpp b/Sources/Kernel/BusmasterDriverInterface/DIL_CAN.cpp
index 9a17d9809..9ba134033 100644
--- a/Sources/Kernel/BusmasterDriverInterface/DIL_CAN.cpp
+++ b/Sources/Kernel/BusmasterDriverInterface/DIL_CAN.cpp
@@ -67,7 +67,6 @@ enum
DRIVER_CAN_VSCOM,
DRIVER_CAN_IVIEW,
DRIVER_CAN_ISOLAR,
- DRIVER_CAN_CANTACT,
DIL_TOTAL, // Its value must be <= MAX_DILS
DAL_NONE = ~0x0
};
@@ -77,7 +76,6 @@ static ENTRY_DIL sg_ListDIL[] =
/* simulation should be the first entry... */
{DRIVER_CAN_STUB, "&Simulation" },
/* ...all other drivers should be in alphabetical order */
- {DRIVER_CAN_CANTACT, "&CANtact" },
{DRIVER_CAN_ETAS_BOA, "ETAS &BOA" },
{DRIVER_CAN_ETAS_ES581, "ETAS &ES581.3" },
{DRIVER_CAN_ETAS_ES5814, "ETAS ES581.&4" },
@@ -356,11 +354,6 @@ HRESULT CDIL_CAN::DILC_SelectDriver(DWORD dwDriverID, HWND hWndOwner)
case DRIVER_CAN_ISOLAR:
m_hDll = LoadLibrary("CAN_ISOLAR_EVE_VCAN.dll");
break;
-
- case DRIVER_CAN_CANTACT:
- m_hDll = LoadLibrary("CAN_CANtact.dll");
- break;
-
case DAL_NONE:
DILC_PerformClosureOperations();
vSelectInterface_Dummy();