Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
clearpath::Transport Class Reference

#include <Transport.h>

List of all members.

Public Types

enum  counterTypes {
  GARBLE_BYTES, INVALID_MSG, IGNORED_ACK, QUEUE_FULL,
  NUM_COUNTERS
}

Public Member Functions

int close ()
void configure (const char *device, int retries)
void flush (std::list< Message * > *queue=0)
void flush (enum MessageTypes type, std::list< Message * > *queue=0)
unsigned long getCounter (enum counterTypes counter)
bool isConfigured ()
void poll ()
MessagepopNext ()
MessagepopNext (enum MessageTypes type)
void printCounters (std::ostream &stream=std::cout)
void send (Message *m)
MessagewaitNext (double timeout=0.0)
MessagewaitNext (enum MessageTypes type, double timeout=0.0)

Static Public Member Functions

static Transportinstance ()

Static Public Attributes

static const char * counter_names [NUM_COUNTERS]

Protected Member Functions

 Transport ()
 ~Transport ()

Private Member Functions

int closeComm ()
void enqueueMessage (Message *msg)
MessagegetAck ()
int openComm (const char *device)
void resetCounters ()
MessagerxMessage ()

Private Attributes

bool configured
unsigned long counters [NUM_COUNTERS]
int retries
std::list< Message * > rx_queue
void * serial

Static Private Attributes

static const size_t MAX_QUEUE_LEN = 10000
static const int RETRY_DELAY_MS = 200

Detailed Description

Definition at line 97 of file Transport.h.


Member Enumeration Documentation

Enumerator:
GARBLE_BYTES 
INVALID_MSG 
IGNORED_ACK 
QUEUE_FULL 
NUM_COUNTERS 

Definition at line 100 of file Transport.h.


Constructor & Destructor Documentation

Constructs an unconfigured transport instance.

Definition at line 138 of file Transport.cpp.

Definition at line 149 of file Transport.cpp.


Member Function Documentation

Close this Transport.

Returns:
Zero on success, nonzero otherwise
Postcondition:
Tranport will be unconfigured, regardless of success/failure.

Definition at line 192 of file Transport.cpp.

Closes the associated serial port

Definition at line 226 of file Transport.cpp.

void clearpath::Transport::configure ( const char *  device,
int  retries 
)

Configure this Transport for communication. If this Transport is already configured, it will be closed and reconfigured. The RX buffer and Message queue will be flushed. Counters will be reset.

Parameters:
deviceThe device to communicate over. (Currently, must be serial)
retriesNumber of times to resend an unacknowledged message.
Exceptions:
TransportExceptionif configuration fails
Postcondition:
Transport becomes configured.

Definition at line 164 of file Transport.cpp.

void clearpath::Transport::enqueueMessage ( Message msg) [private]

Add a Message to the Message queue. Checks Message validity, and drops invalid messages. Trims queue down to size if it gets too big.

Parameters:
msgThe message to enqueue.

Definition at line 349 of file Transport.cpp.

void clearpath::Transport::flush ( std::list< Message * > *  queue = 0)
void clearpath::Transport::flush ( enum MessageTypes  type,
std::list< Message * > *  queue = 0 
)

Read data until an ack message is found. Any data messages received by this function will be queued.

Returns:
The next ack message, if one is read. Null if no ack message has been read yet.

Definition at line 316 of file Transport.cpp.

unsigned long clearpath::Transport::getCounter ( enum counterTypes  counter) [inline]

Definition at line 169 of file Transport.h.

Transport singleton instance accessor.

Returns:
The Transport singleton instance.

Definition at line 129 of file Transport.cpp.

Definition at line 146 of file Transport.h.

int clearpath::Transport::openComm ( const char *  device) [private]

Opens a serial port with the default configuration (115200 bps, 8-N-1), using the device specified in the constructor

Definition at line 208 of file Transport.cpp.

Public function which makes sure buffered messages are still being read into the internal buffer. A compromise between forcing a thread-based implementation and blocking on results. This could be placed into a separate thread, but will need to be wrapped for thread safety

Definition at line 378 of file Transport.cpp.

Removes the oldest Message from the Message queue and returns it. All data waiting in the input buffer will be read and queued.

Returns:
The oldest message in the queue. This Message is removed from the queue. It is dynamically allocated; the caller is responsible for freeing it. Null if no Messages are currently queued.

Definition at line 476 of file Transport.cpp.

Finds the oldest message of a specific type in the Message queue, removes it, and returns it. Older messages of the wrong type will be left in the queue. All data waiting in the input buffer will be read and queued.

Returns:
The oldest message of the correct type in the queue. This Message is removed from the queue. It is dynamically allocated; the caller is responsible for freeing it. Null if no Messages are currently queued.

Definition at line 499 of file Transport.cpp.

void clearpath::Transport::printCounters ( std::ostream &  stream = std::cout)

Prints a nice list of counter values

Definition at line 661 of file Transport.cpp.

Wipes out counters

Definition at line 687 of file Transport.cpp.

Non-blocking message receive function. !!! Absolutely not reentrant !!! !!! Keeps internal static state !!!

Returns:
A pointer to a dynamically allocated message, if one has been received this call. Null if no complete message has been received. Bad data are silently eaten.

Definition at line 241 of file Transport.cpp.

Send a message. Waits for the firmware to acknowlge and resends the packet a few timew if not acknowledged.

Parameters:
mThe message to send
Exceptions:
Transport::Exceptionif never acknowledged.

Definition at line 406 of file Transport.cpp.

Message * clearpath::Transport::waitNext ( double  timeout = 0.0)

Fetch a message, blocking if there are no messages currently available.

Parameters:
timeoutMaximum time to block, in seconds. Actual resolution is system dependent A timeout of 0.0 indicates no timeout.
Returns:
A message. Null if the timeout elapses.

Definition at line 525 of file Transport.cpp.

Message * clearpath::Transport::waitNext ( enum MessageTypes  type,
double  timeout = 0.0 
)

Fetch a particular type of message, blocking if one isn't available.

Parameters:
typeThe type of message to fetch
timeoutMaximum time to block, in seconds. Actual resolution is system dependent A timeout of 0.0 indicates no timeout.
Returns:
A message of the requested type. Nul if the timeout elapses.

Definition at line 557 of file Transport.cpp.


Member Data Documentation

Definition at line 112 of file Transport.h.

const char * clearpath::Transport::counter_names [static]
Initial value:
 {
      "Garbled bytes",
      "Invalid messages",
      "Ignored acknowledgment",
      "Message queue overflow"
  }

Definition at line 108 of file Transport.h.

unsigned long clearpath::Transport::counters[NUM_COUNTERS] [private]

Definition at line 121 of file Transport.h.

const size_t clearpath::Transport::MAX_QUEUE_LEN = 10000 [static, private]

Definition at line 119 of file Transport.h.

Definition at line 114 of file Transport.h.

const int clearpath::Transport::RETRY_DELAY_MS = 200 [static, private]

Definition at line 116 of file Transport.h.

std::list<Message *> clearpath::Transport::rx_queue [private]

Definition at line 118 of file Transport.h.

Definition at line 113 of file Transport.h.


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


husky_base
Author(s): Mike Purvis , Paul Bovbel
autogenerated on Sat Jun 8 2019 18:26:01