Example for updating the MTi-1's firmware. Uses a platform independent, retargetable pure C implementation of the firmware updater protocol.

Dependencies:   mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

MtInterfaceUart Class Reference

MtInterfaceUart Class Reference

Implementation of MtInterface for communicating over UART. More...

Inherits MtInterface.

Public Member Functions

 MtInterfaceUart (int baudrate)
 Constructor.
virtual ~MtInterfaceUart ()
 Destructor.
virtual void process ()
 This function must be periodically called from the main loop. Classes which inherid from MtInterface can place functionality which must run periodically in this function.
virtual void sendXbusMessage (XbusMessage const *xbusMessage)
 Sends an xbus message to the module via UART.
virtual XbusBusFormat busFormat ()
 Returns the low level bus format used by this interface.
void setBaudrate (int baudrate)
 Set the baudrate.
XbusMessagegetXbusMessage ()
 Returns the next message from the rx queue or NULL if the queue is empty.
void releaseXbusMessage (XbusMessage *xbusMessage)
 Releases an xbus message previously obtained by a call to getXbusMessage()
XbusMessagesendAndWait (XbusMessage const *xbusMessage)
 Sends an Xbus message and waits for the related acknowledge.

Protected Member Functions

void * allocateMessageData (size_t bufferSize)
 Callback function for XbusParserCallback to allocate a block of memory.
void deallocateMessageData (void const *buffer)
 Callback function for XbusParserCallback to deallocate a block of memory.
void xbusParserCallbackFunction (struct XbusMessage const *message)
 Callback function for XbusParserCallback that handles a completely received xbus message from the motion tracker.

Friends

void * allocateMessageDataWrapper (size_t bufferSize)
 Callback function for XbusParserCallback for allocating a block of memory.
void deallocateMessageDataWrapper (void const *buffer)
 Callback function for XbusParserCallback for deallocating a block of memory.
void xbusParserCallbackFunctionWrapper (struct XbusMessage const *message)
 Callback function for XbusParserCallback that handles completely received xbus messages from the motion tracker.

Detailed Description

Implementation of MtInterface for communicating over UART.

The low level UART driver is provided by the mbed platform.

Definition at line 23 of file mtinterface_uart.h.


Constructor & Destructor Documentation

MtInterfaceUart ( int  baudrate )

Constructor.

Parameters:
baudrateUart baud rate used to communicate with the module

Definition at line 35 of file mtinterface_uart.cpp.

~MtInterfaceUart (  ) [virtual]

Destructor.

Definition at line 49 of file mtinterface_uart.cpp.


Member Function Documentation

void * allocateMessageData ( size_t  bufferSize ) [protected, inherited]

Callback function for XbusParserCallback to allocate a block of memory.

Parameters:
bufferSizebuffer size

Definition at line 117 of file mtinterface.cpp.

XbusBusFormat busFormat (  ) [virtual]

Returns the low level bus format used by this interface.

Implements MtInterface.

Definition at line 72 of file mtinterface_uart.cpp.

void deallocateMessageData ( void const *  buffer ) [protected, inherited]

Callback function for XbusParserCallback to deallocate a block of memory.

Parameters:
bufferPointer to the buffer that should be deallocated

Definition at line 129 of file mtinterface.cpp.

XbusMessage * getXbusMessage (  ) [inherited]

Returns the next message from the rx queue or NULL if the queue is empty.

Note:
The caller must dealocate the message with releaseXbusMessage() after use.

Definition at line 89 of file mtinterface.cpp.

virtual void process (  ) [virtual]

This function must be periodically called from the main loop. Classes which inherid from MtInterface can place functionality which must run periodically in this function.

Implements MtInterface.

Definition at line 29 of file mtinterface_uart.h.

void releaseXbusMessage ( XbusMessage xbusMessage ) [inherited]

Releases an xbus message previously obtained by a call to getXbusMessage()

Parameters:
xbusMessagethat should be released

Definition at line 104 of file mtinterface.cpp.

XbusMessage * sendAndWait ( XbusMessage const *  xbusMessage ) [inherited]

Sends an Xbus message and waits for the related acknowledge.

Returns:
0 if no related message was received. Pointer to the message otherwise. This message can also be an error message.

Definition at line 149 of file mtinterface.cpp.

void sendXbusMessage ( XbusMessage const *  xbusMessage ) [virtual]

Sends an xbus message to the module via UART.

Parameters:
xbusMessageXbus message to be send

Implements MtInterface.

Definition at line 60 of file mtinterface_uart.cpp.

void setBaudrate ( int  baudrate )

Set the baudrate.

Parameters:
baudrateThe baudrate value which should be set

Definition at line 93 of file mtinterface_uart.cpp.

void xbusParserCallbackFunction ( struct XbusMessage const *  message ) [protected, inherited]

Callback function for XbusParserCallback that handles a completely received xbus message from the motion tracker.

Parameters:
messagePointer to the received xbus message

Definition at line 138 of file mtinterface.cpp.


Friends And Related Function Documentation

void* allocateMessageDataWrapper ( size_t  bufferSize ) [friend, inherited]

Callback function for XbusParserCallback for allocating a block of memory.

Parameters:
bufferSizebuffer size

Definition at line 37 of file mtinterface.cpp.

void deallocateMessageDataWrapper ( void const *  buffer ) [friend, inherited]

Callback function for XbusParserCallback for deallocating a block of memory.

Parameters:
bufferPointer to the buffer that should be deallocated

Definition at line 46 of file mtinterface.cpp.

void xbusParserCallbackFunctionWrapper ( struct XbusMessage const *  message ) [friend, inherited]

Callback function for XbusParserCallback that handles completely received xbus messages from the motion tracker.

Parameters:
Pointerto the received xbus message

Definition at line 55 of file mtinterface.cpp.