Redesign (simplify) top-level avclan interface to use expected/nullable unique_ptr

- Peripheral::read/send now return `expected<unique_ptr<Frame>, Error>`
for a unified success/error interface.
- Peripheral::route returns `expected<unique_ptr<Frame>, Error>` to
distinguish intent: (intentional) non-response vs unable to respond
- Other functions with optional message semantics (handle,poll,react)
return a unique_ptr whose ownership-state indicates response intent
(i.e. send new message)

Bundled necessary changes:
- Switch Frame allocation from global to local (enabled via member
  function new/delete)
- Add new header-library tl::expected to shim avr-libstdcpp

Unrelated: Defensive `continue` added after `route`, to reduce Bus
activity check latency

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Allen Hill
2026-07-17 14:24:03 -07:00
parent 200a225add
commit 5208e083f3
17 changed files with 536 additions and 187 deletions
+4 -1
View File
@@ -48,9 +48,11 @@
#pragma once
#include <cstdint>
#include <memory>
#include "avclan.h"
#include "frame.hpp"
#include "stdshim.hpp"
namespace avclan {
@@ -77,7 +79,8 @@ public:
void measure();
#endif
Error::Read read(uint16_t address, Frame *in, Frame::Print print);
expected<std::unique_ptr<Frame>, Error::Read> read(uint16_t address,
Frame::Print print);
Error::Send send(const Frame *out, Frame::Print print);
private: