Ftdi::Context Class Reference

FTDI device context. Represents single FTDI device context. More...

`#include <ftdi.hpp>`

## Classes

class | Private

## Public Types

enum | Direction { Input = 0x2, Output = 0x1 }
| Direction flags for flush(). More...
enum | ModemCtl { Dtr = 0x2, Rts = 0x1 }
| Modem control flags. More...

## Public Member Functions

| Context ()
| Constructor. More...
| ~Context ()
| Destructor. More...
Eeprom * | eeprom ()
const std::string & | vendor ()
| Device strings properties. More...
const std::string & | description ()
| Device strings properties. More...
const std::string & | serial ()
| Device strings properties. More...
bool | is_open ()
int | open (struct libusb_device *dev=0)
int | open (int vendor, int product)
int | open (int vendor, int product, const std::string &description, const std::string &serial=std::string(), unsigned int index=0)
int | open (const std::string &description)
int | close ()
int | reset ()
int | flush (int mask=Input|Output)
int | set_interface (enum ftdi_interface interface)
void | set_usb_device (struct libusb_device_handle *dev)
int | set_baud_rate (int baudrate)
int | set_line_property (enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity)
int | set_line_property (enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity, enum ftdi_break_type break_type)
int | get_usb_read_timeout () const
void | set_usb_read_timeout (int usb_read_timeout)
int | get_usb_write_timeout () const
void | set_usb_write_timeout (int usb_write_timeout)
int | read (unsigned char *buf, int size)
int | write (const unsigned char *buf, int size)
int | set_read_chunk_size (unsigned int chunksize)
int | set_write_chunk_size (unsigned int chunksize)
int | read_chunk_size ()
int | write_chunk_size ()
int | set_event_char (unsigned char eventch, unsigned char enable)
int | set_error_char (unsigned char errorch, unsigned char enable)
int | set_flow_control (int flowctrl)
int | set_modem_control (int mask=Dtr|Rts)
int | set_latency (unsigned char latency)
int | set_dtr (bool state)
int | set_rts (bool state)
unsigned short | poll_modem_status ()
unsigned | latency ()
int | set_bitmode (unsigned char bitmask, unsigned char mode)
int | set_bitmode (unsigned char bitmask, enum ftdi_mpsse_mode mode)
int | bitbang_disable ()
int | read_pins (unsigned char *pins)
const char * | error_string ()

## Protected Member Functions

int | get_strings (bool vendor=true, bool description=true, bool serial=true)
int | get_strings_and_reopen (bool vendor=true, bool description=true, bool serial=true)
struct ftdi_context * | context ()
void | set_context (struct ftdi_context *context)
void | set_usb_device (struct libusb_device *dev)

## Friends

class | Eeprom
class | List

## Detailed Description

FTDI device context. Represents single FTDI device context.

Definition at line 51 of file ftdi.hpp.

## Member Enumeration Documentation

## Direction

enum Ftdi::Context::Direction

Direction flags for flush().

Enumerator
Input |
Output |

Definition at line 60 of file ftdi.hpp.

## ModemCtl

enum Ftdi::Context::ModemCtl

Modem control flags.

Enumerator
Dtr |
Rts |

Definition at line 68 of file ftdi.hpp.

## Constructor & Destructor Documentation

## Context()

Ftdi::Context::Context | ( |  | ) |

Constructor.

Definition at line 71 of file ftdi.cpp.

## ~Context()

Ftdi::Context::~Context | ( |  | ) |

Destructor.

Definition at line 78 of file ftdi.cpp.

## Member Function Documentation

## eeprom()

Eeprom* Ftdi::Context::eeprom | ( |  | ) |

## vendor()

const std::string & Ftdi::Context::vendor | ( |  | ) |

Device strings properties.

Definition at line 387 of file ftdi.cpp.

Referenced by get_strings_and_reopen(), and is_open().

## description()

const std::string & Ftdi::Context::description | ( |  | ) |

Device strings properties.

Definition at line 396 of file ftdi.cpp.

Referenced by get_strings_and_reopen().

## serial()

const std::string & Ftdi::Context::serial | ( |  | ) |

Device strings properties.

Definition at line 405 of file ftdi.cpp.

Referenced by get_strings_and_reopen().

## is_open()

