You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've spent two or three hours trying to understand why a test case wouldn't work, it went roughly like this:
#[tokio::test]asyncfntest_serial() -> Result<(),Box<dynError>>{let(mut rep,mut req) = Serial::pair()?;let f = tokio::spawn(asyncmove{letmut buffer = [0u8;1];
rep.read_exact(&mut buffer).await?;let[command] = buffer;assert_eq!(command,1);
rep.write_all(&buffer).await?;
rep.shutdown().await?;
io::Result::<_>::Ok(())});
req.write_all(&[1]).await?;letmut buffer = [0u8;1];
req.read_exact(&mut buffer).await?;let[response] = buffer;assert_eq!(response,1);// may be a join error, or an IO error from inside the task
f.await??;Ok(())}
Turns out, switching req and rep at the beginning is the solution. The documentation mentions that
Attempting any IO or parameter settings on the slave tty after the master tty is closed will return errors.
but doesn't explain which one is the master and which the slave; at the time I had written the test case to the extent that the error occurred, I had forgotten that there was a distinction between master and slave I hadn't understood sufficiently. Linking the mio docs or adding one or two sentences to the docs would help here, I think.
The text was updated successfully, but these errors were encountered:
zzeroo
added a commit
to zzeroo/tokio-serial
that referenced
this issue
Sep 3, 2020
I've spent two or three hours trying to understand why a test case wouldn't work, it went roughly like this:
Turns out, switching
req
andrep
at the beginning is the solution. The documentation mentions thatbut doesn't explain which one is the master and which the slave; at the time I had written the test case to the extent that the error occurred, I had forgotten that there was a distinction between master and slave I hadn't understood sufficiently. Linking the mio docs or adding one or two sentences to the docs would help here, I think.
The text was updated successfully, but these errors were encountered: