diff --git a/src/core/pitime.cpp b/src/core/pitime.cpp index eeb94f49..8ee6cb3e 100755 --- a/src/core/pitime.cpp +++ b/src/core/pitime.cpp @@ -233,7 +233,7 @@ PISystemTime PISystemTime::current(bool precise_but_not_system) { sft.dwHighDateTime = ft.dwHighDateTime - __pi_ftjan1970.dwHighDateTime; if (ft.dwLowDateTime < __pi_ftjan1970.dwLowDateTime) { sft.dwLowDateTime = ft.dwLowDateTime + (0xFFFFFFFF - __pi_ftjan1970.dwLowDateTime); - sft.dwHighDateTime++; + sft.dwHighDateTime--; } else sft.dwLowDateTime = ft.dwLowDateTime - __pi_ftjan1970.dwLowDateTime; ullong lt = ullong(sft.dwHighDateTime) * 0x100000000U + ullong(sft.dwLowDateTime); diff --git a/src/io/pibinarylog.cpp b/src/io/pibinarylog.cpp index 96d0e4a0..dabb22c0 100644 --- a/src/io/pibinarylog.cpp +++ b/src/io/pibinarylog.cpp @@ -80,6 +80,16 @@ bool PIBinaryLog::openDevice() { if (path().isEmpty() && mode_ == WriteOnly) { setPath(getLogfilePath()); } + if (path().isEmpty() && mode_ == ReadOnly) { + PIDir ld(logDir()); + if (ld.isExists()) { + PIVector es = ld.allEntries(); + piForeachC(PIFile::FileInfo &i, es) { + if (i.extension() == "binlog" && i.isFile()) + setPath(i.path); + } + } + } if (!file.open(path(), mode_)) { piCoutObj << "Error: Can't open file" << path(); return false; @@ -129,6 +139,8 @@ bool PIBinaryLog::closeDevice() { bool PIBinaryLog::threadedRead(uchar *readed, int size) { +// piCout << "binlog threaded read"; + if (!canRead() || isEnd()) return PIIODevice::threadedRead(readed, size); is_thread_ok = false; PISystemTime pt; double delay; @@ -136,6 +148,8 @@ bool PIBinaryLog::threadedRead(uchar *readed, int size) { case PlayRealTime: pt = PISystemTime::current() - startlogtime; if (is_started) { + if ((lastrecord.timestamp - pt).toSeconds() > 100. || (lastrecord.timestamp - pt).toSeconds() < -100.) + piCoutObj << PISystemTime::current() << startlogtime << pt << lastrecord.timestamp << (lastrecord.timestamp - pt); if (lastrecord.timestamp > pt) (lastrecord.timestamp - pt).sleep(); } else { diff --git a/src/io/piconnection.cpp b/src/io/piconnection.cpp index d348b8e8..aee9e6de 100755 --- a/src/io/piconnection.cpp +++ b/src/io/piconnection.cpp @@ -1073,6 +1073,7 @@ void __DevicePool_threadReadDP(void * ddp) { if (dd->dev == 0) {piMSleep(100); return;} PIByteArray ba; ba = dd->dev->read(dd->dev->threadedReadBufferSize()); +// dd->dev->threadedRead(ba.data(), ba.size()); if (ba.isEmpty()) {piMSleep(10); return;} dd->dev->threadedRead(ba.data(), ba.size_s()); //piCout << "Readed from" << dd->dev->path() << Hex << ba; diff --git a/src/io/piiodevice.cpp b/src/io/piiodevice.cpp index 449f7ebe..eb31cc62 100755 --- a/src/io/piiodevice.cpp +++ b/src/io/piiodevice.cpp @@ -319,3 +319,10 @@ PIString PIIODevice::normalizeFullPath(const PIString & full_path) { nfp_cache[full_path] = ret; return ret; } + + +bool PIIODevice::threadedRead(uchar *readed, int size) { +// piCout << "iodevice threaded read"; + if (ret_func_ != 0) return ret_func_(ret_data_, readed, size); + return true; +} diff --git a/src/io/piiodevice.h b/src/io/piiodevice.h index 9a10688c..9bc75944 100755 --- a/src/io/piiodevice.h +++ b/src/io/piiodevice.h @@ -46,6 +46,7 @@ typedef bool (*ReadRetFunc)(void * , uchar * , int ); #endif + class PIP_EXPORT PIIODevice: public PIThread { PIOBJECT_SUBCLASS(PIIODevice, PIThread) @@ -293,7 +294,7 @@ protected: virtual bool closeDevice() {return true;} // use path_, type_, opened_, init_ variables //! Function executed when thread read some data, default implementation execute external slot "ret_func_" - virtual bool threadedRead(uchar * readed, int size) {if (ret_func_ != 0) return ret_func_(ret_data_, readed, size); return true;} + virtual bool threadedRead(uchar * readed, int size); //! Reimplement to configure your device with parameters of full unambiguous string. Default implementation does nothing diff --git a/src/io/piserial.cpp b/src/io/piserial.cpp index a5fe3b16..f94d60d0 100755 --- a/src/io/piserial.cpp +++ b/src/io/piserial.cpp @@ -623,7 +623,7 @@ int PISerial::read(void * read_to, int max_size) { if (!canRead()) return -1; if (sending) return -1; // piCoutObj << "com event ..."; - WaitCommEvent(PRIVATE->hCom, 0, 0); + //WaitCommEvent(PRIVATE->hCom, 0, 0); // piCoutObj << "read ..."; ReadFile(PRIVATE->hCom, read_to, max_size, &PRIVATE->readed, 0); // piCoutObj << "read ok";