bool Ftdi::Context::is_open | ( |  | ) |

Definition at line 82 of file ftdi.cpp.

References ftdi_usb_open(), and vendor().

## open() [1/4]

int Ftdi::Context::open | ( | struct libusb_device * | dev = `0` | ) |

Definition at line 127 of file ftdi.cpp.

## open() [2/4]

int Ftdi::Context::open | ( | int | vendor,
|  | int | product
| ) |  |

Definition at line 87 of file ftdi.cpp.

## open() [3/4]

int Ftdi::Context::open | ( | int | vendor,
|  | int | product,
|  | const std::string & | description,
|  | const std::string & | serial = `std::string()`,
|  | unsigned int | index = `0`
| ) |  |

Definition at line 98 of file ftdi.cpp.

## open() [4/4]

int Ftdi::Context::open | ( | const std::string & | description | ) |

Definition at line 117 of file ftdi.cpp.

## close()

int Ftdi::Context::close | ( |  | ) |

Definition at line 138 of file ftdi.cpp.

## reset()

int Ftdi::Context::reset | ( |  | ) |

Definition at line 145 of file ftdi.cpp.

References Input, and Output.

## flush()

int Ftdi::Context::flush | ( | int | mask = `Input|Output` | ) |

Definition at line 150 of file ftdi.cpp.

## set_interface()

int Ftdi::Context::set_interface | ( | enum ftdi_interface | interface | ) |

Definition at line 176 of file ftdi.cpp.

References ftdi_set_usbdev().

## set_usb_device() [1/2]

void Ftdi::Context::set_usb_device | ( | struct libusb_device_handle * | dev | ) |

Definition at line 181 of file ftdi.cpp.

References ftdi_set_baudrate().

Referenced by Ftdi::List::List().

## set_baud_rate()

int Ftdi::Context::set_baud_rate | ( | int | baudrate | ) |

Definition at line 187 of file ftdi.cpp.

References ftdi_set_line_property().

## set_line_property() [1/2]

int Ftdi::Context::set_line_property | ( | enum ftdi_bits_type | bits,
|  | enum ftdi_stopbits_type | sbit,
|  | enum ftdi_parity_type | parity
| ) |  |

Definition at line 192 of file ftdi.cpp.

References ftdi_set_line_property2().

## set_line_property() [2/2]

int Ftdi::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
| ) |  |

Definition at line 197 of file ftdi.cpp.

## get_usb_read_timeout()

int Ftdi::Context::get_usb_read_timeout | ( |  | ) | const

Definition at line 202 of file ftdi.cpp.

## set_usb_read_timeout()

void Ftdi::Context::set_usb_read_timeout | ( | int | usb_read_timeout | ) |

Definition at line 207 of file ftdi.cpp.

## get_usb_write_timeout()

int Ftdi::Context::get_usb_write_timeout | ( |  | ) | const

Definition at line 212 of file ftdi.cpp.

## set_usb_write_timeout()

void Ftdi::Context::set_usb_write_timeout | ( | int | usb_write_timeout | ) |

Definition at line 217 of file ftdi.cpp.

References ftdi_read_data().

## read()

int Ftdi::Context::read | ( | unsigned char * | buf,
|  | int | size
| ) |  |

Definition at line 222 of file ftdi.cpp.

References ftdi_read_data_set_chunksize().

## write()

int Ftdi::Context::write | ( | const unsigned char * | buf,
|  | int | size
| ) |  |

Definition at line 241 of file ftdi.cpp.

References ftdi_write_data_set_chunksize().

## set_read_chunk_size()

int Ftdi::Context::set_read_chunk_size | ( | unsigned int | chunksize | ) |

Definition at line 227 of file ftdi.cpp.

References ftdi_read_data_get_chunksize().

## set_write_chunk_size()

int Ftdi::Context::set_write_chunk_size | ( | unsigned int | chunksize | ) |

Definition at line 246 of file ftdi.cpp.

References ftdi_write_data_get_chunksize().

## read_chunk_size()

int Ftdi::Context::read_chunk_size | ( |  | ) |

Definition at line 232 of file ftdi.cpp.

## write_chunk_size()

int Ftdi::Context::write_chunk_size | ( |  | ) |

Definition at line 251 of file ftdi.cpp.

