From 3873f0b03b4a1f5f9484bc80910920bd593cb3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=8B=D1=87=D0=BA=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Wed, 27 Jul 2022 15:43:04 +0300 Subject: [PATCH] PIIODevice::bytesAvailible() fix pistringlist pibinarystream write pibinarystream::binaryStreamSize() PIByteArray pibinarystream read with more size fix pistring pibinarystream read optimization fix bug in PIIOBinaryStream read and write if failed workaround in PIIOString::readDevice PISPI readDevice bug Fixed --- doc/examples/piiodevice.cpp | 10 ++-- libs/main/cloud/picloudclient.h | 11 ++-- libs/main/cloud/picloudserver.h | 19 ++++--- libs/main/console/pikbdlistener.h | 6 +- libs/main/console/piscreen.h | 12 ++-- libs/main/console/piscreenconsole.h | 4 +- libs/main/console/piscreentiles.h | 60 ++++++++++---------- libs/main/console/piterminal.h | 2 +- libs/main/core/pibinarystream.h | 49 +++++++++------- libs/main/core/pibytearray.h | 12 ++-- libs/main/core/pistring.h | 2 +- libs/main/core/pistringlist.h | 8 +-- libs/main/core/pitextstream.h | 4 +- libs/main/io_devices/pibinarylog.cpp | 5 +- libs/main/io_devices/pibinarylog.h | 24 ++++---- libs/main/io_devices/pican.h | 18 +++--- libs/main/io_devices/piethernet.h | 24 ++++---- libs/main/io_devices/pifile.h | 22 +++---- libs/main/io_devices/pigpio.h | 6 +- libs/main/io_devices/piiobytearray.h | 13 +++-- libs/main/io_devices/piiodevice.cpp | 3 +- libs/main/io_devices/piiodevice.h | 15 ++++- libs/main/io_devices/piiostream.h | 9 ++- libs/main/io_devices/piiostring.cpp | 8 +-- libs/main/io_devices/piiostring.h | 13 +++-- libs/main/io_devices/pipeer.cpp | 9 +++ libs/main/io_devices/pipeer.h | 22 +++---- libs/main/io_devices/piserial.h | 24 ++++---- libs/main/io_devices/pisharedmemory.h | 18 +++--- libs/main/io_devices/pispi.cpp | 7 ++- libs/main/io_devices/pispi.h | 19 ++++--- libs/main/io_devices/pitransparentdevice.cpp | 9 +++ libs/main/io_devices/pitransparentdevice.h | 16 +++--- libs/main/io_devices/piusb.h | 16 +++--- libs/main/io_utils/pibroadcast.h | 2 +- libs/main/io_utils/piconnection.h | 4 +- libs/main/io_utils/pidiagnostics.h | 4 +- libs/main/io_utils/pipacketextractor.cpp | 6 ++ libs/main/io_utils/pipacketextractor.h | 17 +++--- libs/main/system/piprocess.h | 2 +- libs/main/system/pisingleapplication.h | 4 +- libs/main/system/pisystemmonitor.h | 2 +- libs/main/thread/pigrabberbase.h | 6 +- libs/main/thread/pipipelinethread.h | 4 +- libs/main/thread/pitimer.cpp | 2 +- utils/system_daemon/daemon.h | 8 +-- utils/system_daemon/file_manager.h | 6 +- utils/system_daemon/main.cpp | 2 +- utils/system_daemon/terminal_tile.h | 6 +- utils/udp_file_transfer/main.cpp | 2 +- 50 files changed, 323 insertions(+), 253 deletions(-) diff --git a/doc/examples/piiodevice.cpp b/doc/examples/piiodevice.cpp index 0946dc16..c8ea515f 100644 --- a/doc/examples/piiodevice.cpp +++ b/doc/examples/piiodevice.cpp @@ -7,19 +7,19 @@ class SomeIO: public PIIODevice { public: SomeIO(): PIIODevice() {} protected: - bool openDevice() { + bool openDevice() override { // open your device here return if_success; } - int read(void * read_to, int max_size) { + int readDevice(void * read_to, int max_size) override { // read from your device here return readed_bytes; } - int write(const void * data, int max_size) { + int writeDevice(const void * data, int max_size) override { // write to your device here return written_bytes; } - void configureFromFullPath(const PIString & full_path) { + void configureFromFullPathDevice(const PIString & full_path) override { // parse full_path and configure device here } }; @@ -38,7 +38,7 @@ ser.configure("example.conf", "dev"); //! [configureDevice] class SomeIO: public PIIODevice { ... - bool configureDevice(const void * e_main, const void * e_parent) { + bool configureDevice(const void * e_main, const void * e_parent) override { PIConfig::Entry * em = (PIConfig::Entry * )e_main; PIConfig::Entry * ep = (PIConfig::Entry * )e_parent; setStringParam(readDeviceSetting("stringParam", stringParam(), em, ep)); diff --git a/libs/main/cloud/picloudclient.h b/libs/main/cloud/picloudclient.h index 4d21cb1d..4bd1276d 100644 --- a/libs/main/cloud/picloudclient.h +++ b/libs/main/cloud/picloudclient.h @@ -42,16 +42,17 @@ public: void setServerName(const PIString & server_name); void setKeepConnection(bool on); bool isConnected() const {return is_connected;} + ssize_t bytesAvailible() const override {return buff.size();} EVENT(connected); EVENT(disconnected); protected: - virtual bool openDevice() override; - virtual bool closeDevice() override; - virtual int readDevice(void * read_to, int max_size) override; - virtual int writeDevice(const void * data, int size) override; - virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;} + bool openDevice() override; + bool closeDevice() override; + int readDevice(void * read_to, int max_size) override; + int writeDevice(const void * data, int size) override; + DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;} private: EVENT_HANDLER1(void, _readed, PIByteArray &, data); diff --git a/libs/main/cloud/picloudserver.h b/libs/main/cloud/picloudserver.h index 3936f0d3..4e3b7fd7 100644 --- a/libs/main/cloud/picloudserver.h +++ b/libs/main/cloud/picloudserver.h @@ -45,11 +45,12 @@ public: Client(PICloudServer * srv = nullptr, uint id = 0); virtual ~Client(); protected: - virtual bool openDevice() override; - virtual bool closeDevice() override; - virtual int readDevice(void * read_to, int max_size) override; - virtual int writeDevice(const void * data, int size) override; - virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;} + bool openDevice() override; + bool closeDevice() override; + int readDevice(void * read_to, int max_size) override; + int writeDevice(const void * data, int size) override; + DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;} + ssize_t bytesAvailible() const override {return buff.size();} private: void pushBuffer(const PIByteArray & ba); @@ -68,10 +69,10 @@ public: EVENT1(newConnection, PICloudServer::Client * , client); protected: - virtual bool openDevice() override; - virtual bool closeDevice() override; - virtual int readDevice(void * read_to, int max_size) override; - virtual int writeDevice(const void * data, int max_size) override; + bool openDevice() override; + bool closeDevice() override; + int readDevice(void * read_to, int max_size) override; + int writeDevice(const void * data, int max_size) override; private: EVENT_HANDLER1(void, _readed, PIByteArray &, ba); diff --git a/libs/main/console/pikbdlistener.h b/libs/main/console/pikbdlistener.h index 9dcfca87..3dc32283 100644 --- a/libs/main/console/pikbdlistener.h +++ b/libs/main/console/pikbdlistener.h @@ -205,9 +205,9 @@ public: static PIKbdListener * instance() {return _object;} private: - void begin(); - void run() {readKeyboard();} - void end(); + void begin() override; + void run() override {readKeyboard();} + void end() override; #ifndef WINDOWS struct PIP_EXPORT EscSeq { diff --git a/libs/main/console/piscreen.h b/libs/main/console/piscreen.h index d590c56f..576cf232 100644 --- a/libs/main/console/piscreen.h +++ b/libs/main/console/piscreen.h @@ -134,9 +134,9 @@ private: PIVector > cells, pcells; }; - void begin(); - void run(); - void end(); + void begin() override; + void run() override; + void end() override; void key_event(PIKbdListener::KeyEvent key); EVENT_HANDLER1(void, mouse_event, PIKbdListener::MouseEvent, me); EVENT_HANDLER1(void, wheel_event, PIKbdListener::WheelEvent, we); @@ -145,9 +145,9 @@ private: PIVector prepareMouse(PIKbdListener::MouseEvent * e); PIVector tilesUnderMouse(int x, int y); bool nextFocus(PIScreenTile * rt, PIKbdListener::KeyEvent key = PIKbdListener::KeyEvent()); - void tileEventInternal(PIScreenTile * t, PIScreenTypes::TileEvent e); - void tileRemovedInternal(PIScreenTile * t); - void tileSetFocusInternal(PIScreenTile * t); + void tileEventInternal(PIScreenTile * t, PIScreenTypes::TileEvent e) override; + void tileRemovedInternal(PIScreenTile * t) override; + void tileSetFocusInternal(PIScreenTile * t) override; bool mouse_; SystemConsole console; diff --git a/libs/main/console/piscreenconsole.h b/libs/main/console/piscreenconsole.h index c650358d..60ddf9dc 100644 --- a/libs/main/console/piscreenconsole.h +++ b/libs/main/console/piscreenconsole.h @@ -64,8 +64,8 @@ protected: }; PIVector variables; PIScreenTypes::Alignment alignment; - void sizeHint(int & w, int & h) const; - void drawEvent(PIScreenDrawer * d); + void sizeHint(int & w, int & h) const override; + void drawEvent(PIScreenDrawer * d) override; }; diff --git a/libs/main/console/piscreentiles.h b/libs/main/console/piscreentiles.h index 5a03f58c..62f83929 100644 --- a/libs/main/console/piscreentiles.h +++ b/libs/main/console/piscreentiles.h @@ -40,8 +40,8 @@ public: PIVector content; PIScreenTypes::Alignment alignment; protected: - void sizeHint(int & w, int & h) const; - void drawEvent(PIScreenDrawer * d); + void sizeHint(int & w, int & h) const override; + void drawEvent(PIScreenDrawer * d) override; }; @@ -62,9 +62,9 @@ public: int thickness; protected: void _check(); - void sizeHint(int & w, int & h) const; - void drawEvent(PIScreenDrawer * d); - bool mouseEvent(PIKbdListener::MouseEvent me); + void sizeHint(int & w, int & h) const override; + void drawEvent(PIScreenDrawer * d) override; + bool mouseEvent(PIKbdListener::MouseEvent me) override; int minimum_, maximum_, value_; PIChar line_char; }; @@ -93,12 +93,12 @@ public: PISet selected; int lhei, cur, offset; protected: - void sizeHint(int & w, int & h) const; - void resizeEvent(int w, int h); - void drawEvent(PIScreenDrawer * d); - bool keyEvent(PIKbdListener::KeyEvent key); - bool mouseEvent(PIKbdListener::MouseEvent me); - bool wheelEvent(PIKbdListener::WheelEvent we); + void sizeHint(int & w, int & h) const override; + void resizeEvent(int w, int h) override; + void drawEvent(PIScreenDrawer * d) override; + bool keyEvent(PIKbdListener::KeyEvent key) override; + bool mouseEvent(PIKbdListener::MouseEvent me) override; + bool wheelEvent(PIKbdListener::WheelEvent we) override; TileScrollBar * scroll; bool mouse_sel; }; @@ -115,10 +115,10 @@ public: PIScreenTypes::CellFormat format; PIString text; protected: - void sizeHint(int & w, int & h) const; - void drawEvent(PIScreenDrawer * d); - bool keyEvent(PIKbdListener::KeyEvent key); - bool mouseEvent(PIKbdListener::MouseEvent me); + void sizeHint(int & w, int & h) const override; + void drawEvent(PIScreenDrawer * d) override; + bool keyEvent(PIKbdListener::KeyEvent key) override; + bool mouseEvent(PIKbdListener::MouseEvent me) override; }; @@ -137,10 +137,10 @@ public: PIVector