| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/***************************************************************************** |
| 2 |
|
|
* |
| 3 |
|
|
* This file is part of the ecapp library (EtherCAT application devices). |
| 4 |
|
|
* |
| 5 |
|
|
* Copyright (C) 2026 Florian Pose <fp@igh.de> |
| 6 |
|
|
* |
| 7 |
|
|
* The ecapp library is free software: you can redistribute it and/or |
| 8 |
|
|
* modify it under the terms of the GNU Lesser General Public License |
| 9 |
|
|
* as published by the Free Software Foundation, version 3 of the |
| 10 |
|
|
* License. |
| 11 |
|
|
* |
| 12 |
|
|
* The ecapp library is distributed in the hope that it will be useful, |
| 13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
|
|
* Lesser General Public License for more details. |
| 16 |
|
|
* |
| 17 |
|
|
* You should have received a copy of the GNU Lesser General Public |
| 18 |
|
|
* License along with the ecapp library. If not, see |
| 19 |
|
|
* <https://www.gnu.org/licenses/>. |
| 20 |
|
|
* |
| 21 |
|
|
****************************************************************************/ |
| 22 |
|
|
|
| 23 |
|
|
#ifndef ECAPP_GENERICDEVICE_H |
| 24 |
|
|
#define ECAPP_GENERICDEVICE_H |
| 25 |
|
|
|
| 26 |
|
|
/****************************************************************************/ |
| 27 |
|
|
|
| 28 |
|
|
#include "ecapp/SubDevice.h" // ChannelValue |
| 29 |
|
|
#include "ecapp_export.h" |
| 30 |
|
|
|
| 31 |
|
|
#include <cstdint> |
| 32 |
|
|
|
| 33 |
|
|
/****************************************************************************/ |
| 34 |
|
|
|
| 35 |
|
|
namespace EcApp { |
| 36 |
|
|
|
| 37 |
|
|
/** Capability for a SubDevice implemented by EcApp::GenericSubDevice -- |
| 38 |
|
|
* i.e. one whose PDO layout was not known to this build of ecapp and was |
| 39 |
|
|
* instead generated (from a live "ethercat pdos --json" snapshot, at |
| 40 |
|
|
* ecapp-generate time) directly into the application. |
| 41 |
|
|
* EcApp::hasCapability<GenericDevice>(*device) lets application code |
| 42 |
|
|
* recognize "this device runs generically, not a specific |
| 43 |
|
|
* implementation"; vendorId()/productCode() name which one -- useful to |
| 44 |
|
|
* know which src/devices/*.cpp implementation, once written, would make |
| 45 |
|
|
* this slave "known" on the next ecapp-generate run instead. */ |
| 46 |
|
5 |
class ECAPP_EXPORT GenericDevice |
| 47 |
|
|
{ |
| 48 |
|
|
public: |
| 49 |
|
5 |
virtual ~GenericDevice() = default; |
| 50 |
|
|
|
| 51 |
|
|
virtual uint32_t vendorId() const = 0; |
| 52 |
|
|
virtual uint32_t productCode() const = 0; |
| 53 |
|
|
|
| 54 |
|
|
/** Writes one SDO (CoE mailbox configuration value) via |
| 55 |
|
|
* ecrt_slave_config_sdo() -- e.g. an operating mode a slave needs |
| 56 |
|
|
* set up before its PDOs make sense. Call from application code |
| 57 |
|
|
* after constructing this device (e.g. in RtMain's constructor |
| 58 |
|
|
* body, via EcApp::capability<GenericDevice>(*device).configureSdo(...)) |
| 59 |
|
|
* but before EcApp::Master::activate() -- the same restriction |
| 60 |
|
|
* ecrt_slave_config_sdo() itself has (it only queues the value; the |
| 61 |
|
|
* master's own state machine actually transfers it to the slave |
| 62 |
|
|
* later, while bringing it up into OP once the master is |
| 63 |
|
|
* activated). A no-op if this device has no real slave |
| 64 |
|
|
* configuration (e.g. constructed with a null Master, for testing |
| 65 |
|
|
* without a bus) -- consistent with every other ecrt-facing call in |
| 66 |
|
|
* this library. value's active alternative decides the width |
| 67 |
|
|
* written on the wire (1 byte for bool, matching |
| 68 |
|
|
* ecrt_slave_config_sdo8()'s uint8_t; native width otherwise). */ |
| 69 |
|
|
virtual void configureSdo( |
| 70 |
|
|
uint16_t index, |
| 71 |
|
|
uint8_t subindex, |
| 72 |
|
|
const ChannelValue &value) = 0; |
| 73 |
|
|
}; |
| 74 |
|
|
|
| 75 |
|
|
} // namespace EcApp |
| 76 |
|
|
|
| 77 |
|
|
#endif // ECAPP_GENERICDEVICE_H |
| 78 |
|
|
|
| 79 |
|
|
/****************************************************************************/ |
| 80 |
|
|
|