diff options
author | Taylor Cramer <cramertj@google.com> | 2022-09-01 16:54:52 +0000 |
---|---|---|
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-01 16:54:52 +0000 |
commit | e002d814d347c47fd2d36bd67fe86da451b57d6c (patch) | |
tree | 31ab8084a00213fa74e32c8ecc78932ad15d660b /pw_hdlc | |
parent | 65c3d9bd709165572d2d94a85c0b6f5e9262f55a (diff) | |
download | pigweed-e002d814d347c47fd2d36bd67fe86da451b57d6c.tar.gz |
pw_hdlc: Overload ReadAndProcessPackets w/o ChannelOutput
The ChannelOutput argument is being removed. This will
allow callers to gradually transition their code to the new API.
Change-Id: Id13d7702378d6b67cbe41d65720c1f57d81c7b26
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/108950
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Taylor Cramer <cramertj@google.com>
Diffstat (limited to 'pw_hdlc')
-rw-r--r-- | pw_hdlc/public/pw_hdlc/rpc_packets.h | 9 | ||||
-rw-r--r-- | pw_hdlc/rpc_packets.cc | 10 |
2 files changed, 17 insertions, 2 deletions
diff --git a/pw_hdlc/public/pw_hdlc/rpc_packets.h b/pw_hdlc/public/pw_hdlc/rpc_packets.h index ed8898a67..2913021fa 100644 --- a/pw_hdlc/public/pw_hdlc/rpc_packets.h +++ b/pw_hdlc/public/pw_hdlc/rpc_packets.h @@ -27,6 +27,15 @@ inline constexpr uint8_t kDefaultRpcAddress = 'R'; // Reads HDLC frames with sys_io::ReadByte, using decode_buffer to store frames. // HDLC frames sent to rpc_address are passed to the RPC server. Status ReadAndProcessPackets(rpc::Server& server, + span<std::byte> decode_buffer, + unsigned rpc_address = kDefaultRpcAddress); + +// Reads HDLC frames with sys_io::ReadByte, using decode_buffer to store frames. +// HDLC frames sent to rpc_address are passed to the RPC server. +// +// Note: this overload (with the `ChannelOutput` argument) is deprecated and +// will be removed. +Status ReadAndProcessPackets(rpc::Server& server, rpc::ChannelOutput& output, span<std::byte> decode_buffer, unsigned rpc_address = kDefaultRpcAddress); diff --git a/pw_hdlc/rpc_packets.cc b/pw_hdlc/rpc_packets.cc index d3261fbc6..fd429686f 100644 --- a/pw_hdlc/rpc_packets.cc +++ b/pw_hdlc/rpc_packets.cc @@ -20,7 +20,6 @@ namespace pw::hdlc { Status ReadAndProcessPackets(rpc::Server& server, - rpc::ChannelOutput& output, span<std::byte> decode_buffer, unsigned rpc_address) { Decoder decoder(decode_buffer); @@ -32,11 +31,18 @@ Status ReadAndProcessPackets(rpc::Server& server, if (auto result = decoder.Process(data); result.ok()) { Frame& frame = result.value(); if (frame.address() == rpc_address) { - server.ProcessPacket(frame.data(), output) + server.ProcessPacket(frame.data()) .IgnoreError(); // TODO(b/242598609): Handle Status properly } } } } +Status ReadAndProcessPackets(rpc::Server& server, + rpc::ChannelOutput&, + span<std::byte> decode_buffer, + unsigned rpc_address) { + return ReadAndProcessPackets(server, decode_buffer, rpc_address); +} + } // namespace pw::hdlc |