This is an automated email from the git hooks/post-receive script. mira-guest pushed a commit to branch master in repository garmindev.
commit de1c775b6afe9eb48d5b490a288f90c947d977e2 Author: Jaromír Mikeš <mira.mi...@seznam.cz> Date: Sat Apr 25 17:27:47 2015 +0200 Imported Upstream version 0.3.2 --- .kdev4/GarminDev.kdev4 | 14 ++ CMakeLists.txt | 23 ++- Doxyfile | 316 ---------------------------------------- GarminDev.kdev4 | 3 + GarminDev.kdevelop.pcs | Bin 306938 -> 0 bytes INSTALL | 54 +++++++ changelog.txt | 22 +++ cmake/Modules/FindUSB.cmake | 78 +++++----- src/CMakeLists.txt | 12 +- src/CSerial.cpp | 4 +- src/CTcp.cpp | 2 +- src/CUSB.cpp | 25 ++-- src/CUSB_MacOSX.cpp | 9 +- src/EtrexH/CDevice.cpp | 2 +- src/EtrexH/CMakeLists.txt | 4 +- src/EtrexLegend/CDevice.cpp | 11 -- src/EtrexLegend/CMakeLists.txt | 6 +- src/EtrexLegendC/CDevice.cpp | 2 +- src/EtrexLegendC/CMakeLists.txt | 6 +- src/GPSMap60CSx/CDevice.cpp | 239 +++++++++++++++++++++++------- src/GPSMap60CSx/CDevice.h | 5 +- src/GPSMap60CSx/CMakeLists.txt | 7 +- src/GPSMap60CSx/loader.cpp | 19 +++ src/GPSMap76/CDevice.cpp | 2 +- src/GPSMap76/CMakeLists.txt | 2 +- src/Garmin.cpp | 14 ++ src/Garmin.h | 2 + src/IDevice.h | 8 +- src/IDeviceDefault.cpp | 24 +++ src/IDeviceDefault.h | 3 + src/Platform.h | 6 +- src/whatGarmin/CMakeLists.txt | 4 +- svn-commit.tmp | 14 ++ 33 files changed, 477 insertions(+), 465 deletions(-) diff --git a/.kdev4/GarminDev.kdev4 b/.kdev4/GarminDev.kdev4 new file mode 100644 index 0000000..48e2c4c --- /dev/null +++ b/.kdev4/GarminDev.kdev4 @@ -0,0 +1,14 @@ +[Buildset] +BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x00) + +[CMake] +BuildDirs=/home/oeichler/data/cpp/build_GarminDev/ +CMakeDir=/usr/share/cmake/Modules +Current CMake Binary=file:///usr/bin/cmake +CurrentBuildDir=file:///home/oeichler/data/cpp/build_GarminDev/ +CurrentBuildType= +CurrentInstallDir= +ProjectRootRelative=./ + +[Project] +VersionControlSupport=kdevsubversion diff --git a/CMakeLists.txt b/CMakeLists.txt index 9152e4d..98da923 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,12 +9,12 @@ endif(COMMAND cmake_policy) #this one is for the API version check set(VER_MAJOR 01) -set(VER_MINOR 16) +set(VER_MINOR 17) #this one is for the release version set(PACKAGE_VER_MAJOR 0) set(PACKAGE_VER_MINOR 3) -set(PACKAGE_VER_PATCH 0) +set(PACKAGE_VER_PATCH 2) add_definitions(-DVER_MAJOR=${VER_MAJOR} -DVER_MINOR=${VER_MINOR}) @@ -32,8 +32,8 @@ include(DefineOptions.cmake) include(CPackConfig.cmake) # disallow in-source build -include(MacroEnsureOutOfSourceBuild) -macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.") +# include(MacroEnsureOutOfSourceBuild) +# macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.") # config.h generation include(ConfigureChecks.cmake) @@ -43,6 +43,21 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) +if(APPLE) + set(SHARED_LIB_EXT ".dylib") + set(QLANDKARTEGT_BUILD_DIR "../build_QLandkarteGT" + CACHE PATH "location of the QLandkarteGT build folder") + add_custom_target(mac-deploy + COMMAND + rm -rf "${QLANDKARTEGT_BUILD_DIR}/bin/QLandkarte\ GT.app/Contents/Resources/Drivers" && + mkdir -p "${QLANDKARTEGT_BUILD_DIR}/bin/QLandkarte\ GT.app/Contents/Resources/Drivers" && + tar -cpf - --exclude '*.a' -C ${LIBRARY_OUTPUT_PATH} . | + tar -xpf - -C "${QLANDKARTEGT_BUILD_DIR}/bin/QLandkarte\ GT.app/Contents/Resources/Drivers" + ) +elseif(UNIX) + set(SHARED_LIB_EXT ".so") +endif (APPLE) + find_package(USB REQUIRED) add_subdirectory(./src) diff --git a/Doxyfile b/Doxyfile deleted file mode 100644 index 19df53d..0000000 --- a/Doxyfile +++ /dev/null @@ -1,316 +0,0 @@ -# Doxyfile 1.5.6-KDevelop - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -DOXYFILE_ENCODING = UTF-8 -PROJECT_NAME = GarminDev -PROJECT_NUMBER = $VERSION$ -OUTPUT_DIRECTORY = -CREATE_SUBDIRS = NO -OUTPUT_LANGUAGE = English -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = YES -STRIP_FROM_PATH = /home/oeichler/Documents/ -STRIP_FROM_INC_PATH = -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = NO -QT_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -SEPARATE_MEMBER_PAGES = NO -TAB_SIZE = 8 -ALIASES = -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -OPTIMIZE_FOR_FORTRAN = NO -OPTIMIZE_OUTPUT_VHDL = NO -BUILTIN_STL_SUPPORT = NO -CPP_CLI_SUPPORT = NO -SIP_SUPPORT = NO -IDL_PROPERTY_SUPPORT = YES -DISTRIBUTE_GROUP_DOC = NO -SUBGROUPING = YES -TYPEDEF_HIDES_STRUCT = NO -SYMBOL_CACHE_SIZE = 0 -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = YES -EXTRACT_PRIVATE = YES -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = NO -EXTRACT_ANON_NSPACES = NO -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = YES -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -SORT_BRIEF_DOCS = NO -SORT_GROUP_NAMES = NO -SORT_BY_SCOPE_NAME = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -SHOW_USED_FILES = YES -SHOW_DIRECTORIES = YES -SHOW_FILES = YES -SHOW_NAMESPACES = YES -FILE_VERSION_FILTER = -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_NO_PARAMDOC = NO -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = /home/oeichler/data/cpp/GarminDev -INPUT_ENCODING = UTF-8 -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.d \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.php \ - *.php3 \ - *.inc \ - *.m \ - *.mm \ - *.dox \ - *.py \ - *.f90 \ - *.f \ - *.vhd \ - *.vhdl \ - *.C \ - *.CC \ - *.C++ \ - *.II \ - *.I++ \ - *.H \ - *.HH \ - *.H++ \ - *.CS \ - *.PHP \ - *.PHP3 \ - *.M \ - *.MM \ - *.PY \ - *.F90 \ - *.F \ - *.VHD \ - *.VHDL \ - *.C \ - *.H \ - *.tlh \ - *.diff \ - *.patch \ - *.moc \ - *.xpm \ - *.dox -RECURSIVE = yes -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXCLUDE_SYMBOLS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = * -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO -REFERENCES_RELATION = NO -REFERENCES_LINK_SOURCE = YES -USE_HTAGS = NO -VERBATIM_HEADERS = NO -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -GENERATE_DOCSET = NO -DOCSET_FEEDNAME = "Doxygen generated docs" -DOCSET_BUNDLE_ID = org.doxygen.Project -HTML_DYNAMIC_SECTIONS = NO -CHM_FILE = -HHC_LOCATION = -QTHELP_FILE = -QTHELP_CONFIG = -DOXYGEN2QTHELP_LOC = -GENERATE_CHI = NO -CHM_INDEX_ENCODING = -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = NONE -TREEVIEW_WIDTH = 250 -FORMULA_FONTSIZE = 10 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = yes -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -XML_PROGRAMLISTING = YES -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = GarminDev.tag -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = NO -MSCGEN_PATH = -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = YES -DOT_FONTNAME = FreeSans -DOT_FONTPATH = -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -GROUP_GRAPHS = YES -UML_LOOK = NO -TEMPLATE_RELATIONS = NO -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = NO -CALLER_GRAPH = NO -GRAPHICAL_HIERARCHY = YES -DIRECTORY_GRAPH = YES -DOT_IMAGE_FORMAT = png -DOT_PATH = -DOTFILE_DIRS = -DOT_GRAPH_MAX_NODES = 50 -MAX_DOT_GRAPH_DEPTH = 1000 -DOT_TRANSPARENT = NO -DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO diff --git a/GarminDev.kdev4 b/GarminDev.kdev4 new file mode 100644 index 0000000..deeaa43 --- /dev/null +++ b/GarminDev.kdev4 @@ -0,0 +1,3 @@ +[Project] +Manager=KDevCMakeManager +Name=GarminDev diff --git a/GarminDev.kdevelop.pcs b/GarminDev.kdevelop.pcs deleted file mode 100644 index ac91777..0000000 Binary files a/GarminDev.kdevelop.pcs and /dev/null differ diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..e616955 --- /dev/null +++ b/INSTALL @@ -0,0 +1,54 @@ +To compile the code make sure you meet the following dependencies: + + * cmake - a make file generator (>= Version 2.6) + +For the bleeding edge of development you have to use the SVN repository. For +initial checkout: + + svn co https://qlandkartegt.svn.sourceforge.net/svnroot/qlandkartegt/GarminDev/trunk GarminDev + +To build (out of source build, start one level above source root directory)1: + + mkdir build_GarminDev + + cd build_GarminDev + + ccmake ../GarminDev + +CCmake can be controlled by keys. Watch out for key hints at the bottom. +Especially the"c" and"g" key. Next you do: + + make + +The binary will be placed in ./bin. To catch up latest changes (in the source +root directory): + + svn up + +To send a patch (in the source root directory): + + svn diff > patchname.diff + +As user you might want to do a + + sudo make install + +to copy all stuff into your system. + + +Installation on Mac OS X +------------------------ + +On Mac OS X, you probably want to include the Garmin drivers in the bundle +where QLandkarteGT searches for them. To this end, when running ccmake be sure +to set the variable QLANDKARTEGT_BUILD_DIR to the folder where you built +QLandkarteGT. The default is "../build_QLandkarteGT", assuming that you use an +out-of-source build environment as suggested in the QLandkarteGT instructions. + +Then, after running make, simply say + + make mac-deploy + +which will copy all drivers to the bundle. + +You should not use "make install" on Mac OS X. diff --git a/changelog.txt b/changelog.txt index 3cf28bc..f8ade59 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,23 @@ +--- 2010.01.23 --- + +Bug #8: +Fix drivers to compile and work on OSX and big endian systems + +Request #9: +Add eTrex Legend Cx support + + + +--- 2009.12.21 --- + +Bug #6: +Fixed detect libusb + +Request #7: +Add download of routes (sofar GPSMap60SCx only) + + + --- 2009.06.22 --- Request #4: @@ -30,3 +50,5 @@ Initial Release + + diff --git a/cmake/Modules/FindUSB.cmake b/cmake/Modules/FindUSB.cmake index d0b28d4..ba27f40 100644 --- a/cmake/Modules/FindUSB.cmake +++ b/cmake/Modules/FindUSB.cmake @@ -13,13 +13,14 @@ # For details see the accompanying COPYING-CMAKE-SCRIPTS file. # - -if (USB_LIBRARIES AND USB_INCLUDE_DIRS) +if (LIBUSB_LIBRARIES AND LIBUSB_INCLUDE_DIRS) # in cache already - set(USB_FOUND TRUE) -else (USB_LIBRARIES AND USB_INCLUDE_DIRS) - - find_path(USB_INCLUDE_DIR + set(LIBUSB_FOUND TRUE) +elseif (APPLE) + # use system libraries + set(LIBUSB_FOUND FALSE) +else (LIBUSB_LIBRARIES AND LIBUSB_INCLUDE_DIRS) + find_path(LIBUSB_INCLUDE_DIR NAMES usb.h PATHS @@ -27,54 +28,49 @@ else (USB_LIBRARIES AND USB_INCLUDE_DIRS) /usr/local/include /opt/local/include /sw/include - PATH_SUFFIXES - usb + /usr/include/gdal + /usr/local/include/gdal + /opt/local/include/gdal + /sw/include/gdal ) - mark_as_advanced(USB_INCLUDE_DIR) + # debian uses version suffixes + # add suffix evey new release find_library(LIBUSB_LIBRARY NAMES usb PATHS - /usr/lib - /usr/local/lib - /opt/local/lib - /sw/lib + /usr/lib + /usr/lib64 + /usr/local/lib + /opt/local/lib + /sw/lib ) - mark_as_advanced(LIBUSB_LIBRARY) - - if (LIBUSB_LIBRARY) - set(LIBUSB_FOUND TRUE) - endif (LIBUSB_LIBRARY) - set(USB_INCLUDE_DIRS - ${USB_INCLUDE_DIR} + set(LIBUSB_INCLUDE_DIRS + ${LIBUSB_INCLUDE_DIR} ) + set(LIBUSB_LIBRARIES + ${LIBUSB_LIBRARY} + ) + + if (LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES) + set(LIBUSB_FOUND TRUE) + endif (LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES) if (LIBUSB_FOUND) - set(USB_LIBRARIES - ${USB_LIBRARIES} - ${LIBUSB_LIBRARY} - ) + if (NOT LIBUSB_FIND_QUIETLY) + message(STATUS "Found LIBUSB: ${LIBUSB_LIBRARIES}") + endif (NOT LIBUSB_FIND_QUIETLY) + else (LIBUSB_FOUND) + if (LIBUSB_FIND_REQUIRED) + message(FATAL_ERROR "Could not find LIBUSB") + endif (LIBUSB_FIND_REQUIRED) endif (LIBUSB_FOUND) - if (USB_INCLUDE_DIRS AND USB_LIBRARIES) - set(USB_FOUND TRUE) - endif (USB_INCLUDE_DIRS AND USB_LIBRARIES) - - if (USB_FOUND) - if (NOT USB_FIND_QUIETLY) - message(STATUS "Found USB: ${USB_LIBRARIES}") - endif (NOT USB_FIND_QUIETLY) - else (USB_FOUND) - if (USB_FIND_REQUIRED) - message(FATAL_ERROR "Could not find Libusb. Are the lib and the headers installed?") - endif (USB_FIND_REQUIRED) - endif (USB_FOUND) - - # show the USB_INCLUDE_DIRS and USB_LIBRARIES variables only in the advanced view - mark_as_advanced(USB_INCLUDE_DIRS USB_LIBRARIES) + # show the LIBUSB_INCLUDE_DIRS and LIBUSB_LIBRARIES variables only in the advanced view + mark_as_advanced(LIBUSB_INCLUDE_DIRS LIBUSB_LIBRARIES) -endif (USB_LIBRARIES AND USB_INCLUDE_DIRS) +endif (LIBUSB_LIBRARIES AND LIBUSB_INCLUDE_DIRS) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bd207bc..def25f4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,9 +19,10 @@ set(HDRS ILink.h ) -if(UNIX) +if(UNIX AND NOT APPLE) + include_directories(../ ${LIBUSB_INCLUDE_DIRS}) set(SRCS ${SRCS} CUSB.cpp CSerial.cpp) -endif(UNIX) +endif(UNIX AND NOT APPLE) if(APPLE) set(SRCS ${SRCS} CUSB_MacOSX.cpp CSerial.cpp) @@ -35,6 +36,11 @@ endif(WIN32) add_library(garmin STATIC ${SRCS} ${HDRS}) if(UNIX) + if(APPLE) + target_link_libraries( garmin "-F/Library/Frameworks -L/Library/Frameworks -framework IOKit -framework CoreFoundation") + else(APPLE) + target_link_libraries( garmin ${LIBUSB_LIBRARIES}) + endif(APPLE) SET_TARGET_PROPERTIES( garmin PROPERTIES COMPILE_FLAGS -fPIC) - install(FILES IDevice.h DESTINATION /usr/include/garmin/) + install(FILES IDevice.h DESTINATION ${INCLUDE_INSTALL_DIR}/garmin/) endif(UNIX) diff --git a/src/CSerial.cpp b/src/CSerial.cpp index 6458108..30a63c1 100644 --- a/src/CSerial.cpp +++ b/src/CSerial.cpp @@ -81,7 +81,7 @@ CSerial::~CSerial() #ifdef WIN32 void CSerial::open() { -#if defined(WORDS_BIGENDIAN) || !defined(CAN_UNALIGNED) +#if defined(HAVE_BIGENDIAN) || !defined(CAN_UNALIGNED) throw exce_t(errOpen, "The serial driver still needs to be ported to your platform."); #endif DCB dcb; @@ -153,7 +153,7 @@ void CSerial::open() // UNIX: void CSerial::open() { -#if defined(WORDS_BIGENDIAN) || !defined(CAN_UNALIGNED) +#if defined(HAVE_BIGENDIAN) || !defined(CAN_UNALIGNED) throw exce_t(errOpen, "The serial driver still needs to be ported to your platform."); #endif struct termios tty; diff --git a/src/CTcp.cpp b/src/CTcp.cpp index 0dee0c9..56ce859 100644 --- a/src/CTcp.cpp +++ b/src/CTcp.cpp @@ -99,7 +99,7 @@ struct in_addr * CTcp::atoaddr(char *address) void CTcp::open() { -#if defined(WORDS_BIGENDIAN) || !defined(CAN_UNALIGNED) +#if defined(HAVE_BIGENDIAN) || !defined(CAN_UNALIGNED) throw exce_t(errOpen, "The TCP driver still needs to be ported to your platform."); #endif uint16_t lport = -1; diff --git a/src/CUSB.cpp b/src/CUSB.cpp index 791b2e0..9119c46 100644 --- a/src/CUSB.cpp +++ b/src/CUSB.cpp @@ -41,7 +41,8 @@ using namespace std; #define GUSB_SESSION_START 5 #define GUSB_SESSION_STARTED 6 -#define USB_TIMEOUT 30000 +#define USB_INTERRUPT_TIMEOUT 3000 +#define USB_BULK_TIMEOUT 30000 #undef DBG @@ -116,6 +117,7 @@ void CUSB::close2() if(udev) { usb_release_interface(udev, theInterface); usb_reset(udev); + usb_close(udev); udev = 0; } } @@ -179,24 +181,24 @@ int CUSB::read(Packet_t& data) data.size = 0; if(doBulkRead) { - res = ::usb_bulk_read(udev,epBulkIn,(char*)&data,sizeof(data),USB_TIMEOUT); + res = ::usb_bulk_read(udev,epBulkIn,(char*)&data,sizeof(data),USB_BULK_TIMEOUT); if (res > 0) debug("b >>", data); -#if defined(WORDS_BIGENDIAN) +#if defined(HAVE_BIGENDIAN) // endian fix for id and size data.id = gar_endian(uint16_t, data.id); data.size = gar_endian(uint32_t, data.size); #endif // big endian platform } else { - res = ::usb_interrupt_read(udev,epIntrIn,(char*)&data,sizeof(data),USB_TIMEOUT); + res = ::usb_interrupt_read(udev,epIntrIn,(char*)&data,sizeof(data),USB_INTERRUPT_TIMEOUT); if (res > 0) debug("i >>", data); -#if defined(WORDS_BIGENDIAN) +#if defined(HAVE_BIGENDIAN) // endian fix for id and size data.id = gar_endian(uint16_t, data.id); data.size = gar_endian(uint32_t, data.size); @@ -235,7 +237,7 @@ void CUSB::write(const Packet_t& data) unsigned size = GUSB_HEADER_SIZE + data.size; char * src; -#if defined(WORDS_BIGENDIAN) +#if defined(HAVE_BIGENDIAN) // make a local copy for swapping the header Packet_t real_cmnd(data.type, gar_endian(uint16_t, data.id)); real_cmnd.size = gar_endian(uint32_t, data.size); @@ -250,8 +252,7 @@ void CUSB::write(const Packet_t& data) src = (char *) &data; #endif // big endian platform - int res = ::usb_bulk_write(udev,epBulkOut,src,size,USB_TIMEOUT); - + int res = ::usb_bulk_write(udev,epBulkOut,src,size,USB_BULK_TIMEOUT); debug("b <<", (Packet_t &) *src); if(res < 0) { @@ -266,7 +267,7 @@ void CUSB::write(const Packet_t& data) packet. */ if (size && !(size % max_tx_size)) { - ::usb_bulk_write(udev,epBulkOut,(char*)&data,0,USB_TIMEOUT); + ::usb_bulk_write(udev,epBulkOut,(char*)&data,0,USB_BULK_TIMEOUT); #ifdef DBG cout << "b << zero size packet to terminate" << endl; #endif @@ -286,6 +287,12 @@ void CUSB::start(struct usb_device *dev) throw exce_t(errOpen,msg.str()); } + if (dev->config == 0) { + stringstream msg; + msg << "USB device has no configuration: " << usb_strerror(); + throw exce_t(errOpen,msg.str()); + } + if (usb_set_configuration(udev, dev->config->bConfigurationValue) < 0) { stringstream msg; #if __linux__ diff --git a/src/CUSB_MacOSX.cpp b/src/CUSB_MacOSX.cpp index 07527ac..0443369 100644 --- a/src/CUSB_MacOSX.cpp +++ b/src/CUSB_MacOSX.cpp @@ -34,7 +34,7 @@ Apple is a registered trademark by Apple, Inc. #include "CUSB.h" #include "IDevice.h" -#include "../Platform.h" +#include "Platform.h" #include <iostream> #include <sstream> @@ -49,7 +49,8 @@ using namespace std; #define GUSB_SESSION_START 5 #define GUSB_SESSION_STARTED 6 -#undef DBG +//#undef DBG +#define DBG #define DBG_LINE_SIZE 16 @@ -377,7 +378,7 @@ int CUSB::read(Packet_t& data) if (res == kIOReturnSuccess && size > 0) { debug(doBulkRead ? "b >>" : "i >>", data); -#if defined(WORDS_BIGENDIAN) +#if defined(HAVE_BIGENDIAN) // endian fix for id and size data.id = gar_endian(uint16_t, data.id); data.size = gar_endian(uint32_t, data.size); @@ -408,7 +409,7 @@ void CUSB::write(const Packet_t& data) IOReturn res; char * src; -#if defined(WORDS_BIGENDIAN) +#if defined(HAVE_BIGENDIAN) // make a local copy for swapping the header Packet_t real_cmnd(data.type, gar_endian(uint16_t, data.id)); real_cmnd.size = gar_endian(uint32_t, data.size); diff --git a/src/EtrexH/CDevice.cpp b/src/EtrexH/CDevice.cpp index f63e141..b077fef 100644 --- a/src/EtrexH/CDevice.cpp +++ b/src/EtrexH/CDevice.cpp @@ -146,7 +146,7 @@ void CDevice::_acquire() int foundProducts = 0; uint16_t myid = 0; -#if defined(WORDS_BIGENDIAN) || !defined(CAN_UNALIGNED) +#if defined(HAVE_BIGENDIAN) || !defined(CAN_UNALIGNED) throw exce_t(errSync, "This device has not yet been ported to your platform."); #endif PROGR_CALLBACK ( 0,"acquiring" ); diff --git a/src/EtrexH/CMakeLists.txt b/src/EtrexH/CMakeLists.txt index 2b8dcd5..36a9287 100644 --- a/src/EtrexH/CMakeLists.txt +++ b/src/EtrexH/CMakeLists.txt @@ -14,7 +14,7 @@ set(HDRS include_directories(../) add_library(EtrexH SHARED ${SRCS} ${HDRS}) -target_link_libraries(EtrexH garmin usb pthread) +target_link_libraries(EtrexH garmin ${LIBUSB_LIBRARIES} pthread) set(ALIASES EtrexEuro @@ -24,7 +24,7 @@ foreach(var ${ALIASES}) message(" ${var}") add_custom_command( TARGET EtrexH POST_BUILD - COMMAND ln ARGS -sf libEtrexH.so lib${var}.so + COMMAND ln ARGS -sf libEtrexH${SHARED_LIB_EXT} lib${var}${SHARED_LIB_EXT} WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} ) endforeach(var) diff --git a/src/EtrexLegend/CDevice.cpp b/src/EtrexLegend/CDevice.cpp index c90a36f..1a552ac 100644 --- a/src/EtrexLegend/CDevice.cpp +++ b/src/EtrexLegend/CDevice.cpp @@ -91,17 +91,6 @@ void CDevice::_acquire() throw exce_t(errSync,msg); } - if(devid) { - if(serial->getProductId() != devid) { - string msg = "No " + devname + " unit detected. Please retry to select other device driver."; - throw exce_t(errSync,msg); - } - } - else { - string msg = "No " + devname + " unit detected. Please retry to select other device driver."; - throw exce_t(errSync,msg); - } - } diff --git a/src/EtrexLegend/CMakeLists.txt b/src/EtrexLegend/CMakeLists.txt index e3aff9c..4846902 100644 --- a/src/EtrexLegend/CMakeLists.txt +++ b/src/EtrexLegend/CMakeLists.txt @@ -10,9 +10,9 @@ set(HDRS CDevice.h ) -include_directories(../ ${USB_INCLUDE_DIRS}) +include_directories(../ ${LIBUSB_INCLUDE_DIRS}) add_library(EtrexLegend SHARED ${SRCS} ${HDRS}) -target_link_libraries(EtrexLegend garmin ${USB_LIBRARIES} pthread) +target_link_libraries(EtrexLegend garmin ${LIBUSB_LIBRARIES} pthread) set(ALIASES EtrexVista @@ -24,7 +24,7 @@ foreach(var ${ALIASES}) message(" ${var}") add_custom_command( TARGET EtrexLegend POST_BUILD - COMMAND ln ARGS -sf libEtrexLegend.so lib${var}.so + COMMAND ln ARGS -sf libEtrexLegend${SHARED_LIB_EXT} lib${var}${SHARED_LIB_EXT} WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} ) endforeach(var) diff --git a/src/EtrexLegendC/CDevice.cpp b/src/EtrexLegendC/CDevice.cpp index abcc4c5..0477593 100644 --- a/src/EtrexLegendC/CDevice.cpp +++ b/src/EtrexLegendC/CDevice.cpp @@ -192,7 +192,7 @@ const string& CDevice::getCopyright() void CDevice::_acquire() { -#if defined(WORDS_BIGENDIAN) || !defined(CAN_UNALIGNED) +#if defined(HAVE_BIGENDIAN) || !defined(CAN_UNALIGNED) throw exce_t(errSync, "This device has not yet been ported to your platform."); #endif usb = new CUSB(); diff --git a/src/EtrexLegendC/CMakeLists.txt b/src/EtrexLegendC/CMakeLists.txt index 9877730..c4f4190 100644 --- a/src/EtrexLegendC/CMakeLists.txt +++ b/src/EtrexLegendC/CMakeLists.txt @@ -10,9 +10,9 @@ set(HDRS CDevice.h ) -include_directories(../ ${USB_INCLUDE_DIRS}) +include_directories(../ ${LIBUSB_INCLUDE_DIRS}) add_library(EtrexLegendC SHARED ${SRCS} ${HDRS}) -target_link_libraries(EtrexLegendC garmin ${USB_LIBRARIES} pthread) +target_link_libraries(EtrexLegendC garmin ${LIBUSB_LIBRARIES} pthread) set(ALIASES EtrexVistaC @@ -24,7 +24,7 @@ foreach(var ${ALIASES}) message(" ${var}") add_custom_command( TARGET EtrexLegendC POST_BUILD - COMMAND ln ARGS -sf libEtrexLegendC.so lib${var}.so + COMMAND ln ARGS -sf libEtrexLegendC${SHARED_LIB_EXT} lib${var}${SHARED_LIB_EXT} WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} ) endforeach(var) diff --git a/src/GPSMap60CSx/CDevice.cpp b/src/GPSMap60CSx/CDevice.cpp index 6139cdf..f219ad6 100644 --- a/src/GPSMap60CSx/CDevice.cpp +++ b/src/GPSMap60CSx/CDevice.cpp @@ -33,6 +33,13 @@ using namespace GPSMap60CSx; using namespace Garmin; using namespace std; +#if defined(HAVE_BIGENDIAN) || !defined(CAN_UNALIGNED) +# define DBG_SHOW_WAYPOINT +# define UNTESTED throw exce_t(errSync, "This function has not yet been tested on your platform.") +#else +# define UNTESTED +#endif + namespace GPSMap60CSx { @@ -122,7 +129,7 @@ namespace GPSMap60CSx command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Command_Data; command.size = 2; - *(uint16_t*)command.payload = Cmnd_Start_Pvt_Data; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Start_Pvt_Data); dev->usb->write(command); while(dev->doRealtimeThread) { @@ -143,7 +150,7 @@ namespace GPSMap60CSx command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Command_Data; command.size = 2; - *(uint16_t*)command.payload = Cmnd_Stop_Pvt_Data; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Stop_Pvt_Data); dev->usb->write(command); dev->_release(); @@ -164,6 +171,8 @@ namespace GPSMap60CSx CDevice::CDevice() : devid(0) +, screenhflip(false) +, screenvflip(false) , usb(0) , doRealtimeThread(false) , pScreen(0) @@ -194,9 +203,6 @@ const string& CDevice::getCopyright() void CDevice::_acquire() { -#if defined(WORDS_BIGENDIAN) || !defined(CAN_UNALIGNED) - throw exce_t(errSync, "This device has not yet been ported to your platform."); -#endif usb = new CUSB(); usb->open(); if(devid == 0x01a5) { @@ -220,6 +226,7 @@ void CDevice::_acquire() void CDevice::_uploadMap(const uint8_t * mapdata, uint32_t size, const char * key) { if(usb == 0) return; + UNTESTED; Packet_t command; Packet_t response; int cancel = 0; @@ -235,16 +242,16 @@ void CDevice::_uploadMap(const uint8_t * mapdata, uint32_t size, const char * ke command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Command_Data; command.size = 2; - *(uint16_t*)command.payload = Cmnd_Transfer_Mem; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Transfer_Mem); usb->write(command); while(usb->read(response)) { if(response.id == Pid_Capacity_Data) { - cout << "free memory: " << dec << (((uint32_t*)response.payload)[1] / (1024*1024)) << " MB" << endl; - uint32_t memory = ((uint32_t*)response.payload)[1]; + uint32_t memory = gar_ptr_load(uint32_t, response.payload + 4); + cout << "free memory: " << dec << memory / (1024*1024) << " MB" << endl; if(memory < size) { stringstream msg; - msg << "Failed to send map: Unit has not enought memory (available/needed): " << memory << "/" << size << " bytes"; + msg << "Failed to send map: Unit has not enough memory (available/needed): " << memory << "/" << size << " bytes"; throw exce_t(errRuntime,msg.str()); } } @@ -271,7 +278,7 @@ void CDevice::_uploadMap(const uint8_t * mapdata, uint32_t size, const char * ke command.type = GUSB_APPLICATION_LAYER; command.id = 75; command.size = 2; - *(uint16_t*)command.payload = 0x000A; + *(uint16_t*)command.payload = gar_endian(uint16_t, 0x000A); usb->write(command); while(usb->read(response)) { @@ -291,7 +298,7 @@ void CDevice::_uploadMap(const uint8_t * mapdata, uint32_t size, const char * ke chunkSize = (size < (GUSB_PAYLOAD_SIZE - sizeof(offset))) ? size : (GUSB_PAYLOAD_SIZE - sizeof(offset)); command.size = chunkSize + sizeof(offset); - *(uint32_t*)command.payload = offset; + *(uint32_t*)command.payload = gar_endian(uint32_t, offset); memcpy(command.payload + sizeof(offset),mapdata,chunkSize); size -= chunkSize; mapdata += chunkSize; @@ -300,7 +307,7 @@ void CDevice::_uploadMap(const uint8_t * mapdata, uint32_t size, const char * ke usb->write(command); double progress = ((total - size) * 100.0) / total; - callback(progress,0,&cancel,0,"Transfering map data."); + callback(progress,0,&cancel,0,"Transferring map data."); } callback(100,0,&cancel,0,"done"); @@ -309,7 +316,7 @@ void CDevice::_uploadMap(const uint8_t * mapdata, uint32_t size, const char * ke command.type = GUSB_APPLICATION_LAYER; command.id = 45; command.size = 2; - *(uint16_t*)command.payload = 0x000A; + *(uint16_t*)command.payload = gar_endian(uint16_t, 0x000A); usb->write(command); } @@ -317,6 +324,7 @@ void CDevice::_uploadMap(const uint8_t * mapdata, uint32_t size, const char * ke void CDevice::_uploadMap(const char * filename, uint32_t size, const char * key) { if(usb == 0) return; + UNTESTED; Packet_t command; Packet_t response; int cancel = 0; @@ -332,16 +340,16 @@ void CDevice::_uploadMap(const char * filename, uint32_t size, const char * key) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Command_Data; command.size = 2; - *(uint16_t*)command.payload = Cmnd_Transfer_Mem; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Transfer_Mem); usb->write(command); while(usb->read(response)) { if(response.id == Pid_Capacity_Data) { - cout << "free memory: " << dec << (((uint32_t*)response.payload)[1] / (1024*1024)) << " MB" << endl; - uint32_t memory = ((uint32_t*)response.payload)[1]; + uint32_t memory = gar_ptr_load(uint32_t, response.payload + 4); + cout << "free memory: " << dec << memory / (1024*1024) << " MB" << endl; if(memory < size) { stringstream msg; - msg << "Failed to send map: Unit has not enought memory (available/needed): " << memory << "/" << size << " bytes"; + msg << "Failed to send map: Unit has not enough memory (available/needed): " << memory << "/" << size << " bytes"; throw exce_t(errRuntime,msg.str()); } } @@ -368,7 +376,7 @@ void CDevice::_uploadMap(const char * filename, uint32_t size, const char * key) command.type = GUSB_APPLICATION_LAYER; command.id = 75; command.size = 2; - *(uint16_t*)command.payload = 0x000A; + *(uint16_t*)command.payload = gar_endian(uint16_t, 0x000A); usb->write(command); while(usb->read(response)) { @@ -399,7 +407,7 @@ void CDevice::_uploadMap(const char * filename, uint32_t size, const char * key) fread(buffer, chunkSize, 1, fid); - *(uint32_t*)command.payload = offset; + *(uint32_t*)command.payload = gar_endian(uint32_t, offset); memcpy(command.payload + sizeof(offset),buffer,chunkSize); size -= chunkSize; offset += chunkSize; @@ -407,7 +415,7 @@ void CDevice::_uploadMap(const char * filename, uint32_t size, const char * key) usb->write(command); double progress = ((total - size) * 100.0) / total; - callback(progress,0,&cancel,0,"Transfering map data."); + callback(progress,0,&cancel,0,"Transferring map data."); } callback(100,0,&cancel,0,"done"); @@ -416,7 +424,7 @@ void CDevice::_uploadMap(const char * filename, uint32_t size, const char * key) command.type = GUSB_APPLICATION_LAYER; command.id = 45; command.size = 2; - *(uint16_t*)command.payload = 0x000A; + *(uint16_t*)command.payload = gar_endian(uint16_t, 0x000A); usb->write(command); } @@ -425,6 +433,7 @@ void CDevice::_queryMap(std::list<Map_t>& maps) { maps.clear(); if(usb == 0) return; + UNTESTED; Packet_t command; Packet_t response; @@ -509,7 +518,7 @@ void CDevice::_downloadWaypoints(list<Garmin::Wpt_t>& waypoints) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Command_Data; command.size = 2; - *(uint16_t*)command.payload = Cmnd_Transfer_Wpt; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Transfer_Wpt); usb->write(command); while(1) { @@ -517,7 +526,7 @@ void CDevice::_downloadWaypoints(list<Garmin::Wpt_t>& waypoints) if(response.id == Pid_Records) { #ifdef DBG_SHOW_WAYPOINT - cout << "number of waypoints:" << *(int16_t*)response.payload << endl; + cout << "number of waypoints:" << gar_ptr_load(uint16_t, response.payload) << endl; #endif } @@ -539,7 +548,7 @@ void CDevice::_downloadWaypoints(list<Garmin::Wpt_t>& waypoints) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Command_Data; command.size = 2; - *(uint16_t*)command.payload = Cmnd_Transfer_Prx; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Transfer_Prx); usb->write(command); while(1) { @@ -549,7 +558,7 @@ void CDevice::_downloadWaypoints(list<Garmin::Wpt_t>& waypoints) if(response.id == Pid_Records) { //TODO read data #ifdef DBG_SHOW_WAYPOINT - cout << "number of proximity waypoints:" << *(int16_t*)response.payload << endl; + cout << "number of proximity waypoints:" << gar_ptr_load(uint16_t, response.payload) << endl; #endif } @@ -627,7 +636,7 @@ void CDevice::_uploadWaypoints(std::list<Garmin::Wpt_t>& waypoints) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Records; command.size = 2; - *(uint16_t*)command.payload = prx_wpt_cnt; + *(uint16_t*)command.payload = gar_endian(uint16_t, prx_wpt_cnt); usb->write(command); wpt = waypoints.begin(); @@ -649,7 +658,7 @@ void CDevice::_uploadWaypoints(std::list<Garmin::Wpt_t>& waypoints) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Xfer_Cmplt; command.size = 2; - *(uint16_t*)command.payload = Cmnd_Transfer_Prx; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Transfer_Prx); usb->write(command); } @@ -659,7 +668,7 @@ void CDevice::_uploadWaypoints(std::list<Garmin::Wpt_t>& waypoints) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Records; command.size = 2; - *(uint16_t*)command.payload = waypoints.size(); + *(uint16_t*)command.payload = gar_endian(uint16_t, waypoints.size()); usb->write(command); wpt = waypoints.begin(); @@ -680,7 +689,7 @@ void CDevice::_uploadWaypoints(std::list<Garmin::Wpt_t>& waypoints) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Xfer_Cmplt; command.size = 2; - *(uint16_t*)command.payload = Cmnd_Transfer_Wpt; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Transfer_Wpt); usb->write(command); } @@ -704,13 +713,18 @@ void CDevice::_downloadTracks(std::list<Garmin::Track_t>& tracks) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Command_Data; command.size = 2; - *(uint16_t*)command.payload = Cmnd_Transfer_Trk; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Transfer_Trk); usb->write(command); int trackidx = 0; string name; Track_t * track = 0; - while(1) { + int cancel = 0; + int npts = 0; + int ntotal = 65535; + callback(0,0,&cancel,"Download tracks ...",0); + + while(!cancel) { if(!usb->read(response)) continue; @@ -725,6 +739,10 @@ void CDevice::_downloadTracks(std::list<Garmin::Track_t>& tracks) } + if(response.id == Pid_Records) { + ntotal = gar_ptr_load(uint16_t, response.payload); + } + if(response.id == Pid_Trk_Data) { D302_Trk_t * data = (D302_Trk_t*)response.payload; TrkPt_t pt; @@ -746,12 +764,26 @@ void CDevice::_downloadTracks(std::list<Garmin::Track_t>& tracks) pt << *data; track->track.push_back(pt); + + if (++npts % 100 == 0) { + double progress = (npts * 100.0) / ntotal; + callback(progress,0,&cancel,0,"Transferring track data."); + } } if(response.id == Pid_Xfer_Cmplt) { break; } } + if (cancel) { + command.type = GUSB_APPLICATION_LAYER; + command.id = Pid_Command_Data; + command.size = 2; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Abort_Transfer); + usb->write(command); + } + + callback(100,0,&cancel,0,"done"); } @@ -779,7 +811,7 @@ void CDevice::_uploadTracks(std::list<Garmin::Track_t>& tracks) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Records; command.size = 2; - *(uint16_t*)command.payload = nrec; + *(uint16_t*)command.payload = gar_endian(uint16_t, nrec); usb->write(command); // write track header @@ -821,7 +853,7 @@ void CDevice::_uploadTracks(std::list<Garmin::Track_t>& tracks) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Xfer_Cmplt; command.size = 2; - *(uint16_t*)command.payload = Cmnd_Transfer_Trk; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Transfer_Trk); usb->write(command); ++track; } @@ -829,6 +861,87 @@ void CDevice::_uploadTracks(std::list<Garmin::Track_t>& tracks) } +void CDevice::_downloadRoutes(std::list<Garmin::Route_t>& routes) +{ + routes.clear(); + if(usb == 0) return; + + Packet_t command; + Packet_t response; + + // ??? + command.type = GUSB_APPLICATION_LAYER; + command.id = 0x1C; + command.size = 2; + *(uint16_t*)command.payload = 0x0000; + usb->write(command); + + command.type = GUSB_APPLICATION_LAYER; + command.id = Pid_Command_Data; + command.size = 2; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Transfer_Rte); + usb->write(command); + + int routeidx = 0; + string name; + Route_t * route = 0; + int cancel = 0; + int npts = 0; + int ntotal = 65535; + callback(0,0,&cancel,"Download routes ...",0); + + while(!cancel) { + + if(!usb->read(response)) continue; + + if(response.id == Pid_Rte_Hdr) { + routeidx = 0; + D202_Rte_Hdr_t * hdr = (D202_Rte_Hdr_t*)response.payload; + routes.push_back(Route_t()); + route = &routes.back(); + + *route << *hdr; + name = hdr->ident; + } + + if(response.id == Pid_Records) { + ntotal = gar_ptr_load(uint16_t, response.payload); + } + + if(response.id == Pid_Rte_Wpt_Data) { + D110_Wpt_t * p = (D110_Wpt_t*)response.payload; + route->route.push_back(RtePt_t()); + RtePt_t& rtept = route->route.back(); + rtept << *p; + + if (++npts % 50 == 0) { + double progress = (npts * 100.0) / ntotal; + callback(progress,0,&cancel,0,"Transferring route data."); + } + } + + if(response.id == Pid_Rte_Link_Data) { + D210_Rte_Link_t * l = (D210_Rte_Link_t*)response.payload; + RtePt_t& rtept = route->route.back(); + rtept << *l; + } + + if(response.id == Pid_Xfer_Cmplt) { + break; + } + } + if (cancel) { + command.type = GUSB_APPLICATION_LAYER; + command.id = Pid_Command_Data; + command.size = 2; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Abort_Transfer); + usb->write(command); + } + + callback(100,0,&cancel,0,"done"); +} + + void CDevice::_uploadRoutes(list<Garmin::Route_t>& routes) { if(usb == 0) return; @@ -850,12 +963,12 @@ void CDevice::_uploadRoutes(list<Garmin::Route_t>& routes) list<Garmin::Route_t>::const_iterator route = routes.begin(); while(route != routes.end()) { //announce number of records - // D202_Rte_Hdr_t + (D110_Wpt_t + D210_Tre_Link_t) * number of route points + // D202_Rte_Hdr_t + (D110_Wpt_t + D210_Rte_Link_t) * number of route points uint16_t nrec = 1 + route->route.size() * 2; command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Records; command.size = 2; - *(uint16_t*)command.payload = nrec; + *(uint16_t*)command.payload = gar_endian(uint16_t, nrec); usb->write(command); // write route header @@ -896,7 +1009,7 @@ void CDevice::_uploadRoutes(list<Garmin::Route_t>& routes) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Xfer_Cmplt; command.size = 2; - *(uint16_t*)command.payload = Cmnd_Transfer_Rte; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Transfer_Rte); usb->write(command); ++route; } @@ -906,7 +1019,9 @@ void CDevice::_uploadRoutes(list<Garmin::Route_t>& routes) void CDevice::_uploadCustomIcons(list<Garmin::Icon_t>& icons) { - if(usb == 0) return; + cout << "running uploadCustomIcons for device " << hex << devid << endl; + + if(usb == 0) return; if(devid == 0x0231) return IDeviceDefault::_uploadCustomIcons(icons); @@ -928,7 +1043,7 @@ void CDevice::_uploadCustomIcons(list<Garmin::Icon_t>& icons) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Req_Icon_Id; command.size = 2; - *(uint16_t*)command.payload = icon->idx + 1; + *(uint16_t*)command.payload = gar_endian(uint16_t, icon->idx + 1); usb->write(command); while(usb->read(response)) { @@ -947,6 +1062,7 @@ void CDevice::_uploadCustomIcons(list<Garmin::Icon_t>& icons) while(usb->read(response)) { if(response.id == Pid_Ack_Clr_Tbl) { // send back color table + memcpy(response.payload + 4, icon->clrtbl, sizeof(icon->clrtbl)); command = response; } } @@ -1069,19 +1185,38 @@ void CDevice::_screenshot(char *& clrtbl, char *& data, int& width, int& height) *(uint32_t*)command.payload = tan; usb->write(command); - if(devid == 0x0312 || devid == 0x02b6) { - for(int r = 0; r < screenheight; ++r) { - for(int c = 0; c < screenwidth; ++c) { - pScreen[r * screenwidth + c] = buffer[(r + 1) * screenwidth - c - 1]; + cout << "device " << devname << " hor " << screenhflip << " vert " << screenvflip << endl; + + if(screenhflip) { + // screen shot is horizontally flipped + if(screenvflip) { + // screen shot is also vertically flipped + for(int r = 0; r < screenheight; ++r) { + for(int c = 0; c < screenwidth; ++c) { + pScreen[r * screenwidth + c] = buffer[(screenheight - r) * screenwidth - c - 1]; + } } - } - } - else { - for(int r = 0; r < screenheight; ++r) { - for(int c = 0; c < screenwidth; ++c) { - pScreen[r * screenwidth + c] = buffer[(screenheight - 1 - r) * screenwidth + c]; + } else { + // vertical organisation of the screen shot is fine + for(int r = 0; r < screenheight; ++r) { + for(int c = 0; c < screenwidth; ++c) { + pScreen[r * screenwidth + c] = buffer[(r + 1) * screenwidth - c - 1]; + } } - } + } + } else { + // horizontal organisation of the screen shot is fine + if(screenvflip) { + // screen shot is vertically flipped + for(int r = 0; r < screenheight; ++r) { + memcpy(pScreen + r * screenwidth, + buffer + (screenheight - 1 - r) * screenwidth, + screenwidth); + } + } else { + // vertical organisation of the screen shot is fine + memcpy(pScreen, buffer, screenheight * screenwidth); + } } clrtbl = aClrtbl; @@ -1135,7 +1270,7 @@ void CDevice::_getDevProperties(Garmin::DevProperties_t& dev_properties) command.type = GUSB_APPLICATION_LAYER; command.id = Pid_Command_Data; command.size = 2; - *(uint16_t*)command.payload = Cmnd_Transfer_Mem; + *(uint16_t*)command.payload = gar_endian(uint16_t, Cmnd_Transfer_Mem); usb->write(command); // try to read SD Ram capacity @@ -1143,8 +1278,8 @@ void CDevice::_getDevProperties(Garmin::DevProperties_t& dev_properties) uint16_t tile_limit = 0; while(usb->read(response)) { if(response.id == Pid_Capacity_Data) { - tile_limit = ((uint16_t*)response.payload)[1]; - memory = ((uint32_t*)response.payload)[1]; + tile_limit = gar_ptr_load(uint16_t, response.payload + 2); + memory = gar_ptr_load(uint32_t, response.payload + 4); } } if(tile_limit == 0) { diff --git a/src/GPSMap60CSx/CDevice.h b/src/GPSMap60CSx/CDevice.h index 348227a..78d412b 100644 --- a/src/GPSMap60CSx/CDevice.h +++ b/src/GPSMap60CSx/CDevice.h @@ -38,6 +38,8 @@ namespace GPSMap60CSx uint32_t devid; uint16_t screenwidth; uint16_t screenheight; + bool screenvflip; + bool screenhflip; const std::string& getCopyright(); @@ -51,7 +53,8 @@ namespace GPSMap60CSx void _downloadWaypoints(std::list<Garmin::Wpt_t>& waypoints); void _uploadWaypoints(std::list<Garmin::Wpt_t>& waypoints); void _downloadTracks(std::list<Garmin::Track_t>& tracks); - void _uploadTracks(std::list<Garmin::Track_t>& tracks); + void _uploadTracks(std::list<Garmin::Track_t>& tracks); + void _downloadRoutes(std::list<Garmin::Route_t>& routes); void _uploadRoutes(std::list<Garmin::Route_t>& routes); void _uploadCustomIcons(std::list<Garmin::Icon_t>& icons); void _screenshot(char *& clrtbl, char *& data, int& width, int& height); diff --git a/src/GPSMap60CSx/CMakeLists.txt b/src/GPSMap60CSx/CMakeLists.txt index 85d6ec9..d8a512b 100644 --- a/src/GPSMap60CSx/CMakeLists.txt +++ b/src/GPSMap60CSx/CMakeLists.txt @@ -10,9 +10,9 @@ set(HDRS CDevice.h ) -include_directories(../ ${USB_INCLUDE_DIRS}) +include_directories(../ ${LIBUSB_INCLUDE_DIRS}) add_library(GPSMap60CSx SHARED ${SRCS} ${HDRS}) -target_link_libraries(GPSMap60CSx garmin ${USB_LIBRARIES} pthread) +target_link_libraries(GPSMap60CSx garmin ${LIBUSB_LIBRARIES} pthread) set(ALIASES GPSMap60Cx @@ -24,6 +24,7 @@ set(ALIASES EtrexSummitHC EtrexVistaHCx EtrexLegendHCx + EtrexLegendCx GPSMap76Cx Quest ) @@ -32,7 +33,7 @@ foreach(var ${ALIASES}) message(" ${var}") add_custom_command( TARGET GPSMap60CSx POST_BUILD - COMMAND ln ARGS -sf libGPSMap60CSx.so lib${var}.so + COMMAND ln ARGS -sf libGPSMap60CSx${SHARED_LIB_EXT} lib${var}${SHARED_LIB_EXT} WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} ) endforeach(var) diff --git a/src/GPSMap60CSx/loader.cpp b/src/GPSMap60CSx/loader.cpp index 664c844..2208736 100644 --- a/src/GPSMap60CSx/loader.cpp +++ b/src/GPSMap60CSx/loader.cpp @@ -177,6 +177,7 @@ extern "C" WIN_EXPORT Garmin::IDevice * initEtrexVentureHC(const char * version) // GPSMap60CSx::device->devid = 0x0312; GPSMap60CSx::device->screenwidth = 176; GPSMap60CSx::device->screenheight = 220; + GPSMap60CSx::device->screenhflip = true; return GPSMap60CSx::device; } @@ -194,6 +195,7 @@ extern "C" WIN_EXPORT Garmin::IDevice * initEtrexVistaHCx(const char * version) GPSMap60CSx::device->devid = 0x02b6; GPSMap60CSx::device->screenwidth = 176; GPSMap60CSx::device->screenheight = 220; + GPSMap60CSx::device->screenhflip = true; return GPSMap60CSx::device; } @@ -211,6 +213,7 @@ extern "C" WIN_EXPORT Garmin::IDevice * initEtrexLegendHCx(const char * version) GPSMap60CSx::device->devid = 0x0694; GPSMap60CSx::device->screenwidth = 176; GPSMap60CSx::device->screenheight = 220; + GPSMap60CSx::device->screenhflip = true; return GPSMap60CSx::device; } @@ -231,3 +234,19 @@ extern "C" WIN_EXPORT Garmin::IDevice * initEtrexSummitHC(const char * version) return GPSMap60CSx::device; } + +extern "C" WIN_EXPORT Garmin::IDevice * initEtrexLegendCx(const char * version) +{ + if(strncmp(version,INTERFACE_VERSION,5) != 0) { + return 0; + } + if(GPSMap60CSx::device == 0) { + GPSMap60CSx::device = new GPSMap60CSx::CDevice(); + } + GPSMap60CSx::device->devname = "eTrex LegendCx"; + GPSMap60CSx::device->devid = 0x01A5; + GPSMap60CSx::device->screenwidth = 176; + GPSMap60CSx::device->screenheight = 220; + GPSMap60CSx::device->screenhflip = true; + return GPSMap60CSx::device; +} diff --git a/src/GPSMap76/CDevice.cpp b/src/GPSMap76/CDevice.cpp index e98084f..5479898 100644 --- a/src/GPSMap76/CDevice.cpp +++ b/src/GPSMap76/CDevice.cpp @@ -73,7 +73,7 @@ const string& CDevice::getCopyright() void CDevice::_acquire() { -#if defined(WORDS_BIGENDIAN) || !defined(CAN_UNALIGNED) +#if defined(HAVE_BIGENDIAN) || !defined(CAN_UNALIGNED) throw exce_t(errSync, "This device has not yet been ported to your platform."); #endif PROGR_CALLBACK ( 0,"acquiring" ); diff --git a/src/GPSMap76/CMakeLists.txt b/src/GPSMap76/CMakeLists.txt index dbb7bd0..8899ebc 100644 --- a/src/GPSMap76/CMakeLists.txt +++ b/src/GPSMap76/CMakeLists.txt @@ -24,7 +24,7 @@ foreach(var ${ALIASES}) message(" ${var}") add_custom_command( TARGET GPSMap76 POST_BUILD - COMMAND ln ARGS -sf libGPSMap76.so lib${var}.so + COMMAND ln ARGS -sf libGPSMap76${SHARED_LIB_EXT} lib${var}${SHARED_LIB_EXT} WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} ) endforeach(var) diff --git a/src/Garmin.cpp b/src/Garmin.cpp index 4bf4479..59090d7 100644 --- a/src/Garmin.cpp +++ b/src/Garmin.cpp @@ -375,12 +375,26 @@ namespace Garmin } + void operator<<(Route_t& tar, const D202_Rte_Hdr_t& src) { + tar.ident = src.ident; + } + int operator>>(const Route_t& src, D202_Rte_Hdr_t& tar) { char * pStr = tar.ident; strcpy(pStr,src.ident.c_str()); return src.ident.size() + 1; } + void operator<<(RtePt_t& tar, const D210_Rte_Link_t& src) { + tar.rte_class = gar_endian(uint16_t, src.rte_class); + tar.subclass_1 = gar_endian(uint16_t, src.subclass_1); + tar.subclass_2 = gar_endian(uint32_t, src.subclass_2); + tar.subclass_3 = gar_endian(uint32_t, src.subclass_3); + tar.subclass_4 = gar_endian(uint32_t, src.subclass_4); + tar.subclass_5 = gar_endian(uint32_t, src.subclass_5); + tar.ident = src.ident; + } + int operator>>(const RtePt_t& src, D210_Rte_Link_t& tar) { tar.rte_class = gar_endian(uint16_t, src.rte_class); tar.subclass_1 = gar_endian(uint16_t, src.subclass_1); diff --git a/src/Garmin.h b/src/Garmin.h index 1393f62..d57cc76 100644 --- a/src/Garmin.h +++ b/src/Garmin.h @@ -298,8 +298,10 @@ namespace Garmin extern void operator<<(Pvt_t& tar, const D800_Pvt_Data_t& src); struct Route_t; + extern void operator<<(Route_t& tar, const D202_Rte_Hdr_t& src); extern int operator>>(const Route_t& src, D202_Rte_Hdr_t& tar); struct RtePt_t; + extern void operator<<(RtePt_t& tar, const D210_Rte_Link_t& src); extern int operator>>(const RtePt_t& src, D210_Rte_Link_t& tar); struct Map_t; diff --git a/src/IDevice.h b/src/IDevice.h index 10762f6..77c2024 100644 --- a/src/IDevice.h +++ b/src/IDevice.h @@ -55,7 +55,7 @@ typedef unsigned __int64 uint64_t; #define _MKSTR(x) _MKSTR_1(x) #endif -#define INTERFACE_VERSION "01.16" +#define INTERFACE_VERSION "01.17" namespace Garmin { @@ -521,6 +521,12 @@ namespace Garmin */ virtual void uploadTracks(std::list<Garmin::Track_t>& tracks) = 0; + /// download routes from device + /** + @param routes list of routes + */ + virtual void downloadRoutes(std::list<Garmin::Route_t>& routes) = 0; + /// upload route to device /** @param routes list of routes diff --git a/src/IDeviceDefault.cpp b/src/IDeviceDefault.cpp index 9e4bea5..a14e139 100644 --- a/src/IDeviceDefault.cpp +++ b/src/IDeviceDefault.cpp @@ -200,6 +200,25 @@ void IDeviceDefault::uploadRoutes(std::list<Garmin::Route_t>& routes) } +void IDeviceDefault::downloadRoutes(std::list<Garmin::Route_t>& routes) +{ + lasterror = ""; + try + { + CMutexLocker lock(mutex); + _acquire(); + _downloadRoutes(routes); + _release(); + } + catch(exce_t& e) { + if(e.err != errBlocked) _release(); + lasterror = "Failed to download routes. " + e.msg; + throw (int)e.err; + } + +} + + void IDeviceDefault::uploadCustomIcons(std::list<Garmin::Icon_t>& icons) { lasterror = ""; @@ -340,6 +359,11 @@ void IDeviceDefault::_uploadTracks(std::list<Garmin::Track_t>& ) throw exce_t(errNotImpl,"uploadTracks(): this method is not implemented for your device."); } +void IDeviceDefault::_downloadRoutes(std::list<Garmin::Route_t>& ) +{ + throw exce_t(errNotImpl,"downloadRoutes(): this method is not implemented for your device."); +} + void IDeviceDefault::_uploadRoutes(std::list<Garmin::Route_t>& ) { throw exce_t(errNotImpl,"uploadRoutes(): this method is not implemented for your device."); diff --git a/src/IDeviceDefault.h b/src/IDeviceDefault.h index ab068bc..c5fb8b7 100644 --- a/src/IDeviceDefault.h +++ b/src/IDeviceDefault.h @@ -53,6 +53,8 @@ namespace Garmin virtual void downloadTracks(std::list<Garmin::Track_t>& tracks); /// see IDevice::uploadTracks() virtual void uploadTracks(std::list<Garmin::Track_t>& tracks); + /// see IDevice::downloadRoutes() + virtual void downloadRoutes(std::list<Garmin::Route_t>& routes); /// see IDevice::uploadRoutes() virtual void uploadRoutes(std::list<Garmin::Route_t>& routes); /// see IDevice::uploadCustomIcons() @@ -85,6 +87,7 @@ namespace Garmin virtual void _uploadWaypoints(std::list<Garmin::Wpt_t>& waypoints); virtual void _downloadTracks(std::list<Garmin::Track_t>& tracks); virtual void _uploadTracks(std::list<Garmin::Track_t>& tracks); + virtual void _downloadRoutes(std::list<Garmin::Route_t>& routes); virtual void _uploadRoutes(std::list<Garmin::Route_t>& routes); virtual void _uploadCustomIcons(std::list<Garmin::Icon_t>& icons); virtual void _screenshot(char *& clrtbl, char *& data, int& width, int& height); diff --git a/src/Platform.h b/src/Platform.h index 76d121a..d0f9dc0 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -32,7 +32,7 @@ The `configure' script in the top-level folder tries to detect if your machine is a little endian (like Intel or ARM) or a big endian (like PowerPC or Sparc). In the latter - case, it defines the macro WORDS_BIGENDIAN. In an other test, it checks if your machine + case, it defines the macro HAVE_BIGENDIAN. In an other test, it checks if your machine supports accessing unaligned memory (like Intel or PowerPC) or if such accesses would fail (as an ARM or Sparc). If unaligned accesses are supported, the macro CAN_UNALIGNED will be defined. Of course, the file config.h from the top-level folder has to be included. @@ -92,7 +92,7 @@ #ifndef __PLATFORM_H__ #define __PLATFORM_H__ -// include platform setup (WORDS_BIGENDIAN, CAN_UNALIGNED) +// include platform setup (HAVE_BIGENDIAN, CAN_UNALIGNED) #include "config.h" // need integer type definitions with fixed width @@ -184,7 +184,7 @@ __gar_endian_double(double x) uint64_t __uv = gar_endian(uint64_t, *(uint64_t *)&x); return *(double *) &__uv; } -#endif // WORDS_BIGENDIAN +#endif // HAVE_BIGENDIAN // -------------------------------------------------------------------------------------------- // macros to deal with pointers or unaligned arguments diff --git a/src/whatGarmin/CMakeLists.txt b/src/whatGarmin/CMakeLists.txt index 2d1b338..cccaaed 100644 --- a/src/whatGarmin/CMakeLists.txt +++ b/src/whatGarmin/CMakeLists.txt @@ -10,8 +10,8 @@ set(HDRS CDevice.h ) -include_directories(../ ${USB_INCLUDE_DIRS}) +include_directories(../ ${LIBUSB_INCLUDE_DIRS}) add_library(whatGarmin SHARED ${SRCS} ${HDRS}) -target_link_libraries(whatGarmin garmin ${USB_LIBRARIES} pthread) +target_link_libraries(whatGarmin garmin ${LIBUSB_LIBRARIES} pthread) diff --git a/svn-commit.tmp b/svn-commit.tmp new file mode 100644 index 0000000..1e0b680 --- /dev/null +++ b/svn-commit.tmp @@ -0,0 +1,14 @@ +add fixes for OSX and big endian stuff +-- Diese und die folgenden Zeilen werden ignoriert -- + +M cmake/Modules/FindUSB.cmake +M src/CUSB_MacOSX.cpp +M src/EtrexH/CDevice.cpp +M src/CSerial.cpp +M src/GPSMap76/CDevice.cpp +M src/EtrexLegendC/CDevice.cpp +M src/CTcp.cpp +M src/Platform.h +M src/GPSMap60CSx/CDevice.cpp +M src/CUSB.cpp +M src/CMakeLists.txt -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/garmindev.git _______________________________________________ Pkg-grass-devel mailing list Pkg-grass-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel