mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-22 09:23:16 +00:00
Merge branch 'i18n-jp' into i18n-jp
This commit is contained in:
commit
d1c443f62e
7 changed files with 314 additions and 189 deletions
|
|
@ -579,12 +579,16 @@ impl Com {
|
|||
Message::new_blocking_scalar(Opcode::IntAck.to_usize().unwrap(), ack_val as usize, 0, 0, 0)
|
||||
).expect("couldn't send IntSetMask message");
|
||||
}
|
||||
pub fn ints_get_active(&self, int_list: &mut Vec::<ComIntSources>) -> (Option<u16>, usize, usize) {
|
||||
pub fn ints_get_active(&self, int_list: &mut Vec::<ComIntSources>) -> Result<(Option<u16>, usize, usize), xous::Error> {
|
||||
let response = send_message(self.conn,
|
||||
Message::new_blocking_scalar(Opcode::IntFetchVector.to_usize().unwrap(), 0, 0, 0, 0))
|
||||
.expect("couldn't get IntFetchVector");
|
||||
let mut rxlen: Option<u16> = None;
|
||||
if let xous::Result::Scalar2(ints, maybe_rxlen) = response {
|
||||
if ints == 0xDDDD {
|
||||
log::warn!("IntFetchVector: 0xDDDD sentinel returned");
|
||||
return Err(xous::Error::Timeout);
|
||||
}
|
||||
let mut mask_bit: u16 = 1;
|
||||
for _ in 0..16 {
|
||||
let int_src = ComIntSources::from(mask_bit & ints as u16);
|
||||
|
|
@ -603,7 +607,7 @@ impl Com {
|
|||
}
|
||||
mask_bit <<= 1;
|
||||
}
|
||||
(rxlen, ints, maybe_rxlen)
|
||||
Ok((rxlen, ints, maybe_rxlen))
|
||||
} else {
|
||||
panic!("failed to send IntGetmask message");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ mod implementation {
|
|||
/// indicate if the chord has been captured. Once captured, further presses are ignored, until all keys are let up.
|
||||
chord_captured: bool,
|
||||
susres: RegManager::<{utra::keyboard::KEYBOARD_NUMREGS}>,
|
||||
pub debug: usize,
|
||||
}
|
||||
|
||||
fn handle_kbd(_irq_no: usize, arg: *mut usize) {
|
||||
|
|
@ -233,11 +234,16 @@ mod implementation {
|
|||
xous::Message::new_scalar(Opcode::HandlerTrigger.to_usize().unwrap(), 0, 0, 0, 0)).ok();
|
||||
}
|
||||
if kbd.csr.rf(utra::keyboard::EV_PENDING_INJECT) != 0 {
|
||||
while kbd.csr.rf(utra::keyboard::UART_CHAR_STB) != 0 {
|
||||
let c = kbd.csr.rf(utra::keyboard::UART_CHAR_CHAR);
|
||||
loop {
|
||||
let char_reg = kbd.csr.r(utra::keyboard::UART_CHAR);
|
||||
if char_reg & kbd.csr.ms(utra::keyboard::UART_CHAR_STB, 1) != 0 {
|
||||
xous::try_send_message(kbd.conn,
|
||||
xous::Message::new_scalar(Opcode::InjectKey.to_usize().unwrap(), c as _, 0, 0, 0)
|
||||
xous::Message::new_scalar(Opcode::InjectKey.to_usize().unwrap(), (char_reg & 0xff) as _, 0, 0, 0)
|
||||
).ok();
|
||||
kbd.debug += 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
kbd.csr.wo(utra::keyboard::EV_PENDING, pending);
|
||||
|
|
@ -300,6 +306,7 @@ mod implementation {
|
|||
chord_active: 0,
|
||||
chord_captured: false,
|
||||
susres: RegManager::new(csr.as_mut_ptr() as *mut u32),
|
||||
debug: 0,
|
||||
};
|
||||
|
||||
xous::claim_interrupt(
|
||||
|
|
@ -757,6 +764,7 @@ mod implementation {
|
|||
rate: u32,
|
||||
delay: u32,
|
||||
chord_interval: u32,
|
||||
pub debug: u32,
|
||||
}
|
||||
|
||||
impl Keyboard {
|
||||
|
|
@ -767,6 +775,7 @@ mod implementation {
|
|||
rate: 20,
|
||||
delay: 200,
|
||||
chord_interval: 50,
|
||||
debug: 0,
|
||||
}
|
||||
}
|
||||
pub fn suspend(&self) {
|
||||
|
|
@ -849,7 +858,8 @@ fn xmain() -> ! {
|
|||
log::warn!("kbd server is overriding WFI for debugging, remember to disable for production");
|
||||
llio.wfi_override(true).unwrap();
|
||||
}*/
|
||||
let mut inject_esc = false;
|
||||
let mut esc_index: Option<usize> = None;
|
||||
let mut esc_chars = [0u8; 16];
|
||||
|
||||
log::trace!("starting main loop");
|
||||
loop {
|
||||
|
|
@ -906,41 +916,61 @@ fn xmain() -> ! {
|
|||
}),
|
||||
Some(Opcode::InjectKey) => msg_scalar_unpack!(msg, k, _, _, _, {
|
||||
// key substitutions to help things work better
|
||||
// 5b31 = home (5b7e now that we have things working better?? maybe this is a three-byte sequence and I'm missing a third?)
|
||||
// 5b44 = left
|
||||
// 5b43 = right
|
||||
// 5b41 = up
|
||||
// 5b42 = down
|
||||
let k_prime = if !inject_esc {
|
||||
match k {
|
||||
0x7f => 0x08,
|
||||
0x5b => {
|
||||
inject_esc = true;
|
||||
0x00
|
||||
}
|
||||
_ => k as u32
|
||||
}
|
||||
// 1b5b317e = home
|
||||
// 1b5b44 = left
|
||||
// 1b5b43 = right
|
||||
// 1b5b41 = up
|
||||
// 1b5b42 = down
|
||||
log::trace!("{:x} {}", k, kbd.debug);
|
||||
kbd.debug = 0;
|
||||
|
||||
let key = match esc_index {
|
||||
Some(i) => {
|
||||
esc_chars[i] = (k & 0xff) as u8;
|
||||
match esc_match(&esc_chars[..i + 1]) {
|
||||
Ok(m) => {
|
||||
if let Some(code) = m {
|
||||
// Ok(Some(code)) is a character found
|
||||
esc_chars = [0u8; 16];
|
||||
esc_index = None;
|
||||
code
|
||||
} else {
|
||||
inject_esc = false;
|
||||
match k {
|
||||
0x7e => '∴' as u32,
|
||||
0x44 => '←' as u32,
|
||||
0x43 => '→' as u32,
|
||||
0x41 => '↑' as u32,
|
||||
0x42 => '↓' as u32,
|
||||
// Ok(None) means we're still accumulating characters
|
||||
if i + 1 < esc_chars.len() {
|
||||
esc_index = Some(i + 1);
|
||||
} else {
|
||||
esc_index = None;
|
||||
esc_chars = [0u8; 16];
|
||||
}
|
||||
'\u{0000}'
|
||||
}
|
||||
}
|
||||
// invalid sequence encountered, abort
|
||||
Err(_) => {
|
||||
log::warn!("Unhandled escape sequence: {:x?}", &esc_chars[..i+1]);
|
||||
esc_chars = [0u8; 16];
|
||||
esc_index = None;
|
||||
'\u{0000}'
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
log::warn!("unknown escape sequence, ignoring: 0x5b{:x}", k);
|
||||
0
|
||||
if k == 0x1b {
|
||||
esc_index = Some(1);
|
||||
esc_chars = [0u8; 16]; // clear the full search array with every escape sequence init
|
||||
esc_chars[0] = 0x1b;
|
||||
'\u{0000}'
|
||||
} else {
|
||||
let bs_del_fix = if k == 0x7f {
|
||||
0x08
|
||||
} else {
|
||||
k
|
||||
};
|
||||
core::char::from_u32(bs_del_fix as u32).unwrap_or('\u{0000}')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let key = if let Some(a) = core::char::from_u32(k_prime) {
|
||||
a
|
||||
} else {
|
||||
log::warn!("Uninterpreable key sequence, ignoring: 0x{:x}", k);
|
||||
'\u{0000}'
|
||||
};
|
||||
if let Some(conn) = listener_conn {
|
||||
if key != '\u{0000}' {
|
||||
log::info!("injecting key '{}'({:x})", key, key as u32); // always be noisy about this, it's an exploit path
|
||||
|
|
@ -1029,3 +1059,33 @@ fn xmain() -> ! {
|
|||
log::trace!("quitting");
|
||||
xous::terminate_process(0)
|
||||
}
|
||||
|
||||
fn esc_match(esc_chars: &[u8]) -> Result<Option<char>, ()> {
|
||||
let mut extended = Vec::<u8>::new();
|
||||
for (i, &c) in esc_chars.iter().enumerate() {
|
||||
match i {
|
||||
0 => if c != 0x1b { return Err(()) },
|
||||
1 => if c != 0x5b { return Err(()) },
|
||||
2 => match c {
|
||||
0x41 => return Ok(Some('↑')),
|
||||
0x42 => return Ok(Some('↓')),
|
||||
0x43 => return Ok(Some('→')),
|
||||
0x44 => return Ok(Some('←')),
|
||||
0x7e => return Err(()), // premature end
|
||||
_ => extended.push(c)
|
||||
}
|
||||
_ => if c == 0x7e {
|
||||
if extended.len() == 1 {
|
||||
if extended[0] == 0x31 {
|
||||
return Ok(Some('∴'))
|
||||
}
|
||||
} else {
|
||||
return Err(()) // code unrecognized
|
||||
}
|
||||
} else {
|
||||
extended.push(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
|
@ -171,6 +171,12 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
|
|||
}
|
||||
}
|
||||
LinkState::WFXError => {
|
||||
// reset the stats cache, and update subscribers that we're disconnected
|
||||
wifi_stats_cache = WlanStatus::from_ipc(WlanStatusIpc::default());
|
||||
for &sub in status_subscribers.keys() {
|
||||
let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(wifi_stats_cache)).or(Err(xous::Error::InternalError)).unwrap();
|
||||
buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()).or(Err(xous::Error::InternalError)).unwrap();
|
||||
}
|
||||
wifi_state = WifiState::Error;
|
||||
}
|
||||
_ => { // should approximately be a "disconnected" state.
|
||||
|
|
@ -484,7 +490,11 @@ fn get_next_ssid(ssid_list: &mut HashSet<String>, ssid_attempted: &mut HashSet<S
|
|||
log::debug!("SSID connect attempt: {:?}", candidate);
|
||||
Some(candidate.to_string())
|
||||
} else {
|
||||
log::info!("No SSID candidates visible");
|
||||
log::info!("No SSID candidates visible. Debug dump:");
|
||||
log::info!("ap_list: {:?}", ap_list);
|
||||
log::info!("ssid_list: {:?}", ssid_list);
|
||||
log::info!("candidate list: {:?}", all_candidate_list);
|
||||
log::info!("untried candidate list: {:?}", untried_candidate_list);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,18 @@ pub struct PingConnection {
|
|||
retop: usize,
|
||||
}
|
||||
|
||||
fn set_com_ints(com_int_list: &mut Vec::<ComIntSources>) {
|
||||
com_int_list.clear();
|
||||
com_int_list.push(ComIntSources::WlanIpConfigUpdate);
|
||||
com_int_list.push(ComIntSources::WlanRxReady);
|
||||
com_int_list.push(ComIntSources::BatteryCritical);
|
||||
com_int_list.push(ComIntSources::Connect);
|
||||
com_int_list.push(ComIntSources::Disconnect);
|
||||
com_int_list.push(ComIntSources::WlanSsidScanUpdate);
|
||||
com_int_list.push(ComIntSources::WlanSsidScanFinished);
|
||||
com_int_list.push(ComIntSources::WfxErr);
|
||||
}
|
||||
|
||||
#[xous::xous_main]
|
||||
fn xmain() -> ! {
|
||||
log_server::init_wait().unwrap();
|
||||
|
|
@ -101,20 +113,12 @@ fn xmain() -> ! {
|
|||
llio.com_event_enable(true).unwrap();
|
||||
// setup the interrupt masks
|
||||
let mut com_int_list: Vec::<ComIntSources> = vec![];
|
||||
com.ints_get_active(&mut com_int_list);
|
||||
com.ints_get_active(&mut com_int_list).ok();
|
||||
log::debug!("COM initial pending interrupts: {:?}", com_int_list);
|
||||
com_int_list.clear();
|
||||
com_int_list.push(ComIntSources::WlanIpConfigUpdate);
|
||||
com_int_list.push(ComIntSources::WlanRxReady);
|
||||
com_int_list.push(ComIntSources::BatteryCritical);
|
||||
com_int_list.push(ComIntSources::Connect);
|
||||
com_int_list.push(ComIntSources::Disconnect);
|
||||
com_int_list.push(ComIntSources::WlanSsidScanUpdate);
|
||||
com_int_list.push(ComIntSources::WlanSsidScanFinished);
|
||||
com_int_list.push(ComIntSources::WfxErr);
|
||||
set_com_ints(&mut com_int_list);
|
||||
com.ints_enable(&com_int_list);
|
||||
com_int_list.clear();
|
||||
com.ints_get_active(&mut com_int_list);
|
||||
com.ints_get_active(&mut com_int_list).ok();
|
||||
log::debug!("COM pending interrupts after enabling: {:?}", com_int_list);
|
||||
const MAX_DELAY_THREADS: u32 = 10; // limit the number of concurrent delay threads. Typically we have 1-2 running at any time, but DoS conditions could lead to many more.
|
||||
let delay_threads = Arc::new(AtomicU32::new(0));
|
||||
|
|
@ -554,7 +558,8 @@ fn xmain() -> ! {
|
|||
|
||||
Some(Opcode::ComInterrupt) => {
|
||||
com_int_list.clear();
|
||||
let (maybe_rxlen, ints, raw_rxlen) = com.ints_get_active(&mut com_int_list);
|
||||
match com.ints_get_active(&mut com_int_list) {
|
||||
Ok((maybe_rxlen, ints, raw_rxlen)) => {
|
||||
log::debug!("COM got interrupts: {:?}, {:?}", com_int_list, maybe_rxlen);
|
||||
// forward the interrupt to the connection manager as well
|
||||
match xous::try_send_message(cm_cid, Message::new_scalar(
|
||||
|
|
@ -676,6 +681,26 @@ fn xmain() -> ! {
|
|||
}
|
||||
}
|
||||
com.ints_ack(&com_int_list);
|
||||
},
|
||||
Err(xous::Error::Timeout) => {
|
||||
log::warn!("Interrupt fetch from COM timed out.");
|
||||
// bread crumb: this is a "normal" error to throw when the EC is being reset,
|
||||
// or when it is handling the reset of the wifi subsystem, so it's not fatal.
|
||||
// However, if we see this repeatedly, it might be a good idea to add some sort
|
||||
// of event counter to log the number of times we've seen this consecutively and
|
||||
// if it's too much, issue a reset to the EC.
|
||||
|
||||
// refresh the interrupt list to the EC, just in case it lost the prior list
|
||||
timer.sleep_ms(1000).unwrap(); // a brief delay because if the EC wasn't responding before, it probably needs /some/ time before being able to handle this next message
|
||||
set_com_ints(&mut com_int_list);
|
||||
com.ints_enable(&com_int_list);
|
||||
com_int_list.clear();
|
||||
}
|
||||
_ => {
|
||||
// not fatal, just report it.
|
||||
log::error!("Unhanlded error in COM interrupt fetch");
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(Opcode::NetPump) => {
|
||||
let timestamp = Instant::from_millis(timer.elapsed_ms() as i64);
|
||||
|
|
|
|||
|
|
@ -31,8 +31,12 @@ impl<'a> ShellCmdApi<'a> for Ssid {
|
|||
|
||||
if let Some(sub_cmd) = tokens.next() {
|
||||
match sub_cmd {
|
||||
"force" => {
|
||||
env.com.set_ssid_scanning(true).unwrap();
|
||||
write!(ret, "Forcing SSID scan. Warning: could put the connection manager in an inconsistent state.").unwrap();
|
||||
}
|
||||
"scan" => {
|
||||
// SSID scanning is automatically initiated by the connection manager
|
||||
// SSID scanning is automatically initiated by the connection manager, so we don't initiate it explicitly, just report results
|
||||
let ssid_list = env.com.ssid_fetch_as_list().unwrap();
|
||||
write!(ret, "RSSI in dBm:\n").unwrap();
|
||||
for (rssi, name) in ssid_list {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,20 @@
|
|||
{
|
||||
"stats.measuring": {
|
||||
"en": "Measuring...",
|
||||
"zh": "进行测量...",
|
||||
"en-audio": "Measuring..."
|
||||
},
|
||||
"stats.disconnected": {
|
||||
"en": "Not connected",
|
||||
"zh": "没有连接",
|
||||
"en-audio": "Not connected"
|
||||
},
|
||||
"stats.uptime": {
|
||||
"translator-note": "This needs to be a very short string, 2 chars max. Trailing space is necessary for English due to proportional font.",
|
||||
"en": "Up ",
|
||||
"zh": "运行",
|
||||
"en-audio": "Uptime"
|
||||
},
|
||||
"secnote.usb_unlock": {
|
||||
"en": " USB unlocked",
|
||||
"ja": "USBロック解除",
|
||||
|
|
|
|||
|
|
@ -357,6 +357,12 @@ fn xmain() -> ! {
|
|||
battstats_tv.clear_str();
|
||||
// have to clear the entire rectangle area, because the SSID has a variable width and can be much wider or shorter than battstats
|
||||
gam.draw_rectangle(status_gid, stats_rect).ok();
|
||||
|
||||
if stats.current == 0xdddd || stats.current == 0xffff
|
||||
|| stats.voltage == 0xdddd || stats.voltage == 0xffff
|
||||
|| stats.soc == 0xdddd || stats.soc == 0xffff {
|
||||
write!(&mut battstats_tv, "{}", t!("stats.measuring", xous::LANG)).unwrap();
|
||||
} else {
|
||||
// toggle between two views of the data every time we have a status update
|
||||
let mut wattage = stats.current as f32 / 1000.0 * stats.voltage as f32 / 1000.0;
|
||||
let sign = if wattage > 0.005 {
|
||||
|
|
@ -368,8 +374,7 @@ fn xmain() -> ! {
|
|||
};
|
||||
wattage = wattage.abs();
|
||||
if battstats_phase {
|
||||
write!(&mut battstats_tv, "{:.3}W{}{:.2}V {}%", wattage, sign, stats.voltage as f32 / 1000.0, stats.soc)
|
||||
.expect("|status: can't write string");
|
||||
write!(&mut battstats_tv, "{:.3}W{}{:.2}V {}%", wattage, sign, stats.voltage as f32 / 1000.0, stats.soc).unwrap();
|
||||
} else {
|
||||
if let Some(ssid) = wifi_status.ssid {
|
||||
write!(
|
||||
|
|
@ -377,14 +382,14 @@ fn xmain() -> ! {
|
|||
"{} -{}dBm",
|
||||
ssid.name.as_str().unwrap_or("UTF-8 Erorr"),
|
||||
ssid.rssi,
|
||||
)
|
||||
.expect("|status: can't write string");
|
||||
).unwrap();
|
||||
} else {
|
||||
write!(
|
||||
&mut battstats_tv,
|
||||
"Not connected"
|
||||
)
|
||||
.expect("|status: can't write string");
|
||||
"{}",
|
||||
t!("stats.disconnected", xous::LANG)
|
||||
).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
gam.post_textview(&mut battstats_tv)
|
||||
|
|
@ -539,7 +544,8 @@ fn xmain() -> ! {
|
|||
// use ticktimer, not stats_phase, because stats_phase encodes some phase drift due to task-switching overhead
|
||||
write!(
|
||||
&mut uptime_tv,
|
||||
" Up {}:{:02}:{:02}",
|
||||
" {}{}:{:02}:{:02}",
|
||||
t!("stats.uptime", xous::LANG),
|
||||
(elapsed_time / 3_600_000),
|
||||
(elapsed_time / 60_000) % 60,
|
||||
(elapsed_time / 1000) % 60,
|
||||
|
|
|
|||
Loading…
Reference in a new issue