libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
|
Data Structures | |
struct | ec_coe_emergency_message |
Message queue qentry. More... | |
struct | ec_coe |
struct | ec_coe_sdo_desc |
CanOpen over EtherCAT sdo descriptor. More... | |
struct | ec_coe_sdo_entry_desc |
Typedefs | |
typedef struct ec_coe_emergency_message | ec_coe_emergency_message_t |
Message queue qentry. | |
typedef struct ec_coe | ec_coe_t |
CoE type. | |
typedef struct PACKED ec_coe_sdo_desc | ec_coe_sdo_desc_t |
CanOpen over EtherCAT sdo descriptor. | |
typedef struct PACKED ec_coe_sdo_entry_desc | ec_coe_sdo_entry_desc_t |
CoE SDO entry description type. | |
typedef struct ec | ec_t |
typedef to ec struct. | |
Enumerations | |
enum | { EC_COE_EMERGENCY = 0x01 , EC_COE_SDOREQ , EC_COE_SDORES , EC_COE_TXPDO , EC_COE_RXPDO , EC_COE_TXPDO_RR , EC_COE_RXPDO_RR , EC_COE_SDOINFO } |
CoE mailbox types. More... | |
enum | { EC_COE_SDO_DOWNLOAD_SEQ_REQ = 0x00 , EC_COE_SDO_DOWNLOAD_REQ = 0x01 , EC_COE_SDO_UPLOAD_REQ = 0x02 , EC_COE_SDO_ABORT_REQ = 0x04 } |
service data object command More... | |
enum | { EC_COE_SDO_INFO_ODLIST_REQ = 0x01 , EC_COE_SDO_INFO_ODLIST_RESP , EC_COE_SDO_INFO_GET_OBJECT_DESC_REQ , EC_COE_SDO_INFO_GET_OBJECT_DESC_RESP , EC_COE_SDO_INFO_GET_ENTRY_DESC_REQ , EC_COE_SDO_INFO_GET_ENTRY_DESC_RESP , EC_COE_SDO_INFO_ERROR_REQUEST } |
service data object information type More... | |
enum | { DEFTYPE_NULL = 0x0000 , DEFTYPE_BOOLEAN = 0x0001 , DEFTYPE_INTEGER8 = 0x0002 , DEFTYPE_INTEGER16 = 0x0003 , DEFTYPE_INTEGER32 = 0x0004 , DEFTYPE_UNSIGNED8 = 0x0005 , DEFTYPE_UNSIGNED16 = 0x0006 , DEFTYPE_UNSIGNED32 = 0x0007 , DEFTYPE_REAL32 = 0x0008 , DEFTYPE_VISIBLESTRING = 0x0009 , DEFTYPE_OCTETSTRING = 0x000A , DEFTYPE_UNICODE_STRING = 0x000B , DEFTYPE_TIME_OF_DAY = 0x000C , DEFTYPE_TIME_DIFFERENCE = 0x000D , DEFTYPE_INTEGER24 = 0x0010 , DEFTYPE_REAL64 = 0x0011 , DEFTYPE_INTEGER40 = 0x0012 , DEFTYPE_INTEGER48 = 0x0013 , DEFTYPE_INTEGER56 = 0x0014 , DEFTYPE_INTEGER64 = 0x0015 , DEFTYPE_UNSIGNED24 = 0x0016 , DEFTYPE_UNSIGNED40 = 0x0018 , DEFTYPE_UNSIGNED48 = 0x0019 , DEFTYPE_UNSIGNED56 = 0x001A , DEFTYPE_UNSIGNED64 = 0x001B , DEFTYPE_GUID = 0x001D , DEFTYPE_BYTE = 0x001E , DEFTYPE_WORD = 0x001F , DEFTYPE_DWORD = 0x0020 , DEFTYPE_PDOMAPPING = 0x0021 , DEFTYPE_IDENTITY = 0x0023 , DEFTYPE_COMMAND = 0x0025 , DEFTYPE_PDOCOMPAR = 0x0027 , DEFTYPE_ENUM = 0x0028 , DEFTYPE_SMPAR = 0x0029 , DEFTYPE_RECORD = 0x002A , DEFTYPE_BACKUP = 0x002B , DEFTYPE_MDP = 0x002C , DEFTYPE_BITARR8 = 0x002D , DEFTYPE_BITARR16 = 0x002E , DEFTYPE_BITARR32 = 0x002F , DEFTYPE_BIT1 = 0x0030 , DEFTYPE_BIT2 = 0x0031 , DEFTYPE_BIT3 = 0x0032 , DEFTYPE_BIT4 = 0x0033 , DEFTYPE_BIT5 = 0x0034 , DEFTYPE_BIT6 = 0x0035 , DEFTYPE_BIT7 = 0x0036 , DEFTYPE_BIT8 = 0x0037 , DEFTYPE_ARRAY_OF_INT = 0x0260 , DEFTYPE_ARRAY_OF_SINT = 0x0261 , DEFTYPE_ARRAY_OF_DINT = 0x0262 , DEFTYPE_ARRAY_OF_UDINT = 0x0263 , DEFTYPE_ERRORHANDLING = 0x0281 , DEFTYPE_DIAGHISTORY = 0x0282 , DEFTYPE_SYNCSTATUS = 0x0283 , DEFTYPE_SYNCSETTINGS = 0x0284 , DEFTYPE_FSOEFRAME = 0x0285 , DEFTYPE_FSOECOMMPAR = 0x0286 } |
datatypes | |
enum | { OBJCODE_VAR = 0x07 , OBJCODE_ARR = 0x08 , OBJCODE_REC = 0x09 } |
enum | { ACCESS_READWRITE = 0x003F , ACCESS_READ = 0x0007 , ACCESS_READ_PREOP = 0x0001 , ACCESS_READ_SAFEOP = 0x0002 , ACCESS_READ_OP = 0x0004 , ACCESS_WRITE = 0x0038 , ACCESS_WRITE_PREOP = 0x0008 , ACCESS_WRITE_SAFEOP = 0x0010 , ACCESS_WRITE_OP = 0x0020 } |
Functions | |
void | ec_coe_init (ec_t *pec, osal_uint16_t slave) |
Initialize CoE structure. | |
void | ec_coe_deinit (ec_t *pec, osal_uint16_t slave) |
deinitialize CoE structure | |
int | ec_coe_sdo_read (ec_t *pec, osal_uint16_t slave, osal_uint16_t index, osal_uint8_t sub_index, int complete, osal_uint8_t *buf, osal_size_t *len, osal_uint32_t *abort_code) |
Read CoE service data object (SDO) | |
int | ec_coe_master_sdo_read (ec_t *pec, osal_uint16_t index, osal_uint8_t sub_index, int complete, osal_uint8_t *buf, osal_size_t *len, osal_uint32_t *abort_code) |
Read CoE service data object (SDO) of master. | |
int | ec_coe_sdo_write (ec_t *pec, osal_uint16_t slave, osal_uint16_t index, osal_uint8_t sub_index, int complete, osal_uint8_t *buf, osal_size_t len, osal_uint32_t *abort_code) |
Write CoE service data object (SDO) | |
int | ec_coe_master_sdo_write (ec_t *pec, osal_uint16_t index, osal_uint8_t sub_index, int complete, osal_uint8_t *buf, osal_size_t len, osal_uint32_t *abort_code) |
Write CoE service data object (SDO) of master. | |
int | ec_coe_sdo_desc_read (ec_t *pec, osal_uint16_t slave, osal_uint16_t index, ec_coe_sdo_desc_t *desc, osal_uint32_t *error_code) |
Read CoE SDO description. | |
int | ec_coe_master_sdo_desc_read (const ec_t *pec, osal_uint16_t index, ec_coe_sdo_desc_t *desc, osal_uint32_t *error_code) |
Read CoE SDO description of master. | |
int | ec_coe_sdo_entry_desc_read (ec_t *pec, osal_uint16_t slave, osal_uint16_t index, osal_uint8_t sub_index, osal_uint8_t value_info, ec_coe_sdo_entry_desc_t *desc, osal_uint32_t *error_code) |
Read CoE SDO entry description. | |
int | ec_coe_master_sdo_entry_desc_read (const ec_t *pec, osal_uint16_t index, osal_uint8_t sub_index, osal_uint8_t value_info, ec_coe_sdo_entry_desc_t *desc, osal_uint32_t *error_code) |
Read CoE SDO entry description of master. | |
int | ec_coe_odlist_read (ec_t *pec, osal_uint16_t slave, osal_uint8_t *buf, osal_size_t *len) |
Read CoE object dictionary list. | |
int | ec_coe_master_odlist_read (ec_t *pec, osal_uint8_t *buf, osal_size_t *len) |
Read CoE object dictionary list of master. | |
int | ec_coe_generate_mapping (ec_t *pec, osal_uint16_t slave) |
generate sync manager process data mapping via coe | |
void | ec_coe_emergency_enqueue (ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry) |
queue read mailbox content | |
int | ec_coe_emergency_get_next (ec_t *pec, osal_uint16_t slave, ec_coe_emergency_message_t *msg) |
Get next CoE emergency message. | |
void | ec_coe_enqueue (ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry) |
Enqueue CoE message received from slave. | |
const osal_char_t * | get_sdo_info_error_string (osal_uint32_t errorcode) |
Get SDO INFO error string. | |
This modules contains functions on how to communicate to the CANOpen over EtherCAT mailbox.
typedef struct PACKED ec_coe_sdo_desc ec_coe_sdo_desc_t |
CanOpen over EtherCAT sdo descriptor.
CoE SDO description type.
anonymous enum |
CoE mailbox types.
anonymous enum |
anonymous enum |
service data object information type
anonymous enum |
anonymous enum |
void ec_coe_deinit | ( | ec_t * | pec, |
osal_uint16_t | slave | ||
) |
deinitialize CoE structure
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
void ec_coe_emergency_enqueue | ( | ec_t * | pec, |
osal_uint16_t | slave, | ||
pool_entry_t * | p_entry | ||
) |
queue read mailbox content
[in] | pec | Pointer to ethercat master struct. |
[in] | slave | Number of EtherCAT slave connected to bus. |
[in] | p_entry | Emergency message to enqueue. |
int ec_coe_emergency_get_next | ( | ec_t * | pec, |
osal_uint16_t | slave, | ||
ec_coe_emergency_message_t * | msg | ||
) |
Get next CoE emergency message.
[in] | pec | Pointer to EtherCAT mater struct. |
[in] | slave | Number of EtherCAT slave connected to bus. |
[out] | msg | Pointer to return emergency message. |
void ec_coe_enqueue | ( | ec_t * | pec, |
osal_uint16_t | slave, | ||
pool_entry_t * | p_entry | ||
) |
Enqueue CoE message received from slave.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
[in] | p_entry | Pointer to pool entry containing received mailbox message from slave. |
EC_ERROR_UNAVAILABLE | No more emergency message in queue. |
EC_OK | Success, got next emergency message. |
int ec_coe_generate_mapping | ( | ec_t * | pec, |
osal_uint16_t | slave | ||
) |
generate sync manager process data mapping via coe
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
EC_OK | CoE transfer was successfull. |
EC_ERROR_MAILBOX_TIMEOUT | Got timeout waiting for message. |
EC_ERROR_UNAVAILABLE | Locking mailbox failed for some reason. |
EC_ERROR_MAILBOX_NOT_SUPPORTED_COE | No CoE support on slave's mailbox. |
EC_ERROR_MAILBOX_OUT_OF_SEND_BUFFERS | No more free send buffer available. |
EC_ERROR_MAILBOX_ABORT | Got SDO abort request. |
EC_ERROR_MAILBOX_READ | Got unexpected message on CoE read. |
void ec_coe_init | ( | ec_t * | pec, |
osal_uint16_t | slave | ||
) |
Initialize CoE structure.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
int ec_coe_master_odlist_read | ( | ec_t * | pec, |
osal_uint8_t * | buf, | ||
osal_size_t * | len | ||
) |
Read CoE object dictionary list of master.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[out] | buf | Pointer to a preallocated buffer. |
[in,out] | len | Length of buffer, outputs read length. |
EC_OK | CoE transfer was successfull. |
EC_ERROR_MAILBOX_COE_INDEX_NOT_FOUND | Requested index not found. |
EC_ERROR_MAILBOX_ABORT | Got SDO abort request. |
EC_ERROR_MAILBOX_BUFFER_TOO_SMALL | Provided buffer was too small, returning size in len . |
int ec_coe_master_sdo_desc_read | ( | const ec_t * | pec, |
osal_uint16_t | index, | ||
ec_coe_sdo_desc_t * | desc, | ||
osal_uint32_t * | error_code | ||
) |
Read CoE SDO description of master.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | index | CoE SDO index number. |
[out] | desc | Returns CoE SDO description. |
[out] | error_code | Returns the error code if we got one. |
EC_OK | CoE transfer was successfull. |
EC_ERROR_MAILBOX_COE_INDEX_NOT_FOUND | Requested index not found. |
EC_ERROR_MAILBOX_ABORT | Got SDO abort request. |
int ec_coe_master_sdo_entry_desc_read | ( | const ec_t * | pec, |
osal_uint16_t | index, | ||
osal_uint8_t | sub_index, | ||
osal_uint8_t | value_info, | ||
ec_coe_sdo_entry_desc_t * | desc, | ||
osal_uint32_t * | error_code | ||
) |
Read CoE SDO entry description of master.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | index | CoE SDO index number. |
[in] | sub_index | CoE SDO sub index number. |
[in] | value_info | Bitset which description values you want to get |
[in] | desc | Return CoE entry description. |
[out] | error_code | Returns the error code if we got one. |
EC_OK | CoE transfer was successfull. |
EC_ERROR_MAILBOX_COE_INDEX_NOT_FOUND | Requested index not found. |
EC_ERROR_MAILBOX_ABORT | Got SDO abort request. |
int ec_coe_master_sdo_read | ( | ec_t * | pec, |
osal_uint16_t | index, | ||
osal_uint8_t | sub_index, | ||
int | complete, | ||
osal_uint8_t * | buf, | ||
osal_size_t * | len, | ||
osal_uint32_t * | abort_code | ||
) |
Read CoE service data object (SDO) of master.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | index | CoE SDO index number. |
[in] | sub_index | CoE SDO sub index number. |
[in] | complete | SDO Complete access (only if sub_index == 0) |
[out] | buf | Buffer where to store the answer. User supplied pointer to a buffer. If buffer is too small an error code is returned and the needed length is stored in 'len'. |
[in,out] | len | Length of buffer, outputs read length. |
[out] | abort_code | Returns the abort code if we got abort request |
EC_OK | CoE transfer was successfull. |
EC_ERROR_MAILBOX_COE_INDEX_NOT_FOUND | Requested index not found. |
EC_ERROR_MAILBOX_ABORT | Got SDO abort request. |
int ec_coe_master_sdo_write | ( | ec_t * | pec, |
osal_uint16_t | index, | ||
osal_uint8_t | sub_index, | ||
int | complete, | ||
osal_uint8_t * | buf, | ||
osal_size_t | len, | ||
osal_uint32_t * | abort_code | ||
) |
Write CoE service data object (SDO) of master.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | index | CoE SDO index number. |
[in] | sub_index | CoE SDO sub index number. |
[in] | complete | SDO Complete access (only if sub_index == 0) |
[in] | buf | Buffer with data which will be written. |
[in] | len | Length of buffer. |
[out] | abort_code | Returns the abort code if we got abort request |
EC_OK | CoE transfer was successfull. |
EC_ERROR_MAILBOX_COE_INDEX_NOT_FOUND | Requested index not found. |
EC_ERROR_MAILBOX_ABORT | Got SDO abort request. |
int ec_coe_odlist_read | ( | ec_t * | pec, |
osal_uint16_t | slave, | ||
osal_uint8_t * | buf, | ||
osal_size_t * | len | ||
) |
Read CoE object dictionary list.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
[out] | buf | Pointer to a preallocated buffer. |
[in,out] | len | Length of buffer, outputs read length. |
EC_OK | CoE transfer was successfull. |
EC_ERROR_UNAVAILABLE | Locking mailbox failed for some reason. |
EC_ERROR_MAILBOX_NOT_SUPPORTED_COE | No CoE support on slave's mailbox. |
EC_ERROR_MAILBOX_OUT_OF_SEND_BUFFERS | No more free send buffer available. |
EC_ERROR_MAILBOX_TIMEOUT | Got timeout waiting for message. |
EC_ERROR_MAILBOX_BUFFER_TOO_SMALL | Provided buffer was too small, returning size in len . |
int ec_coe_sdo_desc_read | ( | ec_t * | pec, |
osal_uint16_t | slave, | ||
osal_uint16_t | index, | ||
ec_coe_sdo_desc_t * | desc, | ||
osal_uint32_t * | error_code | ||
) |
Read CoE SDO description.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
[in] | index | CoE SDO index number. |
[out] | desc | Returns CoE SDO description. |
[out] | error_code | Returns the error code if we got one. |
EC_OK | CoE transfer was successfull. |
EC_ERROR_UNAVAILABLE | Locking mailbox failed for some reason. |
EC_ERROR_MAILBOX_NOT_SUPPORTED_COE | No CoE support on slave's mailbox. |
EC_ERROR_MAILBOX_OUT_OF_SEND_BUFFERS | No more free send buffer available. |
EC_ERROR_MAILBOX_ABORT | Got SDO abort request. |
EC_ERROR_MAILBOX_READ | Got unexpected message on CoE read. |
int ec_coe_sdo_entry_desc_read | ( | ec_t * | pec, |
osal_uint16_t | slave, | ||
osal_uint16_t | index, | ||
osal_uint8_t | sub_index, | ||
osal_uint8_t | value_info, | ||
ec_coe_sdo_entry_desc_t * | desc, | ||
osal_uint32_t * | error_code | ||
) |
Read CoE SDO entry description.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
[in] | index | CoE SDO index number. |
[in] | sub_index | CoE SDO sub index number. |
[in] | value_info | Bitset which description values you want to get |
[in] | desc | Return CoE entry description. |
[out] | error_code | Returns the error code if we got one. |
EC_OK | CoE transfer was successfull. |
EC_ERROR_UNAVAILABLE | Locking mailbox failed for some reason. |
EC_ERROR_MAILBOX_NOT_SUPPORTED_COE | No CoE support on slave's mailbox. |
EC_ERROR_MAILBOX_OUT_OF_SEND_BUFFERS | No more free send buffer available. |
EC_ERROR_MAILBOX_ABORT | Got SDO abort request. |
EC_ERROR_MAILBOX_READ | Got unexpected message on CoE read. |
int ec_coe_sdo_read | ( | ec_t * | pec, |
osal_uint16_t | slave, | ||
osal_uint16_t | index, | ||
osal_uint8_t | sub_index, | ||
int | complete, | ||
osal_uint8_t * | buf, | ||
osal_size_t * | len, | ||
osal_uint32_t * | abort_code | ||
) |
Read CoE service data object (SDO)
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
[in] | index | CoE SDO index number. |
[in] | sub_index | CoE SDO sub index number. |
[in] | complete | SDO Complete access (only if sub_index == 0) |
[out] | buf | Buffer where to store the answer. User supplied pointer to a buffer. If buffer is too small an error code is returned and the needed length is stored in 'len'. |
[in,out] | len | Length of buffer, outputs read length. |
[out] | abort_code | Returns the abort code if we got abort request |
EC_OK | CoE transfer was successfull. |
EC_ERROR_MAILBOX_READ | Got unexpected message on CoE read. |
EC_ERROR_MAILBOX_BUFFER_TOO_SMALL | Provided buffer was too small, returning size in len . |
EC_ERROR_MAILBOX_ABORT | Got SDO abort request. |
EC_ERROR_MAILBOX_OUT_OF_SEND_BUFFERS | No more free send buffer available. |
EC_ERROR_MAILBOX_NOT_SUPPORTED_COE | No CoE support on slave's mailbox. |
EC_ERROR_UNAVAILABLE | Locking mailbox failed for some reason. |
EC_ERROR_MAILBOX_TIMEOUT | Got timeout waiting for message. |
int ec_coe_sdo_write | ( | ec_t * | pec, |
osal_uint16_t | slave, | ||
osal_uint16_t | index, | ||
osal_uint8_t | sub_index, | ||
int | complete, | ||
osal_uint8_t * | buf, | ||
osal_size_t | len, | ||
osal_uint32_t * | abort_code | ||
) |
Write CoE service data object (SDO)
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
[in] | index | CoE SDO index number. |
[in] | sub_index | CoE SDO sub index number. |
[in] | complete | SDO Complete access (only if sub_index == 0) |
[in] | buf | Buffer with data which will be written. |
[in] | len | Length of buffer. |
[out] | abort_code | Returns the abort code if we got abort request |
EC_OK | CoE transfer was successfull. |
EC_ERROR_UNAVAILABLE | Locking mailbox failed for some reason. |
EC_ERROR_MAILBOX_NOT_SUPPORTED_COE | No CoE support on slave's mailbox. |
EC_ERROR_MAILBOX_OUT_OF_SEND_BUFFERS | No more free send buffer available. |
EC_ERROR_MAILBOX_TIMEOUT | Got timeout waiting for message. |
EC_ERROR_MAILBOX_ABORT | Got SDO abort request. |
EC_ERROR_MAILBOX_READ | Got unexpected message on CoE read. |
const osal_char_t * get_sdo_info_error_string | ( | osal_uint32_t | errorcode | ) |
Get SDO INFO error string.
[in] | errorcode | Error code number. |