From 39153f6fba2c2da3c47d915720f0402d8b406b32 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 2 Apr 2021 18:07:39 +0800 Subject: [PATCH] cleanup warnings --- RELEASE-v0.8.md | 8 +++++++- services/com/src/api.rs | 6 ------ services/com/src/lib.rs | 6 ++---- services/com/src/main.rs | 7 +------ services/rkyv-test-client/src/main.rs | 4 ++-- xtask/src/main.rs | 2 +- 6 files changed, 13 insertions(+), 20 deletions(-) diff --git a/RELEASE-v0.8.md b/RELEASE-v0.8.md index b07d8d8b6..92719b5ac 100644 --- a/RELEASE-v0.8.md +++ b/RELEASE-v0.8.md @@ -299,7 +299,13 @@ fn xmain() -> ! { } /// only if doing callbacks. This might actually make more sense in a thread of its own, to make it -/// truly asynchronous, but this example is focused on the messaging API, not the threading API +/// truly asynchronous, but this example is focused on the messaging API, not the threading API. +/// This example admittedly sweeps a rather hairy issue (passing data between process-local threads) +/// under the carpet. As of Xous 0.8 your options to send data around between threads within a process +/// are: +/// 1. Define a crate-local API to pass the messages +/// 2. Use Atomic data types (only applicable if you have primitive data to send) +/// 3. Do some static mut unsafe thing because we don't have a Mutex data type yet. fn do_callback(cb_conns: [Option; 32]) { let a = useful_computation(); for maybe_conn in cb_conns.iter() { diff --git a/services/com/src/api.rs b/services/com/src/api.rs index 67ad1bc2f..a4659036d 100644 --- a/services/com/src/api.rs +++ b/services/com/src/api.rs @@ -1,12 +1,6 @@ -use xous::{Message, ScalarMessage}; -use xous_ipc::String; - // NOTE: the use of ComState "verbs" as commands is not meant as a 1:1 mapping of commands // It's just a convenient abuse of already-defined constants. However, it's intended that // the COM server on the SoC side abstracts much of the EC bus complexity away. -use com_rs::*; -use com_rs_ref as com_rs; - pub(crate) const SERVER_NAME_COM: &str = "_COM manager_"; #[derive(Debug, Default, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] diff --git a/services/com/src/lib.rs b/services/com/src/lib.rs index bf2680068..a93b3c774 100644 --- a/services/com/src/lib.rs +++ b/services/com/src/lib.rs @@ -1,7 +1,5 @@ #![cfg_attr(target_os = "none", no_std)] -use core::convert::TryInto; - /// This is the API that other servers use to call the COM. Read this code as if you /// are calling these functions inside a different process. pub mod api; @@ -23,7 +21,7 @@ fn battstats_server(sid0: usize, sid1: usize, sid2: usize, sid3: usize) { loop { let msg = xous::receive_message(sid).unwrap(); match FromPrimitive::from_usize(msg.body.id()) { - Some(api::Callback::BattStats) => msg_scalar_unpack!(msg, lo, hi, _, _, { + Some(Callback::BattStats) => msg_scalar_unpack!(msg, lo, hi, _, _, { let bs: BattStats = [lo, hi].into(); unsafe { if let Some(cb) = BATTSTATS_CB { @@ -31,7 +29,7 @@ fn battstats_server(sid0: usize, sid1: usize, sid2: usize, sid3: usize) { } } }), - Some(api::Callback::Drop) => { + Some(Callback::Drop) => { break; // this exits the loop and kills the thread } None => (), diff --git a/services/com/src/main.rs b/services/com/src/main.rs index 687ba9cb4..94b404048 100644 --- a/services/com/src/main.rs +++ b/services/com/src/main.rs @@ -4,7 +4,6 @@ mod api; use api::Opcode; -use core::convert::TryFrom; use num_traits::{ToPrimitive, FromPrimitive}; use log::{error, info, trace}; @@ -12,7 +11,7 @@ use log::{error, info, trace}; use com_rs_ref as com_rs; use com_rs::*; -use xous::{CID, msg_scalar_unpack, msg_blocking_scalar_unpack}; +use xous::{CID, msg_scalar_unpack}; use xous_ipc::{Buffer, String}; const STD_TIMEOUT: u32 = 100; @@ -39,7 +38,6 @@ mod implementation { use com_rs::*; use log::error; use utralib::generated::*; - use xous::CID; use heapless::Vec; use heapless::consts::U64; @@ -232,9 +230,6 @@ mod implementation { #[xous::xous_main] fn xmain() -> ! { use crate::implementation::XousCom; - use core::pin::Pin; - use xous::buffer; - use rkyv::archived_value_mut; log_server::init_wait().unwrap(); info!("my PID is {}", xous::process::id()); diff --git a/services/rkyv-test-client/src/main.rs b/services/rkyv-test-client/src/main.rs index 03a16c2f7..7e5a35b2c 100644 --- a/services/rkyv-test-client/src/main.rs +++ b/services/rkyv-test-client/src/main.rs @@ -41,7 +41,7 @@ fn rkyv_test_client() -> ! { let xns = xous_names::XousNames::new().unwrap(); let mut com = com::Com::new(xns).unwrap(); - com.hook_batt_stats(handle_battstats); + com.hook_batt_stats(handle_battstats).unwrap(); loop { log::info!("2 + {} = {}", idx, rkyv_test_server::add(2, idx).unwrap()); @@ -61,7 +61,7 @@ fn rkyv_test_client() -> ! { log::info!("Sending a string \"{}\"", sent_str); rkyv_test_server::log_message("prefix", sent_str); - com.req_batt_stats(); + com.req_batt_stats().unwrap(); idx += 1; } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index dfb2e1974..d6470e2e3 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -41,7 +41,7 @@ fn try_main() -> Result<(), DynError> { //"shellchat", //"ime-frontend", //"ime-plugin-shell", - //"graphics-server", + "graphics-server", "ticktimer-server", "log-server", "com",