piserial should be fixed

This commit is contained in:
2022-10-24 10:55:25 +03:00
parent ea0df21726
commit 609ff8e9c8
4 changed files with 4 additions and 18 deletions

View File

@@ -714,10 +714,7 @@ ssize_t PIEthernet::readDevice(void * read_to, ssize_t max_size) {
PRIVATE->addr_.sin_len = sizeof(PRIVATE->addr_); PRIVATE->addr_.sin_len = sizeof(PRIVATE->addr_);
#endif #endif
//piCout << "connect to " << path() << "..."; //piCout << "connect to " << path() << "...";
bool was_block_read_flag = blockingReadFlag();
setBlockingReadFlag(true);
connected_ = (::connect(sock, (sockaddr * )&(PRIVATE->addr_), sizeof(PRIVATE->addr_)) == 0); connected_ = (::connect(sock, (sockaddr * )&(PRIVATE->addr_), sizeof(PRIVATE->addr_)) == 0);
setBlockingReadFlag(was_block_read_flag);
//piCout << "connect to " << path() << connected_; //piCout << "connect to " << path() << connected_;
if (!connected_) if (!connected_)
piCoutObj << "Can`t connect to" << addr_r << "," << ethErrorString(); piCoutObj << "Can`t connect to" << addr_r << "," << ethErrorString();

View File

@@ -341,16 +341,6 @@ PIIODevice * PIIODevice::newDeviceByPrefix(const char * prefix) {
} }
bool PIIODevice::blockingReadFlag() const {
return reading_now;
}
void PIIODevice::setBlockingReadFlag(bool yes) {
reading_now = yes;
}
void PIIODevice::read_func() { void PIIODevice::read_func() {
if (!isReadable()) { if (!isReadable()) {
read_thread.stop(); read_thread.stop();

View File

@@ -528,15 +528,15 @@ protected:
virtual void threadedReadBufferSizeChanged() {;} virtual void threadedReadBufferSizeChanged() {;}
static PIIODevice * newDeviceByPrefix(const char * prefix); static PIIODevice * newDeviceByPrefix(const char * prefix);
bool blockingReadFlag() const;
void setBlockingReadFlag(bool yes);
bool isThreadedReadStopping() const {return read_thread.isStopping();}
DeviceMode mode_; DeviceMode mode_;
DeviceOptions options_; DeviceOptions options_;
ReadRetFunc func_read = nullptr; ReadRetFunc func_read = nullptr;
bool opened_ = false; bool opened_ = false;
void * ret_data_ = nullptr; void * ret_data_ = nullptr;
std::atomic_bool reading_now;
private: private:
EVENT_HANDLER(void, read_func); EVENT_HANDLER(void, read_func);
@@ -554,7 +554,6 @@ private:
PIQueue<PIPair<PIByteArray, ullong> > write_queue; PIQueue<PIPair<PIByteArray, ullong> > write_queue;
ullong tri = 0; ullong tri = 0;
uint threaded_read_buffer_size, reopen_timeout = 1000; uint threaded_read_buffer_size, reopen_timeout = 1000;
std::atomic_bool reading_now;
bool reopen_enabled = true; bool reopen_enabled = true;
static PIMutex nfp_mutex; static PIMutex nfp_mutex;

View File

@@ -680,7 +680,7 @@ bool PISerial::openDevice() {
bool PISerial::closeDevice() { bool PISerial::closeDevice() {
if (isThreadedRead()) { if (isThreadedRead() && !isThreadedReadStopping()) {
stopThreadedRead(); stopThreadedRead();
} }
if (fd != -1) { if (fd != -1) {