MIP_SDK  v3.0.0
MicroStrain Communications Library for embedded systems
Public Member Functions | List of all members
mip::FirmwareVersion Class Reference

Represents the device firmware version. More...

#include <firmware_version.hpp>

Public Member Functions

 FirmwareVersion ()=default
 
 FirmwareVersion (uint8_t major, uint8_t minor, uint8_t patch)
 
 FirmwareVersion (uint16_t version)
 
 FirmwareVersion (const FirmwareVersion &)=default
 
FirmwareVersionoperator= (const FirmwareVersion &)=default
 
FirmwareVersionoperator= (uint16_t version)
 
bool isNull () const
 
bool isValid () const
 
bool isDevVersion () const
 
bool isReleaseVersion () const
 
bool isSpecialVersion () const
 
uint16_t asU16 () const
 
uint16_t & asU16 ()
 
void fromParts (uint8_t major, uint8_t minor, uint8_t patch)
 
uint8_t major () const
 
uint8_t minor () const
 
uint8_t patch () const
 
bool operator== (FirmwareVersion other) const
 
bool operator!= (FirmwareVersion other) const
 
bool operator<= (FirmwareVersion other) const
 
bool operator>= (FirmwareVersion other) const
 
bool operator< (FirmwareVersion other) const
 
bool operator> (FirmwareVersion other) const
 
void toString (char *buffer, size_t buffer_size) const
 Convert the version to a string in the standard X.Y.ZZ format. More...
 
bool fromString (const char *str, size_t length=-1)
 Reads a standard-format string (X.Y.ZZ\0 or XYZZ\0). More...
 
std::string toString () const
 Convert a FirmwareVersion to a string separated by periods. More...
 

Detailed Description

Represents the device firmware version.

Device firmware is of the form X.Y.ZZ, where:

Internally this class stores the version as a 16-bit unsigned integer.

Constructor & Destructor Documentation

◆ FirmwareVersion() [1/4]

mip::FirmwareVersion::FirmwareVersion ( )
default

◆ FirmwareVersion() [2/4]

mip::FirmwareVersion::FirmwareVersion ( uint8_t  major,
uint8_t  minor,
uint8_t  patch 
)
inline

◆ FirmwareVersion() [3/4]

mip::FirmwareVersion::FirmwareVersion ( uint16_t  version)
inlineexplicit

◆ FirmwareVersion() [4/4]

mip::FirmwareVersion::FirmwareVersion ( const FirmwareVersion )
default

Member Function Documentation

◆ asU16() [1/2]

uint16_t& mip::FirmwareVersion::asU16 ( )
inline

◆ asU16() [2/2]

uint16_t mip::FirmwareVersion::asU16 ( ) const
inline

◆ fromParts()

void mip::FirmwareVersion::fromParts ( uint8_t  major,
uint8_t  minor,
uint8_t  patch 
)
inline

◆ fromString()

bool mip::FirmwareVersion::fromString ( const char *  str,
size_t  length = -1 
)

Reads a standard-format string (X.Y.ZZ\0 or XYZZ\0).

Parameters
strInput string. Can be unterminated if length is specified.
lengthLength of input string. Assumed to be NULL-terminated if -1.
Returns
True if a valid version was parsed.

◆ isDevVersion()

bool mip::FirmwareVersion::isDevVersion ( ) const
inline

◆ isNull()

bool mip::FirmwareVersion::isNull ( ) const
inline

◆ isReleaseVersion()

bool mip::FirmwareVersion::isReleaseVersion ( ) const
inline

◆ isSpecialVersion()

bool mip::FirmwareVersion::isSpecialVersion ( ) const
inline

◆ isValid()

bool mip::FirmwareVersion::isValid ( ) const
inline

◆ major()

uint8_t mip::FirmwareVersion::major ( ) const
inline

◆ minor()

uint8_t mip::FirmwareVersion::minor ( ) const
inline

◆ operator!=()

bool mip::FirmwareVersion::operator!= ( FirmwareVersion  other) const
inline

◆ operator<()

bool mip::FirmwareVersion::operator< ( FirmwareVersion  other) const
inline

◆ operator<=()

bool mip::FirmwareVersion::operator<= ( FirmwareVersion  other) const
inline

◆ operator=() [1/2]

FirmwareVersion& mip::FirmwareVersion::operator= ( const FirmwareVersion )
default

◆ operator=() [2/2]

FirmwareVersion& mip::FirmwareVersion::operator= ( uint16_t  version)
inline

◆ operator==()

bool mip::FirmwareVersion::operator== ( FirmwareVersion  other) const
inline

◆ operator>()

bool mip::FirmwareVersion::operator> ( FirmwareVersion  other) const
inline

◆ operator>=()

bool mip::FirmwareVersion::operator>= ( FirmwareVersion  other) const
inline

◆ patch()

uint8_t mip::FirmwareVersion::patch ( ) const
inline

◆ toString() [1/2]

std::string mip::FirmwareVersion::toString ( ) const

Convert a FirmwareVersion to a string separated by periods.

This is different from Version::toString in that the patch number uses zero-padding.

◆ toString() [2/2]

void mip::FirmwareVersion::toString ( char *  buffer,
size_t  buffer_size 
) const

Convert the version to a string in the standard X.Y.ZZ format.

Note: The result is unspecified for invalid version numbers.

Parameters
bufferCharacter buffer to write into.
buffer_sizeLength (including space for null terminator) of buffer.

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