Open Tim-Paik opened 2 years ago
I had a similar problem so I went digging:
EditorBuilder::build_sync
will send these bytes and expect a response indicating the terminal size
https://github.com/rustne-kretser/noline/blob/6e6d8b79a0cb79501ffaccbf6b2a81eab17ae46c/noline/src/core.rs#L46-L52
Your Console
provides an invalid response which results in the error.
Btw, you should use self.0.pop()
instead of self.0.last()
in your Read
impl.
@Tim-Paik Sorry for not responding, I missed the github notification so I didn't see this before now.
Do you have a full example I can have a look at?
@Tim-Paik Sorry for not responding, I missed the github notification so I didn't see this before now.
Do you have a full example I can have a look at?
You can execute the following command to reproduce my problem
cargo new nolinetest
cd nolinetest
cargo add noline --features alloc
Populate src/main.rs
with the code from main.rs
that I provided at the beginning, after that, you can use cargo run
to run it
I had a similar problem so I went digging:
EditorBuilder::build_sync
will send these bytes and expect a response indicating the terminal sizeYour
Console
provides an invalid response which results in the error.Btw, you should use
self.0.pop()
instead ofself.0.last()
in yourRead
impl.
Looks like you're making sense, since I'm not providing a terminal width, which noline definitely needs. But I don't know how should I provide the size of the terminal...
Noline expects to be connected to an ANSI terminal. During init, noline probes the terminal using ANSI escape codes to get the size of the terminal. You can have a look at here for an example of a mockterminal.
But, what is your use case here? Without an actual terminal, noline isn't of much use.
Not entirely sure if related, but I'm consistently getting this panic on the rp2040
example. Regardless of the dumb terminal emulator I use, the first time I hit "enter" it panics at the unwrap:
let mut editor = EditorBuilder::from_slice(&mut buffer)
.with_slice_history(&mut history)
.build_sync(&mut io)
.unwrap();
I had to modify the example slightly for it to work on the second attempt:
let mut editor = loop {
break match EditorBuilder::from_slice(&mut buffer)
.with_slice_history(&mut history)
.build_sync(&mut io) {
Ok(ed) => ed,
Err(err) => {
let error = match err {
NolineError::IoError(_) => "IoError",
NolineError::ParserError => "ParseError",
NolineError::Aborted=> "Aborted",
};
writeln!(io, "Error: {}\r", error).unwrap();
continue;
}
}
};
Now it works, but the error still happens:
$ picocom /dev/ttyACM1
(...)
Terminal ready
Error: ParseError
>
Is this something that's fixable on noline
's side, or should the example be modified to keep retrying?
I would need to be able to reproduce this in order to debug it. Could you provide more details of your setup:
stty -F /dev/ttyACM
?Thanks!
- What operating system are you running?
Linux 6.10.8 (archlinux)
- Does this happen with other terminal emulators (minicom, etc)?
Yes, I've tried minicom and screen, same thing on both.
- What terminal settings are you using (output of
stty -F /dev/ttyACM
?
$ stty -F /dev/ttyACM1
speed 9600 baud; line = 0;
min = 1; time = 0;
-brkint -icrnl -imaxbel
-opost
-isig -icanon -iexten -echo
- What UART-to-USB adapter are you using?
This is a straight USB connection to the rp-pico (using rp2040 usb serial example).
Thanks! I don't have an RP pico here now, but I'll try to bring one tomorrow and have look.
I've done some testing, and it appears that when using minicom the serial port is opened for read/write before configuring it, which means that dtr()
is true on the device, but raw -echo
hasn't been set yet. Try running stty raw -echo -F /dev/ttyACM1
before starting minicom and see if that helps.
I guess noline should be a bit more robust in the face of unexpected data, but I'm not sure how this should be handled.
I'm having some issues trying to use this crate to make an interaction for my no_std project. I tried implementing my own IO type (for my environment), but always panic when building the editor:
here is my code:
Did I write something wrong? It looks like everything works fine