From 4ab1e6d72b56a459f0d6b23c73935765257657c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Tue, 7 May 2024 17:12:20 -0300 Subject: [PATCH] controllers: support doubles in write_general and write_channel. Since these functions are proxies for the RegisterDecoder ones, they should have had the same type for their value arguments. This required some fixes to decode-reg where implicit conversion to the variant wasn't available. Fixes: d85970229cdd56c7c9ef11a8ed01ba6fe7ac99ec --- app/decode-reg.cc | 8 ++++---- util/controllers.h | 4 ++-- util/tests/controllers-test.cc | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/decode-reg.cc b/app/decode-reg.cc index fb06f5b..5ea1c2f 100644 --- a/app/decode-reg.cc +++ b/app/decode-reg.cc @@ -285,9 +285,9 @@ int main(int argc, char *argv[]) auto channel = args.get("-c"); ctl.write_channel("AMP_EN", channel, args.is_used("-e")); - ctl.write_channel("MODE", channel, get_index(args.get("-m"), lamp::mode_list)); - ctl.write_channel("PI_KP", channel, args.get("-k")); - ctl.write_channel("PI_TI", channel, args.get("-t")); + ctl.write_channel("MODE", channel, (int32_t)get_index(args.get("-m"), lamp::mode_list)); + ctl.write_channel("PI_KP", channel, (int32_t)args.get("-k")); + ctl.write_channel("PI_TI", channel, (int32_t)args.get("-t")); ctl.write_channel("PI_SP", channel, args.get("-s")); ctl.write_channel("DAC", channel, args.get("-d")); @@ -295,7 +295,7 @@ int main(int argc, char *argv[]) ctl.write_channel("LIMIT_B", channel, args.get("-L")); ctl.write_channel("CNT", channel, args.get("-C")); - ctl.write_channel("TRIG_EN", channel, args.get("-T")); + ctl.write_channel("TRIG_EN", channel, (int32_t)args.get("-T")); ctl.write_params(); } diff --git a/util/controllers.h b/util/controllers.h index 9888029..e3fc725 100644 --- a/util/controllers.h +++ b/util/controllers.h @@ -51,11 +51,11 @@ class RegisterDecoderController: public RegisterController { virtual void encode_params() override { } - void write_general(const char *name, int32_t value) + void write_general(const char *name, decoders::data_type value) { pdec->write_general(name, value, read_dest); } - void write_channel(const char *name, unsigned pos, int32_t value) + void write_channel(const char *name, unsigned pos, decoders::data_type value) { pdec->write_channel(name, pos, value, read_dest); } diff --git a/util/tests/controllers-test.cc b/util/tests/controllers-test.cc index 7b74073..8586df1 100644 --- a/util/tests/controllers-test.cc +++ b/util/tests/controllers-test.cc @@ -44,7 +44,7 @@ TEST_CASE("RegisterDecoderController write_general", "[controllers-test]") CHECK(dec.get_general_data("RF_INT") == -0x11); } -TEST_CASE("RegisterDecoderController write_general fixed-point", "[controllers-test][!shouldfail]") +TEST_CASE("RegisterDecoderController write_general fixed-point", "[controllers-test]") { TestRegisterDecoderController ctl{}; TestRegisterDecoder dec{};