Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rprint! adding newline #47

Open
pkoevesdi opened this issue May 1, 2024 · 8 comments
Open

rprint! adding newline #47

pkoevesdi opened this issue May 1, 2024 · 8 comments

Comments

@pkoevesdi
Copy link

Strange behaviour:

rprint!("rprint");
rprintln!("rprintln");

works as expected, output: rprintrprintln.
But

rprint!("rprint");
Timer::after_millis(TIME).await; // use embassy_time::Timer;
rprintln!("rprintln");

adds a newline, depending on the value of TIME. Output:

rprintr
rprintln

when TIME is something above 270 (thereshold is changing from time to time).

@pkoevesdi
Copy link
Author

This shows some more strange behaviour:

for _ in 0..100 {
Timer::after_millis(10).await;
rprint!(".");
}

Output:

.
.
.....
.....
.....
.
.....
.....
.....
.....
.
.....
.....
.
.....
.....
.....
.
.....
.....
.....
.
.....
.....
.....
.
..

@noppej
Copy link
Contributor

noppej commented May 1, 2024 via email

@mvirkkunen
Copy link
Contributor

Very mysterious. Which program on your computer are you using to look at the output?

@pkoevesdi
Copy link
Author

I use both, cargo run in a normal Linux Terminal and vscode (which also uses cargo in the background).

@mvirkkunen
Copy link
Contributor

What do you have configured as the runner in .cargo/config.toml? Is it probe-rs run or?

runner = 'probe-rs run --chip <chip-name>'

@noppej
Copy link
Contributor

noppej commented May 1, 2024

From the original posting, I think what is happening is that somewhere between rtt-target and probe-rs, a newline is added after every write of String RTT data to the client (Terminal or VSCode). I'll have to look through the code to confirm, but I think what happens is the process reads all the data available in the target RTT buffer, and sends it to the output with a newline at the end of it, then goes back to look for more data.

  • If the data comes in during a single buffer read , e.g. "rprintrprintln", then it will send that to the output.
  • If the data comes in the first buffer read having "rprint", it will process it, and then look again, and find the slightly delayed "rprintln" and send that on another (new) line.

@pkoevesdi
Copy link
Author

pkoevesdi commented May 2, 2024

Were you able to reproduce the problem?

My config.toml has this line, yes:
runner = [ "probe-rs", "run", "--chip", "STM32H730VBTx"]
and I can also run probe-rs run --chip STM32H730VBTx target/thumbv7em-none-eabihf/debug/pintest on the terminal and have this effect.

@pkoevesdi
Copy link
Author

pkoevesdi commented May 2, 2024

I put up a minimum (?) working project that shows this behaviour.
rprinttest.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants