diff --git a/.gitignore b/.gitignore index 17db614..d8a88d9 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ # Application Generated Files # ############################### *.cfg +.* # Logs and databases # ###################### @@ -78,4 +79,4 @@ CVS # Folders starting with underscore. # ##################################### -_* \ No newline at end of file +_* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9ef4971 --- /dev/null +++ b/Makefile @@ -0,0 +1,75 @@ +# +# Makefile for Libusbpp +# +# + +NAME = libusbpp +INCLUDE_PATH = ./headers + +# +# Compiler +# +# By default, the GNU C++ compiler is used. +# + +COMPILER = g++ +LINKER = g++ + +# +# Compiler and linker flags +# +# This variable holds the flags that are passed to the compiler. By default, +# we include the -O2 flag. This flag tells the compiler to optimize the code, +# but it makes debugging more difficult. So if you're debugging your application, +# you probably want to remove this -O2 flag. At the same time, you can then +# add the -g flag to instruct the compiler to include debug information in +# the library (but this will make the final file much bigger, so +# you want to leave that flag out on production servers). +# +#COMPILER_FLAGS = -Wall -c -ggdb3 -fpic -I${INCLUDE_PATH} -o +COMPILER_FLAGS = -Wall -c -O2 -fpic -I${INCLUDE_PATH} -o +LINKER_FLAGS = -lusb-1.0 -lpthread + +# +# Command to remove files, copy files and create directories. +# + +RM = rm -f +CP = cp -f +MKDIR = mkdir -p +LS = ls -1 + +# +# All source files are simply all *.cpp files found in the current directory +# +# A builtin Makefile macro is used to scan the current directory and find +# all source files. The object files are all compiled versions of the source +# file, with the .cpp extension being replaced by .o. +# + +SOURCES = $(wildcard ./src/*.cpp) +HEARDERS = $(wildcard ./src/*.hpp) +EXAMPELS = $(wildcard ./examples/*.cpp) +OBJECTS = $(SOURCES:%.cpp=%.o) $(EXAMPELS:%.cpp=%.o) +EXECUTABLES = $(EXAMPELS:%.cpp=%) + +# +# From here the build instructions start +# +all: ${EXECUTABLES} ${OBJECTS} ${SOURCES} ${HEARDERS} ${EXAMPELS} + echo ${EXECUTABLES} ${OBJECTS} ${SOURCES} ${HEARDERS} ${EXAMPELS} + +${OBJECTS}: ${SOURCES} ${HEARDERS} ${EXAMPELS} + ${COMPILER} ${COMPILER_FLAGS} $@ ${@:%.o=%.cpp} + +${EXECUTABLES}: ${OBJECTS} + ${LINKER} -o $@ ${OBJECTS} ${LINKER_FLAGS} + +test: .TEST + +.TEST: + ./examples/LibusbTest + +clean: + echo ${RM} ${OBJECTS} + ${RM} ${OBJECTS} diff --git a/src/ConfigurationImpl.hpp b/src/ConfigurationImpl.hpp index d907b6a..553ac57 100644 --- a/src/ConfigurationImpl.hpp +++ b/src/ConfigurationImpl.hpp @@ -25,7 +25,11 @@ #include #include -#include +#ifdef __linux__ + #include +#elif _WIN32 + #include +#endif #include diff --git a/src/DeviceImpl.cpp b/src/DeviceImpl.cpp index 4ddbeab..7c6adc0 100644 --- a/src/DeviceImpl.cpp +++ b/src/DeviceImpl.cpp @@ -22,7 +22,11 @@ #include #include -#include +#ifdef __linux__ + #include +#elif _WIN32 + #include +#endif #include #include @@ -155,7 +159,7 @@ std::wstring LibUSB::DeviceImpl::getStringDescriptorW( uint8_t index ) std::wstring strResult; strResult.resize((descSize-2)/2); - for (size_t i = 0; i < (descSize-2)/2; ++i) { + for (int i = 0; i < (descSize-2)/2; ++i) { unsigned char chr1 = (unsigned char)descStr[2 * i + 2]; unsigned char chr2 = (unsigned char)descStr[2 * i + 3]; diff --git a/src/DeviceImpl.hpp b/src/DeviceImpl.hpp index 78c2f3a..7a23e5c 100644 --- a/src/DeviceImpl.hpp +++ b/src/DeviceImpl.hpp @@ -25,7 +25,11 @@ #include #include -#include +#ifdef __linux__ + #include +#elif _WIN32 + #include +#endif #include diff --git a/src/EndpointImpl.hpp b/src/EndpointImpl.hpp index 62d7fe0..4233974 100644 --- a/src/EndpointImpl.hpp +++ b/src/EndpointImpl.hpp @@ -24,7 +24,11 @@ #include #include -#include +#ifdef __linux__ + #include +#elif _WIN32 + #include +#endif #include #include diff --git a/src/Exception.cpp b/src/Exception.cpp index 18d0e40..25521df 100644 --- a/src/Exception.cpp +++ b/src/Exception.cpp @@ -20,7 +20,11 @@ #include -#include +#ifdef __linux__ + #include +#elif _WIN32 + #include +#endif #include diff --git a/src/Interface.cpp b/src/Interface.cpp index f4cab21..a230a59 100644 --- a/src/Interface.cpp +++ b/src/Interface.cpp @@ -18,7 +18,11 @@ * along with libusbpp. If not, see . */ -#include +#ifdef __linux__ + #include +#elif _WIN32 + #include +#endif #include @@ -131,4 +135,3 @@ bool LibUSB::Interface::isClaimed() const return m_pInterfaceImpl->isClaimed(); } - diff --git a/src/InterfaceImpl.cpp b/src/InterfaceImpl.cpp index 0cd541e..d13ac86 100644 --- a/src/InterfaceImpl.cpp +++ b/src/InterfaceImpl.cpp @@ -29,7 +29,7 @@ LibUSB::InterfaceImpl::InterfaceImpl( const libusb_interface* pInterface, std::weak_ptr pDeviceImpl ) - : m_pInterface(pInterface), m_alternateSetting(0), m_bClaimed(false) + : m_alternateSetting(0), m_pInterface(pInterface), m_bClaimed(false) { if (!pDeviceImpl.expired()) diff --git a/src/InterfaceImpl.hpp b/src/InterfaceImpl.hpp index 2a627d9..627f295 100644 --- a/src/InterfaceImpl.hpp +++ b/src/InterfaceImpl.hpp @@ -25,7 +25,11 @@ #include #include -#include +#ifdef __linux__ + #include +#elif _WIN32 + #include +#endif #include @@ -74,7 +78,7 @@ namespace LibUSB /*! * \brief Selects an alternate interface setting. - * + * * * \param AlternateSetting (uint8_t): the index of the alternate setting to select/use. * \throws (std::logic_error) if the alternate setting is out-of-range. diff --git a/src/LibusbImpl.hpp b/src/LibusbImpl.hpp index 7433726..a0d2a6b 100644 --- a/src/LibusbImpl.hpp +++ b/src/LibusbImpl.hpp @@ -26,7 +26,11 @@ #include #include -#include +#ifdef __linux__ + #include +#elif _WIN32 + #include +#endif namespace LibUSB diff --git a/src/Transfer.cpp b/src/Transfer.cpp index 48566cb..d808e6f 100644 --- a/src/Transfer.cpp +++ b/src/Transfer.cpp @@ -233,7 +233,7 @@ void LibUSB::Transfer::AsyncStart() std::thread transferThread([=]() { - bool Result = false; + //bool Result = false; try { diff --git a/src/TransferImpl.cpp b/src/TransferImpl.cpp index e471350..82fbd47 100644 --- a/src/TransferImpl.cpp +++ b/src/TransferImpl.cpp @@ -32,7 +32,7 @@ LibUSB::TransferImpl::TransferImpl(std::weak_ptr pEndpointImpl) - : m_Timeout(0), m_Complete(false), m_Submitted(false), m_transferSize(0) + : m_Timeout(0), m_transferSize(0), m_Complete(false), m_Submitted(false) { if (pEndpointImpl.expired()) diff --git a/src/TransferImpl.hpp b/src/TransferImpl.hpp index bf71a6a..17f19ee 100644 --- a/src/TransferImpl.hpp +++ b/src/TransferImpl.hpp @@ -26,7 +26,11 @@ #include #include -#include +#ifdef __linux__ + #include +#elif _WIN32 + #include +#endif #include #include