From b89cb3198ca4533d0e6e73b5320ddd90a4896a61 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 12 Jun 2016 21:56:49 +0200 Subject: [PATCH] [DEV] better sed and receive message --- jus/Buffer.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/jus/Buffer.cpp b/jus/Buffer.cpp index b4dc224..bfbbfec 100644 --- a/jus/Buffer.cpp +++ b/jus/Buffer.cpp @@ -473,7 +473,9 @@ bool jus::Buffer::internalGetParameter(int32_t _id) const { return 0; } const char* pointer2 = reinterpret_cast(pointer); - if (*pointer2 == 'T') { + if ( *pointer2 == 'T' + || *pointer2 == '1' + || *pointer2 == 1) { return true; } return false; @@ -496,7 +498,80 @@ int8_t jus::Buffer::internalGetParameter(int32_t _id) const { std::string type = internalGetParameterType(_id); const uint8_t* pointer = internalGetParameterPointer(_id); uint32_t dataSize = internalGetParameterSize(_id); + // TODO : Check size ... if (createType() != type) { + // check coverion case: + if (createType() == type) { + const uint8_t* tmp = reinterpret_cast(pointer); + if (tmp>= 127) { + return 127; + } + return tmp; + } else if (createType() == type) { + const uint16_t* tmp = reinterpret_cast(pointer); + if (tmp>= 127) { + return 127; + } + return tmp; + } else if (createType() == type) { + const uint32_t* tmp = reinterpret_cast(pointer); + if (tmp>= 127) { + return 127; + } + return tmp; + } else if (createType() == type) { + const uint64_t* tmp = reinterpret_cast(pointer); + if (tmp>= 127) { + return 127; + } + return tmp; + } else if (createType() == type) { + const int16_t* tmp = reinterpret_cast(pointer); + if (tmp>= 127) { + return 127; + } + if (tmp<= 0) { + return 0; + } + return tmp; + } else if (createType() == type) { + const int32_t* tmp = reinterpret_cast(pointer); + if (tmp>= 127) { + return 127; + } + if (tmp<= 0) { + return 0; + } + return tmp; + } else if (createType() == type) { + const int64_t* tmp = reinterpret_cast(pointer); + if (tmp>= 127) { + return 127; + } + if (tmp<= 0) { + return 0; + } + return tmp; + } else if (createType() == type) { + const float* tmp = reinterpret_cast(pointer); + if (tmp>= 127.0) { + return 127; + } + if (tmp<= 0.0) { + return 0; + } + return int8_t(tmp); + } else if (createType() == type) { + const double* tmp = reinterpret_cast(pointer); + if (tmp>= 127.0) { + return 127; + } + if (tmp<= 0.0) { + return 0; + } + return int8_t(tmp); + } + JUS_ERROR("Can not get type from '" << type << "'"); return 0; } const int8_t* pointer2 = reinterpret_cast(pointer);