Hallo.
I can successfully run the embassy example usb_serial.rs
.
But I see a strange thing happening:
When I put an introductory message class.write_packet("welcome to the echo test".as_bytes()).await?;
before the loop in line 121, I get this message echoed back via serial and in the rtt output (from line 124), as soon as I connect my serial terminal (and only then). It's not the terminal program that echoes (I tried about 5 different programs). I uncommented the echo-back line, to be sure, then of ocurse I get the echo only inside the rtt output. Still, it's an echo back to the target, who is the sender.
So my echo function looks like this:
async fn echo<'d, T: Instance + 'd>(class: &mut CdcAcmClass<'d, Driver<'d, T>>) -> Result<(), Disconnected> {
let mut buf = [0; 64];
class.write_packet("welcome to the echo test".as_bytes()).await?;
loop {
let n = class.read_packet(&mut buf).await?;
let data = &buf[..n];
info!("data: {:x}", data);
// class.write_packet(data).await?;
}
}
What's goin on there? Is there some buffer involved that I should flush after sending my welcome message?
To be clear: Of course I see what I type in my serial terminal echoed back there (before uncommenting this), that's what the function is about. But not the other way around: what the target sends out through usb is not supposed to arrive back.