I consider this to be strange behavior if not simply erroneous. Either something is wrong with the core programming, the ESP32 S3 chip itself, or I am completely batty (the latter having already been government certified).
This program:
typedef struct {char path[40];
char stat[4];
uint64_t filesize;
uint64_t written
} FMupload;
FMupload FMuploads[]={{"","E",0,0},{"","E",0,0},{"","E",0,0},{"","E",0,0},{"","E",0,0}};
const int numFMuploads = sizeof(FMuploads) / sizeof(FMupload);
void setup(){
Serial.begin(115200);
for(int i=0; i < numFMuploads; i++){
dump(i);
}
Serial.println("Changing Path");
strcpy(FMuploads[0].path, "/thisfile.txt");
dump(0);
Serial.println("Changing Status");
strcpy(FMuploads[0].stat, "I");
dump(0);
Serial.println("Changing Filesize");
FMuploads[0].filesize = 2048;
dump(0);
Serial.println("Changing Written");
FMuploads[0].written = 1024;
dump(0);
}
void loop(){
}
void dump(int i){
Serial.printf("Index: %i Path: %s Status %s Filesize %d Written %d\n", i, FMuploads[i].path, FMuploads[i].stat, FMuploads[i].filesize, FMuploads[i].written);
}
Produces random output similar to this:
Index: 0 Path: Status E Filesize 0 Written 0
Index: 1 Path: Status E Filesize 1070513980 Written 0
Index: 2 Path: Status E Filesize 1070513980 Written 0
Index: 3 Path: Status E Filesize 1070513980 Written 0
Index: 4 Path: Status E Filesize 1070513980 Written 0
Changing Path
Index: 0 Path: /thisfile.txt Status E Filesize 1070513980 Written 0
Changing Status
Index: 0 Path: /thisfile.txt Status I Filesize 1070516488 Written 0
Changing Filesize
Index: 0 Path: /thisfile.txt Status I Filesize 1070516488 Written 2048
Changing Written
Index: 0 Path: /thisfile.txt Status I Filesize 1070516488 Written 2048
Strange behavior:
-
Although the array is created with five identical inline objects, the first has the correct filesize of 0 but the others have a big number which is apparently random and changes every time.
-
After changing the path, the filesize was also changed to a different big number.
-
After changing the status, the filesize has a different big number in it. The filesize changed when only the status should have.
-
After changing the filesize, it remains unchanged, but written gets changed instead.
-
After changing written, no change was made at all.
IDE 1.8.19
ESP32 by Espressif Systems 2.0.14
Can someone please either point out what I am doing wrong or verify that this program simply doesn't work?
Thank you!