Consuming a UDPStreamer feed so far meant either linking MARTe2 (UDPSClient) or writing Go (Common/Client/go/udpsprotocol). Common/Client/c fills the gap for plain C/C++ integrators: two files depending on nothing but libc and BSD sockets, covering the whole receive path — CONNECT, fragment reassembly, CONFIG/DATA decoding with dequantisation, keepalives and silence-triggered reconnect. No threads are spawned; udps_client_poll() does all the work and runs every callback, so it drops into an existing event loop unsynchronised. Verified against run_udp_producer.sh at 1 Msps: unicast (120 MiB, no loss) and multicast with 12-fragment cycles (116k datagrams, no loss). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
47 lines
1.3 KiB
Makefile
47 lines
1.3 KiB
Makefile
# UDPS C client library — standalone, no MARTe2, no external dependencies.
|
|
#
|
|
# make build libudpsclient.a and the example
|
|
# make example build only the example
|
|
# make cxxcheck verify the header is usable from C++
|
|
# make clean
|
|
|
|
CC ?= cc
|
|
CXX ?= c++
|
|
AR ?= ar
|
|
CFLAGS ?= -O2 -g
|
|
WARN = -Wall -Wextra -Wpedantic
|
|
STD = -std=c99
|
|
CPPFLAGS += -I.
|
|
|
|
# Old glibc (< 2.17) keeps clock_gettime in librt; harmless to add there.
|
|
LDLIBS ?=
|
|
|
|
LIB = libudpsclient.a
|
|
OBJ = udps_client.o
|
|
EXAMPLE = udps_dump
|
|
|
|
.PHONY: all example cxxcheck clean
|
|
|
|
all: $(LIB) $(EXAMPLE)
|
|
|
|
$(LIB): $(OBJ)
|
|
$(AR) rcs $@ $^
|
|
|
|
udps_client.o: udps_client.c udps_client.h
|
|
$(CC) $(STD) $(WARN) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
|
|
|
example: $(EXAMPLE)
|
|
|
|
$(EXAMPLE): example/udps_dump.c $(LIB)
|
|
$(CC) $(STD) $(WARN) $(CFLAGS) $(CPPFLAGS) -o $@ $< $(LIB) $(LDLIBS)
|
|
|
|
# The header is C++-safe; this target keeps it that way.
|
|
cxxcheck: udps_client.h
|
|
echo '#include "udps_client.h"' > .cxxcheck.cpp
|
|
echo 'int main() { udps_client_config_t c; udps_client_config_init(&c); return 0; }' >> .cxxcheck.cpp
|
|
$(CXX) -std=c++11 -Wall -Wextra $(CPPFLAGS) -o .cxxcheck .cxxcheck.cpp $(LIB) $(LDLIBS)
|
|
./.cxxcheck && rm -f .cxxcheck .cxxcheck.cpp
|
|
|
|
clean:
|
|
rm -f $(LIB) $(OBJ) $(EXAMPLE) .cxxcheck .cxxcheck.cpp
|