Skip to content
Snippets Groups Projects
Commit ef37873f authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Merge branch 'pthread_cancel'

parents 39abc776 4bed725c
No related branches found
Tags 1.0.3
1 merge request!1Used the pthread_setcancelstate function to configure where the thread can be cancelled.
Pipeline #6584 passed
......@@ -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)
......
......@@ -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)
......
......@@ -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")
......
......@@ -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);
}
......@@ -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
......
......@@ -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
//
......
libftd2xx.so.1.3.6
\ No newline at end of file
libftd2xx.so.1.4.8
\ No newline at end of file
File deleted
File added
libftd2xx.so.1.3.6
\ No newline at end of file
libftd2xx.so.1.4.8
\ No newline at end of file
File deleted
File added
......@@ -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 */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment