Modbus cpp 0.1
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
MB::ModbusException Class Reference

#include <modbusException.hpp>

Inheritance diagram for MB::ModbusException:

Public Member Functions

 ModbusException (const std::vector< uint8_t > &inputData, bool CRC=false) noexcept
 Constructs Exception from raw data.
 
 ModbusException (utils::MBErrorCode errorCode, uint8_t slaveId=0xFF, utils::MBFunctionCode functionCode=utils::Undefined) noexcept
 Constructs Exception based on error code, function code and slaveId.
 
uint8_t slaveID () const noexcept
 
bool isSlaveValid () const noexcept
 Checks if SlaveID is specified.
 
void setSlaveID (uint8_t slaveId) noexcept
 Sets SlaveID.
 
utils::MBErrorCode getErrorCode () const noexcept
 Returns detected error code.
 
const char * what () const noexcept override
 
std::string toString () const noexcept
 Returns string representation of object.
 
std::vector< uint8_t > toRaw () const noexcept
 Converts object to modbus byte representation.
 
utils::MBFunctionCode functionCode () const noexcept
 
void setFunctionCode (utils::MBFunctionCode functionCode) noexcept
 

Static Public Member Functions

static bool exist (const std::vector< uint8_t > &inputData) noexcept
 

Detailed Description

Thic class represent Modbus exception and is derived form std::exception. It is just a wrapper around standard error codes and some custom codes.

Constructor & Destructor Documentation

◆ ModbusException()

ModbusException::ModbusException ( const std::vector< uint8_t > & inputData,
bool CRC = false )
explicitnoexcept

Constructs Exception from raw data.

Parameters
inputDatais vector of bytes that will be be interpreted
CRCbased on this param method performs CRC calculation and throws exception if it is invalid
Note
if CRC = true input data needs to contain 2 CRC bytes on back (used in RS)

Member Function Documentation

◆ what()

const char * MB::ModbusException::what ( ) const
inlineoverridenoexcept

This function is less optimal, it is just to be compatible with std::excepetion You should preferably use toString()


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