## set_event_char()

int Ftdi::Context::set_event_char | ( | unsigned char | eventch,
|  | unsigned char | enable
| ) |  |

Definition at line 306 of file ftdi.cpp.

References ftdi_set_error_char().

## set_error_char()

int Ftdi::Context::set_error_char | ( | unsigned char | errorch,
|  | unsigned char | enable
| ) |  |

Definition at line 311 of file ftdi.cpp.

References ftdi_set_bitmode().

## set_flow_control()

int Ftdi::Context::set_flow_control | ( | int | flowctrl | ) |

Definition at line 260 of file ftdi.cpp.

References Dtr.

## set_modem_control()

int Ftdi::Context::set_modem_control | ( | int | mask = `Dtr|Rts` | ) |

Definition at line 265 of file ftdi.cpp.

## set_latency()

int Ftdi::Context::set_latency | ( | unsigned char | latency | ) |

Definition at line 287 of file ftdi.cpp.

References ftdi_get_latency_timer(), and latency().

## set_dtr()

int Ftdi::Context::set_dtr | ( | bool | state | ) |

Definition at line 277 of file ftdi.cpp.

References ftdi_setrts().

## set_rts()

int Ftdi::Context::set_rts | ( | bool | state | ) |

Definition at line 282 of file ftdi.cpp.

References ftdi_set_latency_timer(), and latency().

## poll_modem_status()

unsigned short Ftdi::Context::poll_modem_status | ( |  | ) |

Definition at line 299 of file ftdi.cpp.

## latency()

unsigned Ftdi::Context::latency | ( |  | ) |

Definition at line 292 of file ftdi.cpp.

Referenced by set_latency(), and set_rts().

## set_bitmode() [1/2]

int Ftdi::Context::set_bitmode | ( | unsigned char | bitmask,
|  | unsigned char | mode
| ) |  |

Definition at line 316 of file ftdi.cpp.

References ftdi_set_bitmode().

## set_bitmode() [2/2]

int Ftdi::Context::set_bitmode | ( | unsigned char | bitmask,
|  | enum ftdi_mpsse_mode | mode
| ) |  |

Definition at line 321 of file ftdi.cpp.

References ftdi_disable_bitbang().

## bitbang_disable()

int Ftdi::Context::bitbang_disable | ( |  | ) |

Definition at line 326 of file ftdi.cpp.

References ftdi_read_pins().

## read_pins()

int Ftdi::Context::read_pins | ( | unsigned char * | pins | ) |

Definition at line 331 of file ftdi.cpp.

References ftdi_get_error_string().

## error_string()

const char * Ftdi::Context::error_string | ( |  | ) |

Definition at line 336 of file ftdi.cpp.

## get_strings()

int Ftdi::Context::get_strings | ( | bool | vendor = `true`,
|  | bool | description = `true`,
|  | bool | serial = `true`
| ) |  |

protected

Definition at line 341 of file ftdi.cpp.

Referenced by get_strings_and_reopen(), and Ftdi::List::List().

## get_strings_and_reopen()

int Ftdi::Context::get_strings_and_reopen | ( | bool | vendor = `true`,
|  | bool | description = `true`,
|  | bool | serial = `true`
| ) |  |

protected

Definition at line 358 of file ftdi.cpp.

References description(), ftdi_usb_open_dev(), get_strings(), serial(), and vendor().

## context()

struct ftdi_context * Ftdi::Context::context | ( |  | ) |

protected

Definition at line 423 of file ftdi.cpp.

References Ftdi::Eeprom::Private::context, and Ftdi::Eeprom::Private::Private().

Referenced by Ftdi::List::erase().

## set_context()

void Ftdi::Context::set_context | ( | struct ftdi_context * | context | ) |

protected

Definition at line 412 of file ftdi.cpp.

## set_usb_device() [2/2]

void Ftdi::Context::set_usb_device | ( | struct libusb_device * | dev | ) |

protected

Definition at line 418 of file ftdi.cpp.

## Friends And Related Function Documentation

## Eeprom

friend class Eeprom

friend

Definition at line 54 of file ftdi.hpp.

## List

friend class List

friend

Definition at line 55 of file ftdi.hpp.

The documentation for this class was generated from the following files:

- ftdi.hpp
- ftdi.cpp