#include <mgen_device.h>
◆ MGenDevice()
MGenDevice::MGenDevice |
( |
| ) |
|
◆ ~MGenDevice()
MGenDevice::~MGenDevice |
( |
| ) |
|
|
virtual |
◆ Connect()
int MGenDevice::Connect |
( |
unsigned short |
vid = 0 , |
|
|
unsigned short |
pid = 0 |
|
) |
| |
Connecting a device identified by VID:PID.
This function only connects to the FTDI device.
- Parameters
-
vid | is the Vendor identifier of the device to connect (0x0403 for instance). |
pid | is the Product identifier of the device to connect (0x6001 for instance). |
- Returns
- 0 if successful
-
the return code of the last ftdi failure, and disable() is called.
- Note
- PID:VID=0:0 is used as default to connect to the first available FTDI device.
-
If PID:VID connection is not successful, enumerates and log devices to debug output.
◆ DBG_OpModeString()
char const * MGenDevice::DBG_OpModeString |
( |
IOMode |
mode | ) |
|
|
static |
◆ disable()
void MGenDevice::disable |
( |
| ) |
|
Disabling the device from use.
This function thread-safely marks the device as disconnected and deletes its FTDI context.
◆ enable()
void MGenDevice::enable |
( |
| ) |
|
Enabling the device for use.
This function thread-safely marks the device as connected.
- Warning
- This function does not run a connection, use Connect() for this purpose.
◆ getOpMode()
IOMode MGenDevice::getOpMode |
( |
| ) |
const |
|
inline |
Returning the current operational mode the device is in.
- Returns
- the IOMode the device was set to by setOpMode().
◆ isConnected()
bool MGenDevice::isConnected |
( |
| ) |
const |
|
inline |
◆ lock()
bool MGenDevice::lock |
( |
| ) |
|
◆ read()
int MGenDevice::read |
( |
IOBuffer & |
answer | ) |
|
Reading the answer part of a command from the device.
- Returns
- the number of bytes read, or -1 if the command is invalid or device is not accessible.
- Exceptions
-
IOError | when device communication is malfunctioning. |
◆ setOpMode()
int MGenDevice::setOpMode |
( |
IOMode |
_mode | ) |
|
Setting the current operational mode of the device.
This function thread-safely updates the operational mode, and switch the device line to the adequate baudrate.
- Returns
- 0 if successful, else a FTDI failure code.
◆ TurnPowerOn()
int MGenDevice::TurnPowerOn |
( |
| ) |
|
Turning the device on.
This function uses the FTDI special functions to obtain the same functionality as a long press on ESC to turn the M-Gen device on.
- Note
- Switches operational mode to UNKNOWN if successful.
◆ unlock()
void MGenDevice::unlock |
( |
| ) |
|
◆ write()
Writing the query field of a command to the device.
- Returns
- the number of bytes written, or -1 if the command is invalid or device is not accessible.
- Exceptions
-
IOError | when device communication is malfunctioning. |
◆ _lock
pthread_mutex_t MGenDevice::_lock |
|
protected |
◆ ftdi
struct ftdi_context* MGenDevice::ftdi |
|
protected |
◆ is_device_connected
bool MGenDevice::is_device_connected |
|
protected |
◆ mode
◆ pid
unsigned short MGenDevice::pid |
|
protected |
◆ tried_turn_on
bool MGenDevice::tried_turn_on |
|
protected |
◆ vid
unsigned short MGenDevice::vid |
|
protected |
The documentation for this class was generated from the following files: