Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected some template functions that manipulate memory and words in namespace embot::core::binary::word #100

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

marcoaccame
Copy link
Contributor

@marcoaccame marcoaccame commented Oct 29, 2024

This PR corrects some template functions that are used by the amcfoc.mot board to move words (uint8_t, uint16_t, uint32_t uint64_t and their signed counterpart) to and from memory.

The functions can be useful for instance for placing into memory some words in little endian (or big endian) as in following code.

std::uint8_t dd[6] = {0};
auto e = embot::core::binary::word::Endianess::Little; // or embot::core::binary::word::Endianess::Big ...

int32_t value32 = 0x12345678;
embot::core::binary::word::load2memory<int32_t>(value32, &dd[0], e);
// now dd[] is filled w/ 0x78, 0x56, 0x34, 0x12, 0x00, 0x00

uint16_t value16 = 0xAABB;
embot::core::binary::word::load2memory<uint16_t>(value16, &dd[4]); 
// as default is embot::core::binary::word::Endianess::Little, 
// now dd[] is filled w/ 0x78, 0x56, 0x34, 0x12, 0xBB, 0xAA

Code Listing. Example of use of template function embot::core::binary::word::load2memory()

The change will affect only a future PR related to the amcfoc.mot application and nothing else, so it can be safely merged. Also, no change of versioning of the repo is required.

@marcoaccame marcoaccame merged commit 56e7353 into robotology:devel Oct 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant