@@ -2140,9 +2140,10 @@ inline uint16_t Logger::serzQueuedFlushFile() {
21402140 MS_DEEP_DBG (F (" seQFF opened " ), tempFn);
21412141 }
21422142
2143- // Get the length of the line being read
2143+ // Get the length of the last line that was deserialized
21442144 num_char = strlen (deszq_line);
2145- // If there is data in the line being read, copy it to the new temp file
2145+ // If there is data in the last deserialized line, copy it to the new temp
2146+ // file
21462147 if (num_char) { // Test could be min size, but this unknown
21472148 MS_DBG (F (" seQFF Last POST Failed " ), deszq_line);
21482149 retNum = tgtoutFile.write (deszq_line, num_char);
@@ -2154,7 +2155,9 @@ inline uint16_t Logger::serzQueuedFlushFile() {
21542155
21552156 MS_DBG (F (" seQFF cpy lines across" ));
21562157 // While still able to read lines from the queue file, copy them to the new
2157- // temp file
2158+ // temp file. This will proceed from the last point of entry to the file,
2159+ // not from the beginning, so only lines after the last one read will be
2160+ // transferred.
21582161 while (0 <
21592162 (num_char = serzQueuedFile.fgets (deszq_line, QUEFILE_MAX_LINE))) {
21602163#if defined(USE_PS_modularSensorsNetwork)
@@ -2166,21 +2169,24 @@ inline uint16_t Logger::serzQueuedFlushFile() {
21662169 */
21672170 postLogLine ((MAX_NUMBER_SENDERS + 1 ), HTTPSTATUS_NC_903);
21682171 num_skipped++;
2169- } else
2172+ } else {
21702173#endif // USE_PS_modularSensorsNetwork
2171- {
21722174
21732175 retNum = tgtoutFile.write (deszq_line, num_char);
21742176 // Squelch last char LF
21752177 deszq_line[sizeof (deszq_line) - 1 ] = 0 ;
21762178 MS_DBG (deszq_line);
2177- if (retNum != num_char) {
2179+ if (retNum != num_char) { // If the number of characters read and
2180+ // written don't match
21782181 PRINTOUT (F (" seQFF tgtoutFile write3 err" ), num_char, retNum);
21792182 // sd1_Err("seQFF write4");
21802183 break ;
21812184 }
2185+ // add one to the total number of lines in the file
21822186 num_lines++;
2187+ #if defined(USE_PS_modularSensorsNetwork)
21832188 }
2189+ #endif // USE_PS_modularSensorsNetwork
21842190 }
21852191 if (num_skipped) {
21862192 PRINTOUT (F (" seQFF sendQueue Size " ), _sendQueueSz_num, F (" ,queued" ),
@@ -2197,8 +2203,9 @@ inline uint16_t Logger::serzQueuedFlushFile() {
21972203 }
21982204 }
21992205
2206+ // rename the old queue file to the deletable queue name
22002207 retBool = serzQueuedFile.rename (queDelFn);
2201- if (!retBool) {
2208+ if (!retBool) { // If rename fails, reboot
22022209 PRINTOUT (F (" seQFF REBOOT rename1 err" ), queDelFn);
22032210 // Problem - unrecoverable, so reboot
22042211 retBool = serzQueuedFile.close ();
@@ -2210,6 +2217,7 @@ inline uint16_t Logger::serzQueuedFlushFile() {
22102217 } else {
22112218 MS_DBG (F (" seQFF cleanup rename " ), serzQueuedFn, F (" to" ), queDelFn);
22122219
2220+ // close the original queue file
22132221 retBool = serzQueuedFile.close ();
22142222 if (!retBool) {
22152223 sd1_Err (" seQFF serzQueuedFile.close2 err" );
@@ -2218,14 +2226,17 @@ inline uint16_t Logger::serzQueuedFlushFile() {
22182226 MS_DEEP_DBG (F (" seQFF close serzQueuedFile" ));
22192227 }
22202228
2229+ // rename the new temporary file to the proper queue file name
22212230 retBool = tgtoutFile.rename (serzQueuedFn);
22222231 if (!retBool) {
22232232 sd1_Err (" seQFF tgtoutFile.rename err" );
2233+ // return the number of lines copied from one file to the next
22242234 return num_lines;
22252235 } else {
22262236 MS_DEEP_DBG (F (" seQFF rename " ), tempFn, F (" to" ), serzQueuedFn);
22272237 }
22282238
2239+ // close the renamed temporary file
22292240 retBool = tgtoutFile.close ();
22302241 if (!retBool) {
22312242 sd1_Err (" seQFF tgtoutFile.close1 err" );
@@ -2235,6 +2246,7 @@ inline uint16_t Logger::serzQueuedFlushFile() {
22352246 }
22362247 }
22372248
2249+ // return the number of lines copied from one file to the next
22382250 return num_lines;
22392251} // serzQueuedFlushFile
22402252
@@ -2307,6 +2319,8 @@ char* Logger::deszFind(const char* in_line, char caller_id) {
23072319bool Logger::deszRdelStart () {
23082320 deszLinesRead = 0 ;
23092321
2322+ // Reset the pointer for the next character to the start of the pointer for
2323+ // the whole line
23102324 deszq_nextChar = deszq_line;
23112325 // Open - RD & WR. WR needed to be able to delete when complete.
23122326 if (!serzRdelFile.open (serzRdelFn_str, (O_RDWR | O_CREAT))) {
@@ -2321,6 +2335,8 @@ bool Logger::deszRdelStart() {
23212335bool Logger::deszQueuedStart () {
23222336 deszLinesRead = 0 ;
23232337
2338+ // Reset the pointer for the next character to the start of the pointer for
2339+ // the whole line
23242340 deszq_nextChar = deszq_line;
23252341 // Open - RD & WR. WR needed to be able to delete when complete.
23262342 // Expect serzQueuedFn to be setup in serzQueuedStart
@@ -2414,7 +2430,7 @@ bool Logger::deszqNextCh(void) {
24142430 // Found end of line
24152431 MS_DBG (F (" dSRN unexpected EOL " ));
24162432 return false ;
2417- } else if (NULL == nextCharEnd) {
2433+ } else if (nullptr == nextCharEnd) {
24182434 // Found <value>EOF ~ nextSr_sz is valid
24192435 deszq_nextCharSz -= 1 ; // take off turds <LF>
24202436 MS_DEEP_DBG (F (" dSRN info " ), deszq_nextCharSz, " '" , deszq_nextChar,
0 commit comments