Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
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... | |
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) |
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 |
#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().
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().
uint16_t udp_char_available | ( | struct udp_periph * | p | ) |
Get number of bytes available in receive buffer.
p | pointer to UDP peripheral |
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().
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.
p | pointer to UDP peripheral |
len | how many bytes of free space to check for |
Definition at line 83 of file udp.c.
References udp_periph::tx_insert_idx, 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 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().
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 udp_periph::device, udp_periph::rx_extract_idx, udp_periph::rx_insert_idx, udp_periph::tx_insert_idx, 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 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().
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 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().
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().
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().
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.