From 00974d4f49dd666112a297cb9ec1eb9f891b64e0 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Thu, 9 Dec 2021 12:23:08 -0500 Subject: [PATCH] Skip empty DS2 files. Also update comments based on further testing. --- oscar/SleepLib/loader_plugins/prs1_loader.cpp | 12 +++++++----- oscar/SleepLib/loader_plugins/prs1_parser.cpp | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/oscar/SleepLib/loader_plugins/prs1_loader.cpp b/oscar/SleepLib/loader_plugins/prs1_loader.cpp index d305c57b..a3842cbe 100644 --- a/oscar/SleepLib/loader_plugins/prs1_loader.cpp +++ b/oscar/SleepLib/loader_plugins/prs1_loader.cpp @@ -413,6 +413,10 @@ bool PRDS2File::initializeKey() bool PRDS2File::parseDS2Header() { + if (m_device.size() == 0) { + qWarning() << name() << "is empty, skipping"; + return false; + } int a = read16(); int b = read16(); int c = read16(); @@ -2551,11 +2555,9 @@ void PRS1Import::ImportWaveforms() } if (s2 > 0) { - // NOTE: The 900X (F5V3) clamps the values at 127 (15.875 cmH2O) for some reason. - // - // Previous autoSV machines (950P-961P, F5V0-F5V2) didn't, nor do 1030X (F3V6). - // 1130X (also F3V6) is unknown, but likely follows the 1030X. Older ventilators - // (F3V3) are also unknown. + // NOTE: The 900X (F5V3) firmware V1.0.1 clamps the values at 127 (15.875 cmH2O) + // due to incorrectly treating this value as a signed integer. This bug is fixed + // in firmware V1.0.6. EventList * pres = session->AddEventList(CPAP_MaskPressureHi, EVL_Waveform, pressure_gain, 0.0f, 0.0f, 0.0f, double(dur) / double(s2)); pres->AddWaveform(ti, (unsigned char *)data[1].data(), data[1].size(), dur); } diff --git a/oscar/SleepLib/loader_plugins/prs1_parser.cpp b/oscar/SleepLib/loader_plugins/prs1_parser.cpp index 44b785ee..3667d5d0 100644 --- a/oscar/SleepLib/loader_plugins/prs1_parser.cpp +++ b/oscar/SleepLib/loader_plugins/prs1_parser.cpp @@ -1395,9 +1395,9 @@ static crc32_t CRC32(const unsigned char *data, size_t data_len, crc32_t crc) } -// Strangely, the PRS1 CRC32 appears to consider every byte a 32-bit wchar_t. -// Nothing like trying a bunch of encodings and CRC32 variants on PROP.TXT files -// until you find a winner. +// The PRS1 CRC32 considers every byte a 32-bit wchar_t, presumably due to +// use of the STM32 CRC calculation unit, in which "CRC computation is done +// on the whole 32-bit data word, and not byte per byte". static crc32_t CRC32wchar(const unsigned char *data, size_t data_len, crc32_t crc) {