Files
video-setup/include/error.h
mikael-lovqvists-claude-agent 62c25247ef Add protocol module, video-node binary, query/web CLI tools
- Protocol module: framed binary encoding for control requests/responses
  (ENUM_DEVICES, ENUM_CONTROLS, GET/SET_CONTROL, STREAM_OPEN/CLOSE)
- video-node: scans /dev/media* and /dev/video*, serves V4L2 device
  topology and controls over TCP; uses UDP discovery for peer announce
- query_cli: auto-discovers a node, queries devices and controls
- protocol_cli: low-level protocol frame decoder for debugging
- dev/web: Express 5 ESM web inspector — live SSE discovery picker,
  REST bridge to video-node, controls UI with sliders/selects/checkboxes
- Makefile: sequential module builds before cli/node to fix make -j races
- common.mk: add DEPFLAGS (-MMD -MP) for automatic header dependencies
- All module Makefiles: split compile/link, generate .d dependency files
- discovery: replace 100ms poll loop with pthread_cond_timedwait;
  respond to all announcements (not just new peers) for instant re-discovery
- ENUM_DEVICES response: carry device_caps (V4L2_CAP_*) per video node
  so clients can distinguish capture nodes from metadata nodes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 01:04:56 +00:00

68 lines
1.4 KiB
C

#pragma once
#include <errno.h>
typedef enum Error_Code {
ERR_NONE = 0,
ERR_SYSCALL = 1,
ERR_INVALID = 2,
ERR_NOT_FOUND = 3,
} Error_Code;
struct Syscall_Error_Detail {
int err_no;
};
struct Invalid_Error_Detail {
int config_line; /* source line number, or 0 if not applicable */
const char *message; /* static string describing what was wrong */
};
struct App_Error {
Error_Code code;
const char *file;
int line;
union {
struct Syscall_Error_Detail syscall;
struct Invalid_Error_Detail invalid;
} detail;
};
void app_error_print(struct App_Error *e);
#define APP_OK \
((struct App_Error){ .code = ERR_NONE })
#define APP_IS_OK(e) \
((e).code == ERR_NONE)
#define APP_SYSCALL_ERROR() \
((struct App_Error){ \
.code = ERR_SYSCALL, \
.file = __FILE__, \
.line = __LINE__, \
.detail = { .syscall = { .err_no = errno } }, \
})
#define APP_INVALID_ERROR() \
((struct App_Error){ \
.code = ERR_INVALID, \
.file = __FILE__, \
.line = __LINE__, \
})
#define APP_INVALID_ERROR_MSG(cfg_line, msg) \
((struct App_Error){ \
.code = ERR_INVALID, \
.file = __FILE__, \
.line = __LINE__, \
.detail = { .invalid = { .config_line = (cfg_line), .message = (msg) } }, \
})
#define APP_NOT_FOUND_ERROR() \
((struct App_Error){ \
.code = ERR_NOT_FOUND, \
.file = __FILE__, \
.line = __LINE__, \
})