roll back heapless crate on ime-frontend

This commit is contained in:
bunnie 2021-05-08 23:55:08 +08:00
parent a24803354c
commit a8a35fa434
5 changed files with 91 additions and 26 deletions

81
Cargo.lock generated
View file

@ -32,6 +32,18 @@ version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" 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]] [[package]]
name = "atomic-polyfill" name = "atomic-polyfill"
version = "0.1.2" version = "0.1.2"
@ -326,7 +338,7 @@ name = "com"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"com_rs-ref", "com_rs-ref",
"heapless", "heapless 0.7.0",
"log", "log",
"log-server", "log-server",
"num-derive", "num-derive",
@ -515,7 +527,7 @@ dependencies = [
"com", "com",
"content-plugin-api", "content-plugin-api",
"graphics-server", "graphics-server",
"heapless", "heapless 0.7.0",
"ime-plugin-api", "ime-plugin-api",
"keyboard", "keyboard",
"log", "log",
@ -532,6 +544,34 @@ dependencies = [
"xous-names", "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]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.2" version = "0.2.2"
@ -554,7 +594,7 @@ name = "graphics-server"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"blitstr-ref", "blitstr-ref",
"hash32", "hash32 0.2.1",
"hash32-derive", "hash32-derive",
"keyboard", "keyboard",
"log", "log",
@ -570,6 +610,15 @@ dependencies = [
"xous-names", "xous-names",
] ]
[[package]]
name = "hash32"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4041af86e63ac4298ce40e5cca669066e75b6f1aa3390fe2561ffa5e1d9f4cc"
dependencies = [
"byteorder",
]
[[package]] [[package]]
name = "hash32" name = "hash32"
version = "0.2.1" version = "0.2.1"
@ -590,6 +639,18 @@ dependencies = [
"syn 0.13.11", "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]] [[package]]
name = "heapless" name = "heapless"
version = "0.7.0" version = "0.7.0"
@ -597,7 +658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e94c13b78b595d2adbd708bce276664f1047f98fc32ddbf463b4c191158334a6" checksum = "e94c13b78b595d2adbd708bce276664f1047f98fc32ddbf463b4c191158334a6"
dependencies = [ dependencies = [
"atomic-polyfill", "atomic-polyfill",
"hash32", "hash32 0.2.1",
"stable_deref_trait", "stable_deref_trait",
] ]
@ -670,7 +731,7 @@ dependencies = [
name = "ime-plugin-shell" name = "ime-plugin-shell"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"heapless", "heapless 0.5.6",
"ime-plugin-api", "ime-plugin-api",
"log", "log",
"log-server", "log-server",
@ -705,7 +766,7 @@ dependencies = [
name = "keyboard" name = "keyboard"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"heapless", "heapless 0.7.0",
"llio", "llio",
"log", "log",
"log-server", "log-server",
@ -752,7 +813,7 @@ dependencies = [
name = "llio" name = "llio"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"heapless", "heapless 0.7.0",
"log", "log",
"log-server", "log-server",
"num-derive", "num-derive",
@ -1338,7 +1399,7 @@ dependencies = [
"content-plugin-api", "content-plugin-api",
"gam", "gam",
"graphics-server", "graphics-server",
"heapless", "heapless 0.7.0",
"ime-plugin-api", "ime-plugin-api",
"keyboard", "keyboard",
"llio", "llio",
@ -1484,7 +1545,7 @@ dependencies = [
name = "ticktimer-server" name = "ticktimer-server"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"heapless", "heapless 0.7.0",
"log", "log",
"log-server", "log-server",
"num-derive", "num-derive",
@ -1844,7 +1905,7 @@ dependencies = [
name = "xous-names" name = "xous-names"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"hash32", "hash32 0.2.1",
"hash32-derive", "hash32-derive",
"log", "log",
"log-server", "log-server",

View file

@ -6,7 +6,7 @@ name = "ime-plugin-shell"
version = "0.1.0" version = "0.1.0"
[dependencies] [dependencies]
heapless = "0.7" heapless = "0.5.6"
ime-plugin-api = {path = "../ime-plugin-api"} ime-plugin-api = {path = "../ime-plugin-api"}
log = "0.4" log = "0.4"
log-server = {path = "../log-server"} log-server = {path = "../log-server"}

View file

@ -5,6 +5,7 @@ use ime_plugin_api::*;
use log::{error, info}; use log::{error, info};
use heapless::spsc::Queue; use heapless::spsc::Queue;
use heapless::consts::*;
use xous_ipc::{String, Buffer}; use xous_ipc::{String, Buffer};
use num_traits::FromPrimitive; 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"); 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); log::trace!("registered with NS -- {:?}", ime_sh_sid);
let mut history: Queue<String<64>, 4> = Queue::new(); // this has 2^4 elements = 16??? or does it just have 4 elements. let mut history: Queue<String<64>, U4> = Queue::new(); // this has 2^4 elements = 16??? or does it just have 4 elements.
let history_max = 4; let history_max = 4;
if false { // loads defaults into the predictor array to test things if false { // loads defaults into the predictor array to test things

View file

@ -109,15 +109,17 @@ pub struct CmdEnv {
impl CmdEnv { impl CmdEnv {
pub fn new(xns: &xous_names::XousNames) -> CmdEnv { pub fn new(xns: &xous_names::XousNames) -> CmdEnv {
let ticktimer = ticktimer_server::Ticktimer::new().expect("Couldn't connect to Ticktimer"); 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 { CmdEnv {
common_env: CommonEnv { common_env: common,
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(),
},
lastverb: String::<256>::new(), lastverb: String::<256>::new(),
///// 3. initialize your storage, by calling new() ///// 3. initialize your storage, by calling new()
//test_cmd: Test::new(), //test_cmd: Test::new(),
@ -129,7 +131,7 @@ impl CmdEnv {
ssid_cmd: Ssid::new(), ssid_cmd: Ssid::new(),
audio_cmd: Audio::new(&xns), audio_cmd: Audio::new(&xns),
fcc_cmd: Fcc::new(), fcc_cmd: fcc,
} }
} }

View file

@ -15,7 +15,7 @@ use xous::{Message, ScalarMessage, MessageEnvelope};
use core::sync::atomic::{AtomicBool, Ordering}; use core::sync::atomic::{AtomicBool, Ordering};
static CB_RUN: AtomicBool = AtomicBool::new(false); static CB_RUN: AtomicBool = AtomicBool::new(false);
static CB_GO: 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 ticktimer = ticktimer_server::Ticktimer::new().expect("Couldn't connect to Ticktimer");
let xns = xous_names::XousNames::new().unwrap(); let xns = xous_names::XousNames::new().unwrap();
let callback_conn = xns.request_connection_blocking(crate::SERVER_NAME_SHELLCHAT).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(); ticktimer.sleep_ms(20_000).unwrap();
// after we wait, check and see if we still need the callback... // after we wait, check and see if we still need the callback...
if CB_GO.load(Ordering::Relaxed) { 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{ 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(); })).unwrap();
} }
} else { } else {
@ -46,8 +46,9 @@ pub struct Fcc {
tx_start_time: u64, tx_start_time: u64,
} }
impl Fcc { impl Fcc {
pub fn new() -> Fcc { pub fn new(env: &mut CommonEnv) -> Fcc {
xous::create_thread_0(callback_thread).expect("couldn't create callback generator thread"); 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 { Fcc {
channel: None, //Some(2), // default to simplify testing, replace with None channel: None, //Some(2), // default to simplify testing, replace with None
rate: None, //Some(Rate::B1Mbps), // default to simplify testing, replace with None rate: None, //Some(Rate::B1Mbps), // default to simplify testing, replace with None