libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
Loading...
Searching...
No Matches
File transfer over EtherCAT (FoE)

Data Structures

struct  ec_foe
 
struct  ec_fw_update
 firmware update More...
 

Macros

#define MAX_FILE_NAME_SIZE   512u
 file name max size
 
#define MAX_ERROR_TEXT_SIZE   512u
 error text max size
 
#define EC_FOE_OP_CODE_READ_REQUEST   0x01u
 read request
 
#define EC_FOE_OP_CODE_WRITE_REQUEST   0x02u
 write request
 
#define EC_FOE_OP_CODE_DATA_REQUEST   0x03u
 data request
 
#define EC_FOE_OP_CODE_ACK_REQUEST   0x04u
 acknowledge request
 
#define EC_FOE_OP_CODE_ERROR_REQUEST   0x05u
 error request
 
#define EC_FOE_OP_CODE_BUSY_REQUEST   0x06u
 busy request
 
#define EC_FOE_ERROR_NOT_DEFINED   0x8000u
 not defined
 
#define EC_FOE_ERROR_NOT_FOUND   0x8001u
 not found
 
#define EC_FOE_ERROR_ACCESS_DENIED   0x8002u
 access denied
 
#define EC_FOE_ERROR_DISK_FULL   0x8003u
 disk full
 
#define EC_FOE_ERROR_ILLEGAL   0x8004u
 illegal
 
#define EC_FOE_ERROR_PACKET_NUMBER_WRONG   0x8005u
 packed number wrong
 
#define EC_FOE_ERROR_ALREADY_EXISTS   0x8006u
 already exist
 
#define EC_FOE_ERROR_NO_USER   0x8007u
 no user
 
#define EC_FOE_ERROR_BOOTSTRAP_ONLY   0x8008u
 bootstrap access only
 
#define EC_FOE_ERROR_NOT_BOOTSTRAP   0x8009u
 not in bootstrap
 
#define EC_FOE_ERROR_NO_RIGHTS   0x800Au
 no access rights
 
#define EC_FOE_ERROR_PROGRAM_ERROR   0x800Bu
 program error
 
#define EFW_CMD_IGNORE   0u
 command ignore
 
#define EFW_CMD_MEMORY_TRANSFER   1u
 command memory transfer
 
#define EFW_CMD_WRCODE   2u
 command wrcode
 
#define EFW_CMD_CHK_DEVID   3u
 command check device id
 
#define EFW_CMD_CHK_DEVICEID   3u
 command check device id
 
#define EFW_CMD_CHKSUM   4u
 command checksum
 
#define EFW_CMD_WRCODECHKSUM   5u
 command wr code checksum
 
#define EFW_CMD_SET_DEVID   6u
 command set device id
 
#define EFW_CMD_CHKSUMCHKSUM   6u
 command checksum checksum
 
#define EFW_CMD_BOOTCHKSUM   7u
 command boot checksum
 
#define EFW_CMD_SET_EEPROM   10u
 command set eeprom
 

Typedefs

typedef struct ec_foe ec_foe_t
 
typedef struct ec_fw_update ec_fw_update_t
 firmware update
 

Functions

void ec_foe_init (ec_t *pec, osal_uint16_t slave)
 initialize FoE structure
 
void ec_foe_deinit (ec_t *pec, osal_uint16_t slave)
 deinitialize FoE structure
 
void ec_foe_enqueue (ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry)
 Enqueue FoE message received from slave.
 
int ec_foe_read (ec_t *pec, osal_uint16_t slave, osal_uint32_t password, osal_char_t file_name[MAX_FILE_NAME_SIZE], osal_uint8_t **file_data, osal_size_t *file_data_len, const osal_char_t **error_message)
 Read file over FoE.
 
int ec_foe_write (ec_t *pec, osal_uint16_t slave, osal_uint32_t password, osal_char_t file_name[MAX_FILE_NAME_SIZE], osal_uint8_t *file_data, osal_size_t file_data_len, const osal_char_t **error_message)
 Write file over FoE.
 

Detailed Description

This modules contains EtherCAT FoE funcitons.

Function Documentation

◆ ec_foe_deinit()

void ec_foe_deinit ( ec_t pec,
osal_uint16_t  slave 
)

deinitialize FoE 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_foe_enqueue()

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

Enqueue FoE message received from 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]p_entryPointer to pool entry containing received mailbox message from slave.

◆ ec_foe_init()

void ec_foe_init ( ec_t pec,
osal_uint16_t  slave 
)

initialize FoE 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_foe_read()

int ec_foe_read ( ec_t pec,
osal_uint16_t  slave,
osal_uint32_t  password,
osal_char_t  file_name[MAX_FILE_NAME_SIZE],
osal_uint8_t **  file_data,
osal_size_t *  file_data_len,
const osal_char_t **  error_message 
)

Read file over FoE.

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]passwordFoE password for file to read.
[in]file_nameFile name on EtherCAT slave to read from.
[out]file_dataThis will be allocated by the ec_foe_read call and return the content of the EtherCAT slaves file. The caller must ensure to free the allocated memory.
[out]file_data_lenThe length of the file and the allocated buffer file_data
[out]error_messageIn error cases this will return the error message set by the EtherCAT slave. If any error has occured, this has to be freed by the caller.
Return values
EC_OKOn success.
EC_ERROR_MAILBOX_NOT_SUPPORTED_FOEFoE not supported by slave.
EC_ERROR_MAILBOX_OUT_OF_SEND_BUFFERSNo more mailbox send buffers left.
EC_ERROR_MAILBOX_FOE_AGAINTry again.
EC_ERROR_MAILBOX_FOE_ERROR_REQError on FoE request.

◆ ec_foe_write()

int ec_foe_write ( ec_t pec,
osal_uint16_t  slave,
osal_uint32_t  password,
osal_char_t  file_name[MAX_FILE_NAME_SIZE],
osal_uint8_t *  file_data,
osal_size_t  file_data_len,
const osal_char_t **  error_message 
)

Write file over FoE.

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]passwordFoE password for file to write.
[in]file_nameFile name on EtherCAT slave to write to.
[out]file_dataThe caller has to provide the data which will be written as content of the file to the EtherCAT slave.
[out]file_data_lenThe length of the file_data.
[out]error_messageIn error cases this will return the error message set by the EtherCAT slave. If any error has occured, this has to be freed by the caller.
Return values
EC_OKOn success.
EC_ERROR_MAILBOX_NOT_SUPPORTED_FOEFoE not supported by slave.
EC_ERROR_MAILBOX_OUT_OF_SEND_BUFFERSNo more mailbox send buffers left.
EC_ERROR_MAILBOX_FOE_AGAINTry again.
EC_ERROR_MAILBOX_FOE_ERROR_REQError on FoE request.
EC_ERROR_MAILBOX_FOE_NO_ACKNo Ack on segment write.