-
Notifications
You must be signed in to change notification settings - Fork 0
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
Report flash memory module capacity in Mebibytes #197
base: main
Are you sure you want to change the base?
Conversation
Implements #150 Would you mind adding example outputs of success and failure in this PR as a code block? Or I can if I get to it before you. Would just be helpful to have a record of what it looks like! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks for doing this! Tiny tweaks.
Take a look at the relevant docs/
file to see how to use LOG_message
. Would be best to start using it as much as possible for new code
@@ -506,8 +509,18 @@ FLASH_error_enum_t FLASH_is_reachable(SPI_HandleTypeDef *hspi, uint8_t chip_numb | |||
are_bytes_correct = 0; | |||
} | |||
|
|||
// Extract memory capacity | |||
uint32_t capacity_mib = (rx_buffer[2] * 512) / 32; // Convert to Mebibytes (MiB) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use const keyword. Avoid unnecessary math (multiply-then-divide). Use bitshifts for power-of-2 operations.
Ideally, include where you got this conversion math from.
Recommend making the variable name include MiB
, as Mib
/mib
means mebibits (one eigth of a mebibyte)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, initially I had it simpler but just so the logic was clear I left the conversion math there, can simplify it and move it over to the comment!
DEBUG_uart_print_array_hex(rx_buffer, 5); | ||
DEBUG_uart_print_str("\n"); | ||
DEBUG_uart_print_str("\t"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, use the LOG_message
function. Avoid using \t
control character; not certain how it's going to behave with the ground station software.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick Question! Did we want this log to be part of LOG_SEVERITY_DEBUG or LOG_SEVERITY_NORMAL, since these messages were not setup to be part of the telecommand response buffer? Currently the is_reachable telecommand only prints the chip# availability and error codes if any. If the capacities are important we can have them printed part of the response itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably NORMAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks solid! Just a tiny detail with the logs severity (log level) first though
@@ -290,7 +301,10 @@ FLASH_error_enum_t FLASH_erase(SPI_HandleTypeDef *hspi, uint8_t chip_number, lfs | |||
|
|||
if ((status_reg_buffer[0] & FLASH_SR1_ERASE_ERROR_MASK) > 0) { | |||
// Flash module returned "erase error" via the status register. | |||
DEBUG_uart_print_str("Flash erase error\n"); | |||
LOG_message( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't errors be reported as a LOG_SEVERITY_WARNING
or ERROR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Catch! Must have missed it!
…being logged * timeout logs set to LOG_SEVERITY_WARNING * error logs respectively assigned LOG_SEVERITY_ERROR
Are you sure the output is right? You're showing a size of I also see this comment in the code: I just tacked on a small commit; make sure you pull it if you make more changes. |
* New chip only returns two bytes: Manufacturer ID & Device ID
@vaibhavkpr Update on this PR? Been open for a while. |
@NuclearTea I took a break off this issue as I didn't have a memory module to test this with, but I was able to pick one up last week. Once the other PR is complete, I was going to try testing the new memory module and see what we can do to find the capacity off it. |
Implements #150 - Reports memory module's sizes as a 'human-readable' string (as Mebibytes MiB). Also updates to utilize
LOG_message
instead ofDEBUG_uart_print
.Success Output:
Failure Output: