Skip to content

mBed online compiler fix + struct example #2

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

Merged
merged 1 commit into from
Jul 16, 2017
Merged

mBed online compiler fix + struct example #2

merged 1 commit into from
Jul 16, 2017

Conversation

pilotak
Copy link
Contributor

@pilotak pilotak commented May 7, 2017

No description provided.

@pilotak pilotak changed the title mBed online compiler fix mBed online compiler fix + struct example May 7, 2017
README.md Outdated
unsigned int setting_block_size = ceil(sizeof(setting)/(double)BLOCK_SIZE)*BLOCK_SIZE;

// Temporary buffer
char buffer[setting_block_size];
Copy link
Contributor

Choose a reason for hiding this comment

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

My only qualm, is that this should probably be dynamically allocated. With BLOCK_SIZE == 32 this is fine, but if we reach a point where we adopt NAND flash, their block sizes can get up into the 4096+ byte range, which runs the risk of stack overflow.

A bit of a nit, but is probably important on the example we show.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, it should be. But as this is a eeprom branch of block memory library and size of eeprom needs to be set by user, it should be fine.

Copy link
Contributor

@geky geky left a comment

Choose a reason for hiding this comment

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

This is a good example to have!

Just a bit of feedback, I'm being a bit picky since this is an example of the front of the repo.

README.md Outdated
}
else {
printf("Error when reading\n");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're changing this file, this should have a bit of a style update:

+ if(i2cee.read(buffer, 0, setting_block_size ) == 0){ // get data into buffer
- if (i2cee.read(buffer, 0, setting_block_size) == 0) { // get data into buffer
      // Convert what we read into struct
      memcpy(&tmp, buffer, sizeof(tmp)); // copy only size of struct not setting_block_size
      printf("\nTemporary struct version: %u, name: %s\n", tmp.version, tmp.name); 
+ } else {
- }
- else {
      printf("Error when reading\n");
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm fine with that 👍

@geky geky merged commit 286a260 into ARMmbed:master Jul 16, 2017
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.

2 participants