libmanta
A cross-platform API for the Snyderphonics Manta
Public Member Functions | Static Public Member Functions
MantaUSB Class Reference

Superclass that handles the low-level USB communication with the Manta. More...

#include <MantaUSB.h>

Inheritance diagram for MantaUSB:
Inheritance graph
[legend]

List of all members.

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.

Detailed Description

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.


Member Function Documentation

void MantaUSB::Connect ( int  connectionSerial = 0)

Connects this instance to a Manta.

Parameters:
connectionSerialThe 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.

Returns:
The serial number as an int

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.

Returns:
true if this instance is connected to a physical Manta, false if not

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.

Parameters:
framePointer to the frame to be transmitted
forceQueuedForces 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.


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