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

Convert LF to CRLF when writing to serial port #474

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

ChocolateLoverRaj
Copy link
Contributor

@ChocolateLoverRaj ChocolateLoverRaj commented Nov 17, 2024

Fixes #473

I'm not sure if this is the best way to implement this in terms of performance.

This fixes the issue with LockedLogger, but the logging that gets done before that still doesn't use CRLF, which is why I marked this as a draft PR. UPDATE: I forgot to change the bootloader dependency in Cargo.toml, after changing it all logging was as expected.

Without this change
image

With this change:
image

@ChocolateLoverRaj ChocolateLoverRaj marked this pull request as ready for review November 17, 2024 19:37
Copy link
Member

@Freax13 Freax13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

This looks good to me! :shipit:

Comment on lines +20 to +25
for char in s.bytes() {
match char {
b'\n' => self.port.write_str("\r\n").unwrap(),
byte => self.port.send(byte),
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another fix for #473 might be to change the writeln! call to a write("...\r\n") call, this wouldn't work if the log message contains multi-line strings, so I think this solution is preferable.

Performance could certainly be improved a bit, but this code is not at all performance-critical, so let's keep things simple.

@Freax13 Freax13 merged commit ea2529b into rust-osdev:main Nov 22, 2024
9 checks passed
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

Successfully merging this pull request may close these issues.

QEMU serial0 logs look bad because logger doesn't use \r\n
2 participants