MIP_SDK  v3.0.0
MicroStrain Communications Library for embedded systems
Public Member Functions | Static Public Attributes | List of all members
microstrain::connections::SerialConnection Class Reference

Can be used on Windows, OSX, or linux to communicate with a MIP device over serial. More...

#include <serial_connection.hpp>

Inheritance diagram for microstrain::connections::SerialConnection:
microstrain::Connection microstrain::connections::UsbSerialConnection

Public Member Functions

 SerialConnection (std::string portName, uint32_t baudrate)
 Creates a Serial Connection that will communicate with a device over serial. More...
 
 ~SerialConnection ()
 Closes the underlying serial port. More...
 
bool recvFromDevice (uint8_t *buffer, size_t max_length, unsigned int wait_time_ms, size_t *length_out, EmbeddedTimestamp *timestamp_out) final
 Receives bytes from the device. More...
 
bool sendToDevice (const uint8_t *data, size_t length) final
 Sends bytes to the device. More...
 
bool isConnected () const override
 Check if the port is connected. More...
 
bool connect () override
 Connect to the port. More...
 
bool disconnect () override
 Disconnect from the port. More...
 
void connectionInfo (std::string &name, uint32_t &baudrate) const
 
const char * interfaceName () const override
 
uint32_t parameter () const override
 
- Public Member Functions inherited from microstrain::Connection
 Connection ()
 
virtual ~Connection ()
 
const char * type () const
 

Static Public Attributes

static constexpr auto TYPE = "Serial"
 
- Static Public Attributes inherited from microstrain::Connection
static constexpr auto TYPE = "None"
 

Additional Inherited Members

- Protected Attributes inherited from microstrain::Connection
const char * mType
 

Detailed Description

Can be used on Windows, OSX, or linux to communicate with a MIP device over serial.

Constructor & Destructor Documentation

◆ SerialConnection()

microstrain::connections::SerialConnection::SerialConnection ( std::string  portName,
uint32_t  baudrate 
)

Creates a Serial Connection that will communicate with a device over serial.

Parameters
portNamePath to the port to connect to. On Windows, this usually looks like "COM<N>", on linux, "/dev/tty<N>"
baudrateBaud rate to open the device at. Note that the device needs to be configured to

◆ ~SerialConnection()

microstrain::connections::SerialConnection::~SerialConnection ( )

Closes the underlying serial port.

Member Function Documentation

◆ connect()

bool microstrain::connections::SerialConnection::connect ( )
overridevirtual

Connect to the port.

Implements microstrain::Connection.

◆ connectionInfo()

void microstrain::connections::SerialConnection::connectionInfo ( std::string &  name,
uint32_t &  baudrate 
) const
inline

◆ disconnect()

bool microstrain::connections::SerialConnection::disconnect ( )
overridevirtual

Disconnect from the port.

Implements microstrain::Connection.

◆ interfaceName()

const char* microstrain::connections::SerialConnection::interfaceName ( ) const
inlineoverridevirtual

◆ isConnected()

bool microstrain::connections::SerialConnection::isConnected ( ) const
overridevirtual

Check if the port is connected.

Implements microstrain::Connection.

◆ parameter()

uint32_t microstrain::connections::SerialConnection::parameter ( ) const
inlineoverridevirtual

◆ recvFromDevice()

bool microstrain::connections::SerialConnection::recvFromDevice ( uint8_t *  buffer,
size_t  max_length,
unsigned int  wait_time_ms,
size_t *  length_out,
EmbeddedTimestamp timestamp_out 
)
finalvirtual

Receives bytes from the device.

Parameters
bufferBuffer to store the received data in
max_lengthMax number of bytes that can be read. Should be at most the length of buffer.
wait_time_msTime to wait for data in milliseconds.
length_outNumber of bytes actually read.
timestamp_outTimestamp of when the data was received

Implements microstrain::Connection.

◆ sendToDevice()

bool microstrain::connections::SerialConnection::sendToDevice ( const uint8_t *  data,
size_t  length 
)
finalvirtual

Sends bytes to the device.

Parameters
dataThe data to send to the device
lengthLength of data in bytes

Implements microstrain::Connection.

Member Data Documentation

◆ TYPE

constexpr auto microstrain::connections::SerialConnection::TYPE = "Serial"
staticconstexpr

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