libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
Loading...
Searching...
No Matches
Mailbox

Data Structures

struct  ec_mbx_header
 ethercat mailbox header More...
 
struct  ec_mbx_buffer
 ethercat mailbox data More...
 
struct  ec_mbx
 

Macros

#define MAILBOX_WRITE   (osal_uint16_t)(0u)
 Write mailbox number.
 
#define MAILBOX_READ   (osal_uint16_t)(1u)
 Read mailbox number.
 
#define MESSAGE_POOL_DEBUG(type)   {}
 
#define ec_mbx_get_free_recv_buffer(pec, slave, entry, timeout, lock)    pool_get(&(pec)->mbx_message_pool_recv_free, &(entry), (timeout))
 
#define ec_mbx_get_free_send_buffer_old(pec, slave, entry, timeout, lock)    pool_get(&(pec)->mbx_message_pool_send_free, &(entry), (timeout))
 
#define ec_mbx_return_free_send_buffer(pec, slave, entry)    pool_put(&(pec)->mbx_message_pool_send_free, (entry))
 
#define ec_mbx_return_free_recv_buffer(pec, slave, entry)    pool_put(&(pec)->mbx_message_pool_recv_free, (entry))
 

Typedefs

typedef struct ec ec_t
 
typedef struct PACKED ec_mbx_header ec_mbx_header_t
 ethercat mailbox header
 
typedef struct PACKED ec_mbx_buffer ec_mbx_buffer_t
 ethercat mailbox data
 
typedef struct ec_mbx ec_mbx_t
 

Enumerations

enum  {
  EC_MBX_ERR = 0x00 , EC_MBX_AOE , EC_MBX_EOE , EC_MBX_COE ,
  EC_MBX_FOE , EC_MBX_SOE , EC_MBX_VOE = 0x0f
}
 mailbox types More...
 

Functions

void ec_mbx_init (ec_t *pec, osal_uint16_t slave)
 Initialize mailbox structure.
 
void ec_mbx_deinit (ec_t *pec, osal_uint16_t slave)
 Deinit mailbox structure.
 
void ec_mbx_enqueue_head (ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry)
 Enqueue mailbox message to send queue.
 
void ec_mbx_enqueue_tail (ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry)
 Enqueue mailbox message to send queue.
 
void ec_mbx_sched_read (ec_t *pec, osal_uint16_t slave)
 Trigger read of mailbox.
 
int ec_mbx_check (ec_t *pec, int slave, osal_uint16_t mbx_flag)
 Checks if mailbox protocol is supported by slave.
 
int ec_mbx_next_counter (ec_t *pec, int slave, int *seq_counter)
 Get next sequence counter.
 
int ec_mbx_get_free_send_buffer (ec_t *pec, osal_uint16_t slave, pool_entry_t **pp_entry, osal_timer_t *timeout)
 Get free mailbox send buffer from slaves send message pool.
 

Detailed Description

This modules contains EtherCAT mailbox funcitons.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

mailbox types

Enumerator
EC_MBX_ERR 

error mailbox

EC_MBX_AOE 

ADS over EtherCAT mailbox.

EC_MBX_EOE 

Ethernet over EtherCAT mailbox.

EC_MBX_COE 

CANopen over EtherCAT mailbox.

EC_MBX_FOE 

File over EtherCAT mailbox.

EC_MBX_SOE 

Servo over EtherCAT mailbox.

EC_MBX_VOE 

Vendor over EtherCAT mailbox.

Function Documentation

◆ ec_mbx_check()

int ec_mbx_check ( ec_t pec,
int  slave,
osal_uint16_t  mbx_flag 
)

Checks if mailbox protocol is supported by slave.

Parameters
[in]pecPointer to ethercat master structure, which you got from ec_open.
[in]slaveNumber of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached).
[in]mbx_flagMailbox protocols flag to be checked
Return values
EC_OKIf all requested protocols supported, otherwise ored error codes.
EC_ERROR_MAILBOX_NOT_SUPPORTED_AOEMailbox AoE not supported.
EC_ERROR_MAILBOX_NOT_SUPPORTED_EOEMailbox EoE not supported.
EC_ERROR_MAILBOX_NOT_SUPPORTED_COEMailbox CoE not supported.
EC_ERROR_MAILBOX_NOT_SUPPORTED_FOEMailbox FoE not supported.
EC_ERROR_MAILBOX_NOT_SUPPORTED_SOEMailbox SoE not supported.
EC_ERROR_MAILBOX_NOT_SUPPORTED_VOEMailbox VoE not supported.

◆ ec_mbx_deinit()

void ec_mbx_deinit ( ec_t pec,
osal_uint16_t  slave 
)

Deinit mailbox structure.

Parameters
[in]pecPointer to ethercat master structure, which you got from ec_open.
[in]slaveNumber of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached).

◆ ec_mbx_enqueue_head()

void ec_mbx_enqueue_head ( ec_t pec,
osal_uint16_t  slave,
pool_entry_t p_entry 
)

Enqueue mailbox message to send queue.

Parameters
[in]pecPointer to ethercat master structure, which you got from ec_open.
[in]slaveNumber of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached).
[in]p_entryEntry to enqueue to be sent via mailbox.

◆ ec_mbx_enqueue_tail()

void ec_mbx_enqueue_tail ( ec_t pec,
osal_uint16_t  slave,
pool_entry_t p_entry 
)

Enqueue mailbox message to send queue.

Parameters
[in]pecPointer to ethercat master structure, which you got from ec_open.
[in]slaveNumber of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached).
[in]p_entryEntry to enqueue to be sent via mailbox.

◆ ec_mbx_get_free_send_buffer()

int ec_mbx_get_free_send_buffer ( ec_t pec,
osal_uint16_t  slave,
pool_entry_t **  pp_entry,
osal_timer_t *  timeout 
)

Get free mailbox send buffer from slaves send message pool.

Parameters
[in]pecPointer to ethercat master structure, which you got from ec_open.
[in]slaveNumber of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached).
[out]pp_entryPointer to pool entry pointer where buffer is returned.
[in]timeoutPointer to timeout or NULL.
Returns
EC_OK on success, otherwise EC_ERROR_MAILBOX_* code.

◆ ec_mbx_init()

void ec_mbx_init ( ec_t pec,
osal_uint16_t  slave 
)

Initialize mailbox structure.

Parameters
[in]pecPointer to ethercat master structure, which you got from ec_open.
[in]slaveNumber of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached).

◆ ec_mbx_next_counter()

int ec_mbx_next_counter ( ec_t pec,
int  slave,
int *  seq_counter 
)

Get next sequence counter.

Parameters
[in]pecPointer to ethercat master structure, which you got from ec_open.
[in]slaveNumber of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached).
[in]seq_cntReturns sequence counter.
Returns
EC_OK on success.

◆ ec_mbx_sched_read()

void ec_mbx_sched_read ( ec_t pec,
osal_uint16_t  slave 
)

Trigger read of mailbox.

Parameters
[in]pecPointer to ethercat master structure, which you got from ec_open.
[in]slaveNumber of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached).