My Project
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
uuid::modbus::Response Class Referenceabstract

Response message. More...

#include <uuid/modbus.h>

Inheritance diagram for uuid::modbus::Response:
Inheritance graph
[legend]

Public Member Functions

bool done () const
 Determine if the request is complete. More...
 
bool pending () const
 Determine if the request is still pending. More...
 
bool success () const
 Determine if the request was successful. More...
 
bool exception () const
 Determine if the request returned an exception. More...
 
bool failed () const
 Determine if the request failed for a reason other than an exception. More...
 
ResponseStatus status () const
 Get the status of the response message. More...
 
void status (ResponseStatus status)
 Set the status of the response message. More...
 
uint8_t exception_code () const
 Get the exception code from the device response. More...
 
void exception_code (uint8_t exception_code)
 Set the exception code from the device response. More...
 
virtual ResponseStatus parse (frame_buffer_t &frame, uint16_t len)=0
 Parse a message frame buffer and store the outcome in this response. More...
 

Protected Member Functions

bool check_length (frame_buffer_t &frame, uint16_t actual, uint16_t expected)
 Check the length of the message frame is correct and log an error if it is not. More...
 

Private Attributes

ResponseStatus status_ = ResponseStatus::QUEUED
 
uint8_t exception_code_ = 0
 

Detailed Description

Response message.

This will be created when a request is submitted and then later updated with the outcome. Poll the status() of the response to know when to access data.

Since
0.1.0

Definition at line 124 of file modbus.h.

Member Function Documentation

◆ check_length()

bool uuid::modbus::Response::check_length ( frame_buffer_t frame,
uint16_t  actual,
uint16_t  expected 
)
protected

Check the length of the message frame is correct and log an error if it is not.

Parameters
[in]frameMessage frame buffer.
[in]actualActual length of the message frame.
[in]expectedExpected length of the message frame.
Returns
True if the message frame length matches, otherwise false.
Since
0.1.0

Definition at line 44 of file generic_functions.cpp.

◆ done()

bool uuid::modbus::Response::done ( ) const
inline

Determine if the request is complete.

Returns
True if the request is finished, otherwise false.
Since
0.1.0

Definition at line 134 of file modbus.h.

◆ exception()

bool uuid::modbus::Response::exception ( ) const
inline

Determine if the request returned an exception.

Returns
True if the request returned an exception, otherwise false.
Since
0.1.0

Definition at line 158 of file modbus.h.

◆ exception_code() [1/2]

uint8_t uuid::modbus::Response::exception_code ( ) const
inline

Get the exception code from the device response.

Valid only if the status() is ResponseStatus::EXCEPTION or exception() returns true.

Returns
Exception code from the device response.
Since
0.1.0

Definition at line 194 of file modbus.h.

◆ exception_code() [2/2]

void uuid::modbus::Response::exception_code ( uint8_t  exception_code)
inline

Set the exception code from the device response.

Valid only if the status() is ResponseStatus::EXCEPTION or exception() returns true.

Parameters
[in]exception_codeException code from the device response.
Since
0.1.0

Definition at line 205 of file modbus.h.

◆ failed()

bool uuid::modbus::Response::failed ( ) const
inline

Determine if the request failed for a reason other than an exception.

Returns
True if the request failed (without receiving an exception), otherwise false.
Since
0.1.0

Definition at line 167 of file modbus.h.

◆ parse()

virtual ResponseStatus uuid::modbus::Response::parse ( frame_buffer_t frame,
uint16_t  len 
)
pure virtual

Parse a message frame buffer and store the outcome in this response.

Parameters
[in]frameMessage frame buffer.
[in]lenSize of message frame.
Returns
The status result of message parsing.
Since
0.1.0

Implemented in uuid::modbus::ExceptionStatusResponse, uuid::modbus::RegisterWriteResponse, and uuid::modbus::RegisterDataResponse.

◆ pending()

bool uuid::modbus::Response::pending ( ) const
inline

Determine if the request is still pending.

Returns
True if the request is in progress, otherwise false.
Since
0.1.0

Definition at line 142 of file modbus.h.

◆ status() [1/2]

ResponseStatus uuid::modbus::Response::status ( ) const
inline

Get the status of the response message.

Returns
Status of the response message.
Since
0.1.0

Definition at line 175 of file modbus.h.

◆ status() [2/2]

void uuid::modbus::Response::status ( ResponseStatus  status)
inline

Set the status of the response message.

Parameters
[in]statusStatus of the response message.
Since
0.1.0

Definition at line 183 of file modbus.h.

◆ success()

bool uuid::modbus::Response::success ( ) const
inline

Determine if the request was successful.

Returns
True if the request was successful, otherwise false.
Since
0.1.0

Definition at line 150 of file modbus.h.

Member Data Documentation

◆ exception_code_

uint8_t uuid::modbus::Response::exception_code_ = 0
private

Device exception response.

Since
0.1.0

Definition at line 234 of file modbus.h.

◆ status_

ResponseStatus uuid::modbus::Response::status_ = ResponseStatus::QUEUED
private

Status of response message.

Since
0.1.0

Definition at line 233 of file modbus.h.


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