Skip to content

Commit

Permalink
Added real32 (Beckhoff float) https://infosys.beckhoff.com/english.ph…
Browse files Browse the repository at this point in the history
  • Loading branch information
JensVanhooydonck authored Jun 25, 2024
1 parent 52be2c2 commit 7dc0ccf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ size_t type2bytes(std::string type)
return 1;
} else if (type == "int16" || type == "uint16") {
return 2;
} else if (type == "int32" || type == "uint32") {
} else if (type == "int32" || type == "uint32" || type == "float" || type == "real32") {
return 4;
} else if (type == "int64" || type == "uint64") {
return 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class EcPdoChannelManager
last_value = static_cast<double>(EC_READ_U64(domain_address));
} else if (data_type == "int64") {
last_value = static_cast<double>(EC_READ_S64(domain_address));
} else if (data_type == "real32" || data_type == "float") {
last_value = static_cast<double>(EC_READ_REAL(domain_address));
} else if (data_type == "bool") {
last_value = (EC_READ_U8(domain_address) & data_mask) ? 1 : 0;
} else {
Expand Down Expand Up @@ -92,6 +94,8 @@ class EcPdoChannelManager
EC_WRITE_U64(domain_address, static_cast<uint64_t>(value));
} else if (data_type == "int64") {
EC_WRITE_S64(domain_address, static_cast<int64_t>(value));
} else if (data_type == "real32" || data_type == "float") {
EC_WRITE_REAL(domain_address, static_cast<float>(value));
} else {
buffer_ = EC_READ_U8(domain_address);
if (popcount(data_mask) == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class SdoConfigEntry
EC_WRITE_U64(buffer, static_cast<uint64_t>(data));
} else if (data_type == "int64") {
EC_WRITE_S64(buffer, static_cast<int64_t>(data));
} else if (data_type == "real32" || data_type == "float") {
EC_WRITE_REAL(buffer, static_cast<float>(data));
}
}

Expand Down Expand Up @@ -105,7 +107,7 @@ class SdoConfigEntry
return 1;
} else if (type == "int16" || type == "uint16") {
return 2;
} else if (type == "int32" || type == "uint32") {
} else if (type == "int32" || type == "uint32" || type == "float" || type == "real32") {
return 4;
} else if (type == "int64" || type == "uint64") {
return 8;
Expand Down

0 comments on commit 7dc0ccf

Please sign in to comment.