Skip to content

Commit 7dc0ccf

Browse files
1 parent 52be2c2 commit 7dc0ccf

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

ethercat_generic_plugins/ethercat_generic_slave/src/generic_ec_slave.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ size_t type2bytes(std::string type)
2525
return 1;
2626
} else if (type == "int16" || type == "uint16") {
2727
return 2;
28-
} else if (type == "int32" || type == "uint32") {
28+
} else if (type == "int32" || type == "uint32" || type == "float" || type == "real32") {
2929
return 4;
3030
} else if (type == "int64" || type == "uint64") {
3131
return 8;

ethercat_interface/include/ethercat_interface/ec_pdo_channel_manager.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class EcPdoChannelManager
6565
last_value = static_cast<double>(EC_READ_U64(domain_address));
6666
} else if (data_type == "int64") {
6767
last_value = static_cast<double>(EC_READ_S64(domain_address));
68+
} else if (data_type == "real32" || data_type == "float") {
69+
last_value = static_cast<double>(EC_READ_REAL(domain_address));
6870
} else if (data_type == "bool") {
6971
last_value = (EC_READ_U8(domain_address) & data_mask) ? 1 : 0;
7072
} else {
@@ -92,6 +94,8 @@ class EcPdoChannelManager
9294
EC_WRITE_U64(domain_address, static_cast<uint64_t>(value));
9395
} else if (data_type == "int64") {
9496
EC_WRITE_S64(domain_address, static_cast<int64_t>(value));
97+
} else if (data_type == "real32" || data_type == "float") {
98+
EC_WRITE_REAL(domain_address, static_cast<float>(value));
9599
} else {
96100
buffer_ = EC_READ_U8(domain_address);
97101
if (popcount(data_mask) == 1) {

ethercat_interface/include/ethercat_interface/ec_sdo_manager.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class SdoConfigEntry
5151
EC_WRITE_U64(buffer, static_cast<uint64_t>(data));
5252
} else if (data_type == "int64") {
5353
EC_WRITE_S64(buffer, static_cast<int64_t>(data));
54+
} else if (data_type == "real32" || data_type == "float") {
55+
EC_WRITE_REAL(buffer, static_cast<float>(data));
5456
}
5557
}
5658

@@ -105,7 +107,7 @@ class SdoConfigEntry
105107
return 1;
106108
} else if (type == "int16" || type == "uint16") {
107109
return 2;
108-
} else if (type == "int32" || type == "uint32") {
110+
} else if (type == "int32" || type == "uint32" || type == "float" || type == "real32") {
109111
return 4;
110112
} else if (type == "int64" || type == "uint64") {
111113
return 8;

0 commit comments

Comments
 (0)