char buf[4800]; text.toCharArray(buf, 4800); char *p = buf; char *str; int i = 0; char bitmap[115]; while ((str = strtok_r(p, ",", &p)) != NULL) { bitmap[i] = str; i++; } Serial.println(bitmap);
char buf[4800];
text.toCharArray(buf, 4800);
char *p = buf;
char *str;
int i = 0;
char bitmap[115];
while ((str = strtok_r(p, ",", &p)) != NULL) {
bitmap[i] = str;
i++;
}
Serial.println(bitmap);
This actually prints the strings to the console, but trying to add them to a char array is still a mystery I am trying to solve right as I write this.
4:
char buf[4800];
text.toCharArray(buf, 4800);
char *p = buf;
char *str;
char *ptr;
char bitmap[115];
int i = 0;
while ((str = strtok_r(p, ",", &p)) != NULL) {
bitmap[i] = strtol(str, &ptr, 16);
i++;
}
Serial.println(bitmap);
I'm getting a lot closer now. strtol(str, &ptr, 16) actually gives me the right integers I need, but it seems like my Arduino crashes when I run this code. It simply reboots it. Error:
assertion "heap != NULL && "free() target pointer is outside heap areas"" failed: file "/Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/heap/./heap_caps.c", line 171, function: heap_caps_free abort() was called at PC 0x4011c173 on core 1