Added finding of TellStick and TellStick Duo on Linux

This commit is contained in:
Micke Prag 2009-11-02 13:33:45 +00:00
parent c688af38c4
commit b2a9d42453
5 changed files with 36 additions and 3 deletions

View file

@ -55,6 +55,13 @@ ENDIF (SUPPORT_USB)
#### TellStickDuo ####
IF (SUPPORT_TELLSTICK_DUO)
#Only build library agains libftdi for TellStick Duo
FIND_LIBRARY(FTDI_LIBRARY ftdi)
SET( telldus-core_LIBRARIES
${telldus-core_LIBRARIES}
${FTDI_LIBRARY}
)
ADD_DEFINITIONS( -DTELLSTICK_DUO )
SET( telldus-core_SRCS
${telldus-core_SRCS}

View file

@ -39,6 +39,22 @@ int TellStick::findFirstDevice() {
}
std::string TellStick::findByVIDPID( int vid, int pid ) {
std::string retval = "";
#ifdef _LINUX
ftdi_context ftdic;
ftdi_init(&ftdic);
int ret = ftdi_usb_open(&ftdic, vid, pid);
if (ret == 0) {
retval = "1";
ftdi_usb_close(&ftdic);
}
ftdi_deinit(&ftdic);
#else
FT_HANDLE fthHandle = 0;
FT_STATUS ftStatus = FT_OK;
@ -71,7 +87,8 @@ std::string TellStick::findByVIDPID( int vid, int pid ) {
if(ftStatus == FT_OK){
if(pData.VendorId == vid && pData.ProductId == pid){
ftStatus = FT_Close(fthHandle);
return pData.SerialNumber;
retval = pData.SerialNumber;
break;
}
}
ftStatus = FT_Close(fthHandle);
@ -81,5 +98,6 @@ std::string TellStick::findByVIDPID( int vid, int pid ) {
catch(...){
throw;
}
return "";
#endif
return retval;
}

View file

@ -12,7 +12,7 @@
#ifndef TELLSTICK_H
#define TELLSTICK_H
#include "controller.h"
#include "Controller.h"
/**
@author Micke Prag <micke.prag@telldus.se>

View file

@ -14,6 +14,10 @@
#include <unistd.h>
#include <stdlib.h>
#ifdef _WINDOWS
typedef HANDLE EVENT_HANDLE;
#endif
using namespace TelldusCore;
namespace TelldusCore {

View file

@ -5,3 +5,7 @@
#include "osx/WinTypes.h"
#include "osx/ftd2xx.h"
#endif
#ifdef _LINUX
#include <ftdi.h>
#endif