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

feat : add writer implementation #39

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Maxtho8
Copy link

@Maxtho8 Maxtho8 commented Mar 4, 2023

Hi,

Actually, we can't retrieve data that is send to serial port because they can only be send to stdout or in a file.
Writers implement the Write trait from std::io and send data to another thread through channel.
With writers we can run VM on one thread and retrieve data that is send to serial port on another thread to process it

@Maxtho8 Maxtho8 force-pushed the writer-implementation branch from ce43c8e to 2cc0e25 Compare March 4, 2023 21:54
Copy link
Contributor

@sameo sameo left a comment

Choose a reason for hiding this comment

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

Could you describe what this feature is for?

@Maxtho8
Copy link
Author

Maxtho8 commented Mar 23, 2023

Could you describe what this feature is for?

This feature is used by the base-api team. In the actual implementation data written to serial port can only be send in stdout or in a file.
If we use writer we can run VM on one thread and retrieve data that is send to serial port on another thread.

@Maxtho8 Maxtho8 force-pushed the writer-implementation branch 2 times, most recently from b038585 to 12ff379 Compare March 23, 2023 22:52
@sameo
Copy link
Contributor

sameo commented Mar 26, 2023

Could you describe what this feature is for?

This feature is used by the base-api team. In the actual implementation data written to serial port can only be send in stdout or in a file. If we use writer we can run VM on one thread and retrieve data that is send to serial port on another thread.

Either a UNIX socket or a named pipe could be used here (https://docs.google.com/presentation/d/1_GdTPlEw4aVCmBlrXdYbhrsmSOp0S_BsL5eAE9hSy1E/edit#slide=id.gcaea852e79_0_1929 and https://docs.google.com/presentation/d/1_GdTPlEw4aVCmBlrXdYbhrsmSOp0S_BsL5eAE9hSy1E/edit#slide=id.gcaea852e79_0_1924).

If you pass a UNIX domain socket as the console path, then your receiving thread becomes a network server, a very well defined pattern. I strongly encourage you to go down that path instead of the one you're proposing here.
See https://doc.rust-lang.org/std/os/unix/net/struct.UnixListener.html

self.configure_console(console)?;
self.configure_writer(writer);
Copy link
Contributor

Choose a reason for hiding this comment

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

So we're overwriting the console setting with a mpsc based Writer? If I give a console path and a mpsc Sender, self serial will be set to the mpsc sender, afaiu.

self.tx
.send(s.to_string())
.map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Error sending data"))?;
if buf.len() > 0 && (buf[0] != 10 && buf[0] != 13) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What are 10 and 13?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we send them?

Copy link
Author

Choose a reason for hiding this comment

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

13 and 10 are non escaped line return and carriage return in unicode. We don't want them because it count like a character
in the protocol here : virt-do/lambdo#5

lucido-simon and others added 9 commits March 30, 2023 11:10
Signed-off-by: Simon LUCIDO <[email protected]>
Signed-off-by: Simon LUCIDO <[email protected]>
Signed-off-by: Simon LUCIDO <[email protected]>
It is now possible to run a VM without a console with --no-console option

Co-authored-by: Esteban Baron <[email protected]>
Signed-off-by: Alexis Langlet <[email protected]>
@Maxtho8 Maxtho8 marked this pull request as draft March 31, 2023 08:34
Maxtho8 added 4 commits March 31, 2023 10:46
We don't want to send new line (10)  and carriage return (13) to the receiver.

Signed-off-by: Maxime <[email protected]>
@Maxtho8 Maxtho8 force-pushed the writer-implementation branch from 788acb7 to dd57431 Compare March 31, 2023 09:02
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.

5 participants