Commit f691e1d4 authored by Jussi Lindgren's avatar Jussi Lindgren

Drivers: Fixed gMobilab & gUSBAmp coexistence on Linux

parent 93a457c3
......@@ -11,7 +11,6 @@
#include "ovasIDriver.h"
#include "../ovasCHeader.h"
#include "../ovasCSettingsHelper.h"
#include "../ovasCSettingsHelperOperators.h"
......@@ -19,10 +18,11 @@
#ifdef TARGET_OS_Windows
#include <Windows.h>
#endif
#include <gMOBIlabplus.h>
namespace OpenViBEAcquisitionServer
{
class CDriverGTecGMobiLabPlusPrivate; // fwd declare
/**
* \class CDriverGTecGMobiLabPlus
* \author Lucie Daubigney (Supelec Metz)
......@@ -68,49 +68,23 @@ namespace OpenViBEAcquisitionServer
//params
std::string m_oPortName;
OpenViBE::boolean m_bTestMode;
//usefull data to communicate with the gTec module
_BUFFER_ST m_oBuffer;
HANDLE m_oDevice;
_AIN m_oAnalogIn;
#if defined(TARGET_OS_Windows)
OVERLAPPED m_oOverlap;
#endif
private:
void allowAnalogInputs(OpenViBE::uint32 ui32ChannelIndex);
// Pointers do gtec-specific data and function pointers
OpenViBEAcquisitionServer::CDriverGTecGMobiLabPlusPrivate* m_pGtec;
// Register the function pointers from the dll. (The dll approach
// is used with gMobilab to avoid conflicts with the gUSBAmp lib)
OpenViBE::boolean registerLibraryFunctions(void);
// These gtec function calls are found from the dll library
typedef HANDLE(__stdcall *OV_GT_OpenDevice)(LPSTR lpPort);
typedef BOOL(__stdcall *OV_GT_CloseDevice)(HANDLE hDevice);
typedef BOOL(__stdcall *OV_GT_SetTestmode)(HANDLE hDevice, BOOL Testmode);
typedef BOOL(__stdcall *OV_GT_StartAcquisition)(HANDLE hDevice);
typedef BOOL(__stdcall *OV_GT_GetData)(HANDLE hDevice, _BUFFER_ST *buffer, LPOVERLAPPED lpOvl);
typedef BOOL(__stdcall *OV_GT_InitChannels)(HANDLE hDevice, _AIN analogCh, _DIO digitalCh);
typedef BOOL(__stdcall *OV_GT_StopAcquisition)(HANDLE hDevice);
typedef BOOL(__stdcall *OV_GT_GetLastError)(UINT * LastError);
typedef BOOL(__stdcall *OV_GT_TranslateErrorCode)(_ERRSTR *ErrorString, UINT ErrorCode);
OV_GT_OpenDevice m_fOpenDevice;
OV_GT_CloseDevice m_fCloseDevice;
OV_GT_SetTestmode m_fSetTestmode;
OV_GT_StartAcquisition m_fStartAcquisition;
OV_GT_GetData m_fGetData;
OV_GT_InitChannels m_fInitChannels;
OV_GT_StopAcquisition m_fStopAcquisition;
OV_GT_GetLastError m_fGetLastError;
OV_GT_TranslateErrorCode m_fTranslateErrorCode;
#if defined(TARGET_OS_Windows)
HINSTANCE m_pLibrary;
#elif defined(TARGET_OS_Linux)
void* m_pLibrary;
private:
void allowAnalogInputs(OpenViBE::uint32 ui32ChannelIndex);
#endif
};
};
......
/*
* The only purpose of this class is to hide the gtec API
* data types from the ov driver header. An approach resembling
* this is sometimes called a 'd-pointer'.
*
* Previous situation:
*
* gUsbamp ov driver header depends on gtec gUSBAmp API types
* gMobilab ov driver header depends on gtec gMobilab API types
* Acquisition Server includes both these driver headers
*
* But the gtec types are declared differently in the two gtec APIs.
* Hence we get a conflict if both headers are included by the
* same compilation unit.
*
* With this class, the gmobilab API is not exposed just by
* including ovasCDriverGtecMobiLabPlus.h to the Acquisition Server.
*
*/
#ifndef __OpenViBE_AcquisitionServer_CDriverGTecGMobiLabPlusPrivate_H__
#define __OpenViBE_AcquisitionServer_CDriverGTecGMobiLabPlusPrivate_H__
#if defined TARGET_HAS_ThirdPartyGMobiLabPlusAPI
#include <gMOBIlabplus.h>
namespace OpenViBEAcquisitionServer
{
/**
* \author Jussi T. Lindgren (Inria)
*
* The class collects all members that used to be in
* CDriverGtecMobiLabPlus header that depend on the gmobilab API.
*
*/
class CDriverGTecGMobiLabPlusPrivate
{
public:
//useful data to communicate with the gTec module
_BUFFER_ST m_oBuffer;
HANDLE m_oDevice;
_AIN m_oAnalogIn;
#if defined(TARGET_OS_Windows)
OVERLAPPED m_oOverlap;
#endif
// These functions are defined in the gmobilab library
#if defined(TARGET_OS_Windows)
typedef HANDLE(__stdcall *OV_GT_OpenDevice)(LPSTR lpPort);
typedef BOOL(__stdcall *OV_GT_CloseDevice)(HANDLE hDevice);
typedef BOOL(__stdcall *OV_GT_SetTestmode)(HANDLE hDevice, BOOL Testmode);
typedef BOOL(__stdcall *OV_GT_StartAcquisition)(HANDLE hDevice);
typedef BOOL(__stdcall *OV_GT_GetData)(HANDLE hDevice, _BUFFER_ST *buffer, LPOVERLAPPED lpOvl);
typedef BOOL(__stdcall *OV_GT_InitChannels)(HANDLE hDevice, _AIN analogCh, _DIO digitalCh);
typedef bool(__stdcall *OV_GT_StopAcquisition)(HANDLE hDevice);
typedef bool(__stdcall *OV_GT_GetLastError)(UINT * LastError);
typedef bool(__stdcall *OV_GT_TranslateErrorCode)(_ERRSTR *ErrorString, UINT ErrorCode);
#else
typedef HANDLE(*OV_GT_OpenDevice)(const char* lpPort);
typedef bool(*OV_GT_CloseDevice)(HANDLE hDevice);
typedef bool(*OV_GT_SetTestmode)(HANDLE hDevice, bool Testmode);
typedef bool(*OV_GT_StartAcquisition)(HANDLE hDevice);
typedef bool(*OV_GT_GetData)(HANDLE hDevice, _BUFFER_ST *buffer);
typedef bool(*OV_GT_InitChannels)(HANDLE hDevice, _AIN analogCh, _DIO digitalCh);
typedef bool(*OV_GT_StopAcquisition)(HANDLE hDevice);
typedef bool(*OV_GT_GetLastError)(unsigned int* LastError);
typedef bool(*OV_GT_TranslateErrorCode)(_ERRSTR *ErrorString, unsigned int ErrorCode);
#endif
// Function pointers to the dll
OV_GT_OpenDevice m_fOpenDevice;
OV_GT_CloseDevice m_fCloseDevice;
OV_GT_SetTestmode m_fSetTestmode;
OV_GT_StartAcquisition m_fStartAcquisition;
OV_GT_GetData m_fGetData;
OV_GT_InitChannels m_fInitChannels;
OV_GT_StopAcquisition m_fStopAcquisition;
OV_GT_GetLastError m_fGetLastError;
OV_GT_TranslateErrorCode m_fTranslateErrorCode;
};
};
#endif // TARGET_HAS_ThirdPartyGMobiLabPlusAPI
#endif // __OpenViBE_AcquisitionServer_CDriverGTecGMobiLabPlusPrivate_H__
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment