plptools
Loading...
Searching...
No Matches
Link Class Reference

#include <link.h>

Collaboration diagram for Link:

Public Types

enum  link_type { LINK_TYPE_UNKNOWN = 0 , LINK_TYPE_SIBO = 1 , LINK_TYPE_EPOC = 2 }
 

Public Member Functions

 Link (const char *fname, int baud, NCP *ncp, bool noDSRCheck, unsigned short verbose, const int cancellationFd)
 Construct a new link instance. More...
 
 ~Link ()
 Disconnects from device and destroys instance. More...
 
void send (const BufferStore &buff)
 Send a PLP packet to the Peer. More...
 
bool stuffToSend ()
 Query outstanding packets. More...
 
bool hasFailed ()
 Query connection failure. More...
 
void reset ()
 Reset connection and attempt to reconnect to the peer. More...
 
void purgeQueue (int channel)
 Purge all outstanding packets for a specified remote channel. More...
 
Enum< link_typegetLinkType ()
 Get the current link type. More...
 
int getSpeed ()
 Get current speed of the serial device. More...
 

Private Member Functions

void receive (BufferStore buf)
 Effectively a delegate method that accepts data from our DataLink instance. More...
 
void transmit (BufferStore buf)
 
void sendAck (int seq, Enum< link_type > linkType)
 
void sendReqReq ()
 
void sendReqCon ()
 
void sendReq (Enum< link_type > linkType)
 
void multiAck (struct timeval)
 
void retransmit ()
 
void transmitHoldQueue (int channel)
 
void transmitWaitQueue ()
 
void purgeAllQueues ()
 
unsigned long retransTimeout ()
 

Private Attributes

pthread_t checkThreadId_
 
pthread_mutex_t queueMutex_
 
NCP *const ncp_
 
DataLinkdataLink_ = nullptr
 
int txSequence_ = 1
 
int rxSequence_ = -1
 
int seqMask_ = 7
 
int maxOutstanding_ = 1
 
unsigned long conMagic_
 
const unsigned short verbose_
 
bool failed_
 
Enum< link_typelinkType_
 
std::vector< AckWaitQueueElementackWaitQueue
 
std::vector< BufferStoreholdQueue_
 
std::vector< BufferStorewaitQueue_
 
bool xoff_ [256]
 
const int cancellationFd_
 Used to signal cancellation. More...
 

Friends

class DataLink
 
void * expire_check (void *)
 

Detailed Description

Definition at line 62 of file link.h.

Member Enumeration Documentation

◆ link_type

Enumerator
LINK_TYPE_UNKNOWN 
LINK_TYPE_SIBO 
LINK_TYPE_EPOC 

Definition at line 65 of file link.h.

Constructor & Destructor Documentation

◆ Link()

Link::Link ( const char *  fname,
int  baud,
NCP ncp,
bool  noDSRCheck,
unsigned short  verbose,
const int  cancellationFd 
)

Construct a new link instance.

Parameters
fnameName of serial device.
baudSpeed of serial device.
ncpThe calling NCP instance.
noDSRCheckDisable checking DSR (for buggy serial drivers)
verboseVerbosity (for debugging/troubleshooting)
cancellationFdFile descriptor that can be used to signal that the Link should shutdown.

Definition at line 87 of file link.cc.

◆ ~Link()

Link::~Link ( )

Disconnects from device and destroys instance.

Definition at line 108 of file link.cc.

Member Function Documentation

◆ getLinkType()

Enum< Link::link_type > Link::getLinkType ( )

Get the current link type.

Returns
One of LINK_TYPE_... values.

Definition at line 658 of file link.cc.

◆ getSpeed()

int Link::getSpeed ( )

Get current speed of the serial device.

Returns
The current speed in baud.

Definition at line 662 of file link.cc.

◆ hasFailed()

bool Link::hasFailed ( )

Query connection failure.

Returns
true, if the peer could not be contacted or did not response, false if everything is ok.

Definition at line 648 of file link.cc.

◆ multiAck()

void Link::multiAck ( struct timeval  refstamp)
private

Definition at line 583 of file link.cc.

◆ purgeAllQueues()

void Link::purgeAllQueues ( )
private

Definition at line 141 of file link.cc.

◆ purgeQueue()

void Link::purgeQueue ( int  channel)

Purge all outstanding packets for a specified remote channel.

Parameters
channelThe of the channel for which to remove outstanding packets.

Definition at line 148 of file link.cc.

◆ receive()

void Link::receive ( BufferStore  buf)
private

Effectively a delegate method that accepts data from our DataLink instance.

Called on the DataLink's internal thread.

Definition at line 233 of file link.cc.

◆ reset()

void Link::reset ( )

Reset connection and attempt to reconnect to the peer.

Definition at line 118 of file link.cc.

◆ retransmit()

void Link::retransmit ( )
private

Definition at line 595 of file link.cc.

◆ retransTimeout()

unsigned long Link::retransTimeout ( )
private

Definition at line 114 of file link.cc.

◆ send()

void Link::send ( const BufferStore buff)

Send a PLP packet to the Peer.

Parameters
buffThe contents of the PLP packet.

Definition at line 133 of file link.cc.

◆ sendAck()

void Link::sendAck ( int  seq,
Enum< link_type linkType 
)
private

Definition at line 165 of file link.cc.

◆ sendReq()

void Link::sendReq ( Enum< link_type linkType)
private

Definition at line 221 of file link.cc.

◆ sendReqCon()

void Link::sendReqCon ( )
private

Definition at line 182 of file link.cc.

◆ sendReqReq()

void Link::sendReqReq ( )
private

Definition at line 202 of file link.cc.

◆ stuffToSend()

bool Link::stuffToSend ( )

Query outstanding packets.

Returns
true, if packets are outstanding (not yet acknowledged), false otherwise.

Definition at line 640 of file link.cc.

◆ transmit()

void Link::transmit ( BufferStore  buf)
private

Definition at line 503 of file link.cc.

◆ transmitHoldQueue()

void Link::transmitHoldQueue ( int  channel)
private

Definition at line 466 of file link.cc.

◆ transmitWaitQueue()

void Link::transmitWaitQueue ( )
private

Definition at line 485 of file link.cc.

Friends And Related Function Documentation

◆ DataLink

friend class DataLink
friend

Definition at line 139 of file link.h.

◆ expire_check

void * expire_check ( void *  )
friend

Definition at line 43 of file link.cc.

Member Data Documentation

◆ ackWaitQueue

std::vector<AckWaitQueueElement> Link::ackWaitQueue
private

Definition at line 174 of file link.h.

◆ cancellationFd_

const int Link::cancellationFd_
private

Used to signal cancellation.

Should never be read.

Definition at line 184 of file link.h.

◆ checkThreadId_

pthread_t Link::checkThreadId_
private

Definition at line 160 of file link.h.

◆ conMagic_

unsigned long Link::conMagic_
private

Definition at line 169 of file link.h.

◆ dataLink_

DataLink* Link::dataLink_ = nullptr
private

Definition at line 164 of file link.h.

◆ failed_

bool Link::failed_
private

Definition at line 171 of file link.h.

◆ holdQueue_

std::vector<BufferStore> Link::holdQueue_
private

Definition at line 175 of file link.h.

◆ linkType_

Enum<link_type> Link::linkType_
private

Definition at line 172 of file link.h.

◆ maxOutstanding_

int Link::maxOutstanding_ = 1
private

Definition at line 168 of file link.h.

◆ ncp_

NCP* const Link::ncp_
private

Definition at line 163 of file link.h.

◆ queueMutex_

pthread_mutex_t Link::queueMutex_
private

Definition at line 161 of file link.h.

◆ rxSequence_

int Link::rxSequence_ = -1
private

Definition at line 166 of file link.h.

◆ seqMask_

int Link::seqMask_ = 7
private

Definition at line 167 of file link.h.

◆ txSequence_

int Link::txSequence_ = 1
private

Definition at line 165 of file link.h.

◆ verbose_

const unsigned short Link::verbose_
private

Definition at line 170 of file link.h.

◆ waitQueue_

std::vector<BufferStore> Link::waitQueue_
private

Definition at line 176 of file link.h.

◆ xoff_

bool Link::xoff_[256]
private

Definition at line 177 of file link.h.


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