Open source LXI library
Changes since liblxi v1.19:
Rob Carruthers:
refactor(bonjour): Fix typo & Refine browse default domain
feat(bonjour): Add mdns support for macOS
This code is designed to discover LXI (LAN eXtensions for Instrumentation) devices using the Bonjour service (dns_sd.h) discovery protocol. The flow of the implementation is as follows:
bonjour_discover(lxi_info_t *info, int timeout_ms) is the entry point of the code. It takes an lxi_info_t struct to store the discovered information and a timeout in milliseconds. It calls the browse_lxi_services() function with these parameters. The lxi_info_t is setup with callbacks to initially to recieve the discovered instrument data. See test folder for examples.
lxi_info_t struct is defined in lxi.h. browse_lxi_services(lxi_info_t *info, int timeout_ms) iterates through lxi_services (defined in lxi.h) and calls the Bonjour DNSServiceBrowse() function for each service. It then processes the results and sets a timeout to stop waiting for results after a specified duration. It provides the browse_call back() function as a callback.
browse_callback() is called for each discovered service. It extracts relevant information about the service and then creates a browse_data_t struct to aggregate service data. It calls DNSServiceResolve() to resolve the service's hostname, and provides resolve_callback() as a callback.
resolve_callback() is called once the service hostname is resolved. It calls the resolve_ip_address() function to convert the hostname into an IP address. It also extracts more information about the service and then calls the info->service() callback function with the discovered service's information. Finally, it frees the memory allocated for the browse_data_t struct.
resolve_ip_address() takes a hostname and port, and converts them into an IP address using the getaddrinfo() function. The resulting IP address is stored in the provided buffer.
Service types and labels are declared in the lxi_services array in src/lxc.c
Changes since liblxi v1.18:
Silence cast of function type in autogenerated vxi11 code
Add test example demonstrating how to use RAW protocol
Rob Carruthers:
Docs: Update README with Homebrew installation instructions
macOS: Build support
macOS: Add check for RPC headers
macOS: Remove libtirpc dependency during build process
Changes since liblxi v1.17:
Alexander von Gluck IV:
build: make avahi optional again after meson conversion
vxi11: Drop non-portable pthread timeout call; solves #30
Changes since liblxi v1.16:
Perry Hung:
vxi11: do not fail on zero length messages
Zero length messages are valid replies in VXI-11. Do not return an error and prematurely exit.
Reads should be repeated until EOI or an error is encountered.
Holzapfel:
Fixed missing VXI11 connect-abort multithreading synchronization
Fixed LXI connect error memory leak
Changes since liblxi v1.15:
Changes since liblxi v1.14:
Fix meson libtirpc dependency
Remove the hardcoded include patch to libtirpc and replace it with one dynamically resolved via pkg-config.
The reason for implementing the meson dependency check this way is to avoid linking with libtirpc because it is broken with regards to its Sun RPC implementation so instead we link with the RPC implementation which still reside in glibc. However, glibc removed their RPC header files so we need the headers from libtirpc.
Further investigation is required to find and fix the bug in the libtirpc RPC implementation so we can get back to normal. They changed something moving it out of glibc and they shouldn't have.
Changes since liblxi v1.13:
Add lxi_discover_if() function
Works exactly like the lxi_discover() function but adds an additional parameter ifname that specifies which network interface to broadcast on in case of using the DISCOVER_VXI11 discovery type.
Bypass linking with libtirpc because of bug
When linking with libtirpc some of the VXI11 connect calls starts failing for some instruments. More investigation is needed to find out exactly why. It may be some regression in the libtirpc Sun RPC implementation. The Sun RPC features have recently been moved out of glibc into libtirpc.
When we do not link with libtirpc we fallback to using glibc's implementation of the RPC features which seem to work better.
We will accept this hack for now.
Remove include directory
Reduce compiler optimization level
Introduce proper Avahi timeout handling for mDNS
Increase number of allowed concurrent sessions
Fix timeout for VXI11 connect
The VXI11 API does not provide any way to specify a communications timeout when connecting. To fix that we move the VXI11 connect action into a separate thread that is killed if the timeout is reached before the thread exits.
The old behavior was that the connect action would eventually time out for instruments on known subnets. However, if you tried to connect to an instrument on an unknown subnet it would stall forever.
This new implementation will respect the timeout for all cases.
Replace autotools with meson
zramudzuli:
Changes since liblxi v1.12:
Fix Sun RPC headers configure check
The Sun RPC headers have been moved out of glibc into a separate library, libtirpc.
Hence, check for glibc headers first and in case that fails search for headers in libtirpc via pkg-config.
Add const qualifier
Because it is the right thing to do.
Update Travis
Use libtirpc for Sun RPC headers
Move test directory
Changes since liblxi v1.11:
Add send/receive sanity checks
Strip CR from ID response string
Fixes corrupted output from 'lxi discover'.
Changes since liblxi v1.10: