-
Notifications
You must be signed in to change notification settings - Fork 47
Description
Hi,
Working on a fairly simple ini file but size or the keys may be the issue?
The ini file contents:
[main] scheduler = 0 auto = 0 temperature_set = 30 override = 0 [0] 0 = 1 1 = 1 2 = 1 3 = 1 4 = 1 5 = 1 6 = 1 7 = 1 8 = 1 9 = 1 10 = 1 11 = 1 12 = 1 13 = 1 14 = 1 15 = 1 16 = 1 17 = 1 18 = 1 19 = 1 20 = 1 21 = 1 22 = 1 23 = 1 [1] 0 = 1 1 = 1 2 = 1 3 = 1 4 = 1 5 = 1 6 = 1 7 = 1 8 = 1 9 = 1 10 = 1 11 = 1 12 = 1 13 = 1 14 = 1 15 = 1 16 = 1 17 = 1 18 = 1 19 = 1 20 = 1 21 = 1 22 = 1 23 = 1 [2] 0 = 1 1 = 1 2 = 1 3 = 1 4 = 1 5 = 1 6 = 1 7 = 1 8 = 1 9 = 1 10 = 1 11 = 1 12 = 1 13 = 1 14 = 1 15 = 1 16 = 1 17 = 1 18 = 1 19 = 1 20 = 1 21 = 1 22 = 1 23 = 1 [3] 0 = 1 1 = 1 2 = 1 3 = 1 4 = 1 5 = 1 6 = 1 7 = 1 8 = 1 9 = 1 10 = 1 11 = 1 12 = 1 13 = 1 14 = 1 15 = 1 16 = 1 17 = 1 18 = 1 19 = 1 20 = 1 21 = 1 22 = 1 23 = 1 [4] 0 = 1 1 = 1 2 = 1 3 = 1 4 = 1 5 = 1 6 = 1 7 = 1 8 = 1 9 = 1 10 = 1 11 = 1 12 = 1 13 = 1 14 = 1 15 = 1 16 = 1 17 = 1 18 = 1 19 = 1 20 = 1 21 = 1 22 = 1 23 = 1 [5] 0 = 1 1 = 1 2 = 1 3 = 1 4 = 1 5 = 1 6 = 1 7 = 1 8 = 1 9 = 1 10 = 1 11 = 1 12 = 1 13 = 1 14 = 1 15 = 1 16 = 1 17 = 1 18 = 1 19 = 1 20 = 1 21 = 1 22 = 1 23 = 1 [6] 0 = 1 1 = 1 2 = 1 3 = 1 4 = 1 5 = 1 6 = 1 7 = 1 8 = 1 9 = 1 10 = 1 11 = 1 12 = 1 13 = 1 14 = 1 15 = 1 16 = 1 17 = 1 18 = 1 19 = 1 20 = 1 21 = 1 22 = 1 23 = 1
And the code I'm using to retrieve it:
(DEBUG_PRINT is an alias to Serial.println)
`
const size_t ini_bufferLen = 1000;
char ini_buffer[ini_bufferLen];
const char *ini_filename = "/test.ini";
IniFile ini(ini_filename);
if (!ini.open()) {
DEBUG_PRINT("PANIC - we are in read_inifiledata() and expected the file to exist BUT IT DOES NOT");
} else {
// read ini file and check for valid
if (!ini.validate(ini_buffer, ini_bufferLen)) {
DEBUG_PRINT("PANIC - the ini file did not validate, so we are rejecting it");
DEBUG_PRINT(String(ini.getError()));
} else {
// valid ini file so grab values
int tmp_day=0;
int tmp_hour=0;
while(tmp_day < 7) {
tmp_hour=0;
while (tmp_hour< 24) {
char daybuf[4],hourbuf[4];
itoa(tmp_day, daybuf, 6);
itoa(tmp_hour, hourbuf, 6);
if (ini.getValue(daybuf, hourbuf, ini_buffer, ini_bufferLen)) {
DEBUG_PRINT("Loaded day " + String(tmp_day) + " hour " + String(tmp_hour) + " Value: " + String(ini_buffer));
} else {
DEBUG_PRINT("Ini section NOT found - day " + String(tmp_day) + " and hour " + String(tmp_hour));
};
DEBUG_PRINT("ini error: " + String(ini.getError()));
tmp_hour++;
};
tmp_day++;
};
};
`
It works for the first few iterations, but by the time it gets to day 0, hour 16 it fails and will fail the rest of that day:
16:57:07.867 -> Ini section NOT found - day 0 and hour 16
16:57:07.867 -> ini error: 6
16:57:07.867 -> Ini section NOT found - day 0 and hour 17
16:57:07.867 -> ini error: 6
(and so on)
It then moves to the next day and works:
6:57:08.103 -> Loaded day 1 hour 0 Value: 1
16:57:08.103 -> ini error: 0
16:57:08.103 -> Loaded day 1 hour 1 Value: 1
16:57:08.103 -> ini error: 0
16:57:08.103 -> Loaded day 1 hour 2 Value: 1
(etc, until it gets to hour 16 and fails again):
16:57:08.337 -> Loaded day 1 hour 15 Value: 1
16:57:08.337 -> ini error: 0
16:57:08.337 -> Ini section NOT found - day 1 and hour 16
16:57:08.337 -> ini error: 6
16:57:08.337 -> Ini section NOT found - day 1 and hour 17
16:57:08.337 -> ini error: 6
It continues like that until it gets to day 15, again 16th value fails, it then fails the next day section, and fails all future sections.
16:57:11.624 -> Loaded day 5 hour 15 Value: 1
16:57:11.624 -> ini error: 0
16:57:11.857 -> Ini section NOT found - day 5 and hour 16
16:57:11.857 -> ini error: 6
16:57:11.857 -> Ini section NOT found - day 5 and hour 17
16:57:11.857 -> ini error: 6
16:57:11.857 -> Ini section NOT found - day 5 and hour 18
16:57:11.857 -> ini error: 6
16:57:11.857 -> Ini section NOT found - day 5 and hour 19
16:57:11.857 -> ini error: 6
16:57:11.857 -> Ini section NOT found - day 5 and hour 20
16:57:11.857 -> ini error: 6
16:57:11.857 -> Ini section NOT found - day 5 and hour 21
16:57:11.857 -> ini error: 6
16:57:12.093 -> Ini section NOT found - day 5 and hour 22
16:57:12.093 -> ini error: 6
16:57:12.093 -> Ini section NOT found - day 5 and hour 23
16:57:12.093 -> ini error: 6
16:57:12.093 -> Ini section NOT found - day 6 and hour 0
16:57:12.093 -> ini error: 5
16:57:12.093 -> Ini section NOT found - day 6 and hour 1
16:57:12.093 -> ini error: 5
16:57:12.093 -> Ini section NOT found - day 6 and hour 2
16:57:12.093 -> ini error: 5
16:57:12.093 -> Ini section NOT found - day 6 and hour 3
16:57:12.093 -> ini error: 5
I've checked the ini file is valid, i'm not getting any memory issues or any other error messages, it just appears the iniFile library stops at each of these. It feels like a buffer issue, but I've given it huge buffers to see if that helps and no luck.