Paparazzi UAS  v5.15_devel-113-g1b57ff1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
udp_arch.c File Reference
#include "mcu_periph/udp.h"
#include "udp_socket.h"
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <pthread.h>
#include <sys/select.h>
#include "rt_priority.h"
+ Include dependency graph for udp_arch.c:

Go to the source code of this file.

Macros

#define UDP_THREAD_PRIO   10
 

Functions

static void * udp_thread (void *data)
 check for new udp packets to receive or send. More...
 
void udp_arch_init (void)
 
void udp_arch_periph_init (struct udp_periph *p, char *host, int port_out, int port_in, bool broadcast)
 Initialize the UDP peripheral. 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_receive (struct udp_periph *p)
 Read bytes from UDP. 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...
 

Variables

static pthread_mutex_t udp_mutex = PTHREAD_MUTEX_INITIALIZER
 

Macro Definition Documentation

#define UDP_THREAD_PRIO   10

Definition at line 37 of file udp_arch.c.

Referenced by udp_thread().

Function Documentation

void udp_arch_init ( void  )

Definition at line 43 of file udp_arch.c.

References udp_thread().

+ Here is the call graph for this function:

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 udp_periph::network, and udp_socket_create().

+ Here is the call 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 83 of file udp_arch.c.

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

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 udp_periph::rx_buf, udp_periph::rx_extract_idx, and UDP_RX_BUFFER_SIZE.

void udp_receive ( struct udp_periph p)

Read bytes from UDP.

Definition at line 111 of file udp_arch.c.

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

+ Here is the call graph for this function:

void udp_send_message ( struct udp_periph p,
long  fd 
)
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, udp_periph::network, and UdpSocket::sockfd.

static void * udp_thread ( void *  data)
static

check for new udp packets to receive or send.

Definition at line 182 of file udp_arch.c.

References fd, get_rt_prio(), udp_receive(), and UDP_THREAD_PRIO.

Referenced by udp_arch_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

pthread_mutex_t udp_mutex = PTHREAD_MUTEX_INITIALIZER
static

Definition at line 41 of file udp_arch.c.