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

Increased the default buffer length to improve performance.

Added a special configuration of the ftdi module for high speed communications.
parent 79e9c99b
No related branches found
No related tags found
No related merge requests found
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
#include <string.h> #include <string.h>
#include "mutex.h" #include "mutex.h"
#define QUEUE_DEFAULT_SIZE 1024 #define QUEUE_DEFAULT_SIZE 256*1024
class CQueue class CQueue
{ {
private: private:
int size; int size;
int num_data; long int num_data;
int read_pointer; long int read_pointer;
int write_pointer; long int write_pointer;
unsigned char *data; unsigned char *data;
CMutex queue_access; CMutex queue_access;
public: public:
......
...@@ -70,32 +70,64 @@ void CFTDI::hard_config(void *config) ...@@ -70,32 +70,64 @@ void CFTDI::hard_config(void *config)
/* handle exceptions */ /* handle exceptions */
throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id);
} }
} //2. Set the data characteristics
//2. Set the data characteristics if(ftdi_config->word_length!=-1 && ftdi_config->stop_bits!=-1 && ftdi_config->parity!=-1)
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)
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 */ /* handle exceptions */
throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id);
} }
} }
//3. set read and write timeouts else
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 */ if((ft_status=FT_SetBitMode(this->ft_handle,0xFF,0x00))!=FT_OK)
throw CFTDIException(_HERE_,error_messages[ft_status],this->comm_id); {
/* 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);
}
} }
} }
......
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