Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
arch independent UDP API More...
#include "std.h"
#include "mcu_periph/udp_arch.h"
#include "pprzlink/pprzlink_device.h"
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) |
arch independent UDP API
Definition in file udp.h.
struct 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 |
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().
int udp_char_available | ( | struct udp_periph * | p | ) |
Get number of bytes available in receive buffer.
p | pointer to UDP peripheral |
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().
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.
p | pointer to UDP peripheral |
len | how many bytes of free space to check for |
Definition at line 83 of file udp.c.
References p, and UDP_TX_BUFFER_SIZE.
Referenced by udp_periph_init().
uint8_t udp_getch | ( | struct udp_periph * | p | ) |
Get the last character from the receive buffer.
p | pointer to UDP peripheral |
Definition at line 99 of file udp_arch.c.
References p, udp_mutex, and UDP_RX_BUFFER_SIZE.
Referenced by 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().
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().
void udp_put_byte | ( | struct udp_periph * | p, |
long | fd, | ||
uint8_t | data | ||
) |
Add one data byte to the tx buffer.
p | pointer to UDP peripheral |
data | byte 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().
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().
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().
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.