From 8d57117fcc38cd9c7d28330e08ca6afde5f29f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Mon, 19 Jun 2017 12:35:45 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@510 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- src_main/io/piiodevice.h | 5 ++++- src_main/io/piserial.cpp | 21 ++++++++++++++------- src_main/io/piserial.h | 1 + 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src_main/io/piiodevice.h b/src_main/io/piiodevice.h index 6c6c9bab..958d8831 100755 --- a/src_main/io/piiodevice.h +++ b/src_main/io/piiodevice.h @@ -143,7 +143,7 @@ public: /** \brief Set size of threaded read buffer * \details Default size is 4096 bytes. If your device can read at single read * more than 4096 bytes you should use this function to adjust buffer size */ - void setThreadedReadBufferSize(int new_size) {buffer_tr.resize(new_size);} + void setThreadedReadBufferSize(int new_size) {buffer_tr.resize(new_size); threadedReadBufferSizeChanged();} //! Return size of threaded read buffer int threadedReadBufferSize() const {return buffer_tr.size_s();} @@ -336,6 +336,9 @@ protected: //! Reimplement to apply new device options virtual void optionsChanged() {;} + //! Reimplement to apply new \a threadedReadBufferSize() + virtual void threadedReadBufferSizeChanged() {;} + void terminate(); diff --git a/src_main/io/piserial.cpp b/src_main/io/piserial.cpp index f11ae7d1..4520f0b6 100755 --- a/src_main/io/piserial.cpp +++ b/src_main/io/piserial.cpp @@ -517,13 +517,6 @@ bool PISerial::openDevice() { } tcgetattr(fd, &PRIVATE->desc); PRIVATE->sdesc = PRIVATE->desc; - serial_struct ss; - ioctl(fd, TIOCGSERIAL, &ss); - piCoutObj << "b" << ss.xmit_fifo_size; - ss.xmit_fifo_size = threadedReadBufferSize(); - ioctl(fd, TIOCSSERIAL, &ss); - ioctl(fd, TIOCGSERIAL, &ss); - piCoutObj << "a" << ss.xmit_fifo_size; //piCoutObj << "Initialized " << path_; #endif applySettings(); @@ -831,3 +824,17 @@ PIStringList PISerial::availableDevices(bool test) { void PISerial::optionsChanged() { if (isOpened()) setTimeouts(); } + + +void PISerial::threadedReadBufferSizeChanged() { + if (!isOpened()) return; +#ifndef WINDOWS + serial_struct ss; + ioctl(fd, TIOCGSERIAL, &ss); + piCoutObj << "b" << ss.xmit_fifo_size; + ss.xmit_fifo_size = threadedReadBufferSize(); + ioctl(fd, TIOCSSERIAL, &ss); + ioctl(fd, TIOCGSERIAL, &ss); + piCoutObj << "a" << ss.xmit_fifo_size; +#endif +} diff --git a/src_main/io/piserial.h b/src_main/io/piserial.h index 030811e7..175e0a2f 100755 --- a/src_main/io/piserial.h +++ b/src_main/io/piserial.h @@ -205,6 +205,7 @@ protected: void configureFromFullPathDevice(const PIString & full_path); bool configureDevice(const void * e_main, const void * e_parent = 0); void optionsChanged(); + void threadedReadBufferSizeChanged(); int readDevice(void * read_to, int max_size); int writeDevice(const void * data, int max_size);