# VectorNav C++ Library: vn::util::MemoryPort Class Reference

vn::util::MemoryPort Class Reference

Useful test class for taking place where vn::common::ISimplePort may be used. More...

`#include <memoryport.h>`

Inheritance diagram for vn::util::MemoryPort:

## Public Member Functions

| MemoryPort ()
| Creates a new MemoryPort.
virtual void | open ()
| Opens the simple port.
virtual void | close ()
| Closes the simple port.
virtual bool | isOpen ()
| Indicates if the simple port is open. More...
virtual void | write (const char data[], size_t length)
| Writes out data to the simple port. More...
virtual void | read (char dataBuffer[], size_t numOfBytesToRead, size_t &numOfBytesActuallyRead)
| Allows reading data from the simple port. More...
virtual void | registerDataReceivedHandler (void *userData, DataReceivedHandler handler)
| Registers a callback method for notification when new data is received on the port. More...
virtual void | unregisterDataReceivedHandler ()
| Unregisters the registered callback method.
void | registerDataWrittenHandler (void *userData, DataWrittenHandler handler)
| Registers a callback method for notification when new data is written. More...
void | unregisterDataWrittenHandler ()
| Unregisters the registered callback method.
void | SendDataBackDoor (const uint8_t data[], size_t length)
| Sends data to the MemoryPort which can then be read by read. More...
void | SendDataBackDoor (const char data[], size_t length)
| Sends data to the MemoryPort which can then be read by read. More...
void | SendDataBackDoor (const std::string data)
| Sends data to the MemoryPort which can then be read by read. More...

## Additional Inherited Members

Public Types inherited from vn::xplat::IPort
typedef void(* | DataReceivedHandler) (void *userData)
| Callback handler signature that can receive notification when new data has been received on the port. More...

## Detailed Description

Useful test class for taking place where vn::common::ISimplePort may be used.

## Member Function Documentation

virtual bool vn::util::MemoryPort::isOpen | ( |  | ) |

virtual

Indicates if the simple port is open.

Returns
  `true` if the serial port is open; otherwise `false`.

Implements vn::xplat::IPort.

virtual void vn::util::MemoryPort::read | ( | char | dataBuffer[],
|  | size_t | numOfBytesToRead,
|  | size_t & | numOfBytesActuallyRead
| ) |  |

virtual

Allows reading data from the simple port.

Parameters

  [out] | dataBuffer | The data buffer to write the read data bytes to.
  [in] | numOfBytesToRead | The number of bytes to attempt reading from the simple port.
  [out] | numOfBytesActuallyRead | The number of bytes actually read from the simple port.

Implements vn::xplat::IPort.

virtual void vn::util::MemoryPort::registerDataReceivedHandler | ( | void * | userData,
|  | DataReceivedHandler | handler
| ) |  |

virtual

Registers a callback method for notification when new data is received on the port.

Parameters

  [in] | userData | Pointer to user data, which will be provided to the callback method.
  [in] | handler | The callback method.

Implements vn::xplat::IPort.

void vn::util::MemoryPort::registerDataWrittenHandler | ( | void * | userData,
|  | DataWrittenHandler | handler
| ) |  |

Registers a callback method for notification when new data is written.

Parameters

  [in] | userData | Pointer to user data, which will be provided to the callback method.
  [in] | handler | The callback method.

void vn::util::MemoryPort::SendDataBackDoor | ( | const uint8_t | data[],
|  | size_t | length
| ) |  |

Sends data to the MemoryPort which can then be read by read.

Parameters

  [in] | data | Data buffer containing the data.
  [in] | length | The number of data bytes.

void vn::util::MemoryPort::SendDataBackDoor | ( | const char | data[],
|  | size_t | length
| ) |  |

Sends data to the MemoryPort which can then be read by read.

Parameters

  [in] | data | Data buffer containing the data.
  [in] | length | The number of data bytes.

void vn::util::MemoryPort::SendDataBackDoor | ( | const std::string | data | ) |

Sends data to the MemoryPort which can then be read by read.

Parameters

  [in] | data | The data to send.

virtual void vn::util::MemoryPort::write | ( | const char | data[],
|  | size_t | length
| ) |  |

virtual

Writes out data to the simple port.

Parameters

  [in] | data | The data array to write out.
  [in] | length | The length of the data array to write out.

Implements vn::xplat::IPort.

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

- include/vn/memoryport.h