aboutsummaryrefslogtreecommitdiff
path: root/pw_multisink
diff options
context:
space:
mode:
Diffstat (limited to 'pw_multisink')
-rw-r--r--pw_multisink/BUILD.gn3
-rw-r--r--pw_multisink/Kconfig38
-rw-r--r--pw_multisink/docs.rst9
-rw-r--r--pw_multisink/public/pw_multisink/multisink.h10
-rw-r--r--pw_multisink/public/pw_multisink/util.h2
-rw-r--r--pw_multisink/util.cc10
6 files changed, 62 insertions, 10 deletions
diff --git a/pw_multisink/BUILD.gn b/pw_multisink/BUILD.gn
index 842dfac0f..960ecdacb 100644
--- a/pw_multisink/BUILD.gn
+++ b/pw_multisink/BUILD.gn
@@ -87,6 +87,9 @@ pw_source_set("test_thread") {
# that depends on this pw_source_set and a pw_source_set that provides the
# implementaiton of test_thread. See :stl_multisink_test as an example.
pw_source_set("multisink_threaded_test") {
+ # TODO: b/303282642 - Remove this testonly
+ testonly = pw_unit_test_TESTONLY
+
sources = [ "multisink_threaded_test.cc" ]
deps = [
":pw_multisink",
diff --git a/pw_multisink/Kconfig b/pw_multisink/Kconfig
new file mode 100644
index 000000000..c5d61405a
--- /dev/null
+++ b/pw_multisink/Kconfig
@@ -0,0 +1,38 @@
+# Copyright 2023 The Pigweed Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+menu "pw_multisink"
+
+config PIGWEED_MULTISINK
+ bool "Multisink module used for forwarding multiple attached sinks"
+ help
+ See :ref:`module-pw_multisink` for module details.
+
+if PIGWEED_MULTISINK
+
+config PIGWEED_MULTISINK_LOCK_INTERRUPT_SAFE
+ bool "Use an interrupt safe lock"
+ default y
+ help
+ When reading and writing from the underlying ring-buffer. The multisink
+ module will use an interrupt safe lock instead of a mutex.
+
+config PIGWEED_MULTISINK_UTIL
+ bool "Link pw_multisink.util library"
+ help
+ Include the Pigweed provided utility functions for multisink operations.
+
+endif # PIGWEED_MULTISINK
+
+endmenu
diff --git a/pw_multisink/docs.rst b/pw_multisink/docs.rst
index c8cb8f31b..da95b4558 100644
--- a/pw_multisink/docs.rst
+++ b/pw_multisink/docs.rst
@@ -186,3 +186,12 @@ The `PeekEntry` and `PopEntry` return two different drop counts, one for the
number of entries a drain was skipped forward for providing a small buffer or
draining too slow, and the other for entries that failed to be added to the
MultiSink.
+
+Zephyr
+======
+To enable `pw_multisink` with Zephyr use the following Kconfigs:
+- `CONFIG_PIGWEED_MULTISINK` to link `pw_multisink` into your Zephyr build
+- `CONFIG_PIGWEED_MULTISINK_UTIL` to link `pw_multisink.util`
+
+To enable the Pigweed config value `PW_MULTISINK_CONFIG_LOCK_INTERRUPT_SAFE`, use
+`CONFIG_PIGWEED_MULTISINK_LOCK_INTERRUPT_SAFE`.
diff --git a/pw_multisink/public/pw_multisink/multisink.h b/pw_multisink/public/pw_multisink/multisink.h
index c65d03dd3..3224cffbb 100644
--- a/pw_multisink/public/pw_multisink/multisink.h
+++ b/pw_multisink/public/pw_multisink/multisink.h
@@ -135,13 +135,13 @@ class MultiSink {
Result<ConstByteSpan> PopEntry(ByteSpan buffer,
uint32_t& drain_drop_count_out,
uint32_t& ingress_drop_count_out)
- PW_LOCKS_EXCLUDED(multisink_->lock_);
+ PW_LOCKS_EXCLUDED(multisink_ -> lock_);
// Overload that combines drop counts.
// TODO(cachinchilla): remove when downstream projects migrated to new API.
[[deprecated("Use PopEntry with different drop count outputs")]] Result<
ConstByteSpan>
PopEntry(ByteSpan buffer, uint32_t& drop_count_out)
- PW_LOCKS_EXCLUDED(multisink_->lock_) {
+ PW_LOCKS_EXCLUDED(multisink_ -> lock_) {
uint32_t ingress_drop_count = 0;
Result<ConstByteSpan> result =
PopEntry(buffer, drop_count_out, ingress_drop_count);
@@ -173,7 +173,7 @@ class MultiSink {
// OK - the entry or entries were removed from the multisink succesfully.
// FAILED_PRECONDITION - The drain must be attached to a sink.
Status PopEntry(const PeekedEntry& entry)
- PW_LOCKS_EXCLUDED(multisink_->lock_);
+ PW_LOCKS_EXCLUDED(multisink_ -> lock_);
// Returns a copy of the next available entry if it exists and acquires the
// latest drop count if the drain was advanced, and the latest ingress drop
@@ -195,7 +195,7 @@ class MultiSink {
Result<PeekedEntry> PeekEntry(ByteSpan buffer,
uint32_t& drain_drop_count_out,
uint32_t& ingress_drop_count_out)
- PW_LOCKS_EXCLUDED(multisink_->lock_);
+ PW_LOCKS_EXCLUDED(multisink_ -> lock_);
// Drains are not copyable or movable.
Drain(const Drain&) = delete;
@@ -313,7 +313,7 @@ class MultiSink {
MultiSink(ByteSpan buffer)
: ring_buffer_(true), sequence_id_(0), total_ingress_drops_(0) {
ring_buffer_.SetBuffer(buffer)
- .IgnoreError(); // TODO(b/242598609): Handle Status properly
+ .IgnoreError(); // TODO: b/242598609 - Handle Status properly
AttachDrain(oldest_entry_drain_);
}
diff --git a/pw_multisink/public/pw_multisink/util.h b/pw_multisink/public/pw_multisink/util.h
index d9a335989..9b6a30a5e 100644
--- a/pw_multisink/public/pw_multisink/util.h
+++ b/pw_multisink/public/pw_multisink/util.h
@@ -27,7 +27,7 @@ namespace pw::multisink {
// pw.snapshot.Snapshot.
Status UnsafeDumpMultiSinkLogs(
MultiSink& sink,
- pw::log::LogEntries::StreamEncoder& encoder,
+ pw::log::pwpb::LogEntries::StreamEncoder& encoder,
size_t max_num_entries = std::numeric_limits<size_t>::max());
} // namespace pw::multisink
diff --git a/pw_multisink/util.cc b/pw_multisink/util.cc
index b3ad6616e..be0e95096 100644
--- a/pw_multisink/util.cc
+++ b/pw_multisink/util.cc
@@ -21,13 +21,15 @@
namespace pw::multisink {
-Status UnsafeDumpMultiSinkLogs(MultiSink& sink,
- pw::log::LogEntries::StreamEncoder& encoder,
- size_t max_num_entries) {
+Status UnsafeDumpMultiSinkLogs(
+ MultiSink& sink,
+ pw::log::pwpb::LogEntries::StreamEncoder& encoder,
+ size_t max_num_entries) {
auto callback = [&encoder](ConstByteSpan entry) {
encoder
.WriteBytes(
- static_cast<uint32_t>(pw::log::LogEntries::Fields::kEntries), entry)
+ static_cast<uint32_t>(pw::log::pwpb::LogEntries::Fields::kEntries),
+ entry)
.IgnoreError();
};
return sink.UnsafeForEachEntry(callback, max_num_entries);