Instead, determine when the next send, in the whole pile of sends,
needs to happen and sleep until then.
This is the first functionality in this project that is more than simple
glue code. This is the first non-trivial functionality that has some
internal logic to it.
I'd really like to write a test for it.
This environment (C, CMake, pico-sdk) makes testing hard! :(
I'd like to build the test as a host/native executable and run it on the
build machine at build time, even though the primary/production use of
the code under test would be on the pico, cross-compiled.
I know testing this way is imperfect: It would fail to catch the entire
class of bugs that are caused by the code under test making architecture
assumptions that are valid on the build host but invalid on the cross
target. But it would still be very useful for all other classes of bugs!
This usage is very much not supported:
1. CMake doesn't support it at all: One toolchain per language:
https://discourse.cmake.org/t/compile-unit-test-natively-and-cross-compile-code-for-embedded-target/3607
https://discourse.cmake.org/t/using-multiple-toolchains-in-the-same-project/1505
2. Even if I'm confident in my ability to write portable C that runs
correctly on both build-host and cross-target architectures, I can't
rely on pico-sdk's pheap library to be portable in this way. It is
super-not-portable-at-all; it will never run on the build host.
3. If I use a different, portable heap library, I'm duplicating code
already in the pico-sdk standard library. The pico is small enough
already. I'd rather not deploy two heap libraries.
4. I could define an interface to a heap library & use the pico's heap
library when deploying to the pico & some other heap library when testing
on the native machine, but
a. My interface-to-pico's-heap-library code goes untested.
b. The interface-to-a-heap-library code would likely add overhead.
c. That's a bunch of extra code to write. :(
5. Even if I worked through the interfacing-with-pico's-heap library issue
and made this a separate, independent, portable library, I'd still
be left with the problem of composing the two pieces. Do I build
a library .so separately, spinning up a separate Debian VM for that?
Does pico-sdk even support building libraries? Or do I copy the source
of the library into the executable's source tree & make building the
library part of the executable's build process? Ick. :(
6. Other option: Build a test intended to run on the pico. It's nuts
that this is the least-nuts option. :(
I am very discouraged. :(
I don't even bother to keep this functionality separate with a clean
interface for the test harness. :(
So, no tests. :~(
For now.
Advice welcome.