Skip to content

Commit

Permalink
download everything with -D_TEST_IMU_DATA
Browse files Browse the repository at this point in the history
  • Loading branch information
corruptbear committed Jul 24, 2024
1 parent f9058c0 commit 9a883db
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 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 _TEST_IMU_DATA
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 @@ -640,6 +644,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 @@ -668,6 +673,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 _TEST_IMU_DATA
return (starting_page < current_page) ? (current_page - starting_page) : (BBM_LUT_BASE_ADDRESS - starting_page + current_page);
#else

log_data_size = 0;
if (ending_timestamp)
Expand Down Expand Up @@ -730,6 +738,7 @@ uint32_t storage_retrieve_num_data_chunks(uint32_t ending_timestamp)
}
}
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_num_data_bytes(void)
Expand All @@ -746,6 +755,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 _TEST_IMU_DATA
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 @@ -761,6 +779,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
4 changes: 4 additions & 0 deletions software/firmware/src/tasks/app_task_maintenance.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ static void handle_notification(app_notification_t notification)
storage_begin_reading(download_start_timestamp);
storage_retrieve_experiment_details(&details);
uint32_t total_data_chunks = storage_retrieve_num_data_chunks(download_end_timestamp);
#ifdef _TEST_IMU_DATA
uint32_t total_data_length = total_data_chunks * MEMORY_NUM_DATA_BYTES_PER_PAGE;
#else
uint32_t total_data_length = storage_retrieve_num_data_bytes();
#endif
transmit_log_data(&total_data_length, sizeof(total_data_length));
transmit_log_data(&details, sizeof(details));

Expand Down
4 changes: 4 additions & 0 deletions software/firmware/src/tasks/app_task_ranging.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ static void handle_notification(app_notification_t notification)
storage_begin_reading(download_start_timestamp);
storage_retrieve_experiment_details(&details);
uint32_t total_data_chunks = storage_retrieve_num_data_chunks(download_end_timestamp);
#ifdef _TEST_IMU_DATA
uint32_t total_data_length = total_data_chunks * MEMORY_NUM_DATA_BYTES_PER_PAGE;
#else
uint32_t total_data_length = storage_retrieve_num_data_bytes();
#endif
transmit_log_data(&total_data_length, sizeof(total_data_length));
transmit_log_data(&details, sizeof(details));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ void continueSendingLogData(dmConnId_t connId, uint16_t max_length, bool repeat)
storage_begin_reading(download_start_timestamp);
storage_retrieve_experiment_details(&details);
total_data_chunks = storage_retrieve_num_data_chunks(download_end_timestamp);
#ifdef _TEST_IMU_DATA
total_data_length = total_data_chunks * MEMORY_NUM_DATA_BYTES_PER_PAGE;
#else
total_data_length = storage_retrieve_num_data_bytes();
#endif
memcpy(transmit_buffer, &total_data_length, sizeof(total_data_length));
memcpy(transmit_buffer + sizeof(total_data_length), &details, sizeof(details));
AttsHandleValueInd(connId, MAINTENANCE_RESULT_HANDLE, sizeof(total_data_length) + sizeof(experiment_details_t), transmit_buffer);
Expand Down

0 comments on commit 9a883db

Please sign in to comment.