From 926437d53ab11790283ea263676535fae62649a2 Mon Sep 17 00:00:00 2001 From: GOB Date: Wed, 16 Oct 2024 23:37:28 +0900 Subject: [PATCH] Some tweaks --- src/unit/unit_KmeterISO.cpp | 2 +- test/embedded/avmeter_template.hpp | 3 --- test/embedded/test_kmeterISO/kmeterISO_test.cpp | 8 ++++++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/unit/unit_KmeterISO.cpp b/src/unit/unit_KmeterISO.cpp index 08f83dc..88bad32 100644 --- a/src/unit/unit_KmeterISO.cpp +++ b/src/unit/unit_KmeterISO.cpp @@ -160,8 +160,8 @@ bool UnitKmeterISO::changeI2CAddress(const uint8_t i2c_address) bool done{}; auto timeout_at = m5::utility::millis() + 1000; do { - done = readRegister8(I2C_ADDRESS_REG, v, 0) && v == i2c_address; m5::utility::delay(1); + done = readRegister8(I2C_ADDRESS_REG, v, 0) && v == i2c_address; } while (!done && m5::utility::millis() <= timeout_at); return done; } diff --git a/test/embedded/avmeter_template.hpp b/test/embedded/avmeter_template.hpp index ed37471..2c72201 100644 --- a/test/embedded/avmeter_template.hpp +++ b/test/embedded/avmeter_template.hpp @@ -6,9 +6,6 @@ /* UnitTest for UnitADS111x */ - -// Move to each libarry - #include #include #include diff --git a/test/embedded/test_kmeterISO/kmeterISO_test.cpp b/test/embedded/test_kmeterISO/kmeterISO_test.cpp index 2c36c5d..faf3c46 100644 --- a/test/embedded/test_kmeterISO/kmeterISO_test.cpp +++ b/test/embedded/test_kmeterISO/kmeterISO_test.cpp @@ -148,6 +148,8 @@ TEST_P(TestKmeterISO, I2CAddress) EXPECT_TRUE(unit->changeI2CAddress(0x08)); EXPECT_TRUE(unit->readI2CAddress(addr)); EXPECT_EQ(addr, 0x08); + EXPECT_EQ(unit->address(), 0x08); + EXPECT_TRUE(unit->readFirmwareVersion(ver)); EXPECT_NE(ver, 0x00); EXPECT_TRUE(unit->measureSingleshot(d)); @@ -156,6 +158,8 @@ TEST_P(TestKmeterISO, I2CAddress) EXPECT_TRUE(unit->changeI2CAddress(0x77)); EXPECT_TRUE(unit->readI2CAddress(addr)); EXPECT_EQ(addr, 0x77); + EXPECT_EQ(unit->address(), 0x77); + EXPECT_TRUE(unit->readFirmwareVersion(ver)); EXPECT_NE(ver, 0x00); EXPECT_TRUE(unit->measureSingleshot(d)); @@ -164,6 +168,8 @@ TEST_P(TestKmeterISO, I2CAddress) EXPECT_TRUE(unit->changeI2CAddress(0x52)); EXPECT_TRUE(unit->readI2CAddress(addr)); EXPECT_EQ(addr, 0x52); + EXPECT_EQ(unit->address(), 0528); + EXPECT_TRUE(unit->readFirmwareVersion(ver)); EXPECT_NE(ver, 0x00); EXPECT_TRUE(unit->measureSingleshot(d)); @@ -172,6 +178,8 @@ TEST_P(TestKmeterISO, I2CAddress) EXPECT_TRUE(unit->changeI2CAddress(UnitKmeterISO::DEFAULT_ADDRESS)); EXPECT_TRUE(unit->readI2CAddress(addr)); EXPECT_EQ(addr, +UnitKmeterISO::DEFAULT_ADDRESS); + EXPECT_EQ(unit->address(), +UnitKmeterISO::DEFAULT_ADDRESS); + EXPECT_TRUE(unit->readFirmwareVersion(ver)); EXPECT_NE(ver, 0x00); EXPECT_TRUE(unit->measureSingleshot(d));