/*! \file pican.h * \ingroup IO * \~\brief * \~english CAN device * \~russian Устройство CAN */ /* PIP - Platform Independent Primitives CAN Andrey Bychkov work.a.b@yandex.ru This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #ifndef PICAN_H #define PICAN_H #include "piiodevice.h" //! \ingroup IO //! \~\brief //! \~english CAN device. //! \~russian Устройство CAN. class PIP_EXPORT PICAN: public PIIODevice { PIIODEVICE(PICAN, "can"); public: //! \~english Constructs %PICAN with empty path and ReadWrite mode //! \~russian Создаёт %PICAN с пустым путём и режимом ReadWrite explicit PICAN(const PIString & path = PIString(), PIIODevice::DeviceMode mode = PIIODevice::ReadWrite); //! \~english Destructor //! \~russian Деструктор virtual ~PICAN(); //! \~english Set CAN ID for filtering received messages //! \~russian Устанавливает CAN ID для фильтрации принимаемых сообщений void setCANID(int id); //! \~english Returns current CAN ID //! \~russian Возвращает текущий CAN ID int CANID() const; //! \~english Returns CAN ID of last readed message //! \~russian Возвращает CAN ID последнего прочитанного сообщения int readedCANID() const; //! \~english Interrupt blocking operation //! \~russian Прерывает блокирующую операцию void interrupt() override; protected: bool openDevice() override; bool closeDevice() override; ssize_t readDevice(void * read_to, ssize_t max_size) override; ssize_t writeDevice(const void * data, ssize_t max_size) override; PIString constructFullPathDevice() const override; void configureFromFullPathDevice(const PIString & full_path) override; PIPropertyStorage constructVariantDevice() const override; void configureFromVariantDevice(const PIPropertyStorage & d) override; DeviceInfoFlags deviceInfoFlags() const override { return PIIODevice::Reliable; } private: PRIVATE_DECLARATION(PIP_EXPORT) int sock; int can_id, readed_id; }; #endif // PICAN_H