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

Reading 8- or 16-bit attributes from big-endian device returns 0 (#6166) #6685

Merged
merged 2 commits into from
May 13, 2021

Conversation

pjzander-signify
Copy link
Contributor

Problem

When reading an 8- or 16-bit attribute from a big endian device the value is 0, despite that defaults other than 0 are defined.

The defaults of these attributes are defined in a zap-file and from that a header file is generated (endpoint_config.h).
This header file contains structures that are used by the software to read cluster information and the attributes of these clusters.
The value of these attributes are stored in a union that also contains 2 pointers:
typedef union { uint8_t * ptrToDefaultValue; uint16_t defaultValue; EmberAfAttributeMinMaxValue * ptrToMinMaxValue; } EmberAfDefaultOrMinMaxAttributeValue;

A generated default value is compiled into that union using an explicit type cast to a pointer.
Example:
{ (uint8_t *) 3 } }
In a 32-bit little-endian the memory layout will be:
03 00 00 00
The 16-bit defaultValue (the first 2 bytes) will have the value 3, which is correct.

In a 32-bit big-endian system the layout will be:
00 00 00 03
The 16-bit defaultValue (the first 2 bytes) will have the value 0, which is not correct.

Summary of Changes

Redefinitions of the unions and update of the zap file.

Fixes #6166

Copy link
Contributor

@bzbarsky-apple bzbarsky-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably need to rebase on top of master to get ESP32 to pass, because there were some changes to the infrastructure there landing and then being backed out and so on...

@woody-apple
Copy link
Contributor

Probably need to rebase on top of master to get ESP32 to pass, because there were some changes to the infrastructure there landing and then being backed out and so on...

Done

@woody-apple
Copy link
Contributor

@saurabhst @andy31415 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reading 8- or 16-bit attributes from big-endian device returns 0
5 participants