5 #ifndef ARUNA_COMMTYPES_H 6 #define ARUNA_COMMTYPES_H 40 constexpr
static uint8_t HEADER_SIZE = 4;
81 bool notify_on_ack =
false;
100 (
sizeof(transp.
size)));
102 memcpy(&bin[
sizeof(transp.
size)],
106 memcpy(&bin[
sizeof(transp.
size) +
sizeof(transp.
n)],
110 memcpy(&bin[
sizeof(transp.
size) +
sizeof(transp.
n) +
sizeof(transp.
from_port)],
114 memcpy(&bin[
sizeof(transp.
size) +
sizeof(transp.
n) +
sizeof(transp.
from_port) +
sizeof(transp.
to_port)],
127 const static int header_length = (
sizeof(transp.
size) +
sizeof(transp.
n) +
sizeof(transp.
from_port) +
129 if (bin[0] < header_length)
132 int dataLength = bin[0] - header_length;
134 memcpy(&transp.
size, &bin[0], (
sizeof(transp.
size)));
135 memcpy(&transp.
n, &bin[
sizeof(transp.
size)], (
sizeof(transp.
n)));
159 err_t send(port_t to_port, uint8_t *data,
size_t data_size,
bool wait_for_ack =
false);
172 pthread_mutex_lock(&in_buffer_lock);
173 while (in_buffer.empty()) {
174 pthread_cond_wait(&in_buffer_not_empty, &in_buffer_lock);
176 *tpp = in_buffer.front();
177 pthread_mutex_unlock(&in_buffer_lock);
183 free(in_buffer.front().data_received);
189 return this->port < b.
port;
193 return this->port ==
port;
210 #endif //ARUNA_COMMTYPES_H
uint8_t * data_transmitting
Data to be transmitted.
static void transmitpackage_to_binary(transmitpackage_t transp, uint8_t *bin)
Get binary array of transmitpackage, for sending over a link.
static constexpr size_t MAX_DATA_SIZE
pthread_mutex_t in_buffer_lock
port_t to_port
to whom to send it to.
err_t send(channel_t *channel, port_t to_port, uint8_t *data, size_t data_size, bool wait_for_ack)
Send data.
bool operator()(const channel_t &a, const channel_t &b) const
uint8_t data_lenght
size of the data
uint8_t size
total size of package (+ the size of the size variable)
port_t from_port
channel who is sending the data.
std::queue< transmitpackage_t > in_buffer
bool receive(transmitpackage_t *tpp)
handeler to handle incomming connections
bool operator()(const channel_t *a, const channel_t *b) const
pthread_cond_t in_buffer_not_empty
endpoint type of a comm channel
bool operator<(const channel_t &b) const
static const comm::port_t port
const port_t port
port nr.
uint8_t * data_received
pointer to where incoming data must be stored.
bool operator==(const uint8_t port) const
static bool binary_to_transmitpackage(uint8_t *bin, transmitpackage_t &transp)
get tansmitpackage of binary array.