/usr/include/ftdi.hpp is in libftdipp-dev 0.20-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | /***************************************************************************
ftdi.hpp - C++ wrapper for libftdi
-------------------
begin : Mon Oct 13 2008
copyright : (C) 2008 by Marek Vavruša
email : opensource@intra2net.com and marek@vavrusa.com
***************************************************************************/
/*
Copyright (C) 2008 by Marek Vavruša
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.
*/
#ifndef __libftdi_hpp__
#define __libftdi_hpp__
#include <list>
#include <string>
#include <boost/shared_ptr.hpp>
#include <ftdi.h>
namespace Ftdi
{
/* Forward declarations*/
class List;
class Eeprom;
/*! \brief FTDI device context.
* Represents single FTDI device context.
*/
class Context
{
/* Friends */
friend class Eeprom;
friend class List;
public:
/*! \brief Direction flags for flush().
*/
enum Direction
{
Input,
Output
};
/*! \brief Modem control flags.
*/
enum ModemCtl
{
Dtr,
Rts
};
/* Constructor, Destructor */
Context();
~Context();
/* Properties */
Eeprom* eeprom();
const std::string& vendor();
const std::string& description();
const std::string& serial();
/* Device manipulators */
bool is_open();
int open(struct usb_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 usb_dev_handle *dev);
/* Line manipulators */
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);
/* I/O */
int read(unsigned char *buf, int size);
int write(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();
/* Async IO
TODO: should wrap?
int writeAsync(unsigned char *buf, int size);
void asyncComplete(int wait_for_more);
*/
/* Flow control */
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();
/* BitBang mode */
int set_bitmode(unsigned char bitmask, unsigned char mode);
int set_bitmode(unsigned char bitmask, enum ftdi_mpsse_mode mode);
int DEPRECATED(bitbang_enable(unsigned char bitmask));
int bitbang_disable();
int read_pins(unsigned char *pins);
/* Misc */
char* error_string();
protected:
int get_strings();
int get_strings_and_reopen();
/* Properties */
struct ftdi_context* context();
void set_context(struct ftdi_context* context);
void set_usb_device(struct usb_device *dev);
private:
class Private;
boost::shared_ptr<Private> d;
};
/*! \brief Device EEPROM.
*/
class Eeprom
{
public:
Eeprom(Context* parent);
~Eeprom();
void init_defaults();
void set_size(int size);
int size(unsigned char *eeprom, int maxsize);
int chip_id(unsigned int *chipid);
int build(unsigned char *output);
int read(unsigned char *eeprom);
int write(unsigned char *eeprom);
int read_location(int eeprom_addr, unsigned short *eeprom_val);
int write_location(int eeprom_addr, unsigned short eeprom_val);
int erase();
private:
class Private;
boost::shared_ptr<Private> d;
};
/*! \brief Device list.
*/
class List
{
public:
List(struct ftdi_device_list* devlist = 0);
~List();
static List* find_all(int vendor, int product);
/// List type storing "Context" objects
typedef std::list<Context> ListType;
/// Iterator type for the container
typedef ListType::iterator iterator;
/// Const iterator type for the container
typedef ListType::const_iterator const_iterator;
/// Reverse iterator type for the container
typedef ListType::reverse_iterator reverse_iterator;
/// Const reverse iterator type for the container
typedef ListType::const_reverse_iterator const_reverse_iterator;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
reverse_iterator rbegin();
reverse_iterator rend();
const_reverse_iterator rbegin() const;
const_reverse_iterator rend() const;
ListType::size_type size() const;
bool empty() const;
void clear();
void push_back(const Context& element);
void push_front(const Context& element);
iterator erase(iterator pos);
iterator erase(iterator beg, iterator end);
private:
class Private;
boost::shared_ptr<Private> d;
};
}
#endif
|