- CMake: disable thread/socket-dependent modules (http_client, mqtt_client, client_server) and fftw when the required feature flags are off; client_server/cloud no longer tied to the crypt option - host utils gated on filesystem and the modules they need - Pico keeps the minimal set; generic FreeRTOS (ESP32) keeps filesystem, sockets and serial as in master, module set limited to crypt/compress/io_utils - PICAN, PIBroadcast, PIPackedTCP vanish without socket+threads - PISerial: restore PISERIAL_NO_PINS (auto-enabled on PIP_EMBEDDED) - PIFile: FREERTOS uses fopen/stat (no fopen64 in ESP-IDF newlib) - drop invalid PICout buffer guards, guard PIObject::deleteLater, remove (void)destroying hack, fake PIHIDevice non-Linux stub and the redundant PICO_SDK guard in code_model_generator
88 lines
3.3 KiB
C++
88 lines
3.3 KiB
C++
//! \~\file pican.h
|
|
//! \~\ingroup IO
|
|
//! \~\brief
|
|
//! \~english CAN bus device wrapper
|
|
//! \~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"
|
|
|
|
// CAN raw sockets (PF_CAN) exist only on Linux
|
|
#if defined(LINUX) && defined(PIP_HAS_SOCKET)
|
|
# define PIP_CAN
|
|
#endif
|
|
|
|
|
|
#ifdef PIP_CAN
|
|
//! \~\ingroup IO
|
|
//! \~\brief
|
|
//! \~english CAN device based on interface name and frame identifier.
|
|
//! \~russian CAN-устройство, настраиваемое именем интерфейса и идентификатором кадра.
|
|
class PIP_EXPORT PICAN: public PIIODevice {
|
|
PIIODEVICE(PICAN, "can");
|
|
|
|
public:
|
|
//! \~english Constructs a CAN device for interface "path".
|
|
//! \~russian Создает CAN-устройство для интерфейса "path".
|
|
explicit PICAN(const PIString & path = PIString(), PIIODevice::DeviceMode mode = PIIODevice::ReadWrite);
|
|
|
|
//! \~english Destroys the CAN device.
|
|
//! \~russian Уничтожает CAN-устройство.
|
|
virtual ~PICAN();
|
|
|
|
//! \~english Sets CAN frame identifier for subsequent \a write() calls.
|
|
//! \~russian Устанавливает идентификатор CAN-кадра для последующих вызовов \a write().
|
|
void setCANID(int id);
|
|
|
|
//! \~english Returns CAN frame identifier used by \a write().
|
|
//! \~russian Возвращает идентификатор CAN-кадра, используемый методом \a write().
|
|
int CANID() const;
|
|
|
|
//! \~english Returns identifier of the last frame received by \a read().
|
|
//! \~russian Возвращает идентификатор последнего кадра, полученного методом \a read().
|
|
int readedCANID() const;
|
|
|
|
//! \~english Interrupts a blocking CAN wait operation.
|
|
//! \~russian Прерывает блокирующее ожидание CAN-кадра.
|
|
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 = -1;
|
|
int can_id, readed_id;
|
|
};
|
|
#endif // PIP_CAN
|
|
|
|
#endif // PICAN_H
|