HDLC-Daemon
AliveState Class Reference

Class AliveState. More...

#include <AliveState.h>

Inheritance diagram for AliveState:
Collaboration diagram for AliveState:

Public Member Functions

 AliveState (boost::asio::io_service &a_IOService)
 The constructor of AliveState objects. More...
 
 ~AliveState ()
 The destructor of AliveState objects. More...
 
void SetSendProbeCallback (std::function< void()> a_SendProbeCallback)
 Register callback method for sending a probe request via HDLC. More...
 
void SetChangeBaudrateCallback (std::function< void()> a_ChangeBaudrateCallback)
 Register callback method for changing the baud rate of the related serial port. More...
 
void Start ()
 Start all activities. More...
 
void Stop ()
 Stop all activities. More...
 
bool OnFrameReceived ()
 Indicate that a HDLC frame was received via the related serial port. More...
 
bool IsAlive () const
 Query whether the related serialport is currently considered alive. More...
 

Detailed Description

Class AliveState.

This class is responsible for keeping track of the HDLC message exchange, periodically sends HDLC keep alive packets ("probes") if no other HDLC PDUs were exchanged, and cycles through all available baud rates if no messages were received from a serially attached device.

Definition at line 52 of file AliveState.h.

Constructor & Destructor Documentation

AliveState::AliveState ( boost::asio::io_service &  a_IOService)

The constructor of AliveState objects.

The constructor of AliveState objects

Definition at line 46 of file AliveState.cpp.

AliveState::~AliveState ( )

The destructor of AliveState objects.

The destructor of AliveState objects

Definition at line 54 of file AliveState.cpp.

Here is the call graph for this function:

Member Function Documentation

bool AliveState::IsAlive ( ) const

Query whether the related serialport is currently considered alive.

A serial port is alive if the baud rate is correct and HDLC frames are received.

Returns
bool indicates whether the related serial port is currently alive

Definition at line 141 of file AliveState.cpp.

bool AliveState::OnFrameReceived ( )

Indicate that a HDLC frame was received via the related serial port.

On each valid received HDLC frame this method is called to indicate that the baud rate is ok and that the connected device is alive.

Returns
bool indicates whether the internal state changed

Definition at line 122 of file AliveState.cpp.

void AliveState::SetChangeBaudrateCallback ( std::function< void()>  a_ChangeBaudrateCallback)

Register callback method for changing the baud rate of the related serial port.

The provided callback is called each time the baud rate of the serial port has to be changed.

Parameters
a_ChangeBaudrateCallbackthe callback method to switch to another baud rate setting

Definition at line 111 of file AliveState.cpp.

void AliveState::SetSendProbeCallback ( std::function< void()>  a_SendProbeCallback)

Register callback method for sending a probe request via HDLC.

The provided callback is called each time a probe has to be sent via HDLC.

Parameters
a_SendProbeCallbackthe callback method to send a probe request via HDLC

Definition at line 101 of file AliveState.cpp.

void AliveState::Start ( )

Start all activities.

This method starts all activities of this class, such as sending probe request and testing different baud rate settings

Definition at line 72 of file AliveState.cpp.

void AliveState::Stop ( )

Stop all activities.

This method stops all activities of this class, such as sending probe request and testing different baud rate settings

Definition at line 89 of file AliveState.cpp.

Here is the caller graph for this function:


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