From 45d3572df166da712825e6d3fbe430b92fd78da7 Mon Sep 17 00:00:00 2001 From: guddimon- Date: Mon, 14 Dec 2015 00:15:15 +0100 Subject: [PATCH 1/2] always work with trimmed messages Former-commit-id: a2b3236d22cd935c03a13dfe579c411c648c7dfd --- libsrc/boblightserver/BoblightClientConnection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc/boblightserver/BoblightClientConnection.cpp b/libsrc/boblightserver/BoblightClientConnection.cpp index f78d6784..7599220a 100644 --- a/libsrc/boblightserver/BoblightClientConnection.cpp +++ b/libsrc/boblightserver/BoblightClientConnection.cpp @@ -64,8 +64,8 @@ void BoblightClientConnection::readData() // remove message data from buffer _receiveBuffer = _receiveBuffer.mid(bytes); - // handle message - handleMessage(message); + // handle trimmed message + handleMessage(message.trimmed()); // drop messages if the buffer is too full if (_receiveBuffer.size() > 100*1024) From 87f2883f565d5e5287fe44feba90f7fd54a14e15 Mon Sep 17 00:00:00 2001 From: guddimon- Date: Mon, 14 Dec 2015 00:23:53 +0100 Subject: [PATCH 2/2] replace decimal comma with decimal point Former-commit-id: ec4b3c264fb06143b2e4d635358f259fb7099ed9 --- libsrc/boblightserver/BoblightClientConnection.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libsrc/boblightserver/BoblightClientConnection.cpp b/libsrc/boblightserver/BoblightClientConnection.cpp index 7599220a..e70a8f17 100644 --- a/libsrc/boblightserver/BoblightClientConnection.cpp +++ b/libsrc/boblightserver/BoblightClientConnection.cpp @@ -132,9 +132,15 @@ void BoblightClientConnection::handleMessage(const QString & message) { if (messageParts[3] == "rgb" && messageParts.size() == 7) { + // replace decimal comma with decimal point + messageParts[4].replace(',', '.'); + messageParts[5].replace(',', '.'); + messageParts[6].replace(',', '.'); + bool rc1, rc2, rc3; uint8_t red = qMax(0, qMin(255, int(255 * messageParts[4].toFloat(&rc1)))); + // check for correct locale should not be needed anymore - please check! if (!rc1) { // maybe a locale issue. switch to a locale with a comma instead of a dot as decimal seperator (or vice versa)