I'm new here.
I'm trying to write a small database class which can store/restore data to/from the esp8266's filesystem and can do the records search/find upon the database file(which is a compound of ascii and binary file, is it the problem?)
The LittleFs is used, SPIFFS is fine as well(same results to me).
My problem is, the find() behaves beyond my expected, the keyword could be found but succeeding same ones could not:
find() is success/true once found and could be identified by LittleFS.position() which is the current file pointer position pointing to the next one char of the found keyword. however I do the find() again, isn't it beginning from the current position? what I got was not found.
Simply put, the first one could be found but later ones could not.
Please kindly help me where I went wrong of the above idea or the code, I attached below.
the following is the snippet result:
21:13:08.651 -> [4 -1 4]
21:13:08.651 -> [AA 5A A5 55 0C 00 00 00 ]
21:13:08.651 -> [61 62 63 64 D7 11 00 00 ]
21:13:08.651 -> [66 E6 8A 44 AA 5A A5 55 ]
21:13:08.651 -> [0C 00 00 00 64 65 66 67 ]
21:13:08.651 -> [E6 1D 00 00 0A 1A 00 00 ]
21:13:08.651 -> [AA 5A A5 55 11 00 00 00 ]
21:13:08.651 -> [31 32 33 34 61 62 63 64 ]
21:13:08.651 -> [65 66 67 68 69 6A 6B 6C ]
21:13:08.651 -> [6D ]
keyword is AA 5A A5 55,
search instructions are:
printf("[%d %d %d]\r\n", s.FindNext(PREAMBLE), s.FindNext(PREAMBLE), s.FindNext(PREAMBLE));
the result as I thought might be [4 24 44] rather than [4 -1 4].
Thanks.
Attachments
(1.7 KiB) Downloaded 135 times