PISerial now can configure blocking write and blocking read options from path

git-svn-id: svn://db.shs.com.ru/pip@281 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2016-11-23 07:23:37 +00:00
parent a393f93ee1
commit d3166f8fa5
3 changed files with 47 additions and 16 deletions

View File

@@ -139,9 +139,12 @@ public:
void setVTime(int t) {vtime = t; applySettings();}
//! Set read is blocking for function read(void * read_to, int max_size)
//! Set read is blocking for function \a read
void setReadIsBlocking(bool yes);
//! Set write is blocking for functions \a write and \a send
void setWriteIsBlocking(bool yes);
//! Returns device name
PIString device() const {return path();}
@@ -167,11 +170,11 @@ public:
//! \brief Write to device data "data" with maximum size "max_size" and wait for data written if "wait" is \b true.
//! \returns sended bytes count
int write(const void * data, int max_size, bool wait = false);
int write(const void * data, int max_size);
//! \brief Write to device data "data" with maximum size "size" and wait for data written if "wait" is \b true.
//! \returns \b true if sended bytes count = "size"
bool send(const void * data, int size, bool wait = false) {return (write(data, size, wait) == size);}
bool send(const void * data, int size) {return (write(data, size) == size);}
/// NOTE: no reason to use this function, use PIString::toUtf8() or PIString::dataAscii(),lengthAscii() instead
// //! \brief Write to device string "data" and wait for data written if "wait" is \b true.
@@ -180,7 +183,7 @@ public:
//! \brief Write to device byte array "data" and wait for data written if "wait" is \b true.
//! \returns \b true if sended bytes count = size of string
bool send(const PIByteArray & data, bool wait = false) {return (write(data.data(), data.size_s(), wait) == data.size_s());}
bool send(const PIByteArray & data) {return (write(data.data(), data.size_s()) == data.size_s());}
PIString constructFullPath() const;
@@ -218,7 +221,7 @@ protected:
PIString fullPathPrefix() const {return "ser";}
void configureFromFullPath(const PIString & full_path);
bool configureDevice(const void * e_main, const void * e_parent = 0);
int write(const void * data, int max_size) {return write(data, max_size, true);}
// int write(const void * data, int max_size) {return write(data, max_size);}
//! Executes when any read function was successful. Default implementation does nothing
virtual void received(const void * data, int size) {;}