diff --git a/src/cqueue.h b/src/cqueue.h index 02ce135d325e768610f089bb15b31a79687f7502..cd2b94f024e2446e862da4f7f32bdb7836370373 100755 --- a/src/cqueue.h +++ b/src/cqueue.h @@ -4,15 +4,15 @@ #include <string.h> #include "mutex.h" -#define QUEUE_DEFAULT_SIZE 1024 +#define QUEUE_DEFAULT_SIZE 256*1024 class CQueue { private: int size; - int num_data; - int read_pointer; - int write_pointer; + long int num_data; + long int read_pointer; + long int write_pointer; unsigned char *data; CMutex queue_access; public: diff --git a/src/usb_ftdi/ftdimodule.cpp b/src/usb_ftdi/ftdimodule.cpp index 7520d5d0e0374e201f39e7dd58235a1cccfc1b2b..33bd12fbee70c181d5992a36c5b10e6d52e63495 100644 --- a/src/usb_ftdi/ftdimodule.cpp +++ b/src/usb_ftdi/ftdimodule.cpp @@ -70,32 +70,64 @@ void CFTDI::hard_config(void *config) /* handle exceptions */ throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); } - } - //2. Set the data characteristics - if(ftdi_config->word_length!=-1 && ftdi_config->stop_bits!=-1 && ftdi_config->parity!=-1) - { - if((ft_status=FT_SetDataCharacteristics(this->ft_handle,ftdi_config->word_length,ftdi_config->stop_bits,ftdi_config->parity))!=FT_OK) + //2. Set the data characteristics + if(ftdi_config->word_length!=-1 && ftdi_config->stop_bits!=-1 && ftdi_config->parity!=-1) + { + if((ft_status=FT_SetDataCharacteristics(this->ft_handle,ftdi_config->word_length,ftdi_config->stop_bits,ftdi_config->parity))!=FT_OK) + { + /* handle exceptions */ + throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); + } + } + //3. set read and write timeouts + if((ft_status=FT_SetTimeouts(this->ft_handle,ftdi_config->read_timeout,ftdi_config->write_timeout))!=FT_OK) + { + /* handle exceptions */ + throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); + } + //4. Set latency timer + if((ft_status=FT_SetLatencyTimer(this->ft_handle,ftdi_config->latency_timer))!=FT_OK) + { + /* handle exceptions */ + throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); + } + if((ft_status=FT_SetFlowControl(this->ft_handle,FT_FLOW_NONE,0x00,0x00))!=FT_OK) { /* handle exceptions */ throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); } } - //3. set read and write timeouts - if((ft_status=FT_SetTimeouts(this->ft_handle,ftdi_config->read_timeout,ftdi_config->write_timeout))!=FT_OK) - { - /* handle exceptions */ - throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); - } - //4. Set latency timer - if((ft_status=FT_SetLatencyTimer(this->ft_handle,ftdi_config->latency_timer))!=FT_OK) - { - /* handle exceptions */ - throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); - } - if((ft_status=FT_SetFlowControl(this->ft_handle,FT_FLOW_NONE,0x00,0x00))!=FT_OK) + else { - /* handle exceptions */ - throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); + if((ft_status=FT_SetBitMode(this->ft_handle,0xFF,0x00))!=FT_OK) + { + /* handle exceptions */ + throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); + } + usleep(100); + + if((ft_status=FT_SetLatencyTimer(this->ft_handle,2))!=FT_OK) + { + /* handle exceptions */ + throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); + } + + if((ft_status=FT_SetUSBParameters(this->ft_handle,0x10000,0x10000))!=FT_OK) + { + /* handle exceptions */ + throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); + } + + if((ft_status=FT_SetFlowControl(this->ft_handle,FT_FLOW_RTS_CTS,0x00,0x00))!=FT_OK) + { + /* handle exceptions */ + throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); + } + if((ft_status=FT_Purge(this->ft_handle,FT_PURGE_RX))!=FT_OK) + { + /* handle exceptions */ + throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); + } } }