|
Avionics
Core avionics package for CURE flight computers
|
SPI flash implementation of IDataSaver with timestamp compression. More...
#include <DataSaverSPI.h>


Public Member Functions | |
| DataSaverSPI (uint16_t timestampInterval_ms, Adafruit_SPIFlash *flash) | |
| Construct a new DataSaverSPI object. | |
| int | saveDataPoint (const DataPoint &dataPoint, uint8_t name) override |
| Saves a DataPoint to SPI flash. | |
| int | saveTimestamp (uint32_t timestamp_ms) |
| Persist a bare timestamp entry to flash. | |
| virtual bool | begin () override |
| Initialize the flash chip and metadata. | |
| bool | isPostLaunchMode () |
| Returns whether the metadata from the flash chip indicates that it contains post-launch data that hasn't been dumped yet. Call clearPostLaunchMode() to clear this flag. once you are confident that you have the data you want dumped to a more permanent storage or another machine. | |
| void | clearPostLaunchMode () |
| Clears the post-launch mode flag on the flash chip **WARNING: This will allow the data to be overwritten Only call this after you have dumped the data to a more permanent storage or another machine. | |
| void | launchDetected (uint32_t launchTimestamp_ms) |
| Call this when launch is detected to set the post-launch flag and prevent any data from being overwritten until the flag is cleared. All data written from this point on is "post-launch" data which is sacred and should not be overwritten until it has been dumped. | |
| void | dumpData (Stream &serial, bool ignoreEmptyPages) |
| Stream all recorded data to a serial connection. | |
| void | clearInternalState () |
| Reset in-memory pointers without erasing flash contents. | |
| void | eraseAllData () |
| Erase the entire flash chip to start fresh. | |
| uint32_t | getLastTimestamp () const |
| Returns the last timestamp that was actually written to flash. | |
| DataPoint | getLastDataPoint () const |
| Returns the last DataPoint that was written (not necessarily including timestamp, just the data chunk). | |
| uint32_t | getLaunchWriteAddress () const |
| Returns the launch-protected address computed during launch detection. | |
| uint32_t | getNextWriteAddress () const |
| Returns the next flash address where a full page will be written. | |
| void | resetTimestamp () |
| Resets the timestamp to 0. Can be used to start a new flight during runtime. Useful for testing. | |
| bool | quickGetPostLaunchMode () |
| Returns whether the flash chip is in post-launch mode without updating the post-launch mode flag or reading from flash. | |
| size_t | getBufferIndex () const |
| Returns the current buffer index Useful for testing. | |
| uint32_t | getBufferFlushes () const |
| Returns the current buffer flush count Useful for testing. | |
| bool | getIsChipFullDueToPostLaunchProtection () const |
| Returns whether writes have been stopped by post-launch protection. | |
| bool | getRebootedInPostLaunchMode () const |
| Returns whether startup detected existing post-launch mode metadata. | |
| Public Member Functions inherited from IDataSaver | |
| virtual | ~IDataSaver ()=default |
| virtual int | saveDataPoint (float data, uint32_t timestamp_ms, uint8_t name) final |
| Convenience overload to construct and save a data point. | |
Static Public Attributes | |
| static constexpr size_t | kBufferSize_bytes = 256 |
SPI flash implementation of IDataSaver with timestamp compression.
Definition at line 40 of file DataSaverSPI.h.
| DataSaverSPI::DataSaverSPI | ( | uint16_t | timestampInterval_ms, |
| Adafruit_SPIFlash * | flash ) |
Construct a new DataSaverSPI object.
| timestampInterval_ms | Interval in ms at which timestamps are stored |
| flash | Pointer to an initialized Adafruit_SPIFlash object |
Definition at line 7 of file DataSaverSPI.cpp.
|
overridevirtual |
Initialize the flash chip and metadata.
Reimplemented from IDataSaver.
Definition at line 172 of file DataSaverSPI.cpp.
| void DataSaverSPI::clearInternalState | ( | ) |
Reset in-memory pointers without erasing flash contents.
Definition at line 293 of file DataSaverSPI.cpp.
|
virtual |
Clears the post-launch mode flag on the flash chip **WARNING: This will allow the data to be overwritten Only call this after you have dumped the data to a more permanent storage or another machine.
Reimplemented from IDataSaver.
Definition at line 197 of file DataSaverSPI.cpp.
| void DataSaverSPI::dumpData | ( | Stream & | serial, |
| bool | ignoreEmptyPages ) |
Stream all recorded data to a serial connection.
| serial | Output stream. |
| ignoreEmptyPages | Skip pages that appear unwritten. |
Definition at line 206 of file DataSaverSPI.cpp.
| void DataSaverSPI::eraseAllData | ( | ) |
Erase the entire flash chip to start fresh.
Definition at line 306 of file DataSaverSPI.cpp.
|
inline |
Returns the current buffer flush count Useful for testing.
Definition at line 267 of file DataSaverSPI.h.
|
inline |
Returns the current buffer index Useful for testing.
Definition at line 258 of file DataSaverSPI.h.
|
inline |
Returns whether writes have been stopped by post-launch protection.
Definition at line 275 of file DataSaverSPI.h.
|
inline |
Returns the last DataPoint that was written (not necessarily including timestamp, just the data chunk).
Definition at line 167 of file DataSaverSPI.h.
|
inline |
Returns the last timestamp that was actually written to flash.
Definition at line 158 of file DataSaverSPI.h.
|
inline |
Returns the launch-protected address computed during launch detection.
Definition at line 175 of file DataSaverSPI.h.
|
inline |
Returns the next flash address where a full page will be written.
Definition at line 183 of file DataSaverSPI.h.
|
inline |
Returns whether startup detected existing post-launch mode metadata.
Definition at line 283 of file DataSaverSPI.h.
| bool DataSaverSPI::isPostLaunchMode | ( | ) |
Returns whether the metadata from the flash chip indicates that it contains post-launch data that hasn't been dumped yet. Call clearPostLaunchMode() to clear this flag. once you are confident that you have the data you want dumped to a more permanent storage or another machine.
Will also update the post-launch mode flag.
Definition at line 190 of file DataSaverSPI.cpp.
|
virtual |
Call this when launch is detected to set the post-launch flag and prevent any data from being overwritten until the flag is cleared. All data written from this point on is "post-launch" data which is sacred and should not be overwritten until it has been dumped.
Sets the post-launch mode flag to true on the flash chip. Records the address at which the launch was detected and ensures that it's not overwritten
Data is saved in a circular fashion but once the address where the launch detected is reached this will stop saving data entirely. Also keeps 1 minute of data from before the launch was detected (b/c launch can be detected late and we have extra room)
The rocket may not be recovered for several hours, this prevents the cool launch data from being overwitten with boring laying-on-the-ground data.
| launchTimestamp_ms | Timestamp at which launch was detected. |
Reimplemented from IDataSaver.
Definition at line 317 of file DataSaverSPI.cpp.
|
inline |
Returns whether the flash chip is in post-launch mode without updating the post-launch mode flag or reading from flash.
Definition at line 200 of file DataSaverSPI.h.
|
inline |
Resets the timestamp to 0. Can be used to start a new flight during runtime. Useful for testing.
Definition at line 191 of file DataSaverSPI.h.
|
overridevirtual |
Saves a DataPoint to SPI flash.
If the new data point’s timestamp differs from the last written timestamp by more than timestampInterval_ms_, the new timestamp is also written to flash. Otherwise, the timestamp is omitted (to save space).
| dataPoint | The data point to save |
| name | An 8-bit “identifier” for the data point (could be a sensor ID) |
Implements IDataSaver.
Definition at line 21 of file DataSaverSPI.cpp.
| int DataSaverSPI::saveTimestamp | ( | uint32_t | timestamp_ms | ) |
Persist a bare timestamp entry to flash.
| timestamp_ms | Timestamp in milliseconds to record. |
Definition at line 47 of file DataSaverSPI.cpp.
|
staticconstexpr |
Definition at line 43 of file DataSaverSPI.h.