Go to the documentation of this file.
122 template <
typename T,
typename... U>
125 if constexpr (
sizeof...(U) == 0) {
127 static_cast<uint16_t
>(
sizeof(T)));
130 type, start_addr, flags,
131 static_cast<uint16_t
>(
sizeof(T) + (
sizeof(U) + ...)));
147 uint32_t flags, uint16_t length);
160 template <
typename T>
165 template <
typename T,
typename U,
typename... Other>
189 template <
typename T>
194 template <
typename T,
typename U,
typename... Other>
217 std::function<
void()>&& post);
229 std::function<
void()>&& post);
241 std::function<
void()>&& post);
250 void set_id(
const std::string& name, uint32_t manufacturer, uint32_t model);
304 int write_sdo(uint16_t index, uint8_t sub_index,
int buffer_size,
316 int read_sdo(uint16_t index, uint8_t sub_index,
int buffer_size,
329 template <
typename T>
330 int write_sdo(uint16_t index, uint8_t sub_index, T& value)
const {
331 return write_sdo(index, sub_index,
static_cast<int>(
sizeof(T)),
332 reinterpret_cast<void*
>(&value));
345 template <
typename T>
346 int read_sdo(uint16_t index, uint8_t sub_index, T& value)
const {
347 return read_sdo(index, sub_index,
static_cast<int>(
sizeof(T)),
348 reinterpret_cast<void*
>(&value));
358 template <
typename T>
374 template <
typename T>
396 template <
typename T>
410 template <
typename T>
426 template <
typename T>
450 template <
typename T>
485 int32_t cycle_shift)
const;
491 int32_t
read_file(std::string_view filename, uint32_t password,
492 int32_t size, uint8_t* buffer)
const;
493 bool write_file(std::string_view filename, uint32_t password, int32_t size,
494 uint8_t* buffer)
const;
500 bool read_sercos(uint8_t drive, uint8_t flags, uint16_t idn, int32_t size,
501 uint8_t* buffer)
const;
502 bool write_sercos(uint8_t drive, uint8_t flags, uint16_t idn, int32_t size,
503 uint8_t* buffer)
const;
506 struct EthernetConfiguration {
517 bool detect_ethernet_configuration(uint8_t port,
518 EthernetConfiguration& config);
519 bool configure_ethernet(uint8_t port,
const EthernetConfiguration& config);
521 int32_t read_ethernet(uint8_t port, int32_t size, uint8_t* buffer);
522 bool write_ethernet(uint8_t port, int32_t size, uint8_t* buffer);
622 std::unique_ptr<Impl>
impl_;
625 template <typename T>
627 size_t ptr_increment) {
628 return std::make_tuple(
629 reinterpret_cast<T*
>(
input_buffer(start_addr) + ptr_increment));
632 template <
typename T,
typename U,
typename... Other>
634 size_t ptr_increment) {
635 return std::tuple_cat(input_buffer_tuple<T>(start_addr, ptr_increment),
636 input_buffer_tuple<U, Other...>(
637 start_addr, ptr_increment +
sizeof(T)));
640 template <
typename T>
642 size_t ptr_increment) {
643 return std::make_tuple(
644 reinterpret_cast<T*
>(
output_buffer(start_addr) + ptr_increment));
647 template <
typename T,
typename U,
typename... Other>
649 size_t ptr_increment) {
650 return std::tuple_cat(output_buffer_tuple<T>(start_addr, ptr_increment),
651 output_buffer_tuple<U, Other...>(
652 start_addr, ptr_increment +
sizeof(T)));
T * input_buffer(uint16_t start_addr)
Get data of input physical buffer.
Definition: slave_device.h:161
@ SYNCHROS_IN
define a synchro buffer in (from slave to master)
Definition: slave_device.h:63
bool add_command_pdo_mapping(uint16_t pdo_address)
Add a new command PDO map link.
Definition: slave_device.h:375
std::tuple< T * > output_buffer_tuple(uint16_t start_addr, size_t ptr_increment)
Definition: slave_device.h:641
std::unique_ptr< Impl > impl_
Definition: slave_device.h:621
bool start_command_pdo_mapping()
Start the definition of the command PDO mapping.
Definition: slave_device.h:359
void post_end_step(uint8_t step)
Launch the post_function for one specific end step.
uint8_t end_steps() const
void launch_init_configuration()
Call the init configuration function.
int32_t read_file(std::string_view filename, uint32_t password, int32_t size, uint8_t *buffer) const
void set_id(const std::string &name, uint32_t manufacturer, uint32_t model)
Set a specific ID to the slave.
uint32_t serial_number() const
Get device serial number.
@ ASYNCHROS_OUT
define an asynchro mailbox out (from master to slave)
Definition: slave_device.h:57
SlaveInfo * slave_address() final
Get the device corresponding physical slave address.
std::tuple< T *, U *, Other *... > output_buffer(uint16_t start_addr)
Definition: slave_device.h:195
void pre_init_step(uint8_t step)
Launch the pre_function for one specific init step.
int read_sdo(uint16_t index, uint8_t sub_index, T &value) const
Send a CoE read SDO packet to the slave.
Definition: slave_device.h:346
void add_end_step(std::function< void()> &&pre, std::function< void()> &&post)
Add a end step and define pre_function and post_function for this end step.
syncmanager_buffer_t
This enum define all type of buffers (SyncManager type)
Definition: slave_device.h:56
std::tuple< T *, U *, Other *... > input_buffer_tuple(uint16_t start_addr, size_t ptr_increment)
Definition: slave_device.h:633
Represent a CANOpen PDO mapping.
Definition: coe_utilities.h:163
static constexpr uint16_t coe_tx_pdo_assign
Definition: coe_utilities.h:61
void configure_at_init(std::function< void()> &&func)
Define the function that configures the slave in PREOP state at initialization of the ethercat bus (M...
Header file for Device class.
void define_physical_buffer(syncmanager_buffer_t type, uint16_t start_addr, uint32_t flags)
Define a physical buffer (EtherCAT syncManager buffer).
Definition: slave_device.h:123
void pre_run_step(uint8_t step)
Launch the pre_function for one specific run step.
void set_command_mappings(uint8_t mappings)
void update_buffers()
Update In/Out buffers address.
friend class SlaveInfo
Definition: slave_device.h:526
bool start_status_pdo_mapping()
Start definition of the status PDO mapping.
Definition: slave_device.h:411
This class define The EtherCAT Master.
Definition: master.h:50
void define_period_for_non_cyclic_steps(int period)
Define the period between two non cyclic steps.
bool end_command_pdo_mapping()
Finish the definition of the command PDO mapping.
Definition: slave_device.h:397
void configure_dc_sync0(uint32_t cycle_time_0, int32_t cycle_shift) const
Define DC synchro signal 0.
uint8_t run_steps() const
Get the number of run steps for the device.
std::vector< Device * > device_vector() final
Get the vector of sub-devices contained by the device.
uint8_t get_command_mappings() const
Main header file for CoE utilities.
@ SYNCHROS_OUT
define a synchro buffer out (from master to slave)
Definition: slave_device.h:61
std::tuple< T * > input_buffer_tuple(uint16_t start_addr, size_t ptr_increment)
Definition: slave_device.h:626
int write_sdo(uint16_t index, uint8_t sub_index, T &value) const
Send a CoE write SDO packet to the slave.
Definition: slave_device.h:330
bool write_sercos(uint8_t drive, uint8_t flags, uint16_t idn, int32_t size, uint8_t *buffer) const
void post_init_step(uint8_t step)
Launch the post_function for one specific init step.
This abstract class define an EtherCAT device.
Definition: device.h:49
void add_run_step(std::function< void()> &&pre, std::function< void()> &&post)
Add a run step and define pre_function and post_function run step.
int read_sdo(uint16_t index, uint8_t sub_index, int buffer_size, void *buffer) const
read a SDO capable object field
std::tuple< T *, U *, Other *... > output_buffer_tuple(uint16_t start_addr, size_t ptr_increment)
Definition: slave_device.h:648
void configure_at_end(std::function< void()> &&func)
Define the function that performs configuration actions in PREOP state at termination of the ethercat...
uint8_t get_status_mappings() const
static constexpr uint16_t coe_rx_pdo_assign
Definition: coe_utilities.h:60
void print_slave_info() const
Print all slave informations.
SlaveDevice()
Constructor of SlaveDevice class.
uint8_t init_steps() const
Get the number of init steps for the device.
void configure_dc_sync0_1(uint32_t cycle_time_0, uint32_t cycle_time_1, int32_t cycle_shift) const
Define DC synchro signals 0 and 1.
std::tuple< T *, U *, Other *... > input_buffer(uint16_t start_addr)
Definition: slave_device.h:166
void set_status_mappings(uint8_t mappings)
void set_serial_number(uint32_t serial_number)
Set the serial number of the device.
bool end_status_pdo_mapping()
Finish definition of the status PDO mapping.
Definition: slave_device.h:451
uint32_t eep_manufacturer() const
Get EtherCAT device manufacturer id.
Definition: coe_utilities.h:299
bool write_file(std::string_view filename, uint32_t password, int32_t size, uint8_t *buffer) const
void launch_end_configuration()
Call the end configuration function.
@ ASYNCHROS_IN
define an asynchro mailbox in (from slave to master)
Definition: slave_device.h:59
T * output_buffer(uint16_t start_addr)
Get data of output physical buffer.
Definition: slave_device.h:190
bool add_status_pdo_mapping(uint16_t pdo_address)
Add a new STATUS PDO map link.
Definition: slave_device.h:427
void add_init_step(std::function< void()> &&pre, std::function< void()> &&post)
Add a init step and define pre_function and post_function for this init step.
This class define an EtherCAT unit device.
Definition: slave_device.h:53
uint32_t eep_device() const
Get EtherCAT device id.
void post_run_step(uint8_t step)
Launch the post_function for one specific run step.
int write_sdo(uint16_t index, uint8_t sub_index, int buffer_size, void *buffer) const
write a SDO capable object field
bool read_sercos(uint8_t drive, uint8_t flags, uint16_t idn, int32_t size, uint8_t *buffer) const
void define_distributed_clock(bool have_dc)
Define if the slave have a distributed clock.
void pre_end_step(uint8_t step)
Launch the pre_function for one specific end step.