Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
dipla_camera_backend.c File Reference

Nonblocking USHER-to-Diplacam process admission and reply supervision. More...

#include "dipla_camera_backend.h"
#include "../modules/dipla_cam/dipla_ipc.h"
#include <errno.h>
#include <poll.h>
#include <spawn.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
Include dependency graph for dipla_camera_backend.c:

Go to the source code of this file.

Enumerations

enum  {
  configuration_path_capacity = 512 , worker_descriptor = 198 , shutdown_term_grace_ms = 100 , shutdown_kill_grace_ms = 1000 ,
  shutdown_poll_ms = 10 , reply_batch_limit = 16 , computational_validity_quality = 1000 , milliseconds_per_second = 1000 ,
  nanoseconds_per_millisecond = 1000000
}

Functions

static uint64_t milliseconds (void)
 Read elapsed-time evidence unaffected by changes to civil time.
bool dipla_camera_backend_setup (const char *configuration)
 Select the worker experiment before acquiring its process.
static bool enabled (void)
 Report explicit opt-in independently of process or model readiness.
static int completion_fd (void)
 Expose only completion readiness to USHER's existing event poll.
static bool transmit (const struct dipla_request *request)
 Admit one whole packet without blocking the UART owner.
static bool reap_child (unsigned timeout_ms)
 Invalidate requests before escalating worker shutdown and reaping it.
static void deinit (void)
 Close the planner channel, reset session state, and stop the child.
static int initialize (void)
 Spawn one native planner with a private, close-on-exec packet socket.
static bool start (uint32_t session)
 Admit a nonzero session and discard correlation from the previous one.
static bool stop (uint32_t session)
 End only the matching session, even if its stop packet cannot be sent.
static int record (const union dc_shot_union *shot)
 Retrieve a point and admit a new observation only when its credit is free.
static bool poll_result (struct camera_point_result *point)
 Drain a bounded reply batch and publish only the active request's result.
static void drain (void)
 Stop the selected session and reap the worker during owner shutdown.
static int init (const char *source)
 Acquire the worker without opening any optical camera.
struct camera_backend dipla_camera_backend_get (void)
 Describe camera slot five without starting work.

Variables

char ** environ
static char config_path [configuration_path_capacity]
static int descriptor = -1
static pid_t child = -1
static uint32_t active_session
static uint32_t pending_number
static uint32_t admitted_number
static uint32_t assimilated_number
static struct dipla_reply pending_reply
static bool reply_received
static uint64_t pending_since
static bool survey_lost

Detailed Description

Nonblocking USHER-to-Diplacam process admission and reply supervision.

Only the native worker owns field truth, GP state and inference. This adapter keeps the UART owner responsive by sending bounded local packets and publishing correlated completed replies, never waiting for a new plan.

Definition in file dipla_camera_backend.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
configuration_path_capacity 
worker_descriptor 
shutdown_term_grace_ms 
shutdown_kill_grace_ms 
shutdown_poll_ms 
reply_batch_limit 
computational_validity_quality 
milliseconds_per_second 
nanoseconds_per_millisecond 

Definition at line 36 of file dipla_camera_backend.c.

Function Documentation

◆ completion_fd()

int completion_fd ( void )
static

Expose only completion readiness to USHER's existing event poll.

Definition at line 77 of file dipla_camera_backend.c.

◆ deinit()

void deinit ( void )
static

Close the planner channel, reset session state, and stop the child.

Retain ownership if the child cannot be reaped even after escalation, so another planner cannot be launched over the old one.

Definition at line 113 of file dipla_camera_backend.c.

◆ dipla_camera_backend_get()

struct camera_backend dipla_camera_backend_get ( void )

Describe camera slot five without starting work.

Returns
Native non-image backend with process-owned point-stream callbacks.

Static callback lifetimes let USHER retain the descriptor safely; camera admission remains separate from route readiness.

Definition at line 285 of file dipla_camera_backend.c.

◆ dipla_camera_backend_setup()

bool dipla_camera_backend_setup ( const char * configuration)

Select the worker experiment before acquiring its process.

Parameters
configurationNonempty worker-INI path, copied into bounded storage.
Returns
False for an invalid/overlong path or an already acquired channel.

Copying prevents an argv buffer from becoming a dangling configuration pointer. Setup does not open the field, initialize ONNX or acquire a sensor.

Definition at line 66 of file dipla_camera_backend.c.

◆ drain()

void drain ( void )
static

Stop the selected session and reap the worker during owner shutdown.

Definition at line 279 of file dipla_camera_backend.c.

◆ enabled()

bool enabled ( void )
static

Report explicit opt-in independently of process or model readiness.

Definition at line 75 of file dipla_camera_backend.c.

◆ init()

int init ( const char * source)
static

Acquire the worker without opening any optical camera.

Parameters
sourceUnused image-source argument from the common backend interface.
Returns
Result of local worker acquisition.

Definition at line 283 of file dipla_camera_backend.c.

◆ initialize()

int initialize ( void )
static

Spawn one native planner with a private, close-on-exec packet socket.

Returns
Zero for an existing/started channel or a disabled backend; minus one on failure.

The deliberately reserved child descriptor makes argv independent of the parent's transient descriptor numbers. Duplication clears CLOEXEC only for the endpoint the worker must retain; the parent's other endpoint is closed.

Definition at line 135 of file dipla_camera_backend.c.

◆ milliseconds()

uint64_t milliseconds ( void )
static

Read elapsed-time evidence unaffected by changes to civil time.

Returns
Monotonic milliseconds, or zero when a valid deadline cannot be formed.

Definition at line 59 of file dipla_camera_backend.c.

◆ poll_result()

bool poll_result ( struct camera_point_result * point)
static

Drain a bounded reply batch and publish only the active request's result.

Parameters
pointDestination changed only for a complete correlated reply.
Returns
True for a completed valid or invalid point, false for no eligible reply.

MSG_TRUNC detects oversized packets instead of accepting their prefix. The sixteen-packet work limit prevents stale traffic monopolizing the event loop. Credit and point packets may arrive in either order. Point completion does not wait for assimilation, and credits never become FC camera results. Quality 1000 denotes a valid computation, not physical accuracy.

Definition at line 234 of file dipla_camera_backend.c.

◆ reap_child()

bool reap_child ( unsigned timeout_ms)
static

Invalidate requests before escalating worker shutdown and reaping it.

Closing the channel prevents a late completion from reaching a new session. The polling grace permits ordinary teardown; SIGKILL contains a worker that does not respond. This is supervision, not a real-time guarantee.

Definition at line 95 of file dipla_camera_backend.c.

◆ record()

int record ( const union dc_shot_union * shot)
static

Retrieve a point and admit a new observation only when its credit is free.

Parameters
shotImmutable FC request; groundalt carries Q8 height above ground.
Returns
Zero on packet admission, minus one while busy/disabled or on invalid input.

One unassimilated measurement credit bounds evidence admission in addition to point-reply correlation. While it is occupied, point-only requests can read the retained route without admitting another measurement. A successful send does not imply ONNX finished or a navigation point exists.

Definition at line 206 of file dipla_camera_backend.c.

◆ start()

bool start ( uint32_t session)
static

Admit a nonzero session and discard correlation from the previous one.

Parameters
sessionOwner-selected session token, not a photo number.
Returns
True for packet admission; it does not mean a plan is ready.

Definition at line 170 of file dipla_camera_backend.c.

◆ stop()

bool stop ( uint32_t session)
static

End only the matching session, even if its stop packet cannot be sent.

Parameters
sessionToken returned to the owner at start admission.
Returns
Whether the stop packet was admitted, or a lost survey was ended locally.

Local invalidation is unconditional after the match so a lost stop cannot leave old replies eligible for a later sortie.

Definition at line 189 of file dipla_camera_backend.c.

◆ transmit()

bool transmit ( const struct dipla_request * request)
static

Admit one whole packet without blocking the UART owner.

Parameters
requestImmutable stack-owned packet; no pointer survives this call.
Returns
False on backpressure, a missing channel or an incomplete send.

SOCK_SEQPACKET preserves boundaries, so a failed packet is not retried as an unsafely reconstructed suffix. The caller keeps session ownership.

Definition at line 83 of file dipla_camera_backend.c.

Variable Documentation

◆ active_session

uint32_t active_session
static

Definition at line 50 of file dipla_camera_backend.c.

◆ admitted_number

uint32_t admitted_number
static

Definition at line 51 of file dipla_camera_backend.c.

◆ assimilated_number

uint32_t assimilated_number
static

One unassimilated measurement credit, separate from point retrieval.

Definition at line 51 of file dipla_camera_backend.c.

◆ child

pid_t child = -1
static

Sole child reaped by this owner, not by unrelated camera backends.

Definition at line 49 of file dipla_camera_backend.c.

◆ config_path

char config_path[configuration_path_capacity]
static

Owned configuration path, immutable while a worker is acquired.

Definition at line 47 of file dipla_camera_backend.c.

◆ descriptor

int descriptor = -1
static

One private packet socket; minus one means no process channel.

Definition at line 48 of file dipla_camera_backend.c.

◆ environ

char** environ
extern

Inherited environment; executable/configuration remain explicit argv.

◆ pending_number

uint32_t pending_number
static

Distinct sortie and observation correlation tokens.

Definition at line 50 of file dipla_camera_backend.c.

◆ pending_reply

struct dipla_reply pending_reply
static

Definition at line 52 of file dipla_camera_backend.c.

◆ pending_since

uint64_t pending_since
static

Monotonic admission time, not a worker/FC wall-clock timestamp.

Definition at line 54 of file dipla_camera_backend.c.

◆ reply_received

bool reply_received
static

Definition at line 53 of file dipla_camera_backend.c.

◆ survey_lost

bool survey_lost
static

Worker loss requires STOP before another survey can establish a geographic frame.

Definition at line 55 of file dipla_camera_backend.c.