Loading...
Searching...
No Matches
usher.c
Go to the documentation of this file.
249/** @brief Pool-owned worker request; ownership transfers only after thread creation succeeds. */
256 bool arbiter_owned; /**< Protect admitted survey ownership from legacy newest-waiting replacement. */
272 bool exposure_pose_valid; /**< Only validated frame evidence permits replacing request-time geotags. */
296static void start_shoot_worker(const union dc_shot_union *shoot, uint8_t camera_mask, uint32_t request_id);
297static void start_lwir_worker(const union dc_shot_union *shoot, uint32_t request_id, uint64_t received_us);
304static void send_msg_cam_point(uint32_t camera_id, uint32_t session_id, const struct camera_point_result *point);
308static void send_msg_cam_point_update(uint32_t camera_id, const struct camera_point_result *point);
318static void defer_saved_analysis(const char *filename, const union dc_shot_union *shoot, int camera_id,
412 do { written = write(event_wake_writer, ¬ification, sizeof(notification)); } while (written < 0 && errno == EINTR);
471static void queue_shot_result(uint32_t request_id, int32_t number, unsigned camera_id, uint32_t status)
477 union usher_shot_result_union *result = &shot_results[(shot_result_head + shot_result_count++) % SHOT_RESULT_CAPACITY];
492static void queue_image_results(uint32_t request_id, int32_t number, uint8_t camera_mask, uint32_t status)
495 if (camera_mask & (1U << (camera_id - 1))) queue_shot_result(request_id, number, camera_id, status);
597enum camera_stream_state { CAMERA_STREAM_CLOSED, CAMERA_STREAM_ACTIVE, CAMERA_STREAM_UNAVAILABLE, CAMERA_STREAM_DRAINED };
622 if (point_sessions[index].id || point_sessions[index].pending || point_update_pending[index]) pending = true;
711 for (size_t index = 0; index < sizeof(message.bin); ++index) message.bin[index] = usher_protocol.payload[index];
714 if (clock_alignment_map(&fc_clock, message.data.request, message.data.sample.data.sample_begin_us,
845 fprintf(stderr, "USHER:\t--spottercam-targets requires a valid AIcam PANGEA_CAMERA_V1 profile\n");
949 fprintf(stderr, "USHER:\t--earcam-device expects a nonempty ALSA PCM name of at most 255 bytes\n");
1029 fprintf(stderr, "USHER:\t--mock-map-fov expects HORIZONTAL,VERTICAL degrees between 0 and 179\n");
1093 || test_mode || local_mode || mock_map_enabled || mock_transform_enabled || speedtest_enabled)) {
1094 fprintf(stderr, "USHER:\tLWIR spotting requires real --lwircam capture without test/effects/speedtest\n");
1108 if (requested_camera_backend == CAMERA_BACKEND_UNSELECTED) requested_camera_backend = CAMERA_BACKEND_AI_CAM;
1110 fprintf(stderr, "USHER:\t--loomcam owns the AI camera and cannot be combined with another camera backend\n");
1116 if ((requested_camera_backend != CAMERA_BACKEND_AI_CAM && requested_camera_backend != CAMERA_BACKEND_SPOTTER_CAM)
1119 fprintf(stderr, "USHER:\t--native-photo requires real --aicam or --spottercam without model settings\n");
1138 if ((pangea_camera_profile != NULL || pangea_pause_file != NULL) && pangea_directory == NULL) {
1149 || (requested_camera_backend != CAMERA_BACKEND_CHDK && requested_camera_backend != CAMERA_BACKEND_AI_CAM
1150 && requested_camera_backend != CAMERA_BACKEND_SPOTTER_CAM && requested_camera_backend != CAMERA_BACKEND_LWIR_CAM)))) {
1152 "USHER:\t--pangea needs local MIMIC or --pangea-camera with an explicit real --aicam, --spottercam, --chdk or --lwircam backend; no test/effects/speedtest in real mode\n");
1159 || profile_status.st_size <= 0 || profile_status.st_size > CAMERA_PROFILE_MAX_BYTES || access(resolved_pangea_profile, R_OK) != 0) {
1168 if (!mock_map_enabled || !local_mode || realpath(mock_lens_profile, resolved_mock_lens_profile) == NULL
1194 || stat(tile_cache, &status) != 0 || !S_ISDIR(status.st_mode) || access(tile_cache, R_OK | X_OK) != 0) {
1195 fprintf(stderr, "USHER:\t--mock-map needs zoom-18 XYZ JPEGs in the pprzgcs GOOGLE/18 cache layout\n");
1213 if (capture_arbiter_session_id() && (speedtest_enabled || test_mode || mock_map_enabled || mock_transform_enabled)) {
1214 fprintf(stderr, "USHER:\tsurvey mode is for real survey captures, not speedtest or mock operation\n");
1227 || exposure_latency[USHER_CAMERA_LWIRCAM].valid || exposure_latency[USHER_CAMERA_CHDK].valid) {
1228 fprintf(stderr, "USHER:\t--speedtest cannot be combined with daemon, mock, EARcam, pose, or LWIR processing options\n");
1285 if (!(camera.capabilities & CAMERA_CAP_IMAGE) || !camera.prefix || !camera.photo_directory) return 2;
1351 printf("USHER:\tmock attitude transform: %s\n", mock_transform_enabled ? "enabled" : "disabled");
1386 fprintf(stderr, "USHER:\tunable to initialize nonblocking UART output: %s\n", strerror(errno));
1443 fprintf(stderr, "USHER:\tPANGEA exited (status %d); capture continues, saved photos can be replayed\n", pangea_status);
1467 poll_result = poll(event_sources, sizeof(event_sources) / sizeof(event_sources[0]), event_loop_timeout_ms());
1523 printf("USHER SHOT RESULTS:\tpending=%zu dropped=%" PRIu64 "\n", shot_result_count, shot_result_dropped);
1582 if (pose_log_stop() != 0) fprintf(stderr, "USHER POSE:\tlog incomplete: %s\n", strerror(errno));
1683 for (int camera_id = USHER_CAMERA_CHDK; camera_id <= ordered_camera_max && usher_running(); ++camera_id) {
1752 && image->backend.capture_ops && image->backend.capture_ops->acquire && image->backend.capture_ops->finish) {
1818 const bool live_lwir = image->backend.capture_timing && !(image->backend.capabilities & CAMERA_CAP_MOCK);
1819 image->capture_delay = live_lwir && image->backend.capture_delay ? image->backend.capture_delay() : -1;
1820 image->capture_times = live_lwir ? image->backend.capture_timing() : (struct capture_timing) {0};
1850static void resolve_capture_pose(const union dc_shot_union *request, struct captured_image *image)
1878 || image->backend.capture_ops->finish(&image->pending, image->filename, sizeof(image->filename), &keep_running) != 0) {
1894 if (object_metadata) image->backend.detection_summary(detection_summary, sizeof(detection_summary));
1915 if (image_exif_write_hotspots(filename, "status=unsupported_mock_transform; coordinates_omitted=true") != 0) {
1916 fprintf(stderr, "USHER-%d:\tfailed to record unsupported thermal transform\n", shoot->data.nr);
1919 fprintf(stderr, "USHER-%d:\tLWIR hotspot geolocation failed; photo retained\n", shoot->data.nr);
1921 if (image_exif_write_hotspots(filename, "status=analysis_failed; coordinates_omitted=true") != 0) {
1958 fprintf(stderr, "USHER-%d:\tphoto published; directory sync or private alias cleanup incomplete: %s\n",
1980 bool live_capture = lwir_async_recovery_enabled && !test_capture_enabled && !local_capture_only;
2007 if (usher_protocol.msg_id == USHER_CONTROL_NEGOTIATE || usher_protocol.msg_id == USHER_CONTROL_COMMAND) {
2015 for (size_t index = 0; index < sizeof(message.bin); ++index) message.bin[index] = usher_protocol.payload[index];
2023 for (size_t index = 0; index < sizeof(message.bin); ++index) message.bin[index] = usher_protocol.payload[index];
2027 if ((message.data.camera_mask & (1U << (camera_id - 1))) && prepare_session_backend(camera_id))
2052 pose_log_record(usher_protocol.payload, usher_protocol.payload_len, serial_receive_monotonic_us);
2065 for (size_t index = 0; index < sizeof(message.bin); ++index) message.bin[index] = usher_protocol.payload[index];
2095 if ((camera_mask & (1U << (camera_id - 1))) && (backend.capabilities & CAMERA_CAP_POINT_STREAM)) {
2097 const bool recorded = camera_stream_states[camera_id] == CAMERA_STREAM_ACTIVE && owner->record && owner->record(shoot) == 0;
2102 if (!(camera_mask & (1U << (camera_id - 1))) || !(backend.capabilities & CAMERA_CAP_POINT_SESSION)) continue;
2111 if ((camera_mask & (USHER_CAMERA_MASK_CHDK | USHER_CAMERA_MASK_AICAM | USHER_CAMERA_MASK_LWIR)) != 0) {
2114 } else if (usher_protocol.msg_id == USHER_STOP_TARGETED || usher_protocol.msg_id == USHER_START_TARGETED) {
2116 fprintf(stderr, "USHER:\tinvalid USHER session payload length %u\n", usher_protocol.payload_len);
2168 return camera_backend_registry_route(camera_id, configured_camera_backend, local_capture_only);
2178 if (!usher_running() || camera_id < USHER_CAMERA_CHDK || camera_id > USHER_CAMERA_LWIRCAM) return -1;
2184 if (owner->init != camera.init || owner->shoot != camera.shoot || owner->deinit != camera.deinit
2188 fprintf(stderr, "USHER:\tcamera id %d backend change requires completed teardown\n", camera_id);
2227/** @brief Rate-limit thermal recovery so a missing USB camera does not consume every request. */
2349 if (camera_initialized[camera_id] && camera_owners[camera_id].point_stream != backend->point_stream) return -1;
2373 if (stream_active && owner.point_stream && owner.point_stream->drain) owner.point_stream->drain();
2431 queue_shot_result(next_request_id, next_shot.data.nr, USHER_CAMERA_LWIRCAM, USHER_SHOT_FAILED);
2443 * @param[in] request_id Correlation ID returned to the flight controller; distinct from photo number.
2444 * @param[in] received_us Monotonic time when the request was admitted, used to reject stale queued work.
2448static void start_lwir_worker(const union dc_shot_union *shoot, uint32_t request_id, uint64_t received_us)
2478 queue_shot_result(old_request_id, old_shot.data.nr, USHER_CAMERA_LWIRCAM, USHER_SHOT_SUPERSEDED);
2546 * @return False when no finisher thread could start; the caller then finishes the image inline. */
2547static bool start_chdk_finish(const struct capture_job *job, const struct captured_image *image)
2580 const struct camera_backend backend = camera_backend_get(camera_type_for_id(USHER_CAMERA_CHDK));
2636 if (result->request.session == control_session && result->camera_id >= 1 && result->camera_id <= 8) {
2657 && serial_tx_send(USHER_CONTROL_RESULT, bytes, sizeof(bytes)) == 0) control_results[index].dirty = false;
2678 result.status = backend.control(request.command, request.value, &result.observed, &result.evidence);
2685 chdk_retry_after_us = result.status == CAM_CONTROL_APPLIED ? 0 : now && now <= UINT64_MAX - CHDK_RETRY_COOLDOWN_US
2696 * @return False for busy, cooldown, or shutdown; true if handled, even if worker creation fails.
2699static bool admit_chdk_control_locked(const struct usher_control_request *request, uint64_t now)
2710 if (!error) error = pthread_create(&worker, &attributes, handle_chdk_control, &chdk_control_job);
2729 if (usher_protocol.payload_len != USHER_CONTROL_NEGOTIATE_SIZE || bytes[0] != USHER_CONTROL_VERSION
2752 if (requested_session == control_session && now - control_negotiated_us < USHER_CONTROL_LEASE_US)
2760 usher_control_put_u32(hello, sizeof(hello), 9 + 4 * (camera_id - 1), camera_control_capabilities(camera_id));
2773 if (!usher_control_decode_request(usher_protocol.payload, usher_protocol.payload_len, &request)) return;
2777 || now - control_negotiated_us >= USHER_CONTROL_LEASE_US) { pthread_mutex_unlock(&mut); return; }
2785 if (cached->request.request_id == request.request_id && cached->request.command == request.command
2786 && cached->request.value == request.value && cached->request.camera_mask == request.camera_mask) {
2792 if (usher_control_encode_result(bytes, sizeof(bytes), &unknown)) serial_tx_send(USHER_CONTROL_RESULT, bytes, sizeof(bytes));
2797 const struct usher_control_result busy = {.request = request, .camera_id = camera_id, .status = CAM_CONTROL_BUSY};
2799 if (usher_control_encode_result(bytes, sizeof(bytes), &busy)) serial_tx_send(USHER_CONTROL_RESULT, bytes, sizeof(bytes));
2802 control_results[index].result = (struct usher_control_result){.request = request, .camera_id = camera_id,
2846 if (!result) result = pthread_create(&worker, &attributes, handle_chdk_shoot, &chdk_capture_job);
2854 fprintf(stderr, "USHER: unable to start CHDK worker: %s; other cameras remain active\n", strerror(result));
2866static void start_shoot_worker(const union dc_shot_union *shoot, uint8_t camera_mask, uint32_t request_id)
2871 const bool live_capture = lwir_async_recovery_enabled && !test_capture_enabled && !local_capture_only;
2873 if (chdk_async_capture_enabled && !test_capture_enabled && !local_capture_only && !mock_map_enabled) {
2874 if (camera_mask & USHER_CAMERA_MASK_CHDK) chdk_admitted = start_chdk_worker(shoot, request_id);
2883 if ((camera_mask & USHER_CAMERA_MASK_LWIR) != 0) start_lwir_worker(shoot, request_id, monotonic_time_us());
2886 if ((camera_mask & (USHER_CAMERA_MASK_CHDK | USHER_CAMERA_MASK_AICAM | USHER_CAMERA_MASK_LWIR)) == 0) {
2963 if (mask & (1U << (camera_id - 1))) capture_arbiter_complete(shoot, camera_id, false, false, 0, monotonic_time_us());
3018 union usher_capture_arbiter_hello_union hello = {.data = {USHER_CAPTURE_ARBITER_VERSION, session}};
3019 if (serial_tx_send(USHER_CAPTURE_ARBITER_HELLO, hello.bin, sizeof(hello.bin)) == 0) hello_us = now_us;
3022 uint32_t ready = !is_shooting && !waiting_capture && shooting_thread_count < MAX_PROCESSING_THREADS
3024 if (chdk_async_capture_enabled && !test_capture_enabled && !local_capture_only && !mock_map_enabled) {
3026 if (!chdk_capture_in_progress && now_us && now_us >= chdk_retry_after_us) ready |= USHER_CAMERA_MASK_CHDK;
3044 && serial_tx_send(USHER_CAPTURE_ARBITER_RESULT, result.bin, sizeof(result.bin)) == 0) result_pending = false;
3047 if (usher_running() && capture_arbiter_take(ready, now_us, &shot, &mask)) start_shoot_worker(&shot, mask, 0);
3143 for (uint32_t selected = 1; selected <= CAMERA_BACKEND_MAX_ID; ++selected) handle_targeted_stop(selected, session_id);
3164 if (!ops || !ops->stop || !ops->stop(session_id)) send_msg_cam_point(camera_id, session_id, NULL);
3186static void send_msg_cam_point(uint32_t camera_id, uint32_t session_id, const struct camera_point_result *point)
3210static void send_msg_cam_point_update(uint32_t camera_id, const struct camera_point_result *point)
3212 if (!point || !point->session_id || camera_id < 1 || camera_id > CAMERA_BACKEND_MAX_ID) return;
3232 if (serial_tx_send(USHER_CAM_POINT_UPDATE, point_updates[slot].bin, sizeof(point_updates[slot].bin)) != 0) return;
3256 char executable[PATH_MAX], photos[PATH_MAX], map_dir[PATH_MAX], pause_path[PATH_MAX], parent[32], since[32];
3264 if (base == NULL || (size_t)(base - executable) + sizeof("/bin/pangea") > sizeof(executable)) return;
3273 if (photo_directory == NULL || output_directory == NULL || output_directory[0] == '\0') return;
3276 char *arguments[15] = {executable, "--input", (char *)photo_directory, "--output", (char *)output_directory,
3285 const char *resolved_pause = usher_resolve_path(pangea_pause_file, pause_path, sizeof(pause_path));
3296 printf("USHER:\tPANGEA background watcher pid %ld, map directory %s\n", (long)pangea_pid, output_directory);
3394 if (same_source && !job.spotting_done && job.camera_id == USHER_CAMERA_LWIRCAM && lwir_spotter_enabled()) {
3395 const int spotting = lwir_spotter_analyze(job.filename, &job.shot, &job.timing, &keep_running);
3456static void defer_saved_analysis(const char *filename, const union dc_shot_union *shoot, int camera_id,
3464 bool source_valid = lstat(filename, &source) == 0 && S_ISREG(source.st_mode) && source.st_size > 0;
3471 "USHER-%d:\tSODA backlog unavailable/full; original and flight EXIF retained for offline analysis: %s\n",
3493 fprintf(stderr, "USHER:\tSODA backlog worker unavailable: %s; photos continue\n", strerror(result));
3538 const char *soda_application = test_capture_enabled || local_capture_only ? USHER_SODA : backend.soda_application;
3622/** @brief End worker ownership after publication, distinct from releasing the capture ticket. */
3644 if (serial_tx_send(USHER_PAYLOAD, (const uint8_t *)image_buffer[image_idx], IMAGE_SIZE) != 0) {
3676 printf("Usage: %s [--serial DEVICE | --local] [--chdk | --aicam | --spottercam | --lwircam | --loomcam] [--earcam] [--test] [OPTIONS]\n",
3684 printf(" --spottercam use native IMX500 vehicle detection (camera id 2; default outside local mode)\n");
3685 printf(" --native-photo use native libcamera photos without inference with --aicam or --spottercam\n");
3688 printf(" --lwir-spotter-limits US,M maximum exposure interval and pose uncertainty (5000,1)\n");
3694 printf(" --loomcam-model FILE IMX500 RPK uploaded by loomcam (default: %s)\n", USHER_LOOMCAM_MODEL);
3695 printf(" --loomcam-reference-dir DIR outbound references, same filesystem as photos (default: %s)\n",
3700 printf(" --diplacam-config FILE enable native file-backed XY planning (camera id 5; no photographs)\n");
3701 printf(" --earcam-device PCM enable real EARcam with this ALSA input (e.g. default or plughw:CARD=Device,DEV=0)\n");
3702 printf(" --earcam-sim LAT,LON[,DB] earcam backend with a virtual loudspeaker instead of a microphone\n");
3703 printf(" --earcam-band LOW,HIGH tone search band in Hz (default earcam 1800,3200; motionSCOUT K-T-R: 2400,3200)\n");
3708 printf(" --mock-image FILE image used by local or test capture (default: %s)\n", USHER_MOCK_IMAGE);
3712 printf(" --mock-map-fov H,V horizontal,vertical FOV degrees (default model: 60,45; fixed nadir mount)\n");
3713 printf(" --mock-lens FILE AIcam/LOOM saved-photo lens profile, before neural inference; requires --local --mock-map\n");
3715 printf(" --pangea-camera FILE real JPEG mapping geometry; no test images or simulated effects\n");
3716 printf(" --pangea-pause-file FILE defer map work while FILE exists; capture/detection unchanged\n");
3717 printf(" --survey-camera FILE calibrated PANGEA_CAMERA_V1 key=value profile; repeat per camera\n");
3718 printf(" --survey-enforce enable conservative redundant-photo suppression and bounded lookahead\n");
3719 printf(" --survey-overlap RATIO minimum overlap for predictive delay (0..0.9, default 0.3)\n");
3741 struct camera_backend backend = camera_backend_registry_get(type, test_capture_enabled || mock_map_enabled);
3765 struct camera_backend selected = camera_backend_registry_get(type, test_mode || mock_map_enabled);
3844 snprintf(sim_endpoint, sizeof(sim_endpoint), "pty,raw,echo=0,link=%s", USHER_LOCAL_SIM_DEVICE);
3845 snprintf(app_endpoint, sizeof(app_endpoint), "pty,raw,echo=0,link=%s", USHER_LOCAL_APP_DEVICE);
3851 if (wait_for_path(USHER_LOCAL_SIM_DEVICE) != 0 || wait_for_path(USHER_LOCAL_APP_DEVICE) != 0) {
char ** environ
void ai_cam_pipe_set_photo_directory(const char *directory)
Select a borrowed directory before initialization.
Definition ai_cam_pipe.c:376
int ai_cam_pipe_set_native(bool enabled)
Select native or system-camera capture before startup.
Definition ai_cam_pipe.c:381
Parent-side contract for stock and native Raspberry Pi camera capture.
struct camera_backend camera_backend_registry_identity(int camera_id, enum camera_backend_type preferred, bool mock)
Resolve naming/metadata identity from the profile used for acquisition.
Definition camera_backend_registry.c:118
struct camera_backend camera_backend_registry_get(enum camera_backend_type type, bool mock)
Return a descriptor without selecting, configuring or opening hardware.
Definition camera_backend_registry.c:49
enum camera_backend_type camera_backend_registry_route(int camera_id, enum camera_backend_type preferred, bool local_only)
Resolve a physical ID, preferring its configured logical profile.
Definition camera_backend_registry.c:103
Backend definitions and physical-camera routing.
static void capture_set_running(volatile sig_atomic_t *running, bool active)
Update cancellation without locks; this flag does not publish other shared state.
Definition camera_capture.h:52
static bool capture_running(const volatile sig_atomic_t *running)
Atomically poll a borrowed cancellation flag; NULL means no cancellation.
Definition camera_capture.h:46
bool usher_control_encode_result(uint8_t *bytes, size_t size, const struct usher_control_result *result)
Encode one camera's correlated control result.
Definition camera_control.c:71
bool usher_control_put_u32(uint8_t *bytes, size_t size, size_t offset, uint32_t value)
Encode a 32-bit value as four little-endian protocol bytes.
Definition camera_control.c:27
bool usher_control_get_u32(const uint8_t *bytes, size_t size, size_t offset, uint32_t *value)
Decode a bounded four-byte little-endian protocol value.
Definition camera_control.c:34
bool usher_control_value_valid(uint8_t command, uint8_t value)
Validate the command-specific legal value range.
Definition camera_control.c:42
bool usher_control_decode_request(const uint8_t *bytes, size_t size, struct usher_control_request *request)
Validate and decode one fixed-size command payload.
Definition camera_control.c:61
Fixed-size camera-control wire codec and FC-side ticket state.
Public C API for reading PANGEA camera calibration profiles.
int camera_speedtest_create_output_directory(const char *base_directory, char *output, size_t output_size)
Atomically create a private directory for one benchmark run.
Definition camera_speedtest.c:117
int camera_speedtest_run(const struct camera_speedtest_config *config, int first_image)
Capture one untimed warm-up image and ten timed images sequentially.
Definition camera_speedtest.c:438
int camera_speedtest_find_image_block(const struct camera_speedtest_config *config, int *first_image)
Find an unused consecutive image-number block for warm-up and samples.
Definition camera_speedtest.c:404
Standalone, backend-neutral still-camera throughput benchmark.
bool capture_arbiter_set_overlap(double overlap)
Set the overlap floor for deliberate predictive delay, not FC shot spacing.
Definition capture_arbiter.c:286
void capture_arbiter_pose_invalidate(void)
Forget pose history when synchronization is lost; keep saved coverage.
Definition capture_arbiter.c:562
void capture_arbiter_set_enforce(bool enabled)
Enable coverage-based suppression and limited delay, or observe decisions only.
Definition capture_arbiter.c:279
bool capture_arbiter_pending(void)
Check whether waiting or active survey work remains.
Definition capture_arbiter.c:516
void capture_arbiter_pose_sample(const union usher_pose_sample_union *sample, uint64_t earliest_us, uint64_t latest_us)
Add a pose only after the caller has established bounded clock alignment.
Definition capture_arbiter.c:571
bool capture_arbiter_frame_timing(const char *filename, unsigned camera_id, struct capture_observation *observation)
Read embedded capture identity from a stable JPEG; true need not qualify timing.
Definition capture_arbiter.c:739
bool capture_arbiter_take(uint32_t ready_mask, uint64_t now_us, union dc_shot_union *shot, uint8_t *mask)
Admit the oldest ready camera intention after optional coverage evaluation.
Definition capture_arbiter.c:450
bool capture_arbiter_owns(int32_t number)
Identify a shot whose active survey ownership must not be superseded.
Definition capture_arbiter.c:526
uint32_t capture_arbiter_session_id(void)
Return the peer-session token, or zero when survey mode is not configured.
Definition capture_arbiter.c:304
void capture_arbiter_set_scope(const union usher_capture_arbiter_state_union *scope, uint64_t now_us)
Refresh survey authorization or cancel waiting work when scope is withdrawn.
Definition capture_arbiter.c:312
bool capture_arbiter_set_camera_capacity(unsigned camera_id, unsigned limit)
Set admission from a backend's actual capacity, independent of camera ID.
Definition capture_arbiter.c:295
bool capture_arbiter_result(union usher_capture_arbiter_result_union *result, uint32_t ready_mask)
Pop a bounded best-effort result for UART transmission.
Definition capture_arbiter.c:501
void capture_arbiter_complete(const union dc_shot_union *shot, unsigned camera_id, bool saved, bool exposure_pose_valid, double uncertainty_m, uint64_t now_us)
Release admission and optionally credit verified saved coverage.
Definition capture_arbiter.c:459
bool capture_arbiter_observation_pose(struct capture_observation *observation, uint64_t wait_us)
Resolve one bounded observation; wait_us is 0 on the serial thread, at most 200000 in workers.
Definition capture_arbiter.c:712
bool capture_arbiter_load_camera(const char *filename)
Load one camera's measured profile without guessing geometry from its ID.
Definition capture_arbiter.c:238
void capture_arbiter_stop(void)
Cancel waiting intentions, retaining active-image ownership and saved coverage.
Definition capture_arbiter.c:553
bool capture_arbiter_offer(const union usher_capture_arbiter_shoot_union *request, uint64_t now_us)
Split a survey request into bounded per-camera intentions.
Definition capture_arbiter.c:334
Session-scoped survey admission and saved-image evidence for USHER.
static bool capture_timing_valid(const struct capture_timing *timing)
Check whether timing evidence is internally consistent and recent.
Definition capture_timing.h:155
static bool capture_observation_exposure(const struct capture_observation *observation)
Distinguish exposure evidence from other valid observation times.
Definition capture_timing.h:78
void chdk_camera_backend_set_photo_directory(const char *directory)
Definition chdk_camera_backend.c:51
CHDK-owned download and photo publication.
bool clock_alignment_reply(struct clock_alignment *clock, const uint8_t *payload, size_t length, uint64_t received_us)
Validate a flight-controller clock reply and establish a mapping anchor.
Definition clock_alignment.c:50
bool clock_alignment_request(struct clock_alignment *clock, union usher_clock_request_union token, uint64_t sent_us)
Register a newly transmitted clock probe.
Definition clock_alignment.c:39
bool clock_alignment_map(const struct clock_alignment *clock, union usher_clock_request_union token, uint32_t fc_us, uint64_t now_us, struct clock_interval *interval)
Project a controller timestamp into a conservative USHER time interval.
Definition clock_alignment.c:75
static bool poll_result(struct camera_point_result *point)
Drain a bounded reply batch and publish only the active request's result.
Definition dipla_camera_backend.c:234
bool dipla_camera_backend_setup(const char *configuration)
Select the worker experiment before acquiring its process.
Definition dipla_camera_backend.c:66
Optional non-image camera adapter for the native Diplacam worker.
bool ear_cam_pipe_set_settings(const char *settings)
Copy an assignment path before the microphone supervisor starts.
Definition ear_cam_pipe.c:165
Audio/pose adapter and zero-copy snapshot API for the EAR backend.
void ear_camera_backend_set_band(double low_cut_hz, double high_cut_hz)
Forward startup tone-band selection to the audio adapter.
Definition ear_camera_backend.c:342
bool ear_camera_backend_set_device(const char *device)
Copy an ALSA PCM name before initialization or worker startup.
Definition ear_camera_backend.c:332
void ear_camera_backend_set_simulated_source(double lat_deg, double lon_deg, double level_db_at_1m)
Select deterministic synthetic audio before initialization, bypassing ALSA.
Definition ear_camera_backend.c:337
EAR-specific startup configuration behind USHER's generic backend interface.
static void handle_signal(int signal_number)
Request orderly capture-loop termination from a signal handler.
Definition earcam.c:294
int image_exif_write_hotspots(const char *filename, const char *information)
Append structured thermal hotspot/geolocation evidence to JPEG EXIF.
Definition image_exif.c:372
int image_exif_write_complete(const char *filename, const union dc_shot_union *shot, double capture_delay_s, int compensate, const struct capture_timing *timing, const union dc_shot_union *request, double uncertainty_m, const char *objects)
Write flight provenance and an available object-detection result in one metadata transaction.
Definition image_exif.c:473
int image_exif_write_mock_map(const char *filename, double horizontal_fov, double vertical_fov)
Label a synthetic map fixture with its geometry and provider-neutral XYZ tile scheme.
Definition image_exif.c:382
Flight, timing, and thermal-analysis metadata writing for captured JPEGs.
bool image_lens_emulate(const char *application, const char *input, const char *profile, const char *cache, char *output, size_t capacity, const volatile sig_atomic_t *running)
Definition image_lens.c:29
int image_mock_transform(const char *filename, const union dc_shot_union *shot)
Rewrite a local test JPEG to simulate the shot attitude.
Definition image_mock_transform.c:346
Local-simulation JPEG attitude transform API.
#define IMAGE_MOCK_TRANSFORM_SKIPPED
Successful result: transform was intentionally skipped for a near-horizon attitude.
Definition image_mock_transform.h:30
int local_pipe_map_shoot(char *filename, size_t filename_size, const union dc_shot_union *shot, const struct camera_backend *identity, const char *cache_directory, double horizontal_fov_deg, double vertical_fov_deg)
Render a map-backed capture using the trigger's camera geometry.
Definition local_pipe.c:179
int local_pipe_test_init(const char *mock_image)
Initialize test mode with a supplied JPEG or a random fixture beside USHER.
Definition local_pipe.c:87
int local_pipe_shoot(char *filename, size_t filename_size, int image_number, const struct camera_backend *identity)
Create a mock capture file for a shot.
Definition local_pipe.c:193
int local_pipe_map_init(const char *source)
Prepare output storage for map-backed simulation.
Definition local_pipe.c:171
Local mock-camera backend API for simulator and desk testing.
struct camera_backend loom_camera_backend_get(bool mock)
Return LOOM's descriptor without opening a sensor or starting a thread.
Definition loom_camera_backend.c:111
void loom_camera_backend_configure(const char *references, const char *model)
Configure the LOOM plugin before selecting or initializing its owner.
Definition loom_camera_backend.c:62
int loom_camera_backend_set_settings(const char *settings)
Choose one LOOM assignment before acquiring either worker.
Definition loom_camera_backend.c:54
LOOM-owned capture specialization and stream lifecycle.
#define USHER_LOOMCAM_MODEL
Expected RPK path; the framework does not fabricate a trained model.
Definition loom_camera_backend.h:34
#define USHER_LOOMCAM_REFERENCE_DIR
Default outbound archive; use independent reference storage per sortie.
Definition loom_camera_backend.h:38
int lwir_cam_pipe_process_mock(char *filename)
Process a mock thermal image for hardware-free local testing.
Definition lwir_cam_pipe.c:612
void lwir_cam_pipe_set_native_raw(int enabled)
Select whether successful captures keep an explicit .raw companion.
Definition lwir_cam_pipe.c:189
void lwir_cam_pipe_set_photo_directory(const char *directory)
Override the output directory for an isolated standalone benchmark.
Definition lwir_cam_pipe.c:184
int lwir_cam_pipe_set_calibration(const char *path)
Set the optional calibration file used by server-side geolocation.
Definition lwir_cam_pipe.c:194
int lwir_cam_pipe_set_config(const char *path)
Apply a bounded worker configuration before starting the capture server.
Definition lwir_cam_pipe.c:95
Parent-side protocol for USHER's persistent Tiny1-C LWIR capture server.
bool lwir_spotter_profile(const char *filename)
Load a native LWIR intrinsics and mount profile.
Definition lwir_spotter.c:63
int lwir_spotter_analyze(const char *filename, const union dc_shot_union *shot, const struct capture_timing *timing, const volatile sig_atomic_t *running)
Analyse one immutable image with copied capture evidence; no camera is acquired.
Definition lwir_spotter.c:118
bool lwir_spotter_enabled(void)
Test whether saved-LWIR analysis was explicitly selected.
Definition lwir_spotter.c:91
bool lwir_spotter_settings(const char *settings)
Select a separate ONNX detector assignment.
Definition lwir_spotter.c:56
bool lwir_spotter_limits(const char *limits)
Set the timing and pose uncertainty limits for projection.
Definition lwir_spotter.c:74
Serialized saved-LWIR object analysis with immutable frame and exposure evidence.
Small path and writable-directory helpers shared by USHER backends.
static int usher_complete_photo(char *filename, size_t capacity)
Publish a staged photo and return its immutable public path.
Definition path_utils.h:216
static int usher_enter_executable_directory(void)
Change to the directory containing the running USHER executable.
Definition path_utils.h:46
static const char * usher_resolve_path(const char *path, char *buffer, size_t buffer_size)
Expand a leading home-directory shorthand without allocating memory.
Definition path_utils.h:74
int pose_log_record(const uint8_t *payload, size_t length, uint64_t receive_monotonic_us)
Validate and enqueue a raw pose payload without clock mapping evidence.
Definition pose_log.c:296
int pose_log_record_clocked(const uint8_t *payload, size_t length, uint64_t receive_monotonic_us, const struct pose_clock_evidence *evidence)
Validate and enqueue a pose payload with optional mapped timing provenance.
Definition pose_log.c:307
int pose_log_start(const char *directory)
Start a durable asynchronous CSV session, or disable logging when directory is empty.
Definition pose_log.c:197
int pose_log_stop(void)
Flush queued records, join the writer, and close the CSV file.
Definition pose_log.c:375
struct pose_log_stats pose_log_status(void)
Return a synchronized snapshot of logging health and loss counters.
Definition pose_log.c:365
Non-blocking pose-evidence CSV logging API.
int serial_init(const char *port_name)
Configure the shared non-blocking USHER UART descriptor.
Definition serial.c:41
UART descriptor setup and byte-oriented compatibility helpers.
int serial_tx_start(int descriptor)
Attach an already-open non-blocking UART descriptor.
Definition serial_tx.c:71
int serial_tx_send(uint8_t message, const uint8_t *payload, size_t length)
Queue and opportunistically flush one complete USHER frame.
Definition serial_tx.c:156
void serial_tx_stop(void)
Discard pending output and detach the UART during shutdown/restart.
Definition serial_tx.c:92
int serial_tx_flush(void)
Continue writing queued bytes after POLLOUT reports readiness.
Definition serial_tx.c:166
int serial_tx_send_if_idle(uint8_t message, const uint8_t *payload, size_t length)
Send only when no earlier frame is queued, for low-priority probes.
Definition serial_tx.c:161
bool serial_tx_pending(void)
Report queued data or a latched output error needing event-loop handling.
Definition serial_tx.c:174
Thread-safe, non-blocking framed UART transmission for USHER.
int socket_init(int is_server)
Create the loopback UDP endpoint and, for a server, claim USHER ownership.
Definition socket.c:44
void socket_deinit(void)
Close the owned UDP endpoint; repeated calls are harmless.
Definition socket.c:96
Local non-blocking UDP channel used by USHER's development pipeline.
void spotter_cam_pipe_deinit(void)
Stop the native camera process and clear detector-specific configuration.
Definition spotter_cam_pipe.c:532
int spotter_cam_pipe_set_settings(const char *settings)
Select the detector assignment before either capture or saved-picture analysis starts.
Definition spotter_cam_pipe.c:539
int spotter_cam_pipe_analyze(const char *filename, unsigned number)
Analyze a saved simulation/private picture and bind results to its source hash and request.
Definition spotter_cam_pipe.c:546
void spotter_cam_pipe_set_photo_directory(const char *directory)
Set the borrowed output directory before backend initialization.
Definition spotter_cam_pipe.c:367
int spotter_cam_pipe_set_photo_only(bool enabled)
Select or inspect the model-free capture mode before worker startup.
Definition spotter_cam_pipe.c:116
Native USHER adapter for on-sensor detection or photo-only capture.
bool spotter_camera_backend_targets_enabled(void)
True when native Spottercam UART target projection is configured and active.
Definition spotter_camera_backend.c:102
bool spotter_camera_backend_set_targets_profile(const char *filename)
Configure pinhole camera calibration for projecting Spottercam boxes to UART points.
Definition spotter_camera_backend.c:87
Spottercam backend descriptor and optional native UART target projection.
Compile-time build identity strings for USHER executables.
Definition camera_backend.h:79
Function table describing one backend's owned camera operations.
Definition camera_backend.h:94
void(* image_saved)(const char *filename, const union dc_shot_union *shot)
Definition camera_backend.h:129
void(* detection_summary)(char *buffer, size_t size)
Definition camera_backend.h:125
const struct camera_capture_ops * capture_ops
Optional split-phase capture lifecycle.
Definition camera_backend.h:106
const char * soda_application
Optional SODA application name for this backend's saved files.
Definition camera_backend.h:104
void(* save_detection_copy)(const char *filename)
Definition camera_backend.h:126
bool(* bind_frame)(uint64_t sequence, uint64_t sensor_timestamp_ns)
Definition camera_backend.h:124
int(* init)(const char *source_image)
Initialize backend resources; optional mock image path is borrowed.
Definition camera_backend.h:98
void(* deinit)(void)
Release backend resources and reap owned children.
Definition camera_backend.h:102
int(* shoot)(char *filename, size_t filename_size, int image_number)
Trigger one photo and return the backend's owned staging path.
Definition camera_backend.h:100
const struct camera_point_stream_ops * point_stream
Optional repeated point stream, independent of start/stop sessions.
Definition camera_backend.h:131
Driver capabilities whose table must outlive every pending image.
Definition camera_capture.h:73
bool(* has_capacity)(void)
Nonblocking capacity snapshot; acquisition remains the admission authority.
Definition camera_capture.h:95
Per-image ownership record, kept alive until the matching finish call.
Definition camera_capture.h:61
Definition camera_backend.h:50
Repeated correlated point updates from saved photos or non-image work.
Definition camera_backend.h:68
bool(* poll_result)(struct camera_point_result *result)
Definition camera_backend.h:71
Definition camera_backend.h:56
bool(* poll_result)(struct camera_point_result *result)
Definition camera_backend.h:61
Immutable dependencies for one selected and initialized camera backend.
Definition camera_speedtest.h:41
int(* shoot)(char *filename, size_t filename_size, int image_number)
Definition camera_speedtest.h:51
Pool-owned worker request; ownership transfers only after thread creation succeeds.
Definition usher.c:250
Definition capture_timing.h:41
Shared observation evidence with optional LWIR request/frame-delivery timing.
Definition capture_timing.h:133
Per-image handoff from acquisition to publication, EXIF and optional analysis.
Definition usher.c:264
Stateful evidence for at most one pending and one accepted clock probe.
Definition clock_alignment.h:47
Inclusive USHER monotonic-time bounds for a mapped controller timestamp.
Definition clock_alignment.h:41
Long-to-short option mapping; borrowed values are passed to standard getopt.
Definition earcam.c:213
One timestamped geographic position for a replay annotation.
Definition ear_heatmap_overlay.c:79
Optional token-bound evidence mapping a controller pose interval to MORA time.
Definition pose_log.h:29
Snapshot counters for accepted, flushed, dropped, and rejected pose records.
Definition pose_log.h:40
Saved-file analysis job; retaining pixels here would multiply decoder memory.
Definition usher.c:280
One addressed command request shared with the companion protocol.
Definition camera_control.h:36
uint8_t camera_mask
Camera selection mask, command identifier, and command value.
Definition camera_control.h:40
Result evidence for one camera selected by a request mask.
Definition camera_control.h:44
uint8_t camera_id
One-based camera ID, terminal status, observed value, and evidence.
Definition camera_control.h:48
struct usher_control_request request
Correlated request identity; never substitute a shot number here.
Definition camera_control.h:46
Definition usher_protocol.h:116
struct dc_shot_mask_union::@111210153017120377071246320077003270260354205063 data
Definition usher_protocol.h:51
struct dc_shot_union::@351207206061007345226276304225222200157171312155 data
struct usher_cam_point_update_union::@102362040132143036341157267241205145176054226171 data
uint8_t bin[USHER_CAM_POINT_UPDATE_MSG_SIZE]
Definition usher_protocol.h:202
uint8_t bin[USHER_START_TARGETED_MSG_SIZE]
Definition usher_protocol.h:161
struct usher_camera_session_union::@143240012115064153304013213117135060274266136035 data
USHER-to-FC capability advertisement.
Definition usher_protocol.h:341
uint8_t bin[USHER_CAPTURE_ARBITER_HELLO_MSG_SIZE]
Definition usher_protocol.h:343
Best-effort USHER-to-FC terminal result for one camera and shot number.
Definition usher_protocol.h:368
FC-to-USHER spatial observation request, not a physical shutter acknowledgement.
Definition usher_protocol.h:358
uint8_t bin[USHER_CAPTURE_ARBITER_SHOOT_MSG_SIZE]
Definition usher_protocol.h:360
struct usher_capture_arbiter_shoot_union::@051263346153071110145344217246151166245325226104 data
FC-to-USHER survey authorization, independent of individual shot requests.
Definition usher_protocol.h:349
uint8_t bin[USHER_CAPTURE_ARBITER_STATE_MSG_SIZE]
Definition usher_protocol.h:351
uint8_t bin[USHER_CLOCK_REQUEST_MSG_SIZE]
Definition usher_protocol.h:295
Definition usher_protocol.h:307
union usher_clock_request_union request
Definition usher_protocol.h:310
struct usher_pose_clocked_union::@034256305167013222206020157154353370243343140130 data
uint8_t bin[USHER_POSE_CLOCKED_MSG_SIZE]
Definition usher_protocol.h:312
Definition usher_protocol.h:261
struct usher_pose_sample_union::@042015206147200076364072004013147106310343341221 data
Definition usher_protocol.h:137
Definition usher_protocol.h:82
struct usher_status_union::usher_status_struct data
static bool start_chdk_finish(const struct capture_job *job, const struct captured_image *image)
Hand a captured image to the finisher, waiting if the previous one is still writing.
Definition usher.c:2547
static void queue_shot_result(uint32_t request_id, int32_t number, unsigned camera_id, uint32_t status)
Hand one camera's terminal shot result to the serial owner.
Definition usher.c:471
static int camera_prepare(int camera_id)
Select and lazily initialize a backend under the caller's camera ownership.
Definition usher.c:2176
static void handle_targeted_start(uint32_t camera_id, uint32_t session_id)
Start a point session for the addressed backend or backends.
Definition usher.c:3105
static struct camera_backend camera_backend_get(enum camera_backend_type type)
Return an immutable capability description without selecting or opening a camera.
Definition usher.c:3739
static int wait_for_path(const char *path)
Give the new serial bridge time to publish one endpoint.
Definition usher.c:3867
int main(int argc, char *argv[])
Configure USHER and run its multiplexed UART/local-UDP event loop.
Definition usher.c:745
static void stop_local_serial_bridge(void)
Stop the owned simulator bridge and release the local lock.
Definition usher.c:3881
static void send_msg_cam_point(uint32_t camera_id, uint32_t session_id, const struct camera_point_result *point)
Cache and attempt to queue a terminal point-session result.
Definition usher.c:3186
static void chdk_start_cooldown_locked(void)
Pause new CHDK attempts after a failed request; the caller holds mut.
Definition usher.c:2518
static bool set_exposure_latency(unsigned camera_id, const char *value)
Install a camera's calibrated exposure-to-delivery delay bounds.
Definition usher.c:650
static void event_wake_close(void)
Withdraw the wake descriptors and close the self-pipe.
Definition usher.c:455
static void start_pangea(void)
Launch optional mapping as a separate process with no inherited UART descriptors.
Definition usher.c:3254
static enum camera_stream_state camera_stream_states[CAMERA_BACKEND_MAX_ID+1]
Definition usher.c:598
static void drain_camera_backends(void)
Ask active streams and sessions to drain, then service remaining results.
Definition usher.c:3086
static void * recover_lwir_camera(void *unused)
Retry thermal startup outside both UART reception and the optical lane.
Definition usher.c:2243
static bool lwir_ready_or_start_recovery(void)
Check thermal readiness or start at most one background recovery attempt.
Definition usher.c:2308
static void handle_targeted_stop(uint32_t camera_id, uint32_t session_id)
Request the stop phase for a matching point session.
Definition usher.c:3139
static void drain_event_wake(void)
Consume pending wake hints without monopolizing the event loop.
Definition usher.c:445
static bool usher_running(void)
Read service cancellation state through the capture flag accessor.
Definition usher.c:556
static void * handle_lwir_shoot(void *pointer)
Own thermal capture and its last-frame metadata independently of optical work.
Definition usher.c:2398
static struct @340071115233262330352306106172115236376133177017 waiting_lwir
static void stop_soda_backlog(void)
Join the analysis worker without draining session-only pending jobs.
Definition usher.c:3507
static bool start_chdk_worker(const union dc_shot_union *shoot, uint32_t request_id)
Schedule a shot on CHDK's independent capture lane.
Definition usher.c:2827
static bool prepare_session_backend(unsigned camera_id)
Ensure a point-session backend has a registered owner.
Definition usher.c:2139
static void * handle_chdk_finish(void *pointer)
Write metadata for one captured CHDK image after the camera lane was released.
Definition usher.c:2528
static int normalize_long_options(int argc, char *const argv[], char *normalized[], size_t capacity, const struct option_alias aliases[], size_t alias_count)
Translate supported long options into the short-option parser's input.
Definition usher.c:146
static int event_wake_init(void)
Set up the self-pipe before installing its producers.
Definition usher.c:421
static void cameras_deinit(void)
Tear down registered cameras and independently owned analysis workers.
Definition usher.c:2384
static void flush_control_results(void)
Pass dirty control receipts to the UART transmit queue.
Definition usher.c:2650
static int camera_register_stream(const struct camera_backend *backend)
Admit an optional stream once per owner, without opening its sensor.
Definition usher.c:2341
static void record_clocked_pose(void)
Validate and enqueue a token-bound pose sample with clock evidence.
Definition usher.c:704
static void lwir_mark_backoff(void)
Rate-limit thermal recovery so a missing USB camera does not consume every request.
Definition usher.c:2228
static int local_backend_shoot(char *filename, size_t filename_size, int image_number)
Capture a local fixture under the selected optical camera identity.
Definition usher.c:3791
static void handle_control_message(void)
Process negotiation or dispatch an addressed control request.
Definition usher.c:2769
static struct @222245117367130011346353214305367134373362342261 chdk_finish
static union usher_cam_point_update_union point_updates[CAMERA_BACKEND_MAX_ID]
Definition usher.c:313
static void sleep_microseconds(uint64_t microseconds)
Pause for an interval using nanosleep's remaining-time result.
Definition usher.c:635
static void flush_cam_points(void)
Submit unsent point-session results to the UART transmit queue.
Definition usher.c:3240
static void defer_saved_analysis(const char *filename, const union dc_shot_union *shoot, int camera_id, const struct capture_timing *timing)
Submit a published image to the bounded saved-analysis backlog.
Definition usher.c:3456
static struct @124304315067051034320156230025020026251250036072 point_sessions[CAMERA_BACKEND_MAX_ID]
static void resolve_capture_pose(const union dc_shot_union *request, struct captured_image *image)
Resolve live pose evidence associated with an acquired image.
Definition usher.c:1850
static uint64_t monotonic_time_us(void)
Read USHER's monotonic clock for local latency and event ordering.
Definition usher.c:603
static void negotiate_camera_controls(void)
Establish or renew a camera-control lease from the current UART message.
Definition usher.c:2725
static bool admit_chdk_control_locked(const struct usher_control_request *request, uint64_t now)
Admit a control into the exclusive CHDK lane under mut.
Definition usher.c:2699
static void queue_control_result(const struct usher_control_result *result)
Stage a worker's result for serial transmission.
Definition usher.c:2633
static void send_clock_probe(uint64_t now_us)
Opportunistically send a low-priority flight-controller clock probe.
Definition usher.c:667
static void capture_job_release_locked(struct capture_job *job)
Return a job slot while the caller owns the pool mutex.
Definition usher.c:2985
static struct @207237136054161047266202115162153170331345340123 control_results[8]
static void queue_image_results(uint32_t request_id, int32_t number, uint8_t camera_mask, uint32_t status)
Report a shared outcome separately for each addressed image camera.
Definition usher.c:492
static void capture_arbiter_failed(const union dc_shot_union *shoot, uint8_t mask)
Release per-camera survey admission on a failure before normal completion.
Definition usher.c:2960
static void * handle_msg_shoot(void *ptr)
Consume one optical ticket, then finish images outside the lane where safe.
Definition usher.c:1644
static int camera_backend_select(enum camera_backend_type type, bool test_mode)
Install the startup backend, optionally with local test hooks.
Definition usher.c:3763
static struct @072350163320177310065006100132072134337021011155 exposure_latency[4]
static void release_worker_slot(void)
End worker ownership after publication, distinct from releasing the capture ticket.
Definition usher.c:3623
static void handle_received_message(void)
Dispatch one complete UART frame without running slow camera work inline.
Definition usher.c:2004
static void wake_event_loop(void)
Prompt the event loop to recheck shared state.
Definition usher.c:406
static void flush_shot_results(void)
Transfer a bounded batch of shot results to the UART transmit queue.
Definition usher.c:502
static void * handle_chdk_shoot(void *pointer)
Capture one CHDK request and release the camera lane before metadata is written.
Definition usher.c:2577
static void flush_cam_point_updates(void)
Publish fresh stream mailboxes without changing stopped-session result caches.
Definition usher.c:3228
static void notify_systemd_ready(void)
Send READY=1 to systemd when launched with a notify socket.
Definition usher.c:1594
static int run_soda(const char *filename, const union dc_shot_union *shoot, int camera_id)
Run one analysis child directly with bounded runtime and termination grace.
Definition usher.c:3530
static struct camera_backend camera_owners[CAMERA_BACKEND_MAX_ID+1]
Definition usher.c:523
static void * handle_soda_backlog(void *unused)
Run saved-file analysis with fresh priority and idle catch-up.
Definition usher.c:3338
static void send_msg_image_buffer(void)
Consume the newest buffered payload for a legacy image request.
Definition usher.c:3635
static void print_usage(const char *program)
Print the invocation modes and build-specific defaults.
Definition usher.c:3673
static void * handle_chdk_control(void *pointer)
Execute an admitted lens command away from the serial owner.
Definition usher.c:2668
static enum camera_backend_type requested_camera_backend
Definition usher.c:520
static void defer_soda(const char *filename, const union dc_shot_union *shoot, int camera_id)
Queue analysis of a saved original without retaining camera or pixel buffers.
Definition usher.c:3443
static void send_msg_status(void)
Queue a snapshot of USHER's capture counters.
Definition usher.c:3653
static void send_msg_cam_point_update(uint32_t camera_id, const struct camera_point_result *point)
Keep only the newest stream result per camera across UART backpressure.
Definition usher.c:3210
static void capture_job_release(struct capture_job *job)
Return a job slot from a worker that does not hold the pool lock.
Definition usher.c:2999
static void service_capture_arbiter(uint64_t now_us)
Bridge survey decisions to current backend readiness from the serial event loop.
Definition usher.c:3012
static union usher_shot_result_union shot_results[SHOT_RESULT_CAPACITY]
Definition usher.c:353
static void camera_record_pose(const uint8_t *payload, uint16_t length)
Feed one acoustic sample from the pose stream while a listening session is open.
Definition usher.c:689
static void start_lwir_worker(const union dc_shot_union *shoot, uint32_t request_id, uint64_t received_us)
Dispatch a single-flight thermal request without waiting for USB recovery.
Definition usher.c:2448
static int lock_local_instance(void)
Reserve the shared local serial endpoint namespace.
Definition usher.c:3804
static bool camera_point_valid(const struct camera_point_result *point)
Check whether a backend result is suitable for the point wire format.
Definition usher.c:3172
static enum camera_backend_type configured_camera_backend
Definition usher.c:595
static void start_shoot_worker(const union dc_shot_union *shoot, uint8_t camera_mask, uint32_t request_id)
Dispatch admitted image bits while preserving bounded legacy/local policies.
Definition usher.c:2866
static struct capture_job * capture_job_acquire_locked(void)
Reserve a zeroed slot in the bounded job pool.
Definition usher.c:2970
static enum camera_backend_type camera_type_for_id(int camera_id)
Resolve runtime routing without mutating the global selected backend.
Definition usher.c:2166
static pid_t start_local_serial_bridge(void)
Launch the PTY bridge for a hardware-free session.
Definition usher.c:3831
static bool capture_image(const union dc_shot_union *shoot, struct captured_image *image, int camera_id, const struct camera_backend *backend)
Acquire pixels or a completed file for a single camera.
Definition usher.c:1726
static void camera_close_owner(unsigned camera_id)
Withdraw one backend from service and release its resources.
Definition usher.c:2364
static void service_camera_backends(void)
Collect stream updates and completed point-session results.
Definition usher.c:3055
static bool finish_image(const union dc_shot_union *shoot, struct captured_image *image)
Complete publication and metadata before releasing survey ownership.
Definition usher.c:1874
static int event_loop_timeout_ms(void)
Select the next event-loop polling budget.
Definition usher.c:615
static uint32_t camera_control_capabilities(uint8_t camera_id)
Resolve the currently advertised control capabilities.
Definition usher.c:2621
static void stop_pangea(void)
Bound optional map-worker shutdown rather than waiting for its input backlog.
Definition usher.c:3322
static bool wait_owned_child(pid_t *child, unsigned timeout_ms)
Poll an owned subprocess for exit.
Definition usher.c:3306
static void handle_signal(int signal_number)
Request service shutdown from a signal handler.
Definition usher.c:3908
static struct camera_backend camera_identity_get(int camera_id)
Resolve metadata and hooks for a concrete protocol camera identity.
Definition usher.c:3751
void parse_usher(struct usher_transport *t, uint8_t c)
Consume one UART byte and advance a USHER transport parser. The public parameter and lifetime contrac...
Definition usher_protocol.c:54
Shared FC/MORA byte-stream UART framing, messages and payload layouts.