From c39aa289d55ae1a89c78e8b1717c7e3472f1bc86 Mon Sep 17 00:00:00 2001 From: occheung Date: Fri, 28 Aug 2020 16:32:45 +0800 Subject: [PATCH] toml: add rounding library for f64 --- Cargo.toml | 1 + examples/ethernet.rs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 136a45a..75196d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ smoltcp = { version = "0.6.0", default-features = false, features = [ "ethernet" nb = "1.0.0" scpi = {path = "../scpi-rs/scpi", version = "0.3.4"} lexical-core = { version="0.7.1", features=["radix"], default-features=false } +libm = { version = "0.2.0" } # Logging and Panicking panic-itm = "0.4.1" diff --git a/examples/ethernet.rs b/examples/ethernet.rs index d7f0979..51f9f0b 100644 --- a/examples/ethernet.rs +++ b/examples/ethernet.rs @@ -29,6 +29,8 @@ use stm32h7xx_hal::rcc::CoreClocks; use stm32h7xx_hal::{pac, prelude::*, stm32, stm32::interrupt}; use Speed::*; +use libm::round; + /* #[cfg(feature = "itm")] use cortex_m_log::log::{trick_init, Logger}; @@ -271,8 +273,8 @@ fn main() -> ! { (buffer.len(), buffer) }).unwrap(); hprintln!("{:?}", data).unwrap(); - let result = lexical_core::parse_partial::(data).unwrap(); - writeln!(socket, "{}", (result.0 * 2.0)); + let result = lexical_core::parse_partial::(data).unwrap(); + writeln!(socket, "{}", round(result.0 * 2.0)); } else if socket.can_recv() { // hprintln!("{:?}", socket.can_recv());