add oqc test service

this works around the problem with stdlib allocator not
working quite correctly in spawned threads.
This commit is contained in:
bunnie 2021-09-18 02:22:35 +08:00
parent 74207851ac
commit c2c919ba81
11 changed files with 565 additions and 281 deletions

19
Cargo.lock generated
View file

@ -1296,6 +1296,24 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "oqc-test"
version = "0.1.0"
dependencies = [
"com",
"gam",
"keyboard",
"log",
"log-server",
"num-derive",
"num-traits",
"ticktimer-server",
"utralib",
"xous",
"xous-ipc",
"xous-names",
]
[[package]]
name = "orbclient"
version = "0.3.30"
@ -1869,6 +1887,7 @@ dependencies = [
"log-server",
"num-derive",
"num-traits",
"oqc-test",
"rand_core 0.5.1",
"rkyv 0.4.3",
"root-keys",

View file

@ -32,6 +32,7 @@ default-members = [
"services/spinor",
"services/root-keys",
"services/jtag",
"services/oqc-test",
]
members = [
"xous-ipc",
@ -78,6 +79,7 @@ members = [
"services/root-keys",
"services/jtag",
"tools/wycheproof-import",
"services/oqc-test",
]
resolver = "2"

View file

@ -821,7 +821,7 @@ fn xmain() -> ! {
// connections expected:
// - GAM
// - graphics (if building for hosted mode)
// - shellchat (for factory test)
// - oqc (for factory test)
#[cfg(any(target_os = "none", target_os = "xous"))]
let kbd_sid = xns.register_name(api::SERVER_NAME_KBD, Some(2)).expect("can't register server");
#[cfg(not(any(target_os = "none", target_os = "xous")))]
@ -961,24 +961,18 @@ fn xmain() -> ! {
&& (rawstates.keydowns.len() > 0 || rawstates.keyups.len() > 0)
{
// manual serialization of KeyRawStates, because rkyv can't derive a serializer.
for &rc in rawstates.keydowns.iter() {
xous::send_message(raw_listener_conn.unwrap(),
xous::Message::new_scalar(raw_listener_op.unwrap() as usize,
0,
rc.r as usize,
rc.c as usize,
0
)).unwrap();
let mut krs_ser: [(u8, u8); 32] = [(255, 255); 32];
for (&src, (r, c)) in rawstates.keydowns.iter().zip(krs_ser[..16].iter_mut()) {
*r = src.r;
*c = src.c;
}
for &rc in rawstates.keyups.iter() {
xous::send_message(raw_listener_conn.unwrap(),
xous::Message::new_scalar(raw_listener_op.unwrap() as usize,
1,
rc.r as usize,
rc.c as usize,
0
)).unwrap();
for (&src, (r, c)) in rawstates.keyups.iter().zip(krs_ser[16..].iter_mut()) {
*r = src.r;
*c = src.c;
}
let buf = Buffer::into_buf(krs_ser).or(Err(xous::Error::InternalError)).expect("couldn't serialize krs buffer");
buf.lend(raw_listener_conn.unwrap(), raw_listener_op.unwrap()).expect("couldn't send raw scancodes");
}
// interpret scancodes
@ -997,20 +991,22 @@ fn xmain() -> ! {
if vibe {
llio.vibe(llio::VibePattern::Short).unwrap();
}
let mut keys: [char; 4] = ['\u{0000}', '\u{0000}', '\u{0000}', '\u{0000}'];
for i in 0..kc.len() {
keys[i] = kc[i];
for kv in kc.chunks(4) {
let mut keys: [char; 4] = ['\u{0000}', '\u{0000}', '\u{0000}', '\u{0000}'];
for i in 0..kv.len() {
keys[i] = kv[i];
}
log::trace!("sending keys {:?}", keys);
xous::send_message(listener_conn.unwrap(),
xous::Message::new_scalar(
listener_op.unwrap(),
keys[0] as u32 as usize,
keys[1] as u32 as usize,
keys[2] as u32 as usize,
keys[3] as u32 as usize,
)
).expect("couldn't send key codes to listener");
}
log::trace!("sending keys {:?}", keys);
xous::send_message(listener_conn.unwrap(),
xous::Message::new_scalar(
listener_op.unwrap(),
keys[0] as u32 as usize,
keys[1] as u32 as usize,
keys[2] as u32 as usize,
keys[3] as u32 as usize,
)
).expect("couldn't send key codes to listener");
}
// as long as we have a keydown, keep pinging the loop at a high rate. this consumes more power, but keydowns are relatively rare.
if kbd.is_repeating_key() {

View file

@ -0,0 +1,25 @@
[package]
name = "oqc-test"
version = "0.1.0"
authors = ["bunnie <bunnie@kosagi.com>"]
edition = "2018"
description = "OQC test program"
[dependencies]
xous = { path = "../../xous-rs" }
xous-ipc = { path = "../../xous-ipc" }
log-server = { path = "../log-server" }
ticktimer-server = { path = "../ticktimer-server" }
xous-names = { path = "../xous-names" }
log = "0.4"
num-derive = {version = "0.3", default-features = false}
num-traits = {version = "0.2", default-features = false}
gam = {path = "../gam"}
keyboard = {path = "../keyboard"}
com = {path = "../com"}
[target.'cfg(not(any(windows,unix)))'.dependencies]
utralib = { path = "../../utralib"}
[features]
default = []

View file

@ -0,0 +1,13 @@
pub(crate) const SERVER_NAME_OQC: &str = "_Outgoing Quality Check Test Program_";
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
pub(crate) enum Opcode {
Trigger,
KeyCode,
Status,
UxGutter,
ModalRedraw,
ModalKeys,
ModalDrop,
Quit,
}

View file

@ -0,0 +1,55 @@
#![cfg_attr(target_os = "none", no_std)]
pub mod api;
use api::*;
use xous::{CID, send_message};
use num_traits::*;
#[derive(Debug)]
pub struct Oqc {
conn: CID,
}
impl Oqc {
pub fn new(xns: &xous_names::XousNames) -> Result<Self, xous::Error> {
REFCOUNT.store(REFCOUNT.load(Ordering::Relaxed) + 1, Ordering::Relaxed);
let conn = xns.request_connection_blocking(api::SERVER_NAME_OQC).expect("Can't connect to OQC server");
Ok(Oqc {
conn
})
}
pub fn trigger(&self, timeout: usize) {
send_message(self.conn,
xous::Message::new_blocking_scalar(Opcode::Trigger.to_usize().unwrap(), timeout, 0, 0, 0,)
).expect("couldn't trigger self test");
// ignore return code, it's just to make sure the caller blocks until the test is done
}
pub fn status(&self) -> Option<bool> { // None if still running or not yet run; Some(true) if pass; Some(false) if fail
let result = send_message(self.conn,
xous::Message::new_blocking_scalar(Opcode::Status.to_usize().unwrap(), 0, 0, 0, 0)
).expect("couldn't query test status");
match result {
xous::Result::Scalar1(val) => {
match val {
0 => return None,
1 => return Some(true),
2 => return Some(false),
_ => return Some(false),
}
}
_ => {
log::error!("internal error");
panic!("improper result code on oqc status query");
}
}
}
}
use core::sync::atomic::{AtomicU32, Ordering};
static REFCOUNT: AtomicU32 = AtomicU32::new(0);
impl Drop for Oqc {
fn drop(&mut self) {
if REFCOUNT.load(Ordering::Relaxed) == 0 {
unsafe{xous::disconnect(self.conn).unwrap();}
}
}
}

View file

@ -0,0 +1,374 @@
#![cfg_attr(target_os = "none", no_std)]
#![cfg_attr(target_os = "none", no_main)]
mod api;
use api::*;
use num_traits::*;
use gam::modal::*;
use std::collections::HashMap;
use keyboard::{RowCol, KeyRawStates};
#[xous::xous_main]
fn xmain() -> ! {
log_server::init_wait().unwrap();
log::set_max_level(log::LevelFilter::Info);
log::info!("my PID is {}", xous::process::id());
let xns = xous_names::XousNames::new().unwrap();
// one connection expected:
// - shellchat program initiator
let oqc_sid = xns.register_name(api::SERVER_NAME_OQC, Some(1)).expect("can't register server");
let ticktimer = ticktimer_server::Ticktimer::new().unwrap();
let kbd = keyboard::Keyboard::new(&xns).unwrap();
let com = com::Com::new(&xns).unwrap();
let test_cid = xous::connect(oqc_sid).unwrap();
let mut test_action = Notification::new(
test_cid,
Opcode::UxGutter.to_u32().unwrap()
);
test_action.manual_dismiss = false;
let mut test_modal = Modal::new(
"test modal",
ActionType::Notification(test_action),
None,
Some("Initializing..."),
GlyphStyle::Small,
8
);
let mut test_run = false;
let mut remaining = populate_vectors();
let mut bot_str = String::new();
let mut start_time = 0;
let mut timeout = 120_000;
let mut passing: Option<bool> = None;
let mut test_finished = false;
let mut last_redraw_time = 0;
loop {
let msg = xous::receive_message(oqc_sid).unwrap();
match FromPrimitive::from_usize(msg.body.id()) {
Some(Opcode::Trigger) => xous::msg_blocking_scalar_unpack!(msg, timeout_set, _, _, _, {
if !test_run {
test_modal.spawn_helper(oqc_sid, test_modal.sid,
Opcode::ModalRedraw.to_u32().unwrap(),
Opcode::ModalKeys.to_u32().unwrap(),
Opcode::ModalDrop.to_u32().unwrap(),
);
kbd.register_raw_listener(
SERVER_NAME_OQC,
Opcode::KeyCode.to_usize().unwrap()
);
// test the screen
com.set_backlight(255, 255).unwrap();
test_modal.gam.selftest(3_000); // 12_000 by default
// now start the keyboard test
timeout = if timeout_set > 120_000 {
120_000
} else {
timeout_set as u64
};
start_time = ticktimer.elapsed_ms();
last_redraw_time = start_time;
log::info!("raising modal");
render_string(&mut bot_str, &remaining, timeout - (ticktimer.elapsed_ms() - start_time));
test_modal.modify(None, None, false,
Some(bot_str.as_str()), false, None);
test_modal.activate();
test_modal.redraw();
// start a thread that advances the timer when not hitting keys
xous::create_thread_2(ping_thread, xous::connect(oqc_sid).unwrap() as usize, timeout as usize).unwrap();
xous::return_scalar(msg.sender, 1).unwrap();
} else {
xous::return_scalar(msg.sender, 0).unwrap();
}
test_run = true;
}),
Some(Opcode::KeyCode) => {
if test_finished {
// we'll continue to get keycodes, but ignore them once the test is finished
continue;
}
let elapsed = ticktimer.elapsed_ms();
if elapsed - start_time < timeout {
let buffer = unsafe {
xous_ipc::Buffer::from_memory_message(msg.body.memory_message().unwrap())
};
let krs = buffer.to_original::<[(u8, u8); 32],_>().unwrap();
let mut rawstates = KeyRawStates::new();
for &(r, c) in krs[..16].iter() {
if r != 255 || c != 255 {
rawstates.keydowns.push(RowCol{r, c});
}
}
for &(r, c) in krs[16..].iter() {
if r!= 255 || c != 255 {
rawstates.keyups.push(RowCol{r, c});
}
}
if rawstates.keydowns.len() > 0 { // only worry about keydowns
for &key in rawstates.keydowns.iter() {
match remaining.get(&key) {
Some(_hit) => {
log::info!("got {}", map_codes(key));
remaining.insert(key, true);
},
None => {
if key.r != 254 { // 254 is (ab)used by the tester thread to create a ping event
log::warn!("got unexpected r/c: {:?}", key)
}
},
};
}
if elapsed - last_redraw_time > 100 { // rate limit redraws to 10Hz
render_string(&mut bot_str, &remaining, timeout - (elapsed - start_time));
test_modal.modify(None, None, false,
Some(bot_str.as_str()), false, None);
test_modal.redraw();
last_redraw_time = elapsed;
}
}
// iterate and see if all keys have been hit
let mut finished = true;
for &vals in remaining.values() {
if vals == false {
finished = false;
break;
}
}
if finished {
passing = Some(true);
com.set_backlight(0, 0).unwrap();
test_modal.gam.relinquish_focus().unwrap();
log::info!("all keys hit, exiting");
test_finished = true;
}
} else {
// timeout
passing = Some(false);
com.set_backlight(0, 0).unwrap();
test_modal.gam.relinquish_focus().unwrap();
log::info!("test done, relinquishing focus");
test_finished = true;
}
if !test_run {
log::warn!("OQC got keycodes when unexpected");
}
},
Some(Opcode::Status) => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
let _ = match passing {
None => xous::return_scalar(msg.sender, 0),
Some(true) => xous::return_scalar(msg.sender, 1),
Some(false) => xous::return_scalar(msg.sender, 2),
};
}),
Some(Opcode::UxGutter) => {
// log::info!("gutter");
// an intentional NOP for UX actions that require a destintation but need no action
},
Some(Opcode::ModalRedraw) => {
// log::info!("modal redraw handler");
// test_modal.redraw();
},
Some(Opcode::ModalKeys) => xous::msg_scalar_unpack!(msg, _k1, _k2, _k3, _k4, {
// log::info!("modal keys message, ignoring");
// ignore keys, we have our own key routine
}),
Some(Opcode::ModalDrop) => {
log::error!("test modal quit unexpectedly");
}
Some(Opcode::Quit) => {
log::warn!("Quit received on OQC");
break;
}
None => {
log::error!("couldn't convert opcode: {:?}", msg);
}
}
}
// clean up our program
log::trace!("main loop exit, destroying servers");
xns.unregister_server(oqc_sid).unwrap();
xous::destroy_server(oqc_sid).unwrap();
log::trace!("quitting");
xous::terminate_process(0)
}
fn populate_vectors() -> HashMap::<RowCol, bool> {
let mut vectors = HashMap::<RowCol, bool>::new();
vectors.insert(RowCol::new(0, 0), false);
vectors.insert(RowCol::new(0, 1), false);
vectors.insert(RowCol::new(0, 2), false);
vectors.insert(RowCol::new(0, 3), false);
vectors.insert(RowCol::new(0, 4), false);
vectors.insert(RowCol::new(4, 5), false);
vectors.insert(RowCol::new(4, 6), false);
vectors.insert(RowCol::new(4, 7), false);
vectors.insert(RowCol::new(4, 8), false);
vectors.insert(RowCol::new(4, 9), false);
vectors.insert(RowCol::new(1, 0), false);
vectors.insert(RowCol::new(1, 1), false);
vectors.insert(RowCol::new(1, 2), false);
vectors.insert(RowCol::new(1, 3), false);
vectors.insert(RowCol::new(1, 4), false);
vectors.insert(RowCol::new(5, 5), false);
vectors.insert(RowCol::new(5, 6), false);
vectors.insert(RowCol::new(5, 7), false);
vectors.insert(RowCol::new(5, 8), false);
vectors.insert(RowCol::new(5, 9), false);
vectors.insert(RowCol::new(2, 0), false);
vectors.insert(RowCol::new(2, 1), false);
vectors.insert(RowCol::new(2, 2), false);
vectors.insert(RowCol::new(2, 3), false);
vectors.insert(RowCol::new(2, 4), false);
vectors.insert(RowCol::new(6, 5), false);
vectors.insert(RowCol::new(6, 6), false);
vectors.insert(RowCol::new(6, 7), false);
vectors.insert(RowCol::new(6, 8), false);
vectors.insert(RowCol::new(6, 9), false);
vectors.insert(RowCol::new(3, 0), false);
vectors.insert(RowCol::new(3, 1), false);
vectors.insert(RowCol::new(3, 2), false);
vectors.insert(RowCol::new(3, 3), false);
vectors.insert(RowCol::new(3, 4), false);
vectors.insert(RowCol::new(7, 5), false);
vectors.insert(RowCol::new(7, 6), false);
vectors.insert(RowCol::new(7, 7), false);
vectors.insert(RowCol::new(7, 8), false);
vectors.insert(RowCol::new(7, 9), false);
vectors.insert(RowCol::new(8, 5), false);
vectors.insert(RowCol::new(8, 6), false);
vectors.insert(RowCol::new(8, 7), false);
vectors.insert(RowCol::new(8, 8), false);
vectors.insert(RowCol::new(8, 9), false);
vectors.insert(RowCol::new(8, 0), false);
vectors.insert(RowCol::new(8, 1), false);
vectors.insert(RowCol::new(3, 8), false);
vectors.insert(RowCol::new(3, 9), false);
vectors.insert(RowCol::new(8, 3), false);
vectors.insert(RowCol::new(3, 6), false);
vectors.insert(RowCol::new(6, 4), false);
vectors.insert(RowCol::new(8, 2), false);
vectors.insert(RowCol::new(5, 2), false);
vectors
}
fn map_codes(code: RowCol) -> &'static str {
let rc = (code.r, code.c);
match rc {
(0, 0) => "1",
(0, 1) => "2",
(0, 2) => "3",
(0, 3) => "4",
(0, 4) => "5",
(4, 5) => "6",
(4, 6) => "7",
(4, 7) => "8",
(4, 8) => "9",
(4, 9) => "0",
(1, 0) => "q",
(1, 1) => "w",
(1, 2) => "e",
(1, 3) => "r",
(1, 4) => "t",
(5, 5) => "y",
(5, 6) => "u",
(5, 7) => "i",
(5, 8) => "o",
(5, 9) => "p",
(2, 0) => "a",
(2, 1) => "s",
(2, 2) => "d",
(2, 3) => "f",
(2, 4) => "g",
(6, 5) => "h",
(6, 6) => "j",
(6, 7) => "k",
(6, 8) => "l",
(6, 9) => "BS",
(3, 0) => "!",
(3, 1) => "z",
(3, 2) => "x",
(3, 3) => "c",
(3, 4) => "v",
(7, 5) => "b",
(7, 6) => "n",
(7, 7) => "m",
(7, 8) => "?",
//(7, 9) => "↩️",
(7, 9) => "RET",
(8, 5) => "LS",
(8, 6) => ",",
(8, 7) => "SP",
(8, 8) => ".",
(8, 9) => "RS",
(8, 0) => "F1",
(8, 1) => "F2",
(3, 8) => "F3",
(3, 9) => "F4",
//(8, 3) => "⬅️",
(8, 3) => "LT",
//(3, 6) => "➡️",
(3, 6) => "RT",
//(6, 4) => "⬆️",
(6, 4) => "UP",
//(8, 2) => "⬇️",
(8, 2) => "DN",
(5, 2) => "MID",
_ => "ERR!",
}
}
fn render_string(txt: &mut String, remaining: &HashMap<RowCol, bool>, time_remaining: u64) {
txt.clear();
let mut keyrowstrs: [String; 5] = [
String::new(),
String::new(),
String::new(),
String::new(),
String::new(),
];
for (&code, &was_hit) in remaining.iter() {
if !was_hit {
// lookup table to help organize the key hits remaining
let draw_row = match code.r {
0 | 4 => 0,
1 | 5 => 1,
2 | 6 => 2,
3 => if code.c > 5 {3} else {4}
7 => 3,
_ => 4,
};
keyrowstrs[draw_row].push_str(map_codes(code));
keyrowstrs[draw_row].push_str(" ");
}
}
for s in keyrowstrs.iter() {
txt.push_str(s);
txt.push('\n');
}
txt.push_str("Timeout: ");
txt.push_str(&(time_remaining / 1000).to_string());
txt.push_str("s");
//txt.push_str("\n\n\n\n");
}
fn ping_thread(conn: usize, timeout: usize) {
let tt = ticktimer_server::Ticktimer::new().unwrap();
let start = tt.elapsed_ms();
let mut krs_ser: [(u8, u8); 32] = [(255, 255); 32];
krs_ser[0] = (254, 254);
while tt.elapsed_ms() - start < timeout as u64 {
tt.sleep_ms(2000).unwrap();
let buf = xous_ipc::Buffer::into_buf(krs_ser).or(Err(xous::Error::InternalError)).expect("couldn't serialize krs buffer");
buf.send(conn as xous::CID, Opcode::KeyCode.to_u32().unwrap()).expect("couldn't send raw scancodes");
}
}

View file

@ -41,6 +41,8 @@ rkyv = {version = "0.4.3", default-features = false, features = ["const_generics
# for audio self-test analysis
spectrum-analyzer = "0.5.2"
# for outgoing quality check
oqc-test = {path="../oqc-test"}
# for the curve25519 tests
# hardware acceleration adaptations are inserted into a fork of the main branch.

View file

@ -7,12 +7,6 @@ use codec::*;
use spectrum_analyzer::{FrequencyLimit, FrequencySpectrum, samples_fft_to_spectrum};
use spectrum_analyzer::windows::hann_window;
use rtc::{DateTime, Weekday};
use std::sync::{Arc, Mutex};
use std::thread;
use keyboard::RowCol;
use std::collections::HashMap;
use gam::modal::*;
use num_traits::*;
use core::fmt::Write;
#[derive(Debug)]
@ -35,7 +29,8 @@ pub struct Test {
end_time: Option<DateTime>,
start_elapsed: Option<u64>,
end_elapsed: Option<u64>,
kbd: Arc<Mutex<keyboard::Keyboard>>,
//kbd: Arc<Mutex<keyboard::Keyboard>>,
oqc: oqc_test::Oqc,
jtag: jtag::Jtag,
}
impl Test {
@ -69,7 +64,8 @@ impl Test {
end_time: None,
start_elapsed: None,
end_elapsed: None,
kbd: Arc::new(Mutex::new(keyboard::Keyboard::new(&xns).unwrap())),
//kbd: Arc::new(Mutex::new(keyboard::Keyboard::new(&xns).unwrap())),
oqc: oqc_test::Oqc::new(&xns).unwrap(),
jtag: jtag::Jtag::new(&xns).unwrap(),
}
}
@ -409,134 +405,57 @@ impl<'a> ShellCmdApi<'a> for Test {
write!(ret, "FAIL: JTAG self access").unwrap();
return Ok(Some(ret));
}
#[cfg(any(target_os = "none", target_os = "xous"))]
env.com.set_backlight(196, 196).unwrap();
log::info!("building modal");
const OQC_SERVER: &str = "_OQC server_";
let kbdtest_sid = env.xns.register_name(OQC_SERVER, Some(1)).unwrap();
let test_cid = xous::connect(kbdtest_sid).unwrap();
let mut test_action = Notification::new(
test_cid,
TestOp::UxGutter.to_u32().unwrap()
);
test_action.manual_dismiss = false;
let mut test_modal = Modal::new(
"test modal",
ActionType::Notification(test_action),
Some("Keyboard Test"),
Some("test"),
GlyphStyle::Small,
8
);
// brief pause to check the screen
test_modal.gam.selftest(18_000);
susres.initiate_suspend().unwrap();
env.ticktimer.sleep_ms(1000).unwrap(); // pause for the suspend/resume cycle
/*
// now keyboard test
log::info!("making helper");
test_modal.spawn_helper(kbdtest_sid, test_modal.sid,
TestOp::ModalRedraw.to_u32().unwrap(),
TestOp::ModalKeys.to_u32().unwrap(),
TestOp::ModalDrop.to_u32().unwrap(),
);
log::info!("raising modal");
test_modal.activate();
test_modal.redraw();
self.freq = 659.25;
self.left_play = true;
self.right_play = true;
self.speaker_play = true;
self.codec.setup_8k_stream().expect("couldn't set the CODEC to expected defaults");
env.ticktimer.sleep_ms(50).unwrap();
self.codec.set_speaker_volume(VolumeOps::RestoreDefault, None).unwrap();
self.codec.set_headphone_volume(VolumeOps::RestoreDefault, None).unwrap();
if self.callback_id.is_none() {
let cb_id = env.register_handler(String::<256>::from_str(self.verb()));
log::trace!("hooking frame callback with ID {}", cb_id);
self.codec.hook_frame_callback(cb_id, self.callback_conn).unwrap(); // any non-handled IDs get routed to our callback port
self.callback_id = Some(cb_id);
}
self.play_sample = 0.0;
self.rec_sample = 0;
self.codec.resume().unwrap();
*/
log::info!("spawning helper thread");
let handle = thread::spawn({
log::info!("clone kbd");
let kbd = Arc::clone(&self.kbd);
log::info!("move kbd");
move || {
log::info!("oqc server starting");
kbd.lock().unwrap()
.register_raw_listener(
OQC_SERVER,
TestOp::KeyCode.to_usize().unwrap()
);
let mut count = 0;
let mut remaining = populate_vectors();
self.oqc.trigger(60_000);
let mut bot_str = String::<1024>::new();
loop {
let msg = xous::receive_message(kbdtest_sid).unwrap();
log::info!("got msg: {:?}", msg);
match FromPrimitive::from_usize(msg.body.id()) {
Some(TestOp::KeyCode) => xous::msg_scalar_unpack!(msg, is_keyup, r, c, _, {
log::info!("rawstates");
if is_keyup == 0 { // only worry about keydowns
let key = RowCol::new(r as u8, c as u8);
match remaining.get(&key) {
Some(_hit) => {
log::info!("got {}", map_codes(key));
remaining.insert(key, true);
write!(bot_str, "{}", map_codes(key)).unwrap();
},
None => log::warn!("got unexpected r/c: {:?}", key),
};
log::info!("update modal");
test_modal.modify(None, None, false,
Some(bot_str.as_str().unwrap()), false, None);
log::info!("redraw modal");
test_modal.redraw();
xous::yield_slice();
}
log::info!("epilogue");
// iterate and see if all keys have been hit
let mut finished = true;
for &vals in remaining.values() {
if vals == false {
log::info!("short-circuit remaining eval");
finished = false;
break;
}
}
if finished {
log::info!("all keys hit, exiting");
break;
}
count += 1;
if count > 10 {
log::info!("test threshold hit, exiting");
break;
}
//xous::return_scalar(msg.sender, 0).unwrap();
}),
Some(TestOp::UxGutter) => {
log::info!("gutter");
// an intentional NOP for UX actions that require a destintation but need no action
},
Some(TestOp::ModalRedraw) => {
log::info!("modal redraw handler");
test_modal.redraw();
},
Some(TestOp::ModalKeys) => xous::msg_scalar_unpack!(msg, _k1, _k2, _k3, _k4, {
log::info!("modal keys message, ignoring");
// ignore keys, we have our own key routine
}),
Some(TestOp::ModalDrop) => {
log::error!("test modal quit unexpectedly");
}
_ => {
log::error!("unrecognized message: {:?}", msg);
}
loop {
match self.oqc.status() {
Some(true) => {
write!(ret, "{}\nCHECK: was backlight on?\nIf so, then PASS\nNow engage PROG switch.",
env.com.ssid_fetch_as_string().unwrap()
).unwrap();
break;
}
Some(false) => {
write!(ret, "Keyboard test failed.").unwrap();
break;
}
None => {
env.ticktimer.sleep_ms(500).unwrap();
if self.freq >= 659.0 && self.freq <= 660.0 {
self.freq = 783.99;
} else if self.freq >= 783.0 && self.freq <= 784.0 {
self.freq = 987.77;
} else {
self.freq = 659.25
}
}
test_modal.gam.relinquish_focus().unwrap();
}
});
handle.join().unwrap();
*/
susres.initiate_suspend().unwrap();
env.ticktimer.sleep_ms(500).unwrap(); // pause for the suspend/resume cycle
}
self.codec.pause().unwrap();
write!(ret, "{}\nCHECK: was backlight on?\nIf so, then PASS\nThen engage PROG switch.",
env.com.ssid_fetch_as_string().unwrap()
).unwrap();
env.com.set_backlight(0, 0).unwrap();
env.llio.wfi_override(false).unwrap();
}
"devboot" => {
@ -772,125 +691,3 @@ fn rtc_get(llio: &mut llio::Llio) -> Option<DateTime> {
_ => None
}
}
fn populate_vectors() -> HashMap::<RowCol, bool> {
let mut vectors = HashMap::<RowCol, bool>::new();
vectors.insert(RowCol::new(0, 0), false);
vectors.insert(RowCol::new(0, 1), false);
vectors.insert(RowCol::new(0, 2), false);
vectors.insert(RowCol::new(0, 3), false);
vectors.insert(RowCol::new(0, 4), false);
vectors.insert(RowCol::new(4, 5), false);
vectors.insert(RowCol::new(4, 6), false);
vectors.insert(RowCol::new(4, 7), false);
vectors.insert(RowCol::new(4, 8), false);
vectors.insert(RowCol::new(4, 9), false);
vectors.insert(RowCol::new(1, 0), false);
vectors.insert(RowCol::new(1, 1), false);
vectors.insert(RowCol::new(1, 2), false);
vectors.insert(RowCol::new(1, 3), false);
vectors.insert(RowCol::new(1, 4), false);
vectors.insert(RowCol::new(5, 5), false);
vectors.insert(RowCol::new(5, 6), false);
vectors.insert(RowCol::new(5, 7), false);
vectors.insert(RowCol::new(5, 8), false);
vectors.insert(RowCol::new(5, 9), false);
vectors.insert(RowCol::new(2, 0), false);
vectors.insert(RowCol::new(2, 1), false);
vectors.insert(RowCol::new(2, 2), false);
vectors.insert(RowCol::new(2, 3), false);
vectors.insert(RowCol::new(2, 4), false);
vectors.insert(RowCol::new(6, 5), false);
vectors.insert(RowCol::new(6, 6), false);
vectors.insert(RowCol::new(6, 7), false);
vectors.insert(RowCol::new(6, 8), false);
vectors.insert(RowCol::new(6, 9), false);
vectors.insert(RowCol::new(3, 0), false);
vectors.insert(RowCol::new(3, 1), false);
vectors.insert(RowCol::new(3, 2), false);
vectors.insert(RowCol::new(3, 3), false);
vectors.insert(RowCol::new(3, 4), false);
vectors.insert(RowCol::new(7, 5), false);
vectors.insert(RowCol::new(7, 6), false);
vectors.insert(RowCol::new(7, 7), false);
vectors.insert(RowCol::new(7, 8), false);
vectors.insert(RowCol::new(7, 9), false);
vectors.insert(RowCol::new(8, 5), false);
vectors.insert(RowCol::new(8, 6), false);
vectors.insert(RowCol::new(8, 7), false);
vectors.insert(RowCol::new(8, 8), false);
vectors.insert(RowCol::new(8, 9), false);
vectors.insert(RowCol::new(8, 0), false);
vectors.insert(RowCol::new(8, 1), false);
vectors.insert(RowCol::new(3, 8), false);
vectors.insert(RowCol::new(3, 9), false);
vectors.insert(RowCol::new(8, 3), false);
vectors.insert(RowCol::new(3, 6), false);
vectors.insert(RowCol::new(6, 4), false);
vectors.insert(RowCol::new(8, 2), false);
vectors.insert(RowCol::new(5, 2), false);
vectors
}
fn map_codes(code: RowCol) -> &'static str {
let rc = (code.r, code.c);
match rc {
(0, 0) => "1",
(0, 1) => "2",
(0, 2) => "3",
(0, 3) => "4",
(0, 4) => "5",
(4, 5) => "6",
(4, 6) => "7",
(4, 7) => "8",
(4, 8) => "9",
(4, 9) => "0",
(1, 0) => "q",
(1, 1) => "w",
(1, 2) => "e",
(1, 3) => "r",
(1, 4) => "t",
(5, 5) => "y",
(5, 6) => "u",
(5, 7) => "i",
(5, 8) => "o",
(5, 9) => "p",
(2, 0) => "a",
(2, 1) => "s",
(2, 2) => "d",
(2, 3) => "f",
(2, 4) => "g",
(6, 5) => "h",
(6, 6) => "j",
(6, 7) => "k",
(6, 8) => "l",
(6, 9) => "BS",
(3, 0) => "!",
(3, 1) => "z",
(3, 2) => "x",
(3, 3) => "c",
(3, 4) => "v",
(7, 5) => "b",
(7, 6) => "n",
(7, 7) => "m",
(7, 8) => "?",
(7, 9) => "↩️",
(8, 5) => "LS",
(8, 6) => ",",
(8, 7) => "SP",
(8, 8) => ".",
(8, 9) => "RS",
(8, 0) => "F1",
(8, 1) => "F2",
(3, 8) => "F3",
(3, 9) => "F4",
(8, 3) => "⬅️",
(3, 6) => "➡️",
(6, 4) => "⬆️",
(8, 2) => "⬇️",
(5, 2) => "MID",
_ => "ERR!",
}
}

View file

@ -299,7 +299,7 @@ fn xmain() -> ! {
let xns = xous_names::XousNames::new().unwrap();
// unlimited connections allowed, this is a user app and it's up to the app to decide its policy
let shch_sid = xns.register_name(SERVER_NAME_SHELLCHAT, None).expect("can't register server");
log::trace!("registered with NS -- {:?}", shch_sid);
//log::trace!("registered with NS -- {:?}", shch_sid);
let mut repl = Repl::new(&xns, shch_sid);
let mut update_repl = false;

View file

@ -55,6 +55,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"spinor",
"root-keys",
"jtag",
"oqc-test",
];
let benchmark_pkgs = [
"benchmark",