<commit_before>#include "SDLogDriver.h"

#include <SD.h>

#define LOG_FILENAME    "LOG"
#define BEGIN_LIFE_BYTE 'B'
#define BEGIN_DATA_BYTE 'b'

__LOG_DATA log_data_pack;

File f;

char* const data_begin = (char*)(&log_data_pack); // Yes, yes, I know
int data_length = sizeof(log_data_pack);

void initLogger()
{
	f = SD.open(LOG_FILENAME, FILE_WRITE);
	f.write(BEGIN_LIFE_BYTE);
	f.flush();
}

void logDataPack()
{
	f.write(BEGIN_DATA_BYTE);
	f.write(data_begin, data_length);
	f.flush();
}

void dumpLog()
{
	f.close();

	f = SD.open(LOG_FILENAME, FILE_READ);

	while(f.peek() >= 0)
	{
		char c = f.read();
		if(c == BEGIN_LIFE_BYTE)
		{
			Serial.println("=== UNIT BOOTUP ===");
		}
		else if(c == BEGIN_DATA_BYTE)
		{
			for(int i = 0; i < data_length; ++i)
				data_begin[i] = f.read();

			Serial.print(log_data_pack.timestamp); Serial.print("ms: ");

			Serial.print("Acc ("); // g
			Serial.print(log_data_pack.acc_x); Serial.print(", ");
			Serial.print(log_data_pack.acc_y); Serial.print(", ");
			Serial.print(log_data_pack.acc_z); Serial.print(")\t");

			Serial.print("Gyro ("); // m / s^2
			Serial.print(log_data_pack.gyro_x); Serial.print(", ");
			Serial.print(log_data_pack.gyro_y); Serial.print(", ");
			Serial.print(log_data_pack.gyro_z); Serial.print(")\t");

			Serial.print("Ahrs ("); // degrees
			Serial.print(log_data_pack.ahrs_x * 180 / M_PI); Serial.print(", ");
			Serial.print(log_data_pack.ahrs_y * 180 / M_PI); Serial.print(", ");
			Serial.print(log_data_pack.ahrs_z * 180 / M_PI); Serial.print(")\t");

			Serial.print("Encoders ("); // mm / s
			Serial.print(log_data_pack.leftSpeed); Serial.print(", ");
			Serial.print(log_data_pack.rightSpeed); Serial.print(")\n");
		}
		else
		{
			Serial.println("Log file is corrupt");
			break;
		}
	}

	f.close();

	SD.remove(LOG_FILENAME);

	initLogger();
}
<commit_msg>Indicate dump end<commit_after>#include "SDLogDriver.h"

#include <SD.h>

#define LOG_FILENAME    "LOG"
#define BEGIN_LIFE_BYTE 'B'
#define BEGIN_DATA_BYTE 'b'

__LOG_DATA log_data_pack;

File f;

char* const data_begin = (char*)(&log_data_pack); // Yes, yes, I know
int data_length = sizeof(log_data_pack);

void initLogger()
{
	f = SD.open(LOG_FILENAME, FILE_WRITE);
	f.write(BEGIN_LIFE_BYTE);
	f.flush();
}

void logDataPack()
{
	f.write(BEGIN_DATA_BYTE);
	f.write(data_begin, data_length);
	f.flush();
}

void dumpLog()
{
	f.close();

	f = SD.open(LOG_FILENAME, FILE_READ);

	while(f.peek() >= 0)
	{
		char c = f.read();
		if(c == BEGIN_LIFE_BYTE)
		{
			Serial.println("=== UNIT BOOTUP ===");
		}
		else if(c == BEGIN_DATA_BYTE)
		{
			for(int i = 0; i < data_length; ++i)
				data_begin[i] = f.read();

			Serial.print(log_data_pack.timestamp); Serial.print("ms: ");

			Serial.print("Acc ("); // g
			Serial.print(log_data_pack.acc_x); Serial.print(", ");
			Serial.print(log_data_pack.acc_y); Serial.print(", ");
			Serial.print(log_data_pack.acc_z); Serial.print(")\t");

			Serial.print("Gyro ("); // m / s^2
			Serial.print(log_data_pack.gyro_x); Serial.print(", ");
			Serial.print(log_data_pack.gyro_y); Serial.print(", ");
			Serial.print(log_data_pack.gyro_z); Serial.print(")\t");

			Serial.print("Ahrs ("); // degrees
			Serial.print(log_data_pack.ahrs_x * 180 / M_PI); Serial.print(", ");
			Serial.print(log_data_pack.ahrs_y * 180 / M_PI); Serial.print(", ");
			Serial.print(log_data_pack.ahrs_z * 180 / M_PI); Serial.print(")\t");

			Serial.print("Encoders ("); // mm / s
			Serial.print(log_data_pack.leftSpeed); Serial.print(", ");
			Serial.print(log_data_pack.rightSpeed); Serial.print(")\n");
		}
		else
		{
			Serial.println("Log file is corrupt");
			break;
		}
	}

	Serial.println("=== DUMP COMPLETE ===");

	f.close();

	SD.remove(LOG_FILENAME);

	initLogger();
}

{'fraction_non_alphanumeric': 0.19225634178905207, 'fraction_numerical': 0.006408544726301735, 'mean_word_length': 4.0896739130434785, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5858733', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1510, 'n_words': 239}