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

Fix various bugs in eeprom handling #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

linuxianer99
Copy link
Member

@linuxianer99 linuxianer99 commented Mar 8, 2022

  • Alignment of struct using packed attribute to fix sizeof() return value
  • Exclude checksum itself from checksum calculation

Fixes #45

@linuxianer99 linuxianer99 requested a review from kedder March 8, 2022 07:27
@linuxianer99 linuxianer99 marked this pull request as ready for review March 8, 2022 07:31
24c16.h Outdated
@@ -8,7 +8,7 @@ typedef struct {
unsigned char address;
} t_24c16;

typedef struct {
typedef struct __attribute__((packed)){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a good idea. This moves the float field to a misaligned offset, and may crash with SIGBUS on some CPUs.

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you suggest as alternative ?? Add a stuff variable instead ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to define the float inside the struct as the first item? This will reduce the padding to 1 byte. Then we can add one byte to the serial number to fill that padding byte.

Add padding for struct alignment
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.

Sensorcal not working
3 participants