Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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...
 
int 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...
 
int 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

◆ udp_periph

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

◆ UDP_RX_BUFFER_SIZE

#define UDP_RX_BUFFER_SIZE   256

Definition at line 35 of file udp.h.

◆ UDP_TX_BUFFER_SIZE

#define UDP_TX_BUFFER_SIZE   256

Definition at line 36 of file udp.h.

Function Documentation

◆ udp_arch_periph_init()

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 71 of file udp_arch.c.

References p, 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:

◆ udp_char_available()

int 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 83 of file udp_arch.c.

References p, udp_mutex, and UDP_RX_BUFFER_SIZE.

Referenced by udp_periph_init(), and udp_receive().

+ Here is the caller graph for this function:

◆ udp_check_free_space()

int 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
number of bytes available or 0 if not enough

Definition at line 83 of file udp.c.

References p, and UDP_TX_BUFFER_SIZE.

Referenced by udp_periph_init().

+ Here is the caller graph for this function:

◆ udp_getch()

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 99 of file udp_arch.c.

References p, udp_mutex, and UDP_RX_BUFFER_SIZE.

Referenced by udp_periph_init().

+ Here is the caller graph for this function:

◆ udp_periph_init()

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

Initialize the UDP peripheral.

Definition at line 60 of file udp.c.

References p, udp_arch_periph_init(), udp_char_available(), udp_check_free_space(), udp_getch(), udp_put_buffer(), udp_put_byte(), and udp_send_message().

+ Here is the call graph for this function:

◆ udp_put_buffer()

void udp_put_buffer ( struct udp_periph p,
long  fd,
const uint8_t data,
uint16_t  len 
)

Definition at line 104 of file udp.c.

References p, and UDP_TX_BUFFER_SIZE.

Referenced by udp_periph_init().

+ Here is the caller graph for this function:

◆ udp_put_byte()

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 94 of file udp.c.

References p, and UDP_TX_BUFFER_SIZE.

Referenced by udp_periph_init().

+ Here is the caller graph for this function:

◆ udp_receive()

void udp_receive ( struct udp_periph p)

Read bytes from UDP.

Definition at line 111 of file udp_arch.c.

References UdpSocket::addr_in, if(), p, UdpSocket::sockfd, udp_char_available(), udp_mutex, 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:

◆ udp_send_message()

void udp_send_message ( struct udp_periph p,
long  fd 
)

Send a message.

Definition at line 144 of file udp_arch.c.

References UdpSocket::addr_out, if(), p, and UdpSocket::sockfd.

Referenced by udp_periph_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ udp_send_raw()

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 169 of file udp_arch.c.

References UdpSocket::addr_out, p, and UdpSocket::sockfd.