mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
fix to testing int16_t
This commit is contained in:
@@ -358,13 +358,12 @@ bool Helpers::hasValue(const int8_t v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for short these are typically 0x8300, 0x7D00 and sometimes 0x8000
|
// for short these are typically 0x8300, 0x7D00 and sometimes 0x8000
|
||||||
// so we just check for anything > 0x70
|
|
||||||
bool Helpers::hasValue(const int16_t v) {
|
bool Helpers::hasValue(const int16_t v) {
|
||||||
return ((v >> 8) < 0x70);
|
return (abs(v) < EMS_VALUE_USHORT_NOTSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Helpers::hasValue(const uint16_t v) {
|
bool Helpers::hasValue(const uint16_t v) {
|
||||||
return ((v >> 8) < 0x70);
|
return (v < EMS_VALUE_USHORT_NOTSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Helpers::hasValue(const uint32_t v) {
|
bool Helpers::hasValue(const uint32_t v) {
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ static constexpr uint8_t EMS_VALUE_BOOL_OFF = 0x00; // boolean false. True can b
|
|||||||
static constexpr uint8_t EMS_VALUE_BOOL_NOTSET = 0xFE; // random number for booleans, that's not 0, 1 or FF
|
static constexpr uint8_t EMS_VALUE_BOOL_NOTSET = 0xFE; // random number for booleans, that's not 0, 1 or FF
|
||||||
static constexpr uint8_t EMS_VALUE_UINT_NOTSET = 0xFF; // for 8-bit unsigned ints/bytes
|
static constexpr uint8_t EMS_VALUE_UINT_NOTSET = 0xFF; // for 8-bit unsigned ints/bytes
|
||||||
static constexpr int8_t EMS_VALUE_INT_NOTSET = 0x7F; // for signed 8-bit ints/bytes
|
static constexpr int8_t EMS_VALUE_INT_NOTSET = 0x7F; // for signed 8-bit ints/bytes
|
||||||
static constexpr int16_t EMS_VALUE_SHORT_NOTSET = 0x8300; // -32000: for 2-byte signed shorts
|
|
||||||
static constexpr uint16_t EMS_VALUE_USHORT_NOTSET = 0x7D00; // 32000: for 2-byte unsigned shorts
|
static constexpr uint16_t EMS_VALUE_USHORT_NOTSET = 0x7D00; // 32000: for 2-byte unsigned shorts
|
||||||
|
static constexpr int16_t EMS_VALUE_SHORT_NOTSET = 0x7D00; // 32000: for 2-byte signed shorts
|
||||||
static constexpr uint32_t EMS_VALUE_ULONG_NOTSET = 0xFFFFFFFF; // for 3-byte and 4-byte longs
|
static constexpr uint32_t EMS_VALUE_ULONG_NOTSET = 0xFFFFFFFF; // for 3-byte and 4-byte longs
|
||||||
|
|
||||||
static constexpr uint8_t EMS_MAX_TELEGRAM_LENGTH = 32; // max length of a complete EMS telegram
|
static constexpr uint8_t EMS_MAX_TELEGRAM_LENGTH = 32; // max length of a complete EMS telegram
|
||||||
|
|||||||
@@ -34,13 +34,17 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
uint32_t test6 = 305419896;
|
uint32_t test6 = 305419896;
|
||||||
float test7 = 89.43;
|
float test7 = 89.43;
|
||||||
|
|
||||||
uint8_t test1u = EMS_VALUE_UINT_NOTSET;
|
uint8_t test1u = EMS_VALUE_UINT_NOTSET;
|
||||||
int8_t test2u = EMS_VALUE_INT_NOTSET;
|
int8_t test2u = EMS_VALUE_INT_NOTSET;
|
||||||
uint16_t test3u = EMS_VALUE_USHORT_NOTSET;
|
|
||||||
int16_t test4u = EMS_VALUE_USHORT_NOTSET;
|
|
||||||
uint8_t test5u = EMS_VALUE_BOOL_NOTSET;
|
uint8_t test5u = EMS_VALUE_BOOL_NOTSET;
|
||||||
uint32_t test6u = EMS_VALUE_ULONG_NOTSET;
|
uint32_t test6u = EMS_VALUE_ULONG_NOTSET;
|
||||||
|
|
||||||
|
uint16_t test3u = EMS_VALUE_USHORT_NOTSET;
|
||||||
|
int16_t test4u = EMS_VALUE_SHORT_NOTSET;
|
||||||
|
|
||||||
|
// TODO set to 7D00 for both
|
||||||
|
|
||||||
EMSdevice::print_value(shell, 2, F("Selected flow temperature1"), test1, F_(degrees), 1); // 12
|
EMSdevice::print_value(shell, 2, F("Selected flow temperature1"), test1, F_(degrees), 1); // 12
|
||||||
EMSdevice::print_value(shell, 2, F("Selected flow temperature2"), test2, F_(degrees), 1); // -12
|
EMSdevice::print_value(shell, 2, F("Selected flow temperature2"), test2, F_(degrees), 1); // -12
|
||||||
EMSdevice::print_value(shell, 2, F("Selected flow temperature3"), test3, F_(degrees), 10); // 45.6
|
EMSdevice::print_value(shell, 2, F("Selected flow temperature3"), test3, F_(degrees), 10); // 45.6
|
||||||
@@ -62,6 +66,21 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
EMSdevice::print_value(shell, 2, F("Selected flow temperature5u"), test5u, F_(degrees), EMS_VALUE_BOOL);
|
EMSdevice::print_value(shell, 2, F("Selected flow temperature5u"), test5u, F_(degrees), EMS_VALUE_BOOL);
|
||||||
EMSdevice::print_value(shell, 2, F("Selected flow temperature6u"), test6u, F_(degrees), 100);
|
EMSdevice::print_value(shell, 2, F("Selected flow temperature6u"), test6u, F_(degrees), 100);
|
||||||
|
|
||||||
|
shell.printfln("int16 unset = %d, [%0X] %0X %0X", test4u, test4u, (test4u >> 8), ((test4u >> 8) & 0xFF));
|
||||||
|
shell.printfln("uint16 unset = %d, [%0X] %0X %0X", test3u, test3u, (test3u >> 8), ((test3u >> 8) & 0xFF));
|
||||||
|
|
||||||
|
test3u = 456;
|
||||||
|
test4u = -456;
|
||||||
|
|
||||||
|
shell.printfln("int16 set = %d, [%0X] %0X %0X", test4u, test4u, (test4u >> 8), ((test4u >> 8) & 0xFF));
|
||||||
|
|
||||||
|
shell.printfln("uint16 set = %d, [%0X] %0X %0X", test3u, test3u, (test3u >> 8), ((test3u >> 8) & 0xFF));
|
||||||
|
|
||||||
|
test4u = 0x7D00;
|
||||||
|
|
||||||
|
// test4u = abs(0x7D00);
|
||||||
|
shell.printfln("int16 invalid= %d, [%0X] %0X %0X", test4u, test4u, (test4u >> 8), ((test4u >> 8) & 0xFF));
|
||||||
|
|
||||||
shell.println();
|
shell.println();
|
||||||
|
|
||||||
// check read_value to make sure it handles all the data type correctly
|
// check read_value to make sure it handles all the data type correctly
|
||||||
|
|||||||
Reference in New Issue
Block a user