diff --git a/master/device.c b/master/device.c index 948b0f598a1c61126f8cff3edd4999434e4dabd7..1a3377c5c625dc654ecadea0757b61202337f78b 100644 --- a/master/device.c +++ b/master/device.c @@ -61,7 +61,7 @@ int ec_device_init(ec_device_t *device, /**< EtherCAT device */ device->open = 0; device->link_state = 0; // down - if (!(device->tx_skb = dev_alloc_skb(ETH_HLEN + EC_MAX_FRAME_SIZE))) { + if (!(device->tx_skb = dev_alloc_skb(ETH_FRAME_LEN))) { EC_ERR("Error allocating device socket buffer!\n"); return -1; } diff --git a/master/globals.h b/master/globals.h index 420d7aa0b4fca7686d6e64d992baa12a832a1f28..37c12b8bb7453a34e565b26c5e6380cb618376c2 100644 --- a/master/globals.h +++ b/master/globals.h @@ -53,12 +53,6 @@ * EtherCAT protocol *****************************************************************************/ -/** maximum size of an EtherCAT frame (without header and CRC) */ -#define EC_MAX_FRAME_SIZE 1500 - -/** minimum size of an EtherCAT frame (without header and CRC) */ -#define EC_MIN_FRAME_SIZE 46 - /** size of an EtherCAT frame header */ #define EC_FRAME_HEADER_SIZE 2 @@ -75,7 +69,7 @@ #define EC_FMMU_SIZE 16 /** resulting maximum data size of a single command in a frame */ -#define EC_MAX_DATA_SIZE (EC_MAX_FRAME_SIZE - EC_FRAME_HEADER_SIZE \ +#define EC_MAX_DATA_SIZE (ETH_DATA_LEN - EC_FRAME_HEADER_SIZE \ - EC_COMMAND_HEADER_SIZE - EC_COMMAND_FOOTER_SIZE) /*****************************************************************************/ diff --git a/master/master.c b/master/master.c index d374048058ce52210b8c3ab718506ee93370268e..f3b24173558382d6d5ea392262797b772dabde6b 100644 --- a/master/master.c +++ b/master/master.c @@ -287,7 +287,7 @@ void ec_master_send_commands(ec_master_t *master /**< EtherCAT master */) // does the current command fit in the frame? command_size = EC_COMMAND_HEADER_SIZE + command->data_size + EC_COMMAND_FOOTER_SIZE; - if (cur_data - frame_data + command_size > EC_MAX_FRAME_SIZE) { + if (cur_data - frame_data + command_size > ETH_DATA_LEN) { more_commands_waiting = 1; break; } @@ -332,7 +332,7 @@ void ec_master_send_commands(ec_master_t *master /**< EtherCAT master */) - EC_FRAME_HEADER_SIZE) & 0x7FF) | 0x1000); // pad frame - while (cur_data - frame_data < EC_MIN_FRAME_SIZE) + while (cur_data - frame_data < ETH_ZLEN - ETH_HLEN) EC_WRITE_U8(cur_data++, 0x00); if (unlikely(master->debug_level > 0))