diff --git a/scripts/debian/postinst b/scripts/debian/postinst index 193597eea3704becc4e75fbe5b6288783853baac..d1b8187d634feb77d63fb9de31870d3bc87cdbc1 100755 --- a/scripts/debian/postinst +++ b/scripts/debian/postinst @@ -34,6 +34,9 @@ case "$1" in sudo echo " export PATH=\$PATH:\${iri_script_path}" >> $FILE sudo echo "fi" >> $FILE echo " Done. It's necessary a log out for changes to take effect." + + echo " Trying to add library to ldconfig..." + /usr/share/iri/add_lib_to_ld_config.sh -l comm -p && echo " Done." || echo " /usr/share/iri/add_lib_to_ld_config.sh doesn't exists. Download it from iriutils and execute it." ;; abort-upgrade) diff --git a/scripts/debian/prerm b/scripts/debian/prerm index 0ad26db1be77a2bef43d6c0f40dab52d02e1dfe8..b826b88ed70a3b7333c3454ba39288f8a4c7a981 100644 --- a/scripts/debian/prerm +++ b/scripts/debian/prerm @@ -12,6 +12,9 @@ case "$1" in sudo service udev restart echo " Done. Need to unplug-plug devices for changes to take effect" + echo " Trying to remove library from ldconfig..." + /usr/share/iri/remove_lib_from_ld_config.sh -l comm -p && echo " Done." || echo " /usr/share/iri/remove_lib_from_ld_config.sh doesn't exists. Download it from iriutils and execute it." + ;; upgrade) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index be1879269595f0193ad4db42a7bc22d5ae04a417..cf0b23446d0a4f20468505f4b304691a756f3c72 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,7 +27,7 @@ ELSE(FTDI_INCLUDE_DIRS AND FTDI_LIBRARIES) IF(FTDI_INCLUDE_DIRS AND FTDI_LIBRARIES) SET(BUILD_FTDI TRUE) SET(INSTALL_FTDI TRUE) - SET(FTDI_VER 1.3.6) + SET(FTDI_VER 1.4.8) MESSAGE(STATUS "Use local ftdi files") ELSE(FTDI_INCLUDE_DIRS AND FTDI_LIBRARIES) MESSAGE(STATUS "FTDI library won't be build. Impossible to locate the necessary files") diff --git a/src/comm.cpp b/src/comm.cpp index 3acf8a7f841046905bc147af039a0e6b65096813..0cb3c142099e70afdda4d6cb58d1afb80cb90c58 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -4,6 +4,7 @@ #include "comm.h" #include "commexceptions.h" #include "ctime.h" +#include "pthread.h" CComm::CComm(const std::string& comm_id) { @@ -212,7 +213,9 @@ void CComm::close(void) { /* finish the thread */ if(this->state==configured) + { this->thread_server->kill_thread(this->comm_thread_id); + } /* close the communication device */ this->access_comm.try_enter(); try{ @@ -238,7 +241,9 @@ void *CComm::comm_thread(void *param) while(!end) { + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL); wait_result=comm_dev->hard_wait_comm_event(); + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,NULL); try{ comm_dev->access_comm.enter(); if(wait_result==-1) @@ -256,6 +261,17 @@ void *CComm::comm_thread(void *param) } comm_dev->access_comm.exit(); }catch(CException &e){ + try{ + comm_dev->hard_close(); + }catch(CException &close){ + std::cout << close.what() << std::endl; + } + /* flush the data queues */ + comm_dev->receive_queue.flush(); + /* change the current state */ + comm_dev->state=created; + comm_dev->access_comm.exit(); + std::cout << e.what() << std::endl; end=true; } } @@ -309,16 +325,12 @@ void CComm::on_error(void) CComm::~CComm() { + this->close(); /* delete the events */ - if(this->rx_event_id.size()!=0) - this->event_server->delete_event(this->rx_event_id); - if(this->error_event_id.size()!=0) - { - this->event_server->delete_event(this->error_event_id); - } + this->event_server->delete_event(this->rx_event_id); + this->rx_event_id=""; + this->event_server->delete_event(this->error_event_id); + this->error_event_id=""; /* delete the thread */ - if(this->comm_thread_id.size()!=0) - { - this->thread_server->delete_thread(this->comm_thread_id); - } + this->thread_server->delete_thread(this->comm_thread_id); } diff --git a/tools/libftd2/ReadMe.txt b/tools/libftd2/ReadMe.txt index beb2f0586d1d3e806d44015ff31eb20f2898987a..9360df97d4d250a31eea4286af8867395516fc42 100644 --- a/tools/libftd2/ReadMe.txt +++ b/tools/libftd2/ReadMe.txt @@ -24,7 +24,7 @@ libusb is included in this distribution. Installing the D2XX shared library and static library. ------------------------------------------------------ -1. tar xfvz libftd2xx-i386-1.3.6.tgz +1. tar xfvz libftd2xx-i386-1.4.8.tgz This unpacks the archive, creating the following directory structure: @@ -32,7 +32,7 @@ This unpacks the archive, creating the following directory structure: libftd2xx (re-linkable objects) libusb (re-linkable objects) libftd2xx.a (static library) - libftd2xx.so.1.3.6 (dynamic library) + libftd2xx.so.1.4.8 (dynamic library) libftd2xx.txt (platform-specific information) examples libusb (source code) @@ -52,13 +52,13 @@ already root, then step 3 (and step 7) is not necessary. Copies the libraries to a central location. -5. chmod 0755 /usr/local/lib/libftd2xx.so.1.3.6 +5. chmod 0755 /usr/local/lib/libftd2xx.so.1.4.8 Allows non-root access to the shared object. -6. ln -sf /usr/local/lib/libftd2xx.so.1.3.6 /usr/local/lib/libftd2xx.so +6. ln -sf /usr/local/lib/libftd2xx.so.1.4.8 /usr/local/lib/libftd2xx.so -Creates a symbolic link to the 1.3.6 version of the shared object. +Creates a symbolic link to the 1.4.8 version of the shared object. 7. exit diff --git a/tools/libftd2/WinTypes.h b/tools/libftd2/WinTypes.h index 5114b955578430e1e250e6508ab342ce11982429..88e500e1a79b5c6f9dcc7180912f7eeddb316108 100755 --- a/tools/libftd2/WinTypes.h +++ b/tools/libftd2/WinTypes.h @@ -9,6 +9,7 @@ typedef unsigned short USHORT; typedef unsigned short SHORT; typedef unsigned char UCHAR; typedef unsigned short WORD; +typedef unsigned short WCHAR; typedef unsigned char BYTE; typedef BYTE *LPBYTE; typedef unsigned int BOOL; @@ -32,13 +33,19 @@ typedef ULONG *PULONG; typedef LONG *LPLONG; typedef PVOID LPVOID; typedef void VOID; +typedef USHORT *PUSHORT; typedef unsigned long long int ULONGLONG; typedef struct _OVERLAPPED { DWORD Internal; DWORD InternalHigh; - DWORD Offset; - DWORD OffsetHigh; + union { + struct{ + DWORD Offset; + DWORD OffsetHigh; + }; + PVOID Pointer; + }; HANDLE hEvent; } OVERLAPPED, *LPOVERLAPPED; @@ -61,13 +68,24 @@ typedef struct _EVENT_HANDLE typedef struct timeval SYSTEMTIME; typedef struct timeval FILETIME; + +// WaitForSingleObject return values. +#define WAIT_ABANDONED 0x00000080L +#define WAIT_OBJECT_0 0x00000000L +#define WAIT_TIMEOUT 0x00000102L +#define WAIT_FAILED 0xFFFFFFFF +// Special value for WaitForSingleObject dwMilliseconds parameter +#define INFINITE 0xFFFFFFFF // Infinite timeout + #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif - +#ifndef CONST +#define CONST const +#endif // // Modem Status Flags // diff --git a/tools/libftd2/build/i386/libftd2xx.so b/tools/libftd2/build/i386/libftd2xx.so index 0a78f94d732e3c98968766e205a00050f0a17d8d..e2386ef3164a8c6d7e14503c179191ffb1171635 120000 --- a/tools/libftd2/build/i386/libftd2xx.so +++ b/tools/libftd2/build/i386/libftd2xx.so @@ -1 +1 @@ -libftd2xx.so.1.3.6 \ No newline at end of file +libftd2xx.so.1.4.8 \ No newline at end of file diff --git a/tools/libftd2/build/i386/libftd2xx.so.1.3.6 b/tools/libftd2/build/i386/libftd2xx.so.1.3.6 deleted file mode 100755 index ba8c996d234d8712aa57f58605436b7dc5ff3e3d..0000000000000000000000000000000000000000 Binary files a/tools/libftd2/build/i386/libftd2xx.so.1.3.6 and /dev/null differ diff --git a/tools/libftd2/build/i386/libftd2xx.so.1.4.8 b/tools/libftd2/build/i386/libftd2xx.so.1.4.8 new file mode 100755 index 0000000000000000000000000000000000000000..9b0fcbc9988c3990cadcb4da719420c461adb3c2 Binary files /dev/null and b/tools/libftd2/build/i386/libftd2xx.so.1.4.8 differ diff --git a/tools/libftd2/build/x86_64/libftd2xx.so b/tools/libftd2/build/x86_64/libftd2xx.so index 0a78f94d732e3c98968766e205a00050f0a17d8d..e2386ef3164a8c6d7e14503c179191ffb1171635 120000 --- a/tools/libftd2/build/x86_64/libftd2xx.so +++ b/tools/libftd2/build/x86_64/libftd2xx.so @@ -1 +1 @@ -libftd2xx.so.1.3.6 \ No newline at end of file +libftd2xx.so.1.4.8 \ No newline at end of file diff --git a/tools/libftd2/build/x86_64/libftd2xx.so.1.3.6 b/tools/libftd2/build/x86_64/libftd2xx.so.1.3.6 deleted file mode 100755 index ecd25dbe29c05de403883419da0036aad679753f..0000000000000000000000000000000000000000 Binary files a/tools/libftd2/build/x86_64/libftd2xx.so.1.3.6 and /dev/null differ diff --git a/tools/libftd2/build/x86_64/libftd2xx.so.1.4.8 b/tools/libftd2/build/x86_64/libftd2xx.so.1.4.8 new file mode 100755 index 0000000000000000000000000000000000000000..d38df2f7a43fbf73e1774d7792e0e3ebff334b95 Binary files /dev/null and b/tools/libftd2/build/x86_64/libftd2xx.so.1.4.8 differ diff --git a/tools/libftd2/ftd2xx.h b/tools/libftd2/ftd2xx.h index e9b7fc55222129506765f97ca5a1c6c660f51225..e5bbb46820c1a0d8fa1ef68ed64ac3c02b97fb6c 100755 --- a/tools/libftd2/ftd2xx.h +++ b/tools/libftd2/ftd2xx.h @@ -58,6 +58,10 @@ kernel & user mode #elif defined(FTD2XX_STATIC) // Avoid decorations when linking statically to D2XX. #define FTD2XX_API +// Static D2XX depends on these Windows libs: +#pragma comment(lib, "setupapi.lib") +#pragma comment(lib, "advapi32.lib") +#pragma comment(lib, "user32.lib") #else #define FTD2XX_API __declspec(dllimport) #endif @@ -311,6 +315,18 @@ extern "C" { #endif +#ifdef FTD2XX_STATIC + FTD2XX_API + FT_STATUS WINAPI FT_Initialise( + void + ); + + FTD2XX_API + void WINAPI FT_Finalise( + void + ); +#endif // FTD2XX_STATIC + FTD2XX_API FT_STATUS WINAPI FT_Open( int deviceNumber, @@ -1162,7 +1178,7 @@ extern "C" { WORD XoffLim; /* Transmit X-OFF threshold */ BYTE ByteSize; /* Number of bits/byte, 4-8 */ BYTE Parity; /* 0-4=None,Odd,Even,Mark,Space */ - BYTE StopBits; /* 0,1,2 = 1, 1.5, 2 */ + BYTE StopBits; /* FT_STOP_BITS_1 or FT_STOP_BITS_2 */ char XonChar; /* Tx and Rx X-ON character */ char XoffChar; /* Tx and Rx X-OFF character */ char ErrorChar; /* Error replacement char */