From a8a35fa4342ced7e2541b68c1bfa064518d640e2 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 8 May 2021 23:55:08 +0800 Subject: [PATCH] roll back heapless crate on ime-frontend --- Cargo.lock | 81 +++++++++++++++++++++++---- services/ime-plugin-shell/Cargo.toml | 2 +- services/ime-plugin-shell/src/main.rs | 3 +- services/shellchat/src/cmds.rs | 20 ++++--- services/shellchat/src/cmds/fcc.rs | 11 ++-- 5 files changed, 91 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ed4846b3..e68790ce7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,6 +32,18 @@ version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" +[[package]] +name = "as-slice" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0" +dependencies = [ + "generic-array 0.12.4", + "generic-array 0.13.3", + "generic-array 0.14.4", + "stable_deref_trait", +] + [[package]] name = "atomic-polyfill" version = "0.1.2" @@ -326,7 +338,7 @@ name = "com" version = "0.1.0" dependencies = [ "com_rs-ref", - "heapless", + "heapless 0.7.0", "log", "log-server", "num-derive", @@ -515,7 +527,7 @@ dependencies = [ "com", "content-plugin-api", "graphics-server", - "heapless", + "heapless 0.7.0", "ime-plugin-api", "keyboard", "log", @@ -532,6 +544,34 @@ dependencies = [ "xous-names", ] +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f797e67af32588215eaaab8327027ee8e71b9dd0b2b26996aedf20c030fce309" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.2" @@ -554,7 +594,7 @@ name = "graphics-server" version = "0.1.0" dependencies = [ "blitstr-ref", - "hash32", + "hash32 0.2.1", "hash32-derive", "keyboard", "log", @@ -570,6 +610,15 @@ dependencies = [ "xous-names", ] +[[package]] +name = "hash32" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4041af86e63ac4298ce40e5cca669066e75b6f1aa3390fe2561ffa5e1d9f4cc" +dependencies = [ + "byteorder", +] + [[package]] name = "hash32" version = "0.2.1" @@ -590,6 +639,18 @@ dependencies = [ "syn 0.13.11", ] +[[package]] +name = "heapless" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74911a68a1658cfcfb61bc0ccfbd536e3b6e906f8c2f7883ee50157e3e2184f1" +dependencies = [ + "as-slice", + "generic-array 0.13.3", + "hash32 0.1.1", + "stable_deref_trait", +] + [[package]] name = "heapless" version = "0.7.0" @@ -597,7 +658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e94c13b78b595d2adbd708bce276664f1047f98fc32ddbf463b4c191158334a6" dependencies = [ "atomic-polyfill", - "hash32", + "hash32 0.2.1", "stable_deref_trait", ] @@ -670,7 +731,7 @@ dependencies = [ name = "ime-plugin-shell" version = "0.1.0" dependencies = [ - "heapless", + "heapless 0.5.6", "ime-plugin-api", "log", "log-server", @@ -705,7 +766,7 @@ dependencies = [ name = "keyboard" version = "0.1.0" dependencies = [ - "heapless", + "heapless 0.7.0", "llio", "log", "log-server", @@ -752,7 +813,7 @@ dependencies = [ name = "llio" version = "0.1.0" dependencies = [ - "heapless", + "heapless 0.7.0", "log", "log-server", "num-derive", @@ -1338,7 +1399,7 @@ dependencies = [ "content-plugin-api", "gam", "graphics-server", - "heapless", + "heapless 0.7.0", "ime-plugin-api", "keyboard", "llio", @@ -1484,7 +1545,7 @@ dependencies = [ name = "ticktimer-server" version = "0.1.0" dependencies = [ - "heapless", + "heapless 0.7.0", "log", "log-server", "num-derive", @@ -1844,7 +1905,7 @@ dependencies = [ name = "xous-names" version = "0.1.0" dependencies = [ - "hash32", + "hash32 0.2.1", "hash32-derive", "log", "log-server", diff --git a/services/ime-plugin-shell/Cargo.toml b/services/ime-plugin-shell/Cargo.toml index 149ebf0b1..00f1991f3 100644 --- a/services/ime-plugin-shell/Cargo.toml +++ b/services/ime-plugin-shell/Cargo.toml @@ -6,7 +6,7 @@ name = "ime-plugin-shell" version = "0.1.0" [dependencies] -heapless = "0.7" +heapless = "0.5.6" ime-plugin-api = {path = "../ime-plugin-api"} log = "0.4" log-server = {path = "../log-server"} diff --git a/services/ime-plugin-shell/src/main.rs b/services/ime-plugin-shell/src/main.rs index eee58d807..f4bd227af 100644 --- a/services/ime-plugin-shell/src/main.rs +++ b/services/ime-plugin-shell/src/main.rs @@ -5,6 +5,7 @@ use ime_plugin_api::*; use log::{error, info}; use heapless::spsc::Queue; +use heapless::consts::*; use xous_ipc::{String, Buffer}; use num_traits::FromPrimitive; @@ -19,7 +20,7 @@ fn xmain() -> ! { let ime_sh_sid = xns.register_name(xous::names::SERVER_NAME_IME_PLUGIN_SHELL).expect("can't register server"); log::trace!("registered with NS -- {:?}", ime_sh_sid); - let mut history: Queue, 4> = Queue::new(); // this has 2^4 elements = 16??? or does it just have 4 elements. + let mut history: Queue, U4> = Queue::new(); // this has 2^4 elements = 16??? or does it just have 4 elements. let history_max = 4; if false { // loads defaults into the predictor array to test things diff --git a/services/shellchat/src/cmds.rs b/services/shellchat/src/cmds.rs index 0cb7d8938..2a96b16c4 100644 --- a/services/shellchat/src/cmds.rs +++ b/services/shellchat/src/cmds.rs @@ -109,15 +109,17 @@ pub struct CmdEnv { impl CmdEnv { pub fn new(xns: &xous_names::XousNames) -> CmdEnv { let ticktimer = ticktimer_server::Ticktimer::new().expect("Couldn't connect to Ticktimer"); + let mut common = CommonEnv { + llio: llio::Llio::new(&xns).expect("couldn't connect to LLIO"), + com: com::Com::new(&xns).expect("could't connect to COM"), + ticktimer: ticktimer, + gam: gam::Gam::new(&xns).expect("couldn't connect to GAM"), + cb_registrations: FnvIndexMap::new(), + trng: trng::Trng::new(&xns).unwrap(), + }; + let fcc = Fcc::new(&mut common); CmdEnv { - common_env: CommonEnv { - llio: llio::Llio::new(&xns).expect("couldn't connect to LLIO"), - com: com::Com::new(&xns).expect("could't connect to COM"), - ticktimer: ticktimer, - gam: gam::Gam::new(&xns).expect("couldn't connect to GAM"), - cb_registrations: FnvIndexMap::new(), - trng: trng::Trng::new(&xns).unwrap(), - }, + common_env: common, lastverb: String::<256>::new(), ///// 3. initialize your storage, by calling new() //test_cmd: Test::new(), @@ -129,7 +131,7 @@ impl CmdEnv { ssid_cmd: Ssid::new(), audio_cmd: Audio::new(&xns), - fcc_cmd: Fcc::new(), + fcc_cmd: fcc, } } diff --git a/services/shellchat/src/cmds/fcc.rs b/services/shellchat/src/cmds/fcc.rs index 72527a7ee..645f85126 100644 --- a/services/shellchat/src/cmds/fcc.rs +++ b/services/shellchat/src/cmds/fcc.rs @@ -15,7 +15,7 @@ use xous::{Message, ScalarMessage, MessageEnvelope}; use core::sync::atomic::{AtomicBool, Ordering}; static CB_RUN: AtomicBool = AtomicBool::new(false); static CB_GO: AtomicBool = AtomicBool::new(false); -pub fn callback_thread() { +pub fn callback_thread(callback_id: usize) { let ticktimer = ticktimer_server::Ticktimer::new().expect("Couldn't connect to Ticktimer"); let xns = xous_names::XousNames::new().unwrap(); let callback_conn = xns.request_connection_blocking(crate::SERVER_NAME_SHELLCHAT).unwrap(); @@ -26,9 +26,9 @@ pub fn callback_thread() { ticktimer.sleep_ms(20_000).unwrap(); // after we wait, check and see if we still need the callback... if CB_GO.load(Ordering::Relaxed) { - // just send a bogus message + // send a message that will get routed to our callback handler, locatable with the `callback_id` xous::send_message(callback_conn, Message::Scalar(ScalarMessage{ - id: 0xdeadbeef, arg1: 0, arg2: 0, arg3: 0, arg4: 0, + id: callback_id, arg1: 0, arg2: 0, arg3: 0, arg4: 0, })).unwrap(); } } else { @@ -46,8 +46,9 @@ pub struct Fcc { tx_start_time: u64, } impl Fcc { - pub fn new() -> Fcc { - xous::create_thread_0(callback_thread).expect("couldn't create callback generator thread"); + pub fn new(env: &mut CommonEnv) -> Fcc { + let callback_id = env.register_handler(String::<256>::from_str("fcc")); + xous::create_thread_1(callback_thread, callback_id as usize).expect("couldn't create callback generator thread"); Fcc { channel: None, //Some(2), // default to simplify testing, replace with None rate: None, //Some(Rate::B1Mbps), // default to simplify testing, replace with None