write log header only once
This commit is contained in:
parent
025d2ddbc2
commit
aaabdb3a80
|
@ -21,6 +21,10 @@ unsigned long last_log_send=0;
|
|||
|
||||
#define SENDPERIOD 20 //ms. delay for sending speed and steer data to motor controller via serial
|
||||
#define LOGMININTERVAL 20 //minimum interval (ms) to send logs
|
||||
#define LOGMAXINTERVAL 10000 //maximum time (ms) after which data is send
|
||||
|
||||
#define WRITE_HEADER_TIME 1000
|
||||
bool log_header_written = false;
|
||||
|
||||
bool controllers_connected=false;
|
||||
|
||||
|
@ -270,10 +274,12 @@ void loop() {
|
|||
controllers_connected=false;
|
||||
}else if(!controllers_connected) { //not timeouted but was before
|
||||
controllers_connected=true;
|
||||
writeLogHeader(Serial1); //connection recovered, write log header
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (newData2) {
|
||||
motorparamsFront.cur_pos++;
|
||||
motorparamsFront.cur_pos%=CURRENT_FILTER_SIZE;
|
||||
|
@ -344,7 +350,14 @@ void loop() {
|
|||
}
|
||||
|
||||
|
||||
if (log_update && loopmillis>last_log_send+LOGMININTERVAL) {
|
||||
// ######## LOG ########
|
||||
|
||||
if (!log_header_written && loopmillis>=WRITE_HEADER_TIME){
|
||||
writeLogHeader(Serial1); //connection recovered, write log header
|
||||
log_header_written=true;
|
||||
}
|
||||
|
||||
if ((log_header_written && log_update && loopmillis>last_log_send+LOGMININTERVAL) || loopmillis>last_log_send+LOGMAXINTERVAL) {
|
||||
last_log_send=loopmillis;
|
||||
log_update=false;
|
||||
writeLog(Serial1,loopmillis, motorparamsFront,motorparamsRear, FeedbackFront, FeedbackRear, filtered_currentAll, throttle_pos, brake_pos);
|
||||
|
|
Loading…
Reference in New Issue