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

Logging last 30 seconds of data using file ping pong buffer #13

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

JustinDMorrison
Copy link

Summary

  • Check for the previous max boot number used, if there is a previous use boot number + 1 to not overwrite data
  • Create first logging file and set it to active file pointer
  • Store a base time based on the last modification time of the first logging file (same as creation time)
  • Enter infinite loop

Idle/AirborneState

  • Get current time and check if the difference between the 2 times is greater than 30 seconds
    • If difference greater than 30 seconds, create a second logging file and set it as the active file pointer
      • Set base time as the the current time
  • Write data to the active file

Landed State

  • Open extraction file
  • Copy over data from active file to extraction file
  • Set flight state to Idle
  • Teardown (close all files)
  • Exit thread

… of logging data as well as not overwriting existing data by checking file names. A lot of changes were added as I did a lot of work before commiting.
…dded timespec_diff function to find difference in time between two timespec structs. I am using clock_gettime() to get the current system time to compare to time of the last modification.
…the extraction file. Changed the way flight and extraction log file names are constructed. Fixed some typos in variable names. Added teardown function.
…ve logic in the IDLE state that is also done in the AIRBORNE state. Will remove it if not needed
…ting file descriptor for active storage file before calling fstat on it. Changed some variable names for better readability and commented out some code."
@JustinDMorrison
Copy link
Author

There are a few things left to do or check, indicated by TODOs in the code. I also think error handling could be improved a bit, right now it's mostly just printing if the debug option is defined.

@linguini1
Copy link
Contributor

Can you resolve the merge conflicts and work with @AngusJull to test this on Josh?

}
}

int switch_active_log_file(FILE **active_storage_file, FILE **storage_file_1, FILE **storage_file_2, char **flight_filename2)
Copy link
Contributor

Choose a reason for hiding this comment

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

I want to guess there's a way to work in a more general way to write this func where you just pass active_storage_file and alternate_storage_file (or whatever name you want). Then if the alternate storage file is NULL open it. Then if we ever want to change how the rest of our code works this has a better chance of still working as needed

@AngusJull
Copy link
Contributor

Looking good! Logger is getting pretty big now so if you see blocks of code with a singular purpose you could potentially make them into functions. Like if we factored things out enough, the high-level overview would kind of be spelled out through the names of the functions we're calling in logger's body.

We can give it a try on Josh, but I forget if you had the simulator set up. If not, we could try running the code on that and see if the buffers fill up and overwrites happen as expected. We can even use GDB to check when the ping pong buffers get switched to verify it happens when we expect it to. So far in my testing I've found the simulator to be accurate to NuttX on Josh so if it works on there, we can be confident it'll do the same on the real system.

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.

3 participants