mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +00:00
xous-log: stdout: insert \r when printing \n
When printing messages to stdout or stderr, insert `\r` whenever we encounter `\n`. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
9a1191c0d2
commit
061abb05db
1 changed files with 23 additions and 13 deletions
|
|
@ -22,14 +22,18 @@ struct ConnectRequest {
|
|||
#[cfg(feature = "usb")]
|
||||
impl Default for ConnectRequest {
|
||||
fn default() -> Self {
|
||||
ConnectRequest { name: [0u8; 64], len: 0, _padding: [0u8; 4096 - 4 - 64] }
|
||||
ConnectRequest {
|
||||
name: [0u8; 64],
|
||||
len: 0,
|
||||
_padding: [0u8; 4096 - 4 - 64],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "usb")]
|
||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
||||
pub struct UsbString {
|
||||
pub s: xous_ipc::String::<4000>,
|
||||
pub s: xous_ipc::String<4000>,
|
||||
pub sent: Option<u32>,
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +41,7 @@ pub struct UsbString {
|
|||
fn usb_send_str(conn: xous::CID, s: &str) {
|
||||
let serializer = UsbString {
|
||||
s: xous_ipc::String::<4000>::from_str(s),
|
||||
sent: None
|
||||
sent: None,
|
||||
};
|
||||
let buf = xous_ipc::Buffer::into_buf(serializer).expect("usb error");
|
||||
// failures to send are silent & ignored; also, this API doesn't block.
|
||||
|
|
@ -120,7 +124,8 @@ fn reader_thread(arg: usize) {
|
|||
writeln!(output, ")").ok();
|
||||
#[cfg(feature = "usb")]
|
||||
if let Some(conn) = usb_serial {
|
||||
if usb_str.len() > 0 { // test length so we aren't constantly copying 4096 bytes of 0's clearing an already cleared structure.
|
||||
if usb_str.len() > 0 {
|
||||
// test length so we aren't constantly copying 4096 bytes of 0's clearing an already cleared structure.
|
||||
usb_str.clear();
|
||||
}
|
||||
// duplicate the above code because doing repeated calls to the USB stack is inefficient
|
||||
|
|
@ -165,7 +170,12 @@ fn reader_thread(arg: usize) {
|
|||
buffer_length,
|
||||
)
|
||||
};
|
||||
output.write_all(buffer).unwrap();
|
||||
for c in buffer {
|
||||
if *c == b'\n' {
|
||||
output.putc(b'\r');
|
||||
}
|
||||
output.putc(*c);
|
||||
}
|
||||
// TODO: If the buffer is mutable, set `length` to 0.
|
||||
|
||||
#[cfg(feature = "usb")]
|
||||
|
|
|
|||
Loading…
Reference in a new issue