Use expedited transfer type for Sdos <= 4 byte.
--- a/NEWS Mon Jul 28 14:59:22 2008 +0000
+++ b/NEWS Tue Jul 29 09:04:55 2008 +0000
@@ -97,16 +97,16 @@
queried via the ecrt_domain_state() and ecrt_slave_config_state() functions.
* Added support for slaves that do not support the LRW datagram type. Separate
domains have to be used for inputs and output.
-* Allow gaps in PDO mapping read from CoE.
-* Fixed bug in CoE code.
-* Added some timeouts for CoE transfers.
-* Ansynchronous handling of CoE Emergency requests.
+* CoE implementation:
+ - Use expedites transfer type for Sdos <= 4 byte (thanks to J. Mohre).
+ - Allow gaps in Pdo mapping (thanks to R. Roesch).
+ - Added some transfer timeouts.
+ - Ansynchronous handling of Emergency requests.
+ - Bugfixes.
* Sync managers are disabled, if the size is zero.
-* Improved handling of large EEPROM contents.
* Renamed ec_master module parameters main and backup to main_devices and
backup_devices to avoid warnings of some compilers.
-* List end evaluate CoE detail flags from general category, list
- 'Flags' from general category in slave info file.
+* List end evaluate CoE detail flags from general category.
* Added MODPROBE_FLAGS variable in start script and sysconfig file.
* Implemented missing datagram types.
* Changed all occurrences of 'EEPROM' to 'SII'
--- a/master/fsm_coe.c Mon Jul 28 14:59:22 2008 +0000
+++ b/master/fsm_coe.c Tue Jul 29 09:04:55 2008 +0000
@@ -1053,6 +1053,7 @@
ec_slave_t *slave = fsm->slave;
ec_sdo_request_t *request = fsm->request;
uint8_t *data;
+ uint8_t size;
if (fsm->slave->master->debug_level) {
EC_DBG("Downloading Sdo 0x%04X:%02X to slave %u.\n",
@@ -1065,31 +1066,54 @@
fsm->state = ec_fsm_coe_error;
return;
}
-
- if (slave->sii.rx_mailbox_size < 6 + 10 + request->data_size) {
- EC_ERR("Sdo fragmenting not supported yet!\n");
- fsm->state = ec_fsm_coe_error;
- return;
- }
-
- if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03,
- request->data_size + 10))) {
- fsm->state = ec_fsm_coe_error;
- return;
- }
-
- EC_WRITE_U16(data, 0x2 << 12); // Sdo request
- EC_WRITE_U8 (data + 2, (0x1 // size specified
- | 0x1 << 5)); // Download request
- EC_WRITE_U16(data + 3, request->index);
- EC_WRITE_U8 (data + 5, request->subindex);
- EC_WRITE_U32(data + 6, request->data_size);
- memcpy(data + 10, request->data, request->data_size);
-
- if (slave->master->debug_level) {
- EC_DBG("Download request:\n");
- ec_print_data(data, 10 + request->data_size);
- }
+
+ if (request->data_size <= 4) { // use expedited transfer type
+ if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 10))) {
+ fsm->state = ec_fsm_coe_error;
+ return;
+ }
+
+ size = 4 - request->data_size;
+
+ EC_WRITE_U16(data, 0x2 << 12); // Sdo request
+ EC_WRITE_U8 (data + 2, (0x3 // size specified, expedited
+ | size << 2
+ | 0x1 << 5)); // Download request
+ EC_WRITE_U16(data + 3, request->index);
+ EC_WRITE_U8 (data + 5, request->subindex);
+ memcpy(data + 6, request->data, request->data_size);
+
+ if (slave->master->debug_level) {
+ EC_DBG("Expedited download request:\n");
+ ec_print_data(data, 10 + request->data_size);
+ }
+ }
+ else { // request->data_size > 4, use normal transfer type
+ if (slave->sii.rx_mailbox_size < 6 + 10 + request->data_size) {
+ EC_ERR("Sdo fragmenting not supported yet!\n");
+ fsm->state = ec_fsm_coe_error;
+ return;
+ }
+
+ if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03,
+ request->data_size + 10))) {
+ fsm->state = ec_fsm_coe_error;
+ return;
+ }
+
+ EC_WRITE_U16(data, 0x2 << 12); // Sdo request
+ EC_WRITE_U8 (data + 2, (0x1 // size indicator, normal
+ | 0x1 << 5)); // Download request
+ EC_WRITE_U16(data + 3, request->index);
+ EC_WRITE_U8 (data + 5, request->subindex);
+ EC_WRITE_U32(data + 6, request->data_size);
+ memcpy(data + 10, request->data, request->data_size);
+
+ if (slave->master->debug_level) {
+ EC_DBG("Normal download request:\n");
+ ec_print_data(data, 10 + request->data_size);
+ }
+ }
fsm->request->jiffies_sent = jiffies;
fsm->retries = EC_FSM_RETRIES;