Aruna
aruna::comm::transmitpackage_t Struct Reference

transmit ready package. More...

#include <commTypes.h>

Static Public Member Functions

static void transmitpackage_to_binary (transmitpackage_t transp, uint8_t *bin)
 Get binary array of transmitpackage, for sending over a link. More...
 
static bool binary_to_transmitpackage (uint8_t *bin, transmitpackage_t &transp)
 get tansmitpackage of binary array. More...
 

Public Attributes

port_t from_port
 channel who is sending the data. More...
 
port_t to_port
 to whom to send it to. More...
 
uint8_t n
 
uint8_t * data_transmitting
 Data to be transmitted. More...
 
uint8_t * data_received
 pointer to where incoming data must be stored. More...
 
uint8_t data_lenght
 size of the data More...
 
uint8_t size
 total size of package (+ the size of the size variable) More...
 
bool notify_on_ack = false
 notify the task on ack/no ack More...
 
bool resend = false
 is the package being resend? More...
 

Static Public Attributes

static constexpr uint8_t HEADER_SIZE = 4
 

Detailed Description

transmit ready package.

Definition at line 39 of file commTypes.h.

Member Function Documentation

◆ binary_to_transmitpackage()

static bool aruna::comm::transmitpackage_t::binary_to_transmitpackage ( uint8_t *  bin,
transmitpackage_t transp 
)
inlinestatic

get tansmitpackage of binary array.

Parameters
binarray that stores the info
transptransmitpackage that the data need to go to.
Returns
true if succeeded, false if not

Definition at line 125 of file commTypes.h.

125  {
126  // check for complete header
127  const static int header_length = (sizeof(transp.size) + sizeof(transp.n) + sizeof(transp.from_port) +
128  sizeof(transp.to_port));
129  if (bin[0] < header_length)
130  return 0;
131 
132  int dataLength = bin[0] - header_length;
133  transp.data_received = (uint8_t *) malloc(dataLength);
134  memcpy(&transp.size, &bin[0], (sizeof(transp.size)));
135  memcpy(&transp.n, &bin[sizeof(transp.size)], (sizeof(transp.n)));
136  memcpy(&transp.from_port, &bin[sizeof(transp.size) + sizeof(transp.n)], (sizeof(transp.from_port)));
137  memcpy(&transp.to_port, &bin[sizeof(transp.size) + sizeof(transp.n) + sizeof(transp.from_port)],
138  (sizeof(transp.to_port)));
139  memcpy(transp.data_received,
140  &bin[sizeof(transp.size) + sizeof(transp.n) + sizeof(transp.from_port) + sizeof(transp.to_port)],
141  dataLength);
142  transp.data_lenght = dataLength;
143  return 1;
144  }
Here is the caller graph for this function:

◆ transmitpackage_to_binary()

static void aruna::comm::transmitpackage_t::transmitpackage_to_binary ( transmitpackage_t  transp,
uint8_t *  bin 
)
inlinestatic

Get binary array of transmitpackage, for sending over a link.

bin arrangement: size, n, from_port, to_port, data

Parameters
transppackage to make a binary from.
binto store the data to.

Definition at line 95 of file commTypes.h.

95  {
96 
97  // bit 0: size
98  memcpy(&bin[0],
99  &transp.size,
100  (sizeof(transp.size)));
101  // bit 1: N
102  memcpy(&bin[sizeof(transp.size)],
103  &transp.n,
104  (sizeof(transp.n)));
105  // bit 2: from port
106  memcpy(&bin[sizeof(transp.size) + sizeof(transp.n)],
107  &transp.from_port,
108  (sizeof(transp.from_port)));
109  // bit 3: to port
110  memcpy(&bin[sizeof(transp.size) + sizeof(transp.n) + sizeof(transp.from_port)],
111  &transp.to_port,
112  sizeof(transp.to_port));
113  // bit 4: data
114  memcpy(&bin[sizeof(transp.size) + sizeof(transp.n) + sizeof(transp.from_port) + sizeof(transp.to_port)],
115  transp.data_transmitting,
116  transp.data_lenght);
117  }
Here is the caller graph for this function:

Member Data Documentation

◆ data_lenght

uint8_t aruna::comm::transmitpackage_t::data_lenght

size of the data

Definition at line 70 of file commTypes.h.

◆ data_received

uint8_t* aruna::comm::transmitpackage_t::data_received

pointer to where incoming data must be stored.

Definition at line 65 of file commTypes.h.

◆ data_transmitting

uint8_t* aruna::comm::transmitpackage_t::data_transmitting

Data to be transmitted.

Definition at line 60 of file commTypes.h.

◆ from_port

port_t aruna::comm::transmitpackage_t::from_port

channel who is sending the data.

Definition at line 44 of file commTypes.h.

◆ HEADER_SIZE

constexpr uint8_t aruna::comm::transmitpackage_t::HEADER_SIZE = 4
static

Definition at line 40 of file commTypes.h.

◆ n

uint8_t aruna::comm::transmitpackage_t::n

Definition at line 54 of file commTypes.h.

◆ notify_on_ack

bool aruna::comm::transmitpackage_t::notify_on_ack = false

notify the task on ack/no ack

Definition at line 81 of file commTypes.h.

◆ resend

bool aruna::comm::transmitpackage_t::resend = false

is the package being resend?

Definition at line 86 of file commTypes.h.

◆ size

uint8_t aruna::comm::transmitpackage_t::size

total size of package (+ the size of the size variable)

Definition at line 75 of file commTypes.h.

◆ to_port

port_t aruna::comm::transmitpackage_t::to_port

to whom to send it to.

Definition at line 49 of file commTypes.h.


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