From 8760de0406c3e53926b00b817928fe250b51358c Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 26 Mar 2021 17:16:21 +0800 Subject: [PATCH] rkyv-test-server: add log_message_send to test Send messages This uncovered a bug in the kernel where Send messages didn't work. Signed-off-by: Sean Cross --- services/rkyv-test-server/src/lib.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/services/rkyv-test-server/src/lib.rs b/services/rkyv-test-server/src/lib.rs index d99bf0722..4a510fe96 100644 --- a/services/rkyv-test-server/src/lib.rs +++ b/services/rkyv-test-server/src/lib.rs @@ -106,6 +106,27 @@ pub fn log_message, T: AsRef>(prefix: S, message: T) { .unwrap(); } +/// Log the given message to the server. +/// We accept any two parameters that can be treated as strings. +pub fn log_message_send, T: AsRef>(prefix: S, message: T) { + let op = api::LogString { + prefix: xous::String::from_str(prefix.as_ref()), + message: xous::String::from_str(message.as_ref()), + }; + + // Convert the opcode into a serialized buffer. This consumes the opcode, which will + // exist on the heap in its own page. Furthermore, this will be in a flattened format + // suitable for passing around as a message. + let buf = buffer::Buffer::try_from(op).unwrap(); + + // Send the message to the server. + buf.send( + ensure_connection(), + api::Opcode::LogString.to_u32().unwrap(), + ) + .unwrap(); +} + // Callback messages will be sent to this private server. // Ideally it would be held in a Mutex. static mut CALLBACK_SID: Option = None;