Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
udp.h File Reference

arch independent UDP API More...

#include "std.h"
#include "mcu_periph/udp_arch.h"
#include "pprzlink/pprzlink_device.h"
+ Include dependency graph for udp.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  udp_periph
 

Macros

#define UDP_RX_BUFFER_SIZE   256
 
#define UDP_TX_BUFFER_SIZE   256
 

Functions

void udp_periph_init (struct udp_periph *p, char *host, int port_out, int port_in, bool broadcast)
 Initialize the UDP peripheral. More...
 
bool udp_check_free_space (struct udp_periph *p, long *fd, uint16_t len)
 Check if there is enough free space in the transmit buffer. More...
 
void udp_put_byte (struct udp_periph *p, long fd, uint8_t data)
 Add one data byte to the tx buffer. More...
 
uint16_t udp_char_available (struct udp_periph *p)
 Get number of bytes available in receive buffer. More...
 
uint8_t udp_getch (struct udp_periph *p)
 Get the last character from the receive buffer. More...
 
void udp_arch_periph_init (struct udp_periph *p, char *host, int port_out, int port_in, bool broadcast)
 Initialize the UDP peripheral. More...
 
void udp_send_message (struct udp_periph *p, long fd)
 Send a message. More...
 
void udp_send_raw (struct udp_periph *p, long fd, uint8_t *buffer, uint16_t size)
 Send a packet from another buffer. More...
 
void udp_receive (struct udp_periph *p)
 Read bytes from UDP. More...
 
void udp_put_buffer (struct udp_periph *p, long fd, const uint8_t *data, uint16_t len)
 

Detailed Description

arch independent UDP API

Definition in file udp.h.


Data Structure Documentation

struct udp_periph

Definition at line 38 of file udp.h.

+ Collaboration diagram for udp_periph:
Data Fields
struct link_device device Generic device interface.
void * network UDP network.
uint8_t rx_buf[UDP_RX_BUFFER_SIZE] Receive buffer.
uint16_t rx_extract_idx
uint16_t rx_insert_idx
uint8_t tx_buf[UDP_TX_BUFFER_SIZE] Transmit buffer.
uint16_t tx_insert_idx

Macro Definition Documentation

#define UDP_RX_BUFFER_SIZE   256

Definition at line 35 of file udp.h.

Referenced by udp_char_available(), udp_getch(), and udp_receive().

#define UDP_TX_BUFFER_SIZE   256

Definition at line 36 of file udp.h.

Referenced by udp_check_free_space(), udp_put_buffer(), and udp_put_byte().

Function Documentation

void udp_arch_periph_init ( struct udp_periph p,
char *  host,
int  port_out,
int  port_in,
bool  broadcast 
)

Initialize the UDP peripheral.

Allocate UdpSocket struct and create and bind the UDP socket.

Definition at line 69 of file udp_arch.c.

References udp_periph::network, and udp_socket_create().

Referenced by udp_periph_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint16_t udp_char_available ( struct udp_periph p)

Get number of bytes available in receive buffer.

Parameters
ppointer to UDP peripheral
Returns
number of bytes available in receive buffer

Definition at line 81 of file udp_arch.c.

References udp_periph::rx_extract_idx, udp_periph::rx_insert_idx, and UDP_RX_BUFFER_SIZE.

Referenced by udp_periph_init(), and udp_receive().

+ Here is the caller graph for this function:

bool udp_check_free_space ( struct udp_periph p,
long *  fd,
uint16_t  len 
)

Check if there is enough free space in the transmit buffer.

Parameters
ppointer to UDP peripheral
lenhow many bytes of free space to check for
Returns
TRUE if enough space for len bytes

Definition at line 83 of file udp.c.

References udp_periph::tx_insert_idx, and UDP_TX_BUFFER_SIZE.

Referenced by udp_periph_init().

+ Here is the caller graph for this function:

uint8_t udp_getch ( struct udp_periph p)

Get the last character from the receive buffer.

Parameters
ppointer to UDP peripheral
Returns
last byte

Definition at line 97 of file udp_arch.c.

References udp_periph::rx_buf, udp_periph::rx_extract_idx, and UDP_RX_BUFFER_SIZE.

Referenced by udp_periph_init().

+ Here is the caller graph for this function:

void udp_periph_init ( struct udp_periph p,
char *  host,
int  port_out,
int  port_in,
bool  broadcast 
)
void udp_put_buffer ( struct udp_periph p,
long  fd,
const uint8_t data,
uint16_t  len 
)

Definition at line 103 of file udp.c.

References udp_periph::tx_buf, udp_periph::tx_insert_idx, and UDP_TX_BUFFER_SIZE.

Referenced by udp_periph_init().

+ Here is the caller graph for this function:

void udp_put_byte ( struct udp_periph p,
long  fd,
uint8_t  data 
)

Add one data byte to the tx buffer.

Parameters
ppointer to UDP peripheral
databyte to add to tx buffer

Definition at line 93 of file udp.c.

References udp_periph::tx_buf, udp_periph::tx_insert_idx, and UDP_TX_BUFFER_SIZE.

Referenced by udp_periph_init().

+ Here is the caller graph for this function:

void udp_receive ( struct udp_periph p)

Read bytes from UDP.

Definition at line 109 of file udp_arch.c.

References UdpSocket::addr_in, if(), udp_periph::network, udp_periph::rx_buf, udp_periph::rx_insert_idx, UdpSocket::sockfd, udp_char_available(), and UDP_RX_BUFFER_SIZE.

Referenced by udp_thread().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void udp_send_message ( struct udp_periph p,
long  fd 
)

Send a message.

Definition at line 142 of file udp_arch.c.

References UdpSocket::addr_out, if(), udp_periph::network, UdpSocket::sockfd, udp_periph::tx_buf, and udp_periph::tx_insert_idx.

Referenced by udp_periph_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void udp_send_raw ( struct udp_periph p,
long  fd,
uint8_t buffer,
uint16_t  size 
)

Send a packet from another buffer.

Definition at line 168 of file udp_arch.c.

References UdpSocket::addr_out, udp_periph::network, and UdpSocket::sockfd.