ftdi.cpp
Go to the documentation of this file.
/***************************************************************************
ftdi.cpp - C++ wraper for libftdi
-------------------
begin : Mon Oct 13 2008
copyright : (C) 2008-2017 by Marek Vavruša / libftdi developers
email : opensource@intra2net.com and marek@vavrusa.com
***************************************************************************/
/*
Copyright (C) 2008-2017 by Marek Vavruša / libftdi developers
The software in this package is distributed under the GNU General
Public License version 2 (with a special exception described below).
A copy of GNU General Public License (GPL) is included in this distribution,
in the file COPYING.GPL.
As a special exception, if other files instantiate templates or use macros
or inline functions from this file, or you compile this file and link it
with other works to produce a work based on this file, this file
does not by itself cause the resulting work to be covered
by the GNU General Public License.
However the source code for this file must still be made available
in accordance with section (3) of the GNU General Public License.
This exception does not invalidate any other reasons why a work based
on this file might be covered by the GNU General Public License.
*/
#include <libusb.h>
#include "ftdi.hpp"
#include "ftdi_i.h"
#include "ftdi.h"
namespace Ftdi
{
class Context::Private
{
public:
Private()
: open(false), ftdi(0), dev(0)
{
ftdi = ftdi_new();
}
~Private()
{
if (open)
ftdi_usb_close(ftdi);
ftdi_free(ftdi);
}
bool open;
struct ftdi_context* ftdi;
struct libusb_device* dev;
std::string vendor;
std::string description;
std::string serial;
};
Context::Context()
: d( new Private() )
{
}
Context::~Context()
{
}
bool Context::is_open()
{
return d->open;
}
int Context::open(int vendor, int product)
{
// Open device
int ret = ftdi_usb_open(d->ftdi, vendor, product);
if (ret < 0)
return ret;
return get_strings_and_reopen(false,false,false);
}
int Context::open(int vendor, int product, const std::string& description, const std::string& serial, unsigned int index)
{
// translate empty strings to NULL
// -> do not use them to find the device (vs. require an empty string to be set in the EEPROM)
const char* c_description=NULL;
const char* c_serial=NULL;
if (!description.empty())
c_description=description.c_str();
if (!serial.empty())
c_serial=serial.c_str();
int ret = ftdi_usb_open_desc_index(d->ftdi, vendor, product, c_description, c_serial, index);
if (ret < 0)
return ret;
return get_strings_and_reopen(false,!description.empty(),!serial.empty());
}
int Context::open(const std::string& description)
{
int ret = ftdi_usb_open_string(d->ftdi, description.c_str());
if (ret < 0)
return ret;
return get_strings_and_reopen(false,true,false);
}
int Context::open(struct libusb_device *dev)
{
if (dev != 0)
d->dev = dev;
if (d->dev == 0)
return -1;
return get_strings_and_reopen();
}
int Context::close()
{
d->open = false;
d->dev = 0;
return ftdi_usb_close(d->ftdi);
}
int Context::reset()
{
return ftdi_usb_reset(d->ftdi);
}
int Context::flush(int mask)
{
int ret;
switch (mask & (Input | Output)) {
case Input:
ret = ftdi_usb_purge_rx_buffer(d->ftdi);
break;
case Output:
ret = ftdi_usb_purge_tx_buffer(d->ftdi);
break;
case Input | Output:
ret = ftdi_usb_purge_buffers(d->ftdi);
break;
default:
// Emulate behavior of previous version.
ret = 1;
break;
}
return ret;
}
int Context::set_interface(enum ftdi_interface interface)
{
return ftdi_set_interface(d->ftdi, interface);
}
void Context::set_usb_device(struct libusb_device_handle *dev)
{
ftdi_set_usbdev(d->ftdi, dev);
d->dev = libusb_get_device(dev);
}
int Context::set_baud_rate(int baudrate)
{
return ftdi_set_baudrate(d->ftdi, baudrate);
}
int Context::set_line_property(enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity)
{
return ftdi_set_line_property(d->ftdi, bits, sbit, parity);
}
int Context::set_line_property(enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity, enum ftdi_break_type break_type)
{
return ftdi_set_line_property2(d->ftdi, bits, sbit, parity, break_type);
}
int Context::get_usb_read_timeout() const
{
return d->ftdi->usb_read_timeout;
}
void Context::set_usb_read_timeout(int usb_read_timeout)
{
d->ftdi->usb_read_timeout = usb_read_timeout;
}
int Context::get_usb_write_timeout() const
{
return d->ftdi->usb_write_timeout;
}
void Context::set_usb_write_timeout(int usb_write_timeout)
{
d->ftdi->usb_write_timeout = usb_write_timeout;
}
int Context::read(unsigned char *buf, int size)
{
return ftdi_read_data(d->ftdi, buf, size);
}
int Context::set_read_chunk_size(unsigned int chunksize)
{
return ftdi_read_data_set_chunksize(d->ftdi, chunksize);
}
int Context::read_chunk_size()
{
unsigned chunk = -1;
if (ftdi_read_data_get_chunksize(d->ftdi, &chunk) < 0)
return -1;
return chunk;
}
int Context::write(const unsigned char *buf, int size)
{
return ftdi_write_data(d->ftdi, buf, size);
}
int Context::set_write_chunk_size(unsigned int chunksize)
{
return ftdi_write_data_set_chunksize(d->ftdi, chunksize);
}
int Context::write_chunk_size()
{
unsigned chunk = -1;
if (ftdi_write_data_get_chunksize(d->ftdi, &chunk) < 0)
return -1;
return chunk;
}
int Context::set_flow_control(int flowctrl)
{
return ftdi_setflowctrl(d->ftdi, flowctrl);
}
int Context::set_modem_control(int mask)
{
int dtr = 0, rts = 0;
if (mask & Dtr)
dtr = 1;
if (mask & Rts)
rts = 1;
return ftdi_setdtr_rts(d->ftdi, dtr, rts);
}
int Context::set_dtr(bool state)
{
return ftdi_setdtr(d->ftdi, state);
}
int Context::set_rts(bool state)
{
return ftdi_setrts(d->ftdi, state);
}
int Context::set_latency(unsigned char latency)
{
return ftdi_set_latency_timer(d->ftdi, latency);
}
unsigned Context::latency()
{
unsigned char latency = 0;
ftdi_get_latency_timer(d->ftdi, &latency);
return latency;
}
unsigned short Context::poll_modem_status()
{
unsigned short status = 0;
ftdi_poll_modem_status(d->ftdi, &status);
return status;
}
int Context::set_event_char(unsigned char eventch, unsigned char enable)
{
return ftdi_set_event_char(d->ftdi, eventch, enable);
}
int Context::set_error_char(unsigned char errorch, unsigned char enable)
{
return ftdi_set_error_char(d->ftdi, errorch, enable);
}
int Context::set_bitmode(unsigned char bitmask, unsigned char mode)
{
return ftdi_set_bitmode(d->ftdi, bitmask, mode);
}
int Context::set_bitmode(unsigned char bitmask, enum ftdi_mpsse_mode mode)
{
return ftdi_set_bitmode(d->ftdi, bitmask, mode);
}
int Context::bitbang_disable()
{
return ftdi_disable_bitbang(d->ftdi);
}
int Context::read_pins(unsigned char *pins)
{
return ftdi_read_pins(d->ftdi, pins);
}
const char* Context::error_string()
{
return ftdi_get_error_string(d->ftdi);
}
int Context::get_strings(bool vendor, bool description, bool serial)
{
// Prepare buffers
char ivendor[512], idesc[512], iserial[512];
int ret = ftdi_usb_get_strings(d->ftdi, d->dev, vendor?ivendor:NULL, 512, description?idesc:NULL, 512, serial?iserial:NULL, 512);
if (ret < 0)
return -1;
d->vendor = ivendor;
d->description = idesc;
d->serial = iserial;
return 1;
}
int Context::get_strings_and_reopen(bool vendor, bool description, bool serial)
{
int ret = 0;
if(vendor || description || serial)
{
if (d->dev == 0)
{
d->dev = libusb_get_device(d->ftdi->usb_dev);
}
// Get device strings (closes device)
ret=get_strings(vendor, description, serial);
if (ret < 0)
{
d->open = 0;
return ret;
}
// Reattach device
ret = ftdi_usb_open_dev(d->ftdi, d->dev);
d->open = (ret >= 0);
}
return ret;
}
const std::string& Context::vendor()
{
if(d->vendor.empty())
get_strings_and_reopen(true,false,false);
return d->vendor;
}
const std::string& Context::description()
{
if(d->description.empty())
get_strings_and_reopen(false,true,false);
return d->description;
}
const std::string& Context::serial()
{
if(d->serial.empty())
get_strings_and_reopen(false,false,true);
return d->serial;
}
void Context::set_context(struct ftdi_context* context)
{
ftdi_free(d->ftdi);
d->ftdi = context;
}
void Context::set_usb_device(struct libusb_device *dev)
{
d->dev = dev;
}
struct ftdi_context* Context::context()
{
return d->ftdi;
}
class Eeprom::Private
{
public:
Private()
: context(0)
{}
struct ftdi_eeprom eeprom;
struct ftdi_context* context;
};
Eeprom::Eeprom(Context* parent)
: d ( new Private() )
{
d->context = parent->context();
}
Eeprom::~Eeprom()
{
}
int Eeprom::init_defaults(char* manufacturer, char *product, char * serial)
{
return ftdi_eeprom_initdefaults(d->context, manufacturer, product, serial);
}
int Eeprom::chip_id(unsigned int *chipid)
{
return ftdi_read_chipid(d->context, chipid);
}
int Eeprom::build(unsigned char *output)
{
return ftdi_eeprom_build(d->context);
}
int Eeprom::read(unsigned char *eeprom)
{
return ftdi_read_eeprom(d->context);
}
int Eeprom::write(unsigned char *eeprom)
{
return ftdi_write_eeprom(d->context);
}
int Eeprom::read_location(int eeprom_addr, unsigned short *eeprom_val)
{
return ftdi_read_eeprom_location(d->context, eeprom_addr, eeprom_val);
}
int Eeprom::write_location(int eeprom_addr, unsigned short eeprom_val)
{
return ftdi_write_eeprom_location(d->context, eeprom_addr, eeprom_val);
}
int Eeprom::erase()
{
return ftdi_erase_eeprom(d->context);
}
class List::Private
{
public:
Private(struct ftdi_device_list* _devlist)
: devlist(_devlist)
{}
~Private()
{
if(devlist)
ftdi_list_free(&devlist);
}
std::list<Context> list;
struct ftdi_device_list* devlist;
};
List::List(struct ftdi_device_list* devlist)
: d( new Private(devlist) )
{
if (devlist != 0)
{
// Iterate list
for (; devlist != 0; devlist = devlist->next)
{
Context c;
c.set_usb_device(devlist->dev);
c.get_strings();
d->list.push_back(c);
}
}
}
List::~List()
{
}
List::iterator List::begin()
{
return d->list.begin();
}
List::iterator List::end()
{
return d->list.end();
}
List::const_iterator List::begin() const
{
return d->list.begin();
}
List::const_iterator List::end() const
{
return d->list.end();
}
List::reverse_iterator List::rbegin()
{
return d->list.rbegin();
}
List::reverse_iterator List::rend()
{
return d->list.rend();
}
List::const_reverse_iterator List::rbegin() const
{
return d->list.rbegin();
}
List::const_reverse_iterator List::rend() const
{
return d->list.rend();
}
List::ListType::size_type List::size() const
{
return d->list.size();
}
bool List::empty() const
{
return d->list.empty();
}
void List::clear()
{
ListType().swap(d->list);
// Free device list
if (d->devlist)
{
ftdi_list_free(&d->devlist);
d->devlist = 0;
}
}
void List::push_back(const Context& element)
{
d->list.push_back(element);
}
void List::push_front(const Context& element)
{
d->list.push_front(element);
}
List::iterator List::erase(iterator pos)
{
return d->list.erase(pos);
}
List::iterator List::erase(iterator beg, iterator end)
{
return d->list.erase(beg, end);
}
List* List::find_all(Context &context, int vendor, int product)
{
struct ftdi_device_list* dlist = 0;
ftdi_usb_find_all(context.context(), &dlist, vendor, product);
return new List(dlist);
}
}
ftdi_read_pins
int ftdi_read_pins(struct ftdi_context *ftdi, unsigned char *pins)
Definition: ftdi.c:2140
ftdi_usb_open
int ftdi_usb_open(struct ftdi_context *ftdi, int vendor, int product)
Definition: ftdi.c:698
Ftdi::Context::set_modem_control
int set_modem_control(int mask=Dtr|Rts)
Definition: ftdi.cpp:260
ftdi_device_list
list of usb devices created by ftdi_usb_find_all()
Definition: ftdi.h:344
ftdi_device_list::next
struct ftdi_device_list * next
Definition: ftdi.h:347
Ftdi::Context::get_usb_read_timeout
int get_usb_read_timeout() const
Definition: ftdi.cpp:197
Ftdi::List::end
iterator end()
Definition: ftdi.cpp:534
ftdi_read_data_get_chunksize
int ftdi_read_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize)
Definition: ftdi.c:2070
ftdi_usb_purge_tx_buffer
int ftdi_usb_purge_tx_buffer(struct ftdi_context *ftdi)
Definition: ftdi.c:1046
Ftdi::Context::write
int write(const unsigned char *buf, int size)
Definition: ftdi.cpp:236
ftdi_read_eeprom_location
int ftdi_read_eeprom_location(struct ftdi_context *ftdi, int eeprom_addr, unsigned short *eeprom_val)
Definition: ftdi.c:4300
Ftdi::Context::Output
Definition: ftdi.hpp:59
ftdi_set_usbdev
void ftdi_set_usbdev(struct ftdi_context *ftdi, libusb_device_handle *usb)
Definition: ftdi.c:268
Ftdi::Context
FTDI device context. Represents single FTDI device context.
Definition: ftdi.hpp:47
Ftdi::Context::read_chunk_size
int read_chunk_size()
Definition: ftdi.cpp:227
Ftdi::Context::description
const std::string & description()
Device strings properties.
Definition: ftdi.cpp:391
Ftdi::List::rbegin
reverse_iterator rbegin()
Definition: ftdi.cpp:561
ftdi_interface
ftdi_interface
Definition: ftdi.h:74
Ftdi::List::push_front
void push_front(const Context &element)
Definition: ftdi.cpp:642
ftdi_usb_open_desc_index
int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, int vendor, int product, const char *description, const char *serial, unsigned int index)
Definition: ftdi.c:755
Ftdi::Context::read
int read(unsigned char *buf, int size)
Definition: ftdi.cpp:217
Ftdi::Eeprom::Private::context
struct ftdi_context * context
Definition: ftdi.cpp:431
Ftdi::Context::Dtr
Definition: ftdi.hpp:66
ftdi_set_baudrate
int ftdi_set_baudrate(struct ftdi_context *ftdi, int baudrate)
Definition: ftdi.c:1349
Ftdi::Context::error_string
const char * error_string()
Definition: ftdi.cpp:331
Ftdi::List::iterator
ListType::iterator iterator
Iterator type for the container.
Definition: ftdi.hpp:186
Ftdi::Context::reset
int reset()
Definition: ftdi.cpp:140
ftdi_write_data
int ftdi_write_data(struct ftdi_context *ftdi, const unsigned char *buf, int size)
Definition: ftdi.c:1484
Ftdi::Context::vendor
const std::string & vendor()
Device strings properties.
Definition: ftdi.cpp:382
Ftdi::Eeprom::~Eeprom
~Eeprom()
Definition: ftdi.cpp:440
ftdi_context
Main context structure for all libftdi functions.
Definition: ftdi.h:221
Ftdi::Eeprom::read_location
int read_location(int eeprom_addr, unsigned short *eeprom_val)
Definition: ftdi.cpp:469
Ftdi::Context::Private
Definition: ftdi.cpp:37
Ftdi::List::ListType
std::list< Context > ListType
List type storing "Context" objects.
Definition: ftdi.hpp:184
ftdi_set_event_char
int ftdi_set_event_char(struct ftdi_context *ftdi, unsigned char eventch, unsigned char enable)
Definition: ftdi.c:2393
Ftdi::List::Private::list
std::list< Context > list
Definition: ftdi.cpp:497
Ftdi::Context::~Context
~Context()
Destructor.
Definition: ftdi.cpp:73
ftdi_set_bitmode
int ftdi_set_bitmode(struct ftdi_context *ftdi, unsigned char bitmask, unsigned char mode)
Definition: ftdi.c:2091
Ftdi::Context::bitbang_disable
int bitbang_disable()
Definition: ftdi.cpp:321
ftdi_list_free
void ftdi_list_free(struct ftdi_device_list **devlist)
Definition: ftdi.c:358
Ftdi::Context::eeprom
Eeprom * eeprom()
Ftdi::Context::get_strings
int get_strings(bool vendor=true, bool description=true, bool serial=true)
Definition: ftdi.cpp:336
Ftdi::Context::flush
int flush(int mask=Input|Output)
Definition: ftdi.cpp:145
Ftdi::List::Private::~Private
~Private()
Definition: ftdi.cpp:491
ftdi_set_line_property
int ftdi_set_line_property(struct ftdi_context *ftdi, enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity)
Definition: ftdi.c:1395
Ftdi::List::begin
iterator begin()
Definition: ftdi.cpp:525
Ftdi::Context::write_chunk_size
int write_chunk_size()
Definition: ftdi.cpp:246
ftdi_usb_purge_rx_buffer
int ftdi_usb_purge_rx_buffer(struct ftdi_context *ftdi)
Definition: ftdi.c:1020
Ftdi::Context::open
int open(struct libusb_device *dev=0)
Definition: ftdi.cpp:122
Ftdi::Context::Private::open
bool open
Definition: ftdi.cpp:54
Ftdi::Context::set_latency
int set_latency(unsigned char latency)
Definition: ftdi.cpp:282
Ftdi::Context::serial
const std::string & serial()
Device strings properties.
Definition: ftdi.cpp:400
ftdi_new
struct ftdi_context * ftdi_new(void)
Definition: ftdi.c:128
ftdi_erase_eeprom
int ftdi_erase_eeprom(struct ftdi_context *ftdi)
Definition: ftdi.c:4532
ftdi_set_interface
int ftdi_set_interface(struct ftdi_context *ftdi, enum ftdi_interface interface)
Definition: ftdi.c:157
ftdi_eeprom_initdefaults
int ftdi_eeprom_initdefaults(struct ftdi_context *ftdi, char *manufacturer, char *product, char *serial)
Definition: ftdi.c:2452
Ftdi::Context::Private::dev
struct libusb_device * dev
Definition: ftdi.cpp:57
ftdi_set_error_char
int ftdi_set_error_char(struct ftdi_context *ftdi, unsigned char errorch, unsigned char enable)
Definition: ftdi.c:2422
Ftdi::Context::Private::serial
std::string serial
Definition: ftdi.cpp:61
Ftdi::Context::Input
Definition: ftdi.hpp:58
ftdi_device_list::dev
struct libusb_device * dev
Definition: ftdi.h:349
Ftdi::Eeprom::erase
int erase()
Definition: ftdi.cpp:479
Ftdi::List::Private
Definition: ftdi.cpp:484
ftdi_bits_type
ftdi_bits_type
Definition: ftdi.h:54
Ftdi::Context::get_strings_and_reopen
int get_strings_and_reopen(bool vendor=true, bool description=true, bool serial=true)
Definition: ftdi.cpp:353
Ftdi::Context::set_interface
int set_interface(enum ftdi_interface interface)
Definition: ftdi.cpp:171
Ftdi::Context::set_read_chunk_size
int set_read_chunk_size(unsigned int chunksize)
Definition: ftdi.cpp:222
Ftdi::Context::Private::vendor
std::string vendor
Definition: ftdi.cpp:59
Ftdi::List::Private::Private
Private(struct ftdi_device_list *_devlist)
Definition: ftdi.cpp:487
Ftdi::List::empty
bool empty() const
Definition: ftdi.cpp:607
Ftdi::Context::set_rts
int set_rts(bool state)
Definition: ftdi.cpp:277
Ftdi::Context::latency
unsigned latency()
Definition: ftdi.cpp:287
Ftdi::Context::close
int close()
Definition: ftdi.cpp:133
Ftdi::Context::poll_modem_status
unsigned short poll_modem_status()
Definition: ftdi.cpp:294
Ftdi::Context::set_usb_write_timeout
void set_usb_write_timeout(int usb_write_timeout)
Definition: ftdi.cpp:212
Ftdi::Context::set_write_chunk_size
int set_write_chunk_size(unsigned int chunksize)
Definition: ftdi.cpp:241
ftdi_poll_modem_status
int ftdi_poll_modem_status(struct ftdi_context *ftdi, unsigned short *status)
Definition: ftdi.c:2247
ftdi_setdtr_rts
int ftdi_setdtr_rts(struct ftdi_context *ftdi, int dtr, int rts)
Definition: ftdi.c:2357
ftdi.hpp
Ftdi
Definition: ftdi.cpp:34
Ftdi::Eeprom::Private::Private
Private()
Definition: ftdi.cpp:426
ftdi_write_data_set_chunksize
int ftdi_write_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize)
Definition: ftdi.c:1866
Ftdi::List::reverse_iterator
ListType::reverse_iterator reverse_iterator
Reverse iterator type for the container.
Definition: ftdi.hpp:190
ftdi.h
ftdi_usb_open_dev
int ftdi_usb_open_dev(struct ftdi_context *ftdi, libusb_device *dev)
Definition: ftdi.c:585
Ftdi::Context::Private::~Private
~Private()
Definition: ftdi.cpp:46
Ftdi::Context::set_usb_read_timeout
void set_usb_read_timeout(int usb_read_timeout)
Definition: ftdi.cpp:202
Ftdi::List::rend
reverse_iterator rend()
Definition: ftdi.cpp:570
Ftdi::List::push_back
void push_back(const Context &element)
Definition: ftdi.cpp:633
Ftdi::Context::set_usb_device
void set_usb_device(struct libusb_device_handle *dev)
Definition: ftdi.cpp:176
Ftdi::Context::get_usb_write_timeout
int get_usb_write_timeout() const
Definition: ftdi.cpp:207
ftdi_setflowctrl
int ftdi_setflowctrl(struct ftdi_context *ftdi, int flowctrl)
Definition: ftdi.c:2273
Ftdi::Context::Private::Private
Private()
Definition: ftdi.cpp:40
Ftdi::List::List
List(struct ftdi_device_list *devlist=0)
Definition: ftdi.cpp:501
Ftdi::Context::set_flow_control
int set_flow_control(int flowctrl)
Definition: ftdi.cpp:255
Ftdi::List::erase
iterator erase(iterator pos)
Definition: ftdi.cpp:652
ftdi_get_error_string
const char * ftdi_get_error_string(struct ftdi_context *ftdi)
Definition: ftdi.c:4594
Ftdi::Eeprom::build
int build(unsigned char *output)
Definition: ftdi.cpp:454
ftdi_break_type
ftdi_break_type
Definition: ftdi.h:56
Ftdi::Eeprom::chip_id
int chip_id(unsigned int *chipid)
Definition: ftdi.cpp:449
ftdi_usb_close
int ftdi_usb_close(struct ftdi_context *ftdi)
Definition: ftdi.c:1098
ftdi_setrts
int ftdi_setrts(struct ftdi_context *ftdi, int state)
Definition: ftdi.c:2326
Ftdi::Context::set_bitmode
int set_bitmode(unsigned char bitmask, unsigned char mode)
Definition: ftdi.cpp:311
Ftdi::List::~List
~List()
Definition: ftdi.cpp:517
Ftdi::List::size
ListType::size_type size() const
Definition: ftdi.cpp:598
ftdi_usb_reset
int ftdi_usb_reset(struct ftdi_context *ftdi)
Definition: ftdi.c:994
ftdi_get_latency_timer
int ftdi_get_latency_timer(struct ftdi_context *ftdi, unsigned char *latency)
Definition: ftdi.c:2193
ftdi_usb_get_strings
int ftdi_usb_get_strings(struct ftdi_context *ftdi, struct libusb_device *dev, char *manufacturer, int mnf_len, char *description, int desc_len, char *serial, int serial_len)
Definition: ftdi.c:409
Ftdi::Context::set_error_char
int set_error_char(unsigned char errorch, unsigned char enable)
Definition: ftdi.cpp:306
ftdi_parity_type
ftdi_parity_type
Definition: ftdi.h:50
ftdi_read_data_set_chunksize
int ftdi_read_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize)
Definition: ftdi.c:2033
Ftdi::Eeprom::Private
Definition: ftdi.cpp:423
Ftdi::Context::Context
Context()
Constructor.
Definition: ftdi.cpp:66
ftdi_write_data_get_chunksize
int ftdi_write_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize)
Definition: ftdi.c:1884
ftdi_write_eeprom
int ftdi_write_eeprom(struct ftdi_context *ftdi)
Definition: ftdi.c:4477
ftdi_usb_open_string
int ftdi_usb_open_string(struct ftdi_context *ftdi, const char *description)
Definition: ftdi.c:901
ftdi_disable_bitbang
int ftdi_disable_bitbang(struct ftdi_context *ftdi)
Definition: ftdi.c:2117
ftdi_setdtr
int ftdi_setdtr(struct ftdi_context *ftdi, int state)
Definition: ftdi.c:2296
Ftdi::List::clear
void clear()
Definition: ftdi.cpp:617
Ftdi::Eeprom::init_defaults
int init_defaults(char *manufacturer, char *product, char *serial)
Definition: ftdi.cpp:444
Ftdi::Context::Private::ftdi
struct ftdi_context * ftdi
Definition: ftdi.cpp:56
ftdi_set_latency_timer
int ftdi_set_latency_timer(struct ftdi_context *ftdi, unsigned char latency)
Definition: ftdi.c:2166
ftdi_eeprom
FTDI eeprom structure.
Definition: ftdi_i.h:30
ftdi_stopbits_type
ftdi_stopbits_type
Definition: ftdi.h:52
Ftdi::Context::set_dtr
int set_dtr(bool state)
Definition: ftdi.cpp:272
ftdi_read_eeprom
int ftdi_read_eeprom(struct ftdi_context *ftdi)
Definition: ftdi.c:4324
Ftdi::List
Device list.
Definition: ftdi.hpp:175
Ftdi::Context::set_line_property
int set_line_property(enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity)
Definition: ftdi.cpp:187
ftdi_eeprom_build
int ftdi_eeprom_build(struct ftdi_context *ftdi)
Definition: ftdi.c:2783
ftdi_i.h
Ftdi::List::const_iterator
ListType::const_iterator const_iterator
Const iterator type for the container.
Definition: ftdi.hpp:188
ftdi_usb_purge_buffers
int ftdi_usb_purge_buffers(struct ftdi_context *ftdi)
Definition: ftdi.c:1069
Ftdi::Context::context
struct ftdi_context * context()
Definition: ftdi.cpp:418
Ftdi::Context::Rts
Definition: ftdi.hpp:67
ftdi_read_data
int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size)
Definition: ftdi.c:1908
Ftdi::List::Private::devlist
struct ftdi_device_list * devlist
Definition: ftdi.cpp:498
ftdi_write_eeprom_location
int ftdi_write_eeprom_location(struct ftdi_context *ftdi, int eeprom_addr, unsigned short eeprom_val)
Definition: ftdi.c:4421
Ftdi::Eeprom::Eeprom
Eeprom(Context *parent)
Definition: ftdi.cpp:434
Ftdi::Eeprom::read
int read(unsigned char *eeprom)
Definition: ftdi.cpp:459
Ftdi::Context::set_baud_rate
int set_baud_rate(int baudrate)
Definition: ftdi.cpp:182
Ftdi::Context::Private::description
std::string description
Definition: ftdi.cpp:60
Ftdi::Eeprom::write
int write(unsigned char *eeprom)
Definition: ftdi.cpp:464
ftdi_free
void ftdi_free(struct ftdi_context *ftdi)
Definition: ftdi.c:256
ftdi_read_chipid
int ftdi_read_chipid(struct ftdi_context *ftdi, unsigned int *chipid)
Definition: ftdi.c:4383
ftdi_mpsse_mode
ftdi_mpsse_mode
Definition: ftdi.h:59
Ftdi::List::const_reverse_iterator
ListType::const_reverse_iterator const_reverse_iterator
Const reverse iterator type for the container.
Definition: ftdi.hpp:192
Ftdi::List::find_all
static List * find_all(Context &context, int vendor, int product)
Definition: ftdi.cpp:668
Ftdi::Context::set_event_char
int set_event_char(unsigned char eventch, unsigned char enable)
Definition: ftdi.cpp:301
Ftdi::Context::is_open
bool is_open()
Definition: ftdi.cpp:77
ftdi_usb_find_all
int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list **devlist, int vendor, int product)
Definition: ftdi.c:310
Ftdi::Context::read_pins
int read_pins(unsigned char *pins)
Definition: ftdi.cpp:326
ftdi_set_line_property2
int ftdi_set_line_property2(struct ftdi_context *ftdi, enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity, enum ftdi_break_type break_type)
Definition: ftdi.c:1414
Ftdi::Context::set_context
void set_context(struct ftdi_context *context)
Definition: ftdi.cpp:407
ftdi_context::eeprom
struct ftdi_eeprom * eeprom
Definition: ftdi.h:267
Ftdi::Eeprom::write_location
int write_location(int eeprom_addr, unsigned short eeprom_val)
Definition: ftdi.cpp:474