I’m actually porting the code from the
serial crate. I only need it for Linux (Raspberry Pi), so no need to port the Windows part. I’ve seen that the descriptor that is using is opened like this. It uses some flags (
O_RDWR | O_NOCTTY | O_NONBLOCK) and then removes the
O_NONBLOCK flag. Should the descriptor be opened the same way for async?
I would like to have an API so that I can do something like this:
let mut l = Core::new().unwrap();
let handle = l.handle();
let mut serial = AsyncSerial::open("/dev/tty1", Baud9600, &handle).unwrap();
Then, I would like to be able to use the serial so that when I can iterate through the data. Something like, when new data comes, it runs a function to convert that variable-length data to a
Request, and computes a
Response that is written back to the serial. I’m still not very familiar with async, but I’ve seen that with futures, processing can be chained, and in fact, I’ve seen that it should be possible to buffer
Requests to process them in parallel.
Is there a trait I should be implementing to enable that functionality? Also, is there a “preferred” way to do it? don’t think that using
Write directly would solve it.