remove failchecks for controller power
This commit is contained in:
parent
64d03939d0
commit
baec50d4b6
|
@ -76,8 +76,7 @@ long last_send = 0;
|
||||||
|
|
||||||
boolean board1Enabled=false;
|
boolean board1Enabled=false;
|
||||||
boolean board2Enabled=false;
|
boolean board2Enabled=false;
|
||||||
#define EXPECT_FEEDBACK_ABOVE_SPEED 250 //for error checking
|
|
||||||
#define SERIALACTIVECHECKTIME 3000 //time to say a board is online/active when last message received in the last x ms
|
|
||||||
|
|
||||||
// Global variables for serial communication
|
// Global variables for serial communication
|
||||||
uint8_t idx1 = 0; // Index for new data pointer
|
uint8_t idx1 = 0; // Index for new data pointer
|
||||||
|
@ -86,8 +85,6 @@ byte *p1; // Pointer declaration for the new rece
|
||||||
byte incomingByte1;
|
byte incomingByte1;
|
||||||
byte incomingBytePrev1;
|
byte incomingBytePrev1;
|
||||||
long lastValidDataSerial1_time;
|
long lastValidDataSerial1_time;
|
||||||
long lastSendSerial1expectFeedback; //to check time difference between last >0 speed send and last received feedback
|
|
||||||
long lastBoard1PowerChange;
|
|
||||||
|
|
||||||
//Same for Serial2
|
//Same for Serial2
|
||||||
uint8_t idx2 = 0; // Index for new data pointer
|
uint8_t idx2 = 0; // Index for new data pointer
|
||||||
|
@ -96,8 +93,6 @@ byte *p2; // Pointer declaration for the new rece
|
||||||
byte incomingByte2;
|
byte incomingByte2;
|
||||||
byte incomingBytePrev2;
|
byte incomingBytePrev2;
|
||||||
long lastValidDataSerial2_time;
|
long lastValidDataSerial2_time;
|
||||||
long lastSendSerial2expectFeedback; //to check time difference between last >0 speed send and last received feedback
|
|
||||||
long lastBoard2PowerChange;
|
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
uint16_t start;
|
uint16_t start;
|
||||||
|
@ -209,13 +204,6 @@ void loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//for lastValidSerialData calculation
|
|
||||||
if (abs(out_speedRL)>EXPECT_FEEDBACK_ABOVE_SPEED || abs(out_speedRR)>EXPECT_FEEDBACK_ABOVE_SPEED) { //Rear is serial 1
|
|
||||||
lastSendSerial1expectFeedback=loopmillis;
|
|
||||||
}
|
|
||||||
if (abs(out_speedFL)>EXPECT_FEEDBACK_ABOVE_SPEED || abs(out_speedFR)>EXPECT_FEEDBACK_ABOVE_SPEED) { //Front is serial 2
|
|
||||||
lastSendSerial2expectFeedback=loopmillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (currentmode!=error) { //keep last errormessage
|
if (currentmode!=error) { //keep last errormessage
|
||||||
|
@ -367,21 +355,11 @@ void handleModeChange() {
|
||||||
state_modechange++;
|
state_modechange++;
|
||||||
board1Enabled=true; //assume board is online
|
board1Enabled=true; //assume board is online
|
||||||
board2Enabled=true; //assume board is online
|
board2Enabled=true; //assume board is online
|
||||||
lastBoard1PowerChange=loopmillis;
|
|
||||||
lastBoard2PowerChange=loopmillis;
|
|
||||||
lastSendSerial1expectFeedback=loopmillis; //expect maybe feedback on power on
|
|
||||||
lastSendSerial2expectFeedback=loopmillis;
|
|
||||||
lastValidDataSerial1_time=loopmillis; //assume a feedback was received (boards do not send feedback on poweron)
|
|
||||||
lastValidDataSerial2_time=loopmillis; //assume a feedback was received (boards do not send feedback on poweron)
|
|
||||||
// ### Request Idle or Off (both power boards off) ###
|
// ### Request Idle or Off (both power boards off) ###
|
||||||
}else if(requestmode==idle || requestmode==off) {
|
}else if(requestmode==idle || requestmode==off) {
|
||||||
state_modechange++;
|
state_modechange++;
|
||||||
board1Enabled=false; //assume board is offline
|
board1Enabled=false; //assume board is offline
|
||||||
board2Enabled=false; //assume board is offline
|
board2Enabled=false; //assume board is offline
|
||||||
lastBoard1PowerChange=loopmillis;
|
|
||||||
lastBoard2PowerChange=loopmillis;
|
|
||||||
lastSendSerial1expectFeedback=loopmillis; //expect maybe feedback on power on
|
|
||||||
lastSendSerial2expectFeedback=loopmillis;
|
|
||||||
}else{ //if changed off from error mode
|
}else{ //if changed off from error mode
|
||||||
state_modechange++;
|
state_modechange++;
|
||||||
}
|
}
|
||||||
|
@ -411,30 +389,6 @@ void handleModeChange() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean serial1Active() {
|
|
||||||
if (loopmillis-lastBoard1PowerChange<=SERIALACTIVECHECKTIME) {
|
|
||||||
return board1Enabled; //unclear if mcu just started or board is just starting up. reply with exprected answer
|
|
||||||
}
|
|
||||||
if (lastValidDataSerial1_time==0 && lastSendSerial1expectFeedback==0) { //no valid data received and send ever
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (loopmillis-lastSendSerial1expectFeedback <= SERIALACTIVECHECKTIME){ //enough time passed since last exprected feedback
|
|
||||||
return board1Enabled; //unclear, return exprected value
|
|
||||||
}
|
|
||||||
return loopmillis-lastValidDataSerial1_time < SERIALACTIVECHECKTIME;
|
|
||||||
}
|
|
||||||
boolean serial2Active() {
|
|
||||||
if (loopmillis-lastBoard2PowerChange<=SERIALACTIVECHECKTIME) {
|
|
||||||
return board2Enabled; //unclear if mcu just started or board is just starting up. reply with exprected answer
|
|
||||||
}
|
|
||||||
if (lastValidDataSerial2_time==0 && lastSendSerial2expectFeedback==0) { //no valid data received and send ever
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (loopmillis-lastSendSerial2expectFeedback <= SERIALACTIVECHECKTIME){ //enough time passed since last exprected feedback
|
|
||||||
return board2Enabled; //unclear, return exprected value
|
|
||||||
}
|
|
||||||
return loopmillis-lastValidDataSerial2_time < SERIALACTIVECHECKTIME;
|
|
||||||
}
|
|
||||||
|
|
||||||
void modeloops() {
|
void modeloops() {
|
||||||
if (loopmillis - last_looptime >= LOOPTIME) {
|
if (loopmillis - last_looptime >= LOOPTIME) {
|
||||||
|
@ -494,34 +448,7 @@ boolean boardsPowered()
|
||||||
|
|
||||||
void failChecks()
|
void failChecks()
|
||||||
{
|
{
|
||||||
if (serial1Active() && !board1Enabled){ //serial is active and board should be offline
|
|
||||||
errormessage="Board 1 is online but shouldnt";
|
|
||||||
requestmode=error;
|
|
||||||
}
|
|
||||||
if (serial2Active() && !board2Enabled){ //serial is active and board should be offline
|
|
||||||
errormessage="Board 2 is online but shouldnt";
|
|
||||||
requestmode=error;
|
|
||||||
Serial.print("loopmillis="); Serial.println(loopmillis);
|
|
||||||
Serial.print("lastBoard2PowerChange="); Serial.println(lastBoard2PowerChange);
|
|
||||||
Serial.print("lastSendSerial2expectFeedback="); Serial.println(lastSendSerial2expectFeedback);
|
|
||||||
Serial.print("lastValidDataSerial2_time="); Serial.println(lastValidDataSerial2_time);
|
|
||||||
}
|
|
||||||
if (out_speedRL != 0 || out_speedRR != 0) { //Rear is Serial1
|
|
||||||
if (!serial1Active() && board1Enabled){ //serial is not active and board should be online. only check this if feedback can be exprected (out_speedFL/R > 0)
|
|
||||||
errormessage="Board 1 is offline but should be online";
|
|
||||||
requestmode=error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (out_speedFL != 0 || out_speedFR != 0) { //Front is Serial2
|
|
||||||
if (!serial2Active() && board2Enabled){ //serial is not active and board should be online. only check this if feedback can be exprected (out_speedFL/R > 0)
|
|
||||||
errormessage="Board 2 is offline but should be online";
|
|
||||||
requestmode=error;
|
|
||||||
Serial.print("loopmillis="); Serial.println(loopmillis);
|
|
||||||
Serial.print("lastBoard2PowerChange="); Serial.println(lastBoard2PowerChange);
|
|
||||||
Serial.print("lastSendSerial2expectFeedback="); Serial.println(lastSendSerial2expectFeedback);
|
|
||||||
Serial.print("lastValidDataSerial2_time="); Serial.println(lastValidDataSerial2_time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue