#include <SD.h>
File file;
void setup() {
Serial.begin(9600);
if (!SD.begin()) {
Serial.println("SD init fail");
return;
}
file = SD.open("file.txt", FILE_WRITE);
if (!file) {
Serial.println("Failed to open file");
return;
}
// lets say DLC is 3, so the data array is only 3 bytes
int dlc = 8;
int data[] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0};
char *ptr = (char *) malloc(dlc * 8);
for (int i = 0; i < dlc; i++) {
*(ptr + i) = data[i];
}
free(ptr);
}
void loop() {
// put your main code here, to run repeatedly:
}