From 1e7fd93835924af51e9f0e90d0702561f31d5469 Mon Sep 17 00:00:00 2001 From: occheung Date: Tue, 1 Sep 2020 10:21:55 +0800 Subject: [PATCH] scpi: fix dds test sdio_in_only --- Cargo.toml | 4 +++- examples/ethernet.rs | 19 ++++++------------- src/dds.rs | 2 +- src/scpi.rs | 2 ++ 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b4cb8d6..38d9e78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,9 @@ smoltcp = { version = "0.6.0", default-features = false, features = [ "ethernet" nb = "1.0.0" scpi = { git = "https://github.com/occheung/scpi-rs", branch = "issue-4" } lexical-core = { version="0.7.1", features=["radix"], default-features=false } -libm = { version = "0.2.0" } +libm = "0.2.0" +embedded-nal = "0.1.0" +minimq = "0.1.0" # Logging and Panicking panic-itm = "0.4.1" diff --git a/examples/ethernet.rs b/examples/ethernet.rs index 1522f08..245746e 100644 --- a/examples/ethernet.rs +++ b/examples/ethernet.rs @@ -58,6 +58,9 @@ use smoltcp::socket::SocketSet; use smoltcp::socket::{SocketHandle, TcpSocket, TcpSocketBuffer}; use smoltcp::time::{Duration, Instant}; +// Use embedded-nal to access smoltcp +use embedded_nal::TcpStack; + use firmware; use firmware::{ attenuator::Attenuator, @@ -301,8 +304,6 @@ fn main() -> ! { }; let mut eth_up = false; - let mut receive_and_not_send = true; - let mut counter = 0; // Record activeness of silent socket, init as false let mut silent_socket_active = false; @@ -319,7 +320,7 @@ fn main() -> ! { }, }; - // Counting socket (:6969) + // Float rounding test socket (:6969) { let mut socket = sockets.get::(tcp1_handle); if !socket.is_open() { @@ -327,24 +328,16 @@ fn main() -> ! { socket.set_timeout(Some(Duration::from_millis(5000))); } - if socket.can_recv() && receive_and_not_send { + if socket.can_recv() { let data = socket.recv(|buffer| { (buffer.len(), buffer) }).unwrap(); hprintln!("{:?}", data).unwrap(); let result = lexical_core::parse_partial::(data).unwrap(); writeln!(socket, "{}", round(result.0 * 2.0)); - } - else if socket.can_recv() { - // hprintln!("{:?}", socket.can_recv()); - } - - if socket.can_send() && !receive_and_not_send { - writeln!(socket, "{}", counter); - receive_and_not_send = true; } } - // Silent socket (:7000) + // SCPI interaction socket (:7000) { let mut socket = sockets.get::(silent_handle); if !socket.is_open() { diff --git a/src/dds.rs b/src/dds.rs index 0f181fa..040ce77 100644 --- a/src/dds.rs +++ b/src/dds.rs @@ -357,7 +357,7 @@ where // Test configuration register by getting SDIO_IN_ONLY and LSB_FIRST. let mut error_count = 0; let mut config_checks = [ - (DDSCFRMask::SDIO_IN_ONLY, 0), + (DDSCFRMask::SDIO_IN_ONLY, 1), (DDSCFRMask::LSB_FIRST, 0) ]; self.get_configurations(&mut config_checks)?; diff --git a/src/scpi.rs b/src/scpi.rs index 822cd60..5780d1d 100644 --- a/src/scpi.rs +++ b/src/scpi.rs @@ -29,6 +29,7 @@ use scpi::{ }; use embedded_hal::blocking::spi::Transfer; +use cortex_m_semihosting::hprintln; use crate::Urukul; @@ -70,6 +71,7 @@ where } fn tst(&mut self) -> Result<()> { + hprintln!("Testing Urukul...").unwrap(); match self.test() { Ok(0) => Ok(()), Ok(_) => Err(Error::new(