Renamed library TellUsbD101 to TelldusCore and some minor fixes for building on Windows.

This commit is contained in:
Micke Prag 2008-10-16 15:03:03 +00:00
parent c865bb0fd6
commit 46ba243c2f
28 changed files with 993 additions and 1018 deletions

View file

@ -2,5 +2,5 @@ PROJECT( tellstick )
CMAKE_MINIMUM_REQUIRED( VERSION 2.4.0 ) CMAKE_MINIMUM_REQUIRED( VERSION 2.4.0 )
ADD_SUBDIRECTORY(TellUsbD101) ADD_SUBDIRECTORY(libtelldus-core)

View file

@ -6,7 +6,7 @@ SET( tellusbd101_SRCS
DeviceSartano.cpp DeviceSartano.cpp
DeviceWaveman.cpp DeviceWaveman.cpp
settings/TelldusSettings.cpp settings/TelldusSettings.cpp
TellUsbD101.cpp telldus-core.cpp
) )
IF (APPLE) IF (APPLE)
@ -47,7 +47,7 @@ ELSE (APPLE)
) )
ENDIF (APPLE) ENDIF (APPLE)
INSTALL(TARGETS tellusbd101 LIBRARY INSTALL(TARGETS tellusbd101
DESTINATION lib DESTINATION lib
) )

View file

@ -27,28 +27,28 @@ Device::~Device(void)
* Turn on, virtual * Turn on, virtual
*/ */
int Device::turnOn(void){ int Device::turnOn(void){
//do nothing return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
} }
/* /*
* Turn off, virtual * Turn off, virtual
*/ */
int Device::turnOff(void){ int Device::turnOff(void){
//do nothing return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
} }
/* /*
* Bell, virtual * Bell, virtual
*/ */
int Device::bell(void){ int Device::bell(void){
//do nothing return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
} }
/* /*
* Dim, virtual * Dim, virtual
*/ */
int Device::dim(unsigned char level){ int Device::dim(unsigned char level){
//do nothing return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
} }
/* /*

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "TellUsbD101.h" #include "telldus-core.h"
class Device class Device
{ {

View file

@ -8,6 +8,10 @@
using namespace std; using namespace std;
#ifdef _WINDOWS
#define strcasecmp(x, y) _strcmpi(x, y)
#endif
/* /*
* Constructor * Constructor
*/ */

View file

@ -1,4 +1,4 @@
LIBRARY TellUsbD101 LIBRARY telldus-core
EXPORTS EXPORTS
devGetNumberOfDevices @1 devGetNumberOfDevices @1
devGetDeviceId @2 devGetDeviceId @2

View file

@ -2,9 +2,9 @@
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8,00" Version="8,00"
Name="TellUsbD101" Name="telldus-core"
ProjectGUID="{2A868E40-88D9-4800-A83F-21D0F8DCB611}" ProjectGUID="{2A868E40-88D9-4800-A83F-21D0F8DCB611}"
RootNamespace="TellUsbD101" RootNamespace="TelldusCore"
Keyword="Win32Proj" Keyword="Win32Proj"
> >
<Platforms> <Platforms>
@ -61,8 +61,9 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="advapi32.lib oleaut32.lib"
LinkIncremental="2" LinkIncremental="2"
ModuleDefinitionFile="$(SolutionDir)\tellTest3\tellTest3.def" ModuleDefinitionFile="libtelldus-core.def"
GenerateDebugInformation="true" GenerateDebugInformation="true"
SubSystem="2" SubSystem="2"
TargetMachine="1" TargetMachine="1"
@ -117,7 +118,7 @@
/> />
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;TellUsbD101_EXPORTS" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;TelldusCore_EXPORTS"
GeneratePreprocessedFile="0" GeneratePreprocessedFile="0"
RuntimeLibrary="0" RuntimeLibrary="0"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
@ -138,7 +139,7 @@
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="advapi32.lib oleaut32.lib" AdditionalDependencies="advapi32.lib oleaut32.lib"
LinkIncremental="1" LinkIncremental="1"
ModuleDefinitionFile="TellUsbD101.def" ModuleDefinitionFile="libtelldus-core.def"
GenerateDebugInformation="true" GenerateDebugInformation="true"
SubSystem="2" SubSystem="2"
OptimizeReferences="2" OptimizeReferences="2"
@ -179,6 +180,10 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
> >
<File
RelativePath=".\Device.cpp"
>
</File>
<File <File
RelativePath=".\win\Device.cpp" RelativePath=".\win\Device.cpp"
> >
@ -201,10 +206,6 @@
/> />
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath=".\Device.cpp"
>
</File>
<File <File
RelativePath=".\DeviceIkea.cpp" RelativePath=".\DeviceIkea.cpp"
> >
@ -225,6 +226,10 @@
RelativePath=".\stdafx.cpp" RelativePath=".\stdafx.cpp"
> >
</File> </File>
<File
RelativePath=".\telldus-core.cpp"
>
</File>
<File <File
RelativePath=".\settings\TelldusSettings.cpp" RelativePath=".\settings\TelldusSettings.cpp"
> >
@ -233,10 +238,6 @@
RelativePath=".\settings\TelldusSettingsWinRegistry.cpp" RelativePath=".\settings\TelldusSettingsWinRegistry.cpp"
> >
</File> </File>
<File
RelativePath=".\TellUsbD101.cpp"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Header Files" Name="Header Files"
@ -276,11 +277,11 @@
> >
</File> </File>
<File <File
RelativePath=".\settings\TelldusSettings.h" RelativePath=".\telldus-core.h"
> >
</File> </File>
<File <File
RelativePath=".\TellUsbD101.h" RelativePath=".\settings\TelldusSettings.h"
> >
</File> </File>
</Filter> </Filter>
@ -290,7 +291,7 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
> >
<File <File
RelativePath=".\TellUsbD101.def" RelativePath=".\libtelldus-core.def"
> >
</File> </File>
</Filter> </Filter>

View file

@ -8,7 +8,7 @@
#include "stdafx.h" #include "stdafx.h"
#include <ole2.h> #include <ole2.h>
#endif #endif
#include "TellUsbD101.h" #include "telldus-core.h"
#include "settings/TelldusSettings.h" #include "settings/TelldusSettings.h"
#include "Device.h" #include "Device.h"
#include <vector> #include <vector>

View file

@ -1,16 +1,16 @@
#ifndef TELLUSBD101_H #ifndef TELLDUSCORE_H
#define TELLUSBD101_H #define TELLDUSCORE_H
// The following ifdef block is the standard way of creating macros // The following ifdef block is the standard way of creating macros
// which make exporting from a DLL simpler. All files within this DLL // which make exporting from a DLL simpler. All files within this DLL
// are compiled with the TellUsbD101_EXPORTS symbol defined on the command line. // are compiled with the TelldusCore_EXPORTS symbol defined on the command line.
// This symbol should not be defined on any project that uses this DLL. // This symbol should not be defined on any project that uses this DLL.
// This way any other project whose source files include this file see // This way any other project whose source files include this file see
// TELLSTICK_API functions as being imported from a DLL, whereas this DLL // TELLSTICK_API functions as being imported from a DLL, whereas this DLL
// sees symbols defined with this macro as being exported. // sees symbols defined with this macro as being exported.
#ifdef _WINDOWS #ifdef _WINDOWS
#ifdef TellUsbD101_EXPORTS #ifdef TelldusCore_EXPORTS
#define TELLSTICK_API __declspec(dllexport) #define TELLSTICK_API __declspec(dllexport)
#else #else
#define TELLSTICK_API __declspec(dllimport) #define TELLSTICK_API __declspec(dllimport)

View file

@ -4,6 +4,10 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#ifdef _WINDOWS
#include "..\StdAfx.h"
#endif
#include "ftd2xx.h" #include "ftd2xx.h"
int getDongleIndex(); int getDongleIndex();
@ -11,7 +15,7 @@ int getDongleIndex();
/* /*
* Send message to the USB dongle * Send message to the USB dongle
*/ */
void Device::send(char* strMessage){ int Device::send(char* strMessage){
try{ try{
FT_STATUS ftStatus = FT_OK; FT_STATUS ftStatus = FT_OK;
@ -19,7 +23,7 @@ void Device::send(char* strMessage){
int intDongleIndex = getDongleIndex(); int intDongleIndex = getDongleIndex();
if (intDongleIndex < 0) { if (intDongleIndex < 0) {
return; return TELLSTICK_ERROR_NOT_FOUND;
} }
ftStatus = FT_Open(intDongleIndex, &fthHandle); ftStatus = FT_Open(intDongleIndex, &fthHandle);
@ -35,6 +39,7 @@ void Device::send(char* strMessage){
catch(...){ catch(...){
throw; throw;
} }
return TELLSTICK_SUCCESS;
} }
/* /*
@ -49,7 +54,9 @@ int getDongleIndex(){
try{ try{
DWORD dwNumberOfDevices = 0; DWORD dwNumberOfDevices = 0;
#ifndef _WINDOWS
FT_SetVIDPID(0x1781, 0x0C30); FT_SetVIDPID(0x1781, 0x0C30);
#endif
ftStatus = FT_CreateDeviceInfoList(&dwNumberOfDevices); ftStatus = FT_CreateDeviceInfoList(&dwNumberOfDevices);
if (ftStatus == FT_OK) { if (ftStatus == FT_OK) {
for (int i = 0; i < (int)dwNumberOfDevices; i++) { for (int i = 0; i < (int)dwNumberOfDevices; i++) {

View file

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2001-2003 Future Technology Devices International Ltd. Copyright (c) 2001-2005 Future Technology Devices International Ltd.
Module Name: Module Name:
@ -8,7 +8,7 @@ Module Name:
Abstract: Abstract:
Native USB interface for FTDI FT8U232/245/2232C Native USB device driver for FTDI FT8U232/245
FTD2XX library definitions FTD2XX library definitions
Environment: Environment:
@ -17,14 +17,21 @@ Environment:
Revision History: Revision History:
13/03/01 awm Created. 13/03/01 awm Created.
13/01/03 awm Added device information support. 13/01/03 awm Added device information support.
19/03/03 awm Added FT_W32_CancelIo. 19/03/03 awm Added FT_W32_CancelIo.
12/06/03 awm Added FT_StopInTask and FT_RestartInTask. 12/06/03 awm Added FT_StopInTask and FT_RestartInTask.
18/09/03 awm Added FT_SetResetPipeRetryCount. 18/09/03 awm Added FT_SetResetPipeRetryCount.
10/10/03 awm Added FT_ResetPort. 10/10/03 awm Added FT_ResetPort.
/03/04 st modified for linux users 23/01/04 awm Added support for open-by-location.
12/10/04 st added FT_SetVIDPID 16/03/04 awm Added support for FT2232C.
23/09/04 awm Added support for FT232R.
20/10/04 awm Added FT_CyclePort.
18/01/05 awm Added FT_DEVICE_LIST_INFO_NODE type.
11/02/05 awm Added LocId to FT_DEVICE_LIST_INFO_NODE.
25/08/05 awm Added FT_SetDeadmanTimeout.
02/12/05 awm Removed obsolete references.
05/12/05 awm Added FT_GetVersion, FT_GetVersionEx.
--*/ --*/
@ -33,11 +40,6 @@ Revision History:
#ifndef FTD2XX_H #ifndef FTD2XX_H
#define FTD2XX_H #define FTD2XX_H
#ifndef _WINDOWS
#include <pthread.h>
#define WINAPI
#endif
// The following ifdef block is the standard way of creating macros // The following ifdef block is the standard way of creating macros
// which make exporting from a DLL simpler. All files within this DLL // which make exporting from a DLL simpler. All files within this DLL
// are compiled with the FTD2XX_EXPORTS symbol defined on the command line. // are compiled with the FTD2XX_EXPORTS symbol defined on the command line.
@ -52,45 +54,29 @@ Revision History:
#define FTD2XX_API __declspec(dllimport) #define FTD2XX_API __declspec(dllimport)
#endif #endif
#ifndef _WINDOWS
#include "WinTypes.h"
#ifdef FTD2XX_API typedef PVOID FT_HANDLE;
#undef FTD2XX_API typedef ULONG FT_STATUS;
#define FTD2XX_API
#endif
#endif
typedef struct _EVENT_HANDLE{
pthread_cond_t eCondVar;
pthread_mutex_t eMutex;
int iVar;
} EVENT_HANDLE;
typedef DWORD *FT_HANDLE;
//typedef unsigned int FT_HANDLE;
//typedef struct ftdi_device * FT_HANDLE;
typedef ULONG FT_STATUS;
// //
// Device status // Device status
// //
enum { enum {
FT_OK, FT_OK,
FT_INVALID_HANDLE, FT_INVALID_HANDLE,
FT_DEVICE_NOT_FOUND, FT_DEVICE_NOT_FOUND,
FT_DEVICE_NOT_OPENED, FT_DEVICE_NOT_OPENED,
FT_IO_ERROR, FT_IO_ERROR,
FT_INSUFFICIENT_RESOURCES, FT_INSUFFICIENT_RESOURCES,
FT_INVALID_PARAMETER, FT_INVALID_PARAMETER,
FT_INVALID_BAUD_RATE, //7 FT_INVALID_BAUD_RATE,
FT_DEVICE_NOT_OPENED_FOR_ERASE, FT_DEVICE_NOT_OPENED_FOR_ERASE,
FT_DEVICE_NOT_OPENED_FOR_WRITE, FT_DEVICE_NOT_OPENED_FOR_WRITE,
FT_FAILED_TO_WRITE_DEVICE, FT_FAILED_TO_WRITE_DEVICE,
FT_EEPROM_READ_FAILED, FT_EEPROM_READ_FAILED,
FT_EEPROM_WRITE_FAILED, FT_EEPROM_WRITE_FAILED,
FT_EEPROM_ERASE_FAILED, FT_EEPROM_ERASE_FAILED,
FT_EEPROM_NOT_PRESENT, FT_EEPROM_NOT_PRESENT,
FT_EEPROM_NOT_PROGRAMMED, FT_EEPROM_NOT_PROGRAMMED,
FT_INVALID_ARGS, FT_INVALID_ARGS,
@ -107,6 +93,7 @@ enum {
#define FT_OPEN_BY_SERIAL_NUMBER 1 #define FT_OPEN_BY_SERIAL_NUMBER 1
#define FT_OPEN_BY_DESCRIPTION 2 #define FT_OPEN_BY_DESCRIPTION 2
#define FT_OPEN_BY_LOCATION 4
// //
// FT_ListDevices Flags (used in conjunction with FT_OpenEx Flags // FT_ListDevices Flags (used in conjunction with FT_OpenEx Flags
@ -114,7 +101,7 @@ enum {
#define FT_LIST_NUMBER_ONLY 0x80000000 #define FT_LIST_NUMBER_ONLY 0x80000000
#define FT_LIST_BY_INDEX 0x40000000 #define FT_LIST_BY_INDEX 0x40000000
#define FT_LIST_ALL 0x20000000 #define FT_LIST_ALL 0x20000000
#define FT_LIST_MASK (FT_LIST_NUMBER_ONLY|FT_LIST_BY_INDEX|FT_LIST_ALL) #define FT_LIST_MASK (FT_LIST_NUMBER_ONLY|FT_LIST_BY_INDEX|FT_LIST_ALL)
@ -206,15 +193,16 @@ enum {
FT_DEVICE_AM, FT_DEVICE_AM,
FT_DEVICE_100AX, FT_DEVICE_100AX,
FT_DEVICE_UNKNOWN, FT_DEVICE_UNKNOWN,
FT_DEVICE_2232C, FT_DEVICE_2232C,
FT_DEVICE_232R FT_DEVICE_232R
}; };
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
FTD2XX_API FTD2XX_API
FT_STATUS WINAPI FT_Open( FT_STATUS WINAPI FT_Open(
int deviceNumber, int deviceNumber,
@ -235,18 +223,6 @@ FT_STATUS WINAPI FT_ListDevices(
DWORD Flags DWORD Flags
); );
FTD2XX_API
FT_STATUS FT_SetVIDPID(
DWORD dwVID,
DWORD dwPID
);
FTD2XX_API
FT_STATUS FT_GetVIDPID(
DWORD * pdwVID,
DWORD * pdwPID
);
FTD2XX_API FTD2XX_API
FT_STATUS WINAPI FT_Close( FT_STATUS WINAPI FT_Close(
FT_HANDLE ftHandle FT_HANDLE ftHandle
@ -508,11 +484,10 @@ typedef struct ft_program_data {
UCHAR Cbus3; // Cbus Mux control UCHAR Cbus3; // Cbus Mux control
UCHAR Cbus4; // Cbus Mux control UCHAR Cbus4; // Cbus Mux control
UCHAR RIsVCP; // zero if using VCP drivers UCHAR RIsVCP; // non-zero if using VCP drivers
} FT_PROGRAM_DATA, *PFT_PROGRAM_DATA; } FT_PROGRAM_DATA, *PFT_PROGRAM_DATA;
FTD2XX_API FTD2XX_API
FT_STATUS WINAPI FT_EE_Program( FT_STATUS WINAPI FT_EE_Program(
FT_HANDLE ftHandle, FT_HANDLE ftHandle,
@ -522,7 +497,7 @@ FT_STATUS WINAPI FT_EE_Program(
FTD2XX_API FTD2XX_API
FT_STATUS WINAPI FT_EE_ProgramEx( FT_STATUS WINAPI FT_EE_ProgramEx(
FT_HANDLE ftHandle, FT_HANDLE ftHandle,
PFT_PROGRAM_DATA lpData, PFT_PROGRAM_DATA pData,
char *Manufacturer, char *Manufacturer,
char *ManufacturerId, char *ManufacturerId,
char *Description, char *Description,
@ -538,7 +513,7 @@ FT_STATUS WINAPI FT_EE_Read(
FTD2XX_API FTD2XX_API
FT_STATUS WINAPI FT_EE_ReadEx( FT_STATUS WINAPI FT_EE_ReadEx(
FT_HANDLE ftHandle, FT_HANDLE ftHandle,
PFT_PROGRAM_DATA lpData, PFT_PROGRAM_DATA pData,
char *Manufacturer, char *Manufacturer,
char *ManufacturerId, char *ManufacturerId,
char *Description, char *Description,
@ -596,6 +571,12 @@ FT_STATUS WINAPI FT_SetUSBParameters(
FT_HANDLE ftHandle, FT_HANDLE ftHandle,
ULONG ulInTransferSize, ULONG ulInTransferSize,
ULONG ulOutTransferSize ULONG ulOutTransferSize
);
FTD2XX_API
FT_STATUS WINAPI FT_SetDeadmanTimeout(
FT_HANDLE ftHandle,
ULONG ulDeadmanTimeout
); );
FTD2XX_API FTD2XX_API
@ -629,6 +610,11 @@ FT_STATUS WINAPI FT_ResetPort(
FT_HANDLE ftHandle FT_HANDLE ftHandle
); );
FTD2XX_API
FT_STATUS WINAPI FT_CyclePort(
FT_HANDLE ftHandle
);
// //
// Win32-type functions // Win32-type functions
@ -822,6 +808,7 @@ BOOL WINAPI FT_W32_WaitCommEvent(
LPOVERLAPPED lpOverlapped LPOVERLAPPED lpOverlapped
); );
// //
// Device information // Device information
// //
@ -836,6 +823,7 @@ typedef struct _ft_device_list_info_node {
FT_HANDLE ftHandle; FT_HANDLE ftHandle;
} FT_DEVICE_LIST_INFO_NODE; } FT_DEVICE_LIST_INFO_NODE;
FTD2XX_API FTD2XX_API
FT_STATUS WINAPI FT_CreateDeviceInfoList( FT_STATUS WINAPI FT_CreateDeviceInfoList(
LPDWORD lpdwNumDevs LPDWORD lpdwNumDevs
@ -858,45 +846,25 @@ FT_STATUS WINAPI FT_GetDeviceInfoDetail(
LPVOID lpDescription, LPVOID lpDescription,
FT_HANDLE *pftHandle FT_HANDLE *pftHandle
); );
//
// Events
//
#define EV_RXCHAR 0x0001 // Any Character received
#define EV_RXFLAG 0x0002 // Received certain character
#define EV_TXEMPTY 0x0004 // Transmitt Queue Empty
#define EV_CTS 0x0008 // CTS changed state
#define EV_DSR 0x0010 // DSR changed state
#define EV_RLSD 0x0020 // RLSD changed state
#define EV_BREAK 0x0040 // BREAK received
#define EV_ERR 0x0080 // Line status error occurred
#define EV_RING 0x0100 // Ring signal detected
#define EV_PERR 0x0200 // Printer error occured
#define EV_RX80FULL 0x0400 // Receive buffer is 80 percent full
#define EV_EVENT1 0x0800 // Provider specific event 1
#define EV_EVENT2 0x1000 // Provider specific event 2
// //
// Escape Functions // Version information
// //
#define SETXOFF 1 // Simulate XOFF received FTD2XX_API
#define SETXON 2 // Simulate XON received FT_STATUS WINAPI FT_GetDriverVersion(
#define SETRTS 3 // Set RTS high FT_HANDLE ftHandle,
#define CLRRTS 4 // Set RTS low LPDWORD lpdwVersion
#define SETDTR 5 // Set DTR high );
#define CLRDTR 6 // Set DTR low
#define RESETDEV 7 // Reset device if possible FTD2XX_API
#define SETBREAK 8 // Set the device break line. FT_STATUS WINAPI FT_GetLibraryVersion(
#define CLRBREAK 9 // Clear the device break line. LPDWORD lpdwVersion
);
//
// PURGE function flags.
//
#define PURGE_TXABORT 0x0001 // Kill the pending/current writes to the comm port.
#define PURGE_RXABORT 0x0002 // Kill the pending/current reads to the comm port.
#define PURGE_TXCLEAR 0x0004 // Kill the transmit queue if there.
#define PURGE_RXCLEAR 0x0008 // Kill the typeahead buffer if there.
#ifdef __cplusplus #ifdef __cplusplus
} }
@ -905,8 +873,3 @@ FT_STATUS WINAPI FT_GetDeviceInfoDetail(
#endif /* FTD2XX_H */ #endif /* FTD2XX_H */