libmanta
A cross-platform API for the Snyderphonics Manta
|
Superclass that handles the low-level USB communication with the Manta. More...
#include <MantaUSB.h>
Public Member Functions | |
void | WriteFrame (uint8_t *frame, bool forceQueued) |
Writes a USB transfer frame down to the Manta. | |
bool | IsConnected (void) |
Queries connection status of the Manta. | |
void | Connect (int connectionSerial=0) |
Connects this instance to a Manta. | |
void | Disconnect () |
Disconnects this instance from an attached Manta. | |
int | GetSerialNumber (void) |
Queries the serial number of the attached Manta. | |
Static Public Member Functions | |
static void | HandleEvents (void) |
Services USB communciation with the Manta. |
Superclass that handles the low-level USB communication with the Manta.
The MantaUSB class handles the low-level USB communication with the Manta over hidAPI, a cross-platform HID library.
The public methods of this class are meant to be used by applciations using libmanta to manage the connection to a physical Manta, as well as servicing the low-level USB drivers by periodically calling the HandleEvents() function.
Definition at line 28 of file MantaUSB.h.
void MantaUSB::Connect | ( | int | connectionSerial = 0 | ) |
Connects this instance to a Manta.
connectionSerial | The serial number of the manta to search for. |
If connectionSerial is left out or given as 0 then any connected Manta will match. If a serial number is given then libmanta will attempt to connect to that Manta. If no matching manta is found then Connect will throw a MantaNotFoundException. If no exception is thrown then the connection can be assumed to have been successful.
Definition at line 108 of file MantaUSB.cpp.
int MantaUSB::GetSerialNumber | ( | void | ) |
Queries the serial number of the attached Manta.
Definition at line 224 of file MantaUSB.cpp.
void MantaUSB::HandleEvents | ( | void | ) | [static] |
Services USB communciation with the Manta.
HandleEvents should be called periodically to poll all connected Mantas for incoming USB frames as well as to send any messages that have been queued up with WriteFrame(). It should be called at least once every 6ms, but you may get improved results polling as fast as every 1ms if your application supports it.
Note: Because WriteFrame() accesses the same message queue that HandleEvents() does, they should be protected from each other by a mutex on the application level if they're being called from parallel threads.
Definition at line 164 of file MantaUSB.cpp.
bool MantaUSB::IsConnected | ( | void | ) |
Queries connection status of the Manta.
Definition at line 92 of file MantaUSB.cpp.
void MantaUSB::WriteFrame | ( | uint8_t * | frame, |
bool | forceQueued | ||
) |
Writes a USB transfer frame down to the Manta.
frame | Pointer to the frame to be transmitted |
forceQueued | Forces this message to be queued instead of merged |
WriteFrame() is meant to be called by the Manta subclass, which defines methods for the individual messages (setLED, etc). libmanta maintains a message queue that gets popped from in the HandleEvents() handler.
The default behavior is that if a message is already queued up for a given Manta, subsequent message will be merged into the waiting message instead of being further queued (the queued frame will be the end result of all queued messages). forceQueued can be set to true to force the message to be queued as a separate message instead of being merged
Note: Because WriteFrame() accesses the same message queue that HandleEvents() does, they should be protected from each other by a mutex on the application level if they're being called from parallel threads.
Definition at line 53 of file MantaUSB.cpp.