|
ethercatcpp
|
This class define an EtherCAT unit device. More...
#include <slave_device.h>

Public Types | |
| enum | syncmanager_buffer_t { ASYNCHROS_OUT, ASYNCHROS_IN, SYNCHROS_OUT, SYNCHROS_IN = 4 } |
| This enum define all type of buffers (SyncManager type) More... | |
Public Member Functions | |
| SlaveDevice () | |
| Constructor of SlaveDevice class. More... | |
| virtual | ~SlaveDevice () |
| void | set_serial_number (uint32_t serial_number) |
| Set the serial number of the device. More... | |
| uint32_t | eep_manufacturer () const |
| Get EtherCAT device manufacturer id. More... | |
| uint32_t | eep_device () const |
| Get EtherCAT device id. More... | |
| uint32_t | serial_number () const |
| Get device serial number. More... | |
Public Member Functions inherited from ethercatcpp::Device | |
| Device () | |
| virtual | ~Device () |
Protected Member Functions | |
| template<typename T , typename... U> | |
| void | define_physical_buffer (syncmanager_buffer_t type, uint16_t start_addr, uint32_t flags) |
| Define a physical buffer (EtherCAT syncManager buffer). More... | |
| void | define_physical_buffer (syncmanager_buffer_t type, uint16_t start_addr, uint32_t flags, uint16_t length) |
| Define a physical buffer (EtherCAT syncManager buffer). More... | |
| template<typename T > | |
| T * | input_buffer (uint16_t start_addr) |
| Get data of input physical buffer. More... | |
| template<typename T , typename U , typename... Other> | |
| std::tuple< T *, U *, Other *... > | input_buffer (uint16_t start_addr) |
| uint8_t * | input_buffer (uint16_t start_addr) |
| Get data of input physical buffer. More... | |
| template<typename T > | |
| T * | output_buffer (uint16_t start_addr) |
| Get data of output physical buffer. More... | |
| template<typename T , typename U , typename... Other> | |
| std::tuple< T *, U *, Other *... > | output_buffer (uint16_t start_addr) |
| uint8_t * | output_buffer (uint16_t start_addr) |
| Get data of output physical buffer. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| void | set_id (const std::string &name, uint32_t manufacturer, uint32_t model) |
| Set a specific ID to the slave. More... | |
| void | define_distributed_clock (bool have_dc) |
| Define if the slave have a distributed clock. More... | |
| void | define_period_for_non_cyclic_steps (int period) |
| Define the period between two non cyclic steps. More... | |
| void | configure_at_init (std::function< void()> &&func) |
| Define the function that configures the slave in PREOP state at initialization of the ethercat bus (Master::init()) . More... | |
| void | configure_at_end (std::function< void()> &&func) |
| Define the function that performs configuration actions in PREOP state at termination of the ethercat bus. (Master::end()). More... | |
| int | write_sdo (uint16_t index, uint8_t sub_index, int buffer_size, void *buffer) const |
| write a SDO capable object field More... | |
| int | read_sdo (uint16_t index, uint8_t sub_index, int buffer_size, void *buffer) const |
| read a SDO capable object field More... | |
| template<typename T > | |
| int | write_sdo (uint16_t index, uint8_t sub_index, T &value) const |
| Send a CoE write SDO packet to the slave. More... | |
| template<typename T > | |
| int | read_sdo (uint16_t index, uint8_t sub_index, T &value) const |
| Send a CoE read SDO packet to the slave. More... | |
| template<typename T > | |
| bool | start_command_pdo_mapping () |
| Start the definition of the command PDO mapping. More... | |
| template<typename T > | |
| bool | add_command_pdo_mapping (uint16_t pdo_address) |
| Add a new command PDO map link. More... | |
| template<typename T > | |
| bool | end_command_pdo_mapping () |
| Finish the definition of the command PDO mapping. More... | |
| template<typename T > | |
| bool | start_status_pdo_mapping () |
| Start definition of the status PDO mapping. More... | |
| template<typename T > | |
| bool | add_status_pdo_mapping (uint16_t pdo_address) |
| Add a new STATUS PDO map link. More... | |
| template<typename T > | |
| bool | end_status_pdo_mapping () |
| Finish definition of the status PDO mapping. More... | |
| void | configure_dc_sync0 (uint32_t cycle_time_0, int32_t cycle_shift) const |
| Define DC synchro signal 0. More... | |
| 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. More... | |
| int32_t | read_file (std::string_view filename, uint32_t password, int32_t size, uint8_t *buffer) const |
| bool | write_file (std::string_view filename, uint32_t password, int32_t size, uint8_t *buffer) const |
| bool | read_sercos (uint8_t drive, uint8_t flags, uint16_t idn, int32_t size, uint8_t *buffer) const |
| bool | write_sercos (uint8_t drive, uint8_t flags, uint16_t idn, int32_t size, uint8_t *buffer) const |
Private Member Functions | |
| void | print_slave_info () const |
| Print all slave informations. More... | |
| uint8_t | run_steps () const |
| Get the number of run steps for the device. More... | |
| void | pre_run_step (uint8_t step) |
| Launch the pre_function for one specific run step. More... | |
| void | post_run_step (uint8_t step) |
| Launch the post_function for one specific run step. More... | |
| uint8_t | init_steps () const |
| Get the number of init steps for the device. More... | |
| void | pre_init_step (uint8_t step) |
| Launch the pre_function for one specific init step. More... | |
| void | post_init_step (uint8_t step) |
| Launch the post_function for one specific init step. More... | |
| uint8_t | end_steps () const |
| void | pre_end_step (uint8_t step) |
| Launch the pre_function for one specific end step. More... | |
| void | post_end_step (uint8_t step) |
| Launch the post_function for one specific end step. More... | |
| void | update_buffers () |
| Update In/Out buffers address. More... | |
| void | launch_init_configuration () |
| Call the init configuration function. More... | |
| void | launch_end_configuration () |
| Call the end configuration function. More... | |
| void | set_command_mappings (uint8_t mappings) |
| uint8_t | get_command_mappings () const |
| void | set_status_mappings (uint8_t mappings) |
| uint8_t | get_status_mappings () const |
| std::vector< Device * > | device_vector () final |
| Get the vector of sub-devices contained by the device. More... | |
| SlaveInfo * | slave_address () final |
| Get the device corresponding physical slave address. More... | |
| template<typename T > | |
| std::tuple< T * > | input_buffer_tuple (uint16_t start_addr, size_t ptr_increment) |
| template<typename T , typename U , typename... Other> | |
| std::tuple< T *, U *, Other *... > | input_buffer_tuple (uint16_t start_addr, size_t ptr_increment) |
| template<typename T > | |
| std::tuple< T * > | output_buffer_tuple (uint16_t start_addr, size_t ptr_increment) |
| template<typename T , typename U , typename... Other> | |
| std::tuple< T *, U *, Other *... > | output_buffer_tuple (uint16_t start_addr, size_t ptr_increment) |
Private Attributes | |
| std::unique_ptr< Impl > | impl_ |
Friends | |
| class | coe::PDOMapping |
| class | coe::PDOBuffer |
| class | Master |
| class | SlaveInfo |
This class define an EtherCAT unit device.
A unit device is an EtherCAT device who contain slave informations (it is composed by a dedicated slave object). It define all steps function (run, init and end), define EtherCAT I/O buffers and all EtherCAT slave configurations.
This enum define all type of buffers (SyncManager type)
| ethercatcpp::SlaveDevice::SlaveDevice | ( | ) |
Constructor of SlaveDevice class.
|
virtual |
|
inlineprotected |
Add a new command PDO map link.
| [in] | pdo_address | is the map address who want to add to the PDO. |
| T | represent the type of data register (generally uint8 or uint16). |
|
protected |
Add a end step and define pre_function and post_function for this end step.
| [in] | pre | is the function witch is execute before a end step (generally set commands). |
| [in] | post | is the function witch is execute after a end step (generally get status and datas). |
|
protected |
Add a init step and define pre_function and post_function for this init step.
| [in] | pre | is the function witch is execute before a init step (generally set commands). |
| [in] | post | is the function witch is execute after a init step (generally get status and datas). |
|
protected |
Add a run step and define pre_function and post_function run step.
| [in] | pre | is the function witch is execute before a run step (generally set commands). |
| [in] | post | is the function witch is execute after a run step (generally get status and datas). |
|
inlineprotected |
Add a new STATUS PDO map link.
| [in] | pdo_address | is the map address who want to add to the PDO. |
| T | represent the type of "date register" (generally uint8 or uint16). |
|
protected |
Define the function that performs configuration actions in PREOP state at termination of the ethercat bus. (Master::end()).
This is typically used to configure CanOpen over EtherCAT devices, by calling write_sdo/read_sdo.
| [in] | func | is the function witch is executed at bus termination time. |
|
protected |
Define the function that configures the slave in PREOP state at initialization of the ethercat bus (Master::init()) .
This is typically used to configure CanOpen over EtherCAT devices, by calling write_sdo/read_sdo, and functions to define PDO mappings and PDO buffers configuration. It can also be used for any operations using FoE.
| [in] | func | is the function witch is executed witch is executed at bus initialization time. |
|
protected |
Define DC synchro signal 0.
This function active DC sync 0 mode and set timers for a slave.
| [in] | cycle_time_0 | is Cycltime SYNC0 in ns. |
| [in] | cycle_shift | is CyclShift in ns. |
|
protected |
Define DC synchro signals 0 and 1.
This function active DC sync 0 and 1 mode and set timers for a slave.
| [in] | cycle_time_0 | is Cycltime SYNC0 in ns. |
| [in] | cycle_time_1 | is Cycltime SYNC1 in ns. This time is a delta time in relation to the SYNC0 fire. If CylcTime1 = 0 then SYNC1 fires a the same time as SYNC0. |
| [in] | cycle_shift | is CyclShift in ns. |
|
protected |
Define if the slave have a distributed clock.
| [in] | have_dc | state for distributed clock (TRUE if have DC). |
|
protected |
Define the period between two non cyclic steps.
| [in] | period | time desired to wait in us. |
|
inlineprotected |
Define a physical buffer (EtherCAT syncManager buffer).
This function define a physical buffer and updates size of total I/O buffer
| T | is the first or unique data type defining buffer content. |
| U | are the other data types defining buffer content sequentially happend to T. |
| [in] | type | is the type of buffer selected in syncmanager_buffer_t. |
| [in] | start_addr | is the buffer physical start address. |
| [in] | flags | is the specific flag for this buffer. |
|
protected |
Define a physical buffer (EtherCAT syncManager buffer).
This function defines a physical buffer and update size of total I/O buffer
| [in] | type | is the type of buffer selected in syncmanager_buffer_t. |
| [in] | start_addr | is the buffer physical start address. |
| [in] | flags | is the specific flag for this buffer. |
| [in] | length | is the size of the buffer in bytes. |
|
finalprivatevirtual |
Get the vector of sub-devices contained by the device.
Implements ethercatcpp::Device.
| uint32_t ethercatcpp::SlaveDevice::eep_device | ( | ) | const |
Get EtherCAT device id.
| uint32_t ethercatcpp::SlaveDevice::eep_manufacturer | ( | ) | const |
Get EtherCAT device manufacturer id.
|
inlineprotected |
Finish the definition of the command PDO mapping.
| T | represent the type of date register (generally uint8 or uint16). |
|
inlineprotected |
Finish definition of the status PDO mapping.
| T | represent the type of date register (generally uint8 or uint16). |
|
private |
|
private |
|
private |
|
private |
Get the number of init steps for the device.
|
inlineprotected |
Get data of input physical buffer.
This function get the raw datas of the input physical buffer and cast them in the data structure type indicate with "template param" to more easyest used.
| T | is the data structure type of the buffer. |
| [in] | start_addr | is the input buffer physical start address. |
|
inlineprotected |
|
protected |
Get data of input physical buffer.
| [in] | start_addr | is the input buffer physical start address. |
|
inlineprivate |
|
inlineprivate |
|
private |
Call the end configuration function.
|
private |
Call the init configuration function.
|
inlineprotected |
Get data of output physical buffer.
This function get the raw datas of the output physical buffer and cast them in the data structure type indicate with "template param" to more easyest used.
| T | is the data structure type of the buffer. |
| [in] | start_addr | is the output buffer physical start address. |
|
inlineprotected |
|
protected |
Get data of output physical buffer.
| [in] | start_addr | is the output buffer physical start address. |
|
inlineprivate |
|
inlineprivate |
|
private |
Launch the post_function for one specific end step.
| [in] | step | is the specific step number who want to launch. |
|
private |
Launch the post_function for one specific init step.
| [in] | step | is the specific step number who want to launch. |
|
private |
Launch the post_function for one specific run step.
| [in] | step | is the specific step number who want to launch. |
|
private |
Launch the pre_function for one specific end step.
| [in] | step | is the specific step number who want to launch. |
|
private |
Launch the pre_function for one specific init step.
| [in] | step | is the specific step number who want to launch. |
|
private |
Launch the pre_function for one specific run step.
| [in] | step | is the specific step number who want to launch. |
|
private |
Print all slave informations.
|
protected |
|
protected |
read a SDO capable object field
| index | index of the object |
| sub_index | sub-index of the field |
| buffer_size | size of field data |
| buffer | pointer to the memory zone holding the data read |
|
inlineprotected |
Send a CoE read SDO packet to the slave.
| [in] | index | is the SDO index to read data. |
| [in] | sub_index | is the SDO sub index to read data. |
| [in] | value | is the data readed. |
| T | represent the data type of input parameter value. |
|
protected |
|
private |
Get the number of run steps for the device.
| uint32_t ethercatcpp::SlaveDevice::serial_number | ( | ) | const |
Get device serial number.
|
private |
|
protected |
Set a specific ID to the slave.
| [in] | name | is slave name. |
| [in] | manufacturer | is the slave manufacturer ID. |
| [in] | model | is the slave model ID. |
| void ethercatcpp::SlaveDevice::set_serial_number | ( | uint32_t | serial_number | ) |
Set the serial number of the device.
This make it posible to force the serial number of the device. So at Master::init() step the serial number will be check, and an error throw if the device serial number dos not match.
| [in] | serial_number | the serial number. |
|
private |
|
finalprivatevirtual |
Get the device corresponding physical slave address.
Implements ethercatcpp::Device.
|
inlineprotected |
Start the definition of the command PDO mapping.
| T | represent the type of data register (generally uint8 or uint16). |
|
inlineprotected |
Start definition of the status PDO mapping.
| T | represent the type of date register (generally uint8 or uint16). |
|
private |
Update In/Out buffers address.
|
protected |
|
protected |
write a SDO capable object field
| index | index of the object |
| sub_index | sub-index of the field |
| buffer_size | size of field data |
| buffer | pointer to the memory zone holding the data to xrite |
|
inlineprotected |
Send a CoE write SDO packet to the slave.
| [in] | index | is the SDO index to write data. |
| [in] | sub_index | is the SDO sub index to write data. |
| [in] | value | is the data to write. |
| T | represent the data type of input parameter value. |
|
protected |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
1.8.17