Improved serial write_str implementation to properly handle errors
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
This commit is contained in:
parent
d0f4500481
commit
77a6dad00a
|
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
|
||||
- Updated to stm32-rs v0.6.0 - @HarkonenBade
|
||||
- Updated the ADC code to use variants added in stm32-rs v0.6.0 - @HarkonenBade
|
||||
- Improved serial `write_str` implementation
|
||||
|
||||
## [v0.12.0] - 2019-01-13
|
||||
|
||||
|
|
|
@ -518,10 +518,10 @@ where
|
|||
Tx<USART>: embedded_hal::serial::Write<u8>,
|
||||
{
|
||||
fn write_str(&mut self, s: &str) -> Result {
|
||||
use nb::block;
|
||||
|
||||
let _ = s.as_bytes().iter().map(|c| block!(self.write(*c))).last();
|
||||
Ok(())
|
||||
s.as_bytes()
|
||||
.iter()
|
||||
.try_for_each(|c| nb::block!(self.write(*c)))
|
||||
.map_err(|_| core::fmt::Error)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -531,10 +531,10 @@ where
|
|||
TXPIN: TxPin<USART>,
|
||||
{
|
||||
fn write_str(&mut self, s: &str) -> Result {
|
||||
use nb::block;
|
||||
|
||||
let _ = s.as_bytes().iter().map(|c| block!(self.write(*c))).last();
|
||||
Ok(())
|
||||
s.as_bytes()
|
||||
.iter()
|
||||
.try_for_each(|c| nb::block!(self.write(*c)))
|
||||
.map_err(|_| core::fmt::Error)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue