Files
pip/libs/main/io_devices/pican.h
2022-07-25 11:18:09 +03:00

60 lines
1.6 KiB
C++

/*! \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 <http://www.gnu.org/licenses/>.
*/
#ifndef PICAN_H
#define PICAN_H
#include "piiodevice.h"
class PIP_EXPORT PICAN: public PIIODevice
{
PIIODEVICE(PICAN, "can");
public:
explicit PICAN(const PIString & path = PIString(), PIIODevice::DeviceMode mode = PIIODevice::ReadWrite);
virtual ~PICAN();
void setCANID(int id);
int CANID() const;
int readedCANID() const;
protected:
bool openDevice();
bool closeDevice();
int readDevice(void * read_to, int max_size);
int writeDevice(const void * data, int max_size);
PIString constructFullPathDevice() const;
void configureFromFullPathDevice(const PIString & full_path);
PIPropertyStorage constructVariantDevice() const;
void configureFromVariantDevice(const PIPropertyStorage & d);
DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Reliable;}
private:
int sock;
int can_id, readed_id;
};
#endif // PICAN_H