Aruna
aruna::comm::channel_t Struct Reference

endpoint type of a comm channel More...

#include <commTypes.h>

Classes

struct  compare_refrence
 
struct  compare_value
 

Public Member Functions

 channel_t (port_t port)
 
 ~channel_t ()
 
err_t send (port_t to_port, uint8_t *data, size_t data_size, bool wait_for_ack=false)
 
bool receive (transmitpackage_t *tpp)
 handeler to handle incomming connections More...
 
bool receive_clear ()
 
bool operator< (const channel_t &b) const
 
bool operator== (const uint8_t port) const
 

Public Attributes

pthread_cond_t in_buffer_not_empty
 
pthread_mutex_t in_buffer_lock
 
std::queue< transmitpackage_tin_buffer
 
err_t register_err = err_t::NOT_STARTED
 
const port_t port
 port nr. More...
 

Detailed Description

endpoint type of a comm channel

Definition at line 150 of file commTypes.h.

Constructor & Destructor Documentation

◆ channel_t()

aruna::comm::channel_t::channel_t ( port_t  port)

Definition at line 507 of file comm.cpp.

507  : port(port) {
508  pthread_mutex_init(&in_buffer_lock, NULL);
509  pthread_cond_init(&in_buffer_not_empty, NULL);
511  }
pthread_mutex_t in_buffer_lock
Definition: commTypes.h:152
err_t register_channel(channel_t *channel)
Register a new communication endpoint.
Definition: comm.cpp:362
pthread_cond_t in_buffer_not_empty
Definition: commTypes.h:151
const port_t port
port nr.
Definition: commTypes.h:164
Here is the call graph for this function:

◆ ~channel_t()

aruna::comm::channel_t::~channel_t ( )

Definition at line 517 of file comm.cpp.

517  {
518  pthread_mutex_destroy(&in_buffer_lock);
519  pthread_cond_destroy(&in_buffer_not_empty);
521  }
pthread_mutex_t in_buffer_lock
Definition: commTypes.h:152
pthread_cond_t in_buffer_not_empty
Definition: commTypes.h:151
err_t unregister_channel(channel_t &channel)
unregister an endpoint
Definition: comm.cpp:378
Here is the call graph for this function:

Member Function Documentation

◆ operator<()

bool aruna::comm::channel_t::operator< ( const channel_t b) const
inline

Definition at line 188 of file commTypes.h.

188  {
189  return this->port < b.port;
190  }
const port_t port
port nr.
Definition: commTypes.h:164

◆ operator==()

bool aruna::comm::channel_t::operator== ( const uint8_t  port) const
inline

Definition at line 192 of file commTypes.h.

192  {
193  return this->port == port;
194  }
const port_t port
port nr.
Definition: commTypes.h:164

◆ receive()

bool aruna::comm::channel_t::receive ( transmitpackage_t tpp)
inline

handeler to handle incomming connections

Note
incomming data is not garanteed to be DATA_SIZE in length. Could be smaller.

Definition at line 171 of file commTypes.h.

171  {
172  pthread_mutex_lock(&in_buffer_lock);
173  while (in_buffer.empty()) {
174  pthread_cond_wait(&in_buffer_not_empty, &in_buffer_lock);
175  }
176  *tpp = in_buffer.front();
177  pthread_mutex_unlock(&in_buffer_lock);
178  return true;
179  }
pthread_mutex_t in_buffer_lock
Definition: commTypes.h:152
std::queue< transmitpackage_t > in_buffer
Definition: commTypes.h:153
pthread_cond_t in_buffer_not_empty
Definition: commTypes.h:151
Here is the caller graph for this function:

◆ receive_clear()

bool aruna::comm::channel_t::receive_clear ( )
inline

Definition at line 182 of file commTypes.h.

182  {
183  free(in_buffer.front().data_received);
184  in_buffer.pop();
185  return true;
186  }
std::queue< transmitpackage_t > in_buffer
Definition: commTypes.h:153
Here is the caller graph for this function:

◆ send()

err_t aruna::comm::channel_t::send ( port_t  to_port,
uint8_t *  data,
size_t  data_size,
bool  wait_for_ack = false 
)

Definition at line 513 of file comm.cpp.

513  {
514  return comm::send(this, to_port, data, data_size, wait_for_ack);
515  }
err_t send(channel_t *channel, port_t to_port, uint8_t *data, size_t data_size, bool wait_for_ack)
Send data.
Definition: comm.cpp:386
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ in_buffer

std::queue<transmitpackage_t> aruna::comm::channel_t::in_buffer

Definition at line 153 of file commTypes.h.

◆ in_buffer_lock

pthread_mutex_t aruna::comm::channel_t::in_buffer_lock

Definition at line 152 of file commTypes.h.

◆ in_buffer_not_empty

pthread_cond_t aruna::comm::channel_t::in_buffer_not_empty

Definition at line 151 of file commTypes.h.

◆ port

const port_t aruna::comm::channel_t::port

port nr.

of the endpoint

Definition at line 164 of file commTypes.h.

◆ register_err

err_t aruna::comm::channel_t::register_err = err_t::NOT_STARTED

Definition at line 154 of file commTypes.h.


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