From 3f57e39c6b7b628af10dfe27a341ff41b2aee0fe Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Wed, 20 Aug 2014 00:25:03 +1000 Subject: [PATCH] Oximetry fix #372343 --- .../loader_plugins/cms50f37_loader.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp index a8e2c48a..8faad6c8 100644 --- a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp @@ -319,7 +319,7 @@ void CMS50F37Loader::processBytes(QByteArray bytes) int year, month, day; - unsigned char mask; + quint8 msb; quint8 pulse; do { @@ -462,16 +462,19 @@ void CMS50F37Loader::processBytes(QByteArray bytes) } else if (res == 0x0f) { // f,80,de,c2,de,c2,de,c2 cms50F data... - mask = buffer.at(idx+1); - pulse = buffer.at(idx+3) | ((mask & 2) << 6); - oxirec->append((pulse == 0xff) ? OxiRecord(0,0) : OxiRecord(pulse, buffer.at(idx+2))); + for (int i = 2, msb = buffer.at(idx+1); i < 9; i++, msb>>= 1) { + buffer[idx+i] &= 0x7f; buffer[idx+i] |= msb & 0x01 ? 0x80 : 0; + } - pulse = buffer.at(idx+5) | ((mask & 8) << 4); - oxirec->append((pulse == 0xff) ? OxiRecord(0,0) : OxiRecord(pulse, buffer.at(idx+4))); +// pulse = buffer.at(idx+3) | ((mask & 2) << 6); + oxirec->append((pulse == 0xff) ? OxiRecord(0,0) : OxiRecord(buffer.at(idx+3), buffer.at(idx+2))); - pulse = buffer.at(idx+7) | ((mask & 0x20) << 2); - oxirec->append((pulse == 0xff) ? OxiRecord(0,0) : OxiRecord(pulse, buffer.at(idx+6))); +// pulse = buffer.at(idx+5) | ((mask & 8) << 4); + oxirec->append((pulse == 0xff) ? OxiRecord(0,0) : OxiRecord(buffer.at(idx+5), buffer.at(idx+4))); + +// pulse = buffer.at(idx+7) | ((mask & 0x20) << 2); + oxirec->append((pulse == 0xff) ? OxiRecord(0,0) : OxiRecord(buffer.at(id+7), buffer.at(idx+6))); } QStringList str;