Skip to content

Commit

Permalink
add a flag to just download everything
Browse files Browse the repository at this point in the history
  • Loading branch information
corruptbear committed Jun 23, 2024
1 parent 318e105 commit 11dbc02
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion software/firmware/src/peripherals/src/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ void storage_retrieve_experiment_details(experiment_details_t *details)

void storage_begin_reading(uint32_t starting_timestamp)
{
#ifdef _DOWNLOAD_EVERYTHING
reading_page = (starting_page + 1) % BBM_LUT_BASE_ADDRESS;
is_reading = in_maintenance_mode;
#else
// Update the data reading details
experiment_details_t details;
storage_retrieve_experiment_details(&details);
Expand Down Expand Up @@ -629,6 +633,7 @@ void storage_begin_reading(uint32_t starting_timestamp)
if (!found_valid_timestamp)
reading_page = (reading_page + 1) % BBM_LUT_BASE_ADDRESS;
}
#endif
}

void storage_end_reading(void)
Expand Down Expand Up @@ -657,7 +662,9 @@ uint32_t storage_retrieve_num_data_chunks(uint32_t ending_timestamp)
// Ensure that we are in reading mode
if (!is_reading)
return 0;

#ifdef _DOWNLOAD_EVERYTHING
return (starting_page < current_page) ? (current_page - starting_page) : (BBM_LUT_BASE_ADDRESS - starting_page + current_page);
#else
if (ending_timestamp)
{
// Convert the ending timestamp to the appropriate format
Expand Down Expand Up @@ -697,6 +704,7 @@ uint32_t storage_retrieve_num_data_chunks(uint32_t ending_timestamp)
else
last_reading_page = current_page;
return (reading_page <= last_reading_page) ? (1 + last_reading_page - reading_page) : (BBM_LUT_BASE_ADDRESS - reading_page + last_reading_page + 1);
#endif
}

uint32_t storage_retrieve_next_data_chunk(uint8_t *buffer)
Expand All @@ -707,6 +715,15 @@ uint32_t storage_retrieve_next_data_chunk(uint8_t *buffer)

// Determine if a full page of memory is available to read
uint32_t num_bytes_retrieved = 0;
#ifdef _DOWNLOAD_EVERYTHING
if (reading_page == current_page)
{
// Return the valid available bytes
memcpy(buffer, cache, cache_index);
num_bytes_retrieved = cache_index;
is_reading = false;
}
#else
if (reading_page == last_reading_page)
{
if (reading_page == current_page)
Expand All @@ -722,6 +739,7 @@ uint32_t storage_retrieve_next_data_chunk(uint8_t *buffer)
}
is_reading = false;
}
#endif
else
{
// Read the next page of memory and update the reading metadata
Expand Down
2 changes: 1 addition & 1 deletion software/firmware/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ full: $(CONFIG) $(CONFIG)/main.o $(CONFIG)/$$(TARGET).bin program

full_exp: TARGET = TestFullExp
full_exp: SRC += main.c
full_exp: CFLAGS += -D__USE_FREERTOS__ -DNONBLOCKING=1 -D_TEST_IMU_DATA -D_REMOTE_MODE_SWITCH_ENABLED
full_exp: CFLAGS += -D__USE_FREERTOS__ -DNONBLOCKING=1 -D_TEST_IMU_DATA -D_DOWNLOAD_EVERYTHING -D_REMOTE_MODE_SWITCH_ENABLED
full_exp: $(CONFIG) $(CONFIG)/main.o $(CONFIG)/$$(TARGET).bin program

imu: TARGET = TestIMU
Expand Down

0 comments on commit 11dbc02

Please sign in to comment.