Loading...
Searching...
No Matches
Loopback UDP implementation for USHER's local development transport.
More...
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <unistd.h>
#include <string.h>
#include "socket.h"
Go to the source code of this file.
|
| int | socket_init (int is_server) |
| | Create the loopback UDP endpoint and, for a server, claim USHER ownership.
|
| void | socket_deinit (void) |
| | Close the owned UDP endpoint; repeated calls are harmless.
|
| int | socket_get_fd (void) |
| | Return the active UDP descriptor for polling.
|
| int | socket_recv (char *buffer, int len) |
| | Receive one datagram without blocking.
|
| void | socket_send (char *buffer, int len) |
| | Send one loopback datagram without blocking.
|
Loopback UDP implementation for USHER's local development transport.
The fixed port permits the local bridge and test tools to find each other without configuration. All I/O is non-blocking so local consumers cannot delay the flight-controller UART event loop.
Definition in file socket.c.
◆ SOCKET_PORT
| #define SOCKET_PORT 32000 |
◆ socket_deinit()
| void socket_deinit |
( |
void | | ) |
|
Close the owned UDP endpoint; repeated calls are harmless.
Definition at line 96 of file socket.c.
◆ socket_get_fd()
| int socket_get_fd |
( |
void | | ) |
|
Return the active UDP descriptor for polling.
- Returns
- Borrowed descriptor, or a negative value before initialization/after teardown.
Definition at line 102 of file socket.c.
◆ socket_init()
| int socket_init |
( |
int | is_server | ) |
|
Create the loopback UDP endpoint and, for a server, claim USHER ownership.
- Parameters
-
| is_server | Nonzero to bind the fixed local port; zero for an unbound sender. |
- Returns
- 0 on success, or -1 on failure; EALREADY preserves an active endpoint.
The server bind doubles as the physical-mode single-instance claim. A second USHER must fail rather than share the port because it would also compete for the same UART and camera resources.
Definition at line 44 of file socket.c.
◆ socket_recv()
| int socket_recv |
( |
char * | buffer, |
|
|
int | len ) |
Receive one datagram without blocking.
- Parameters
-
| buffer | Destination bytes. |
| len | Destination capacity. |
- Returns
- recvfrom() result, including -1/EAGAIN when no datagram is ready.
Definition at line 107 of file socket.c.
◆ socket_send()
| void socket_send |
( |
char * | buffer, |
|
|
int | len ) |
Send one loopback datagram without blocking.
- Parameters
-
| buffer | Payload bytes. |
| len | Payload length. |
Definition at line 126 of file socket.c.
◆ socket_fd
◆ socket_server
| struct sockaddr_in socket_server |
|
static |