// made connection to DC more reliable, tries to open until succeeded

This commit is contained in:
Thomas Sax 2023-12-13 15:20:28 +01:00
parent f6f90fe770
commit e50871cf9f

View File

@ -375,6 +375,9 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
// bit0,1: enable/disable button "next" // bit0,1: enable/disable button "next"
// bit2,3: enable/disable button "home" // bit2,3: enable/disable button "home"
// bit4,5: enable/disable button "back" // bit4,5: enable/disable button "back"
QString bs, cn;
int br, ci;
this->updateGui(); this->updateGui();
*nextScreen=0; // 0=no change *nextScreen=0; // 0=no change
@ -385,22 +388,29 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
// load and use last settings: -------------------- // load and use last settings: --------------------
QByteArray myBA; QByteArray myBA;
myBA=datei_readFromFile(FILENAME_COMPORT); myBA=datei_readFromFile(FILENAME_COMPORT);
if (myBA.length()>0)
{
bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
bs=csv_getEntryAsString(myBA,2); // z.B 115200
cn=csv_getEntryAsString(myBA,3); // z.B. COM9
ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
HWaccess->dc_openSerial(br,bs,cn,1);
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
connectButton->setChecked(true); // connect Taste "druecken"
} else
{
// open with default settings
qDebug()<<"CArunGui: open serial with default values";
//uint32_t len= datei_nrOfEntriesInFile(myBA); bs="115200";
//uint64_t ulltmp=csv_getEntryAs2Ulong(myBA,0); br=5;
//qDebug()<<"win_startup load long numer: "<<ulltmp; //cn="COM14"; // Windows
cn="ttymxc2"; // PTU5
QString bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!?? ci=2;
int br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste) HWaccess->dc_openSerial(br,bs,cn,1);
bs=csv_getEntryAsString(myBA,2); // z.B 115200
QString cn=csv_getEntryAsString(myBA,3); // z.B. COM9
int ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
//qDebug()<<"win_startup loaded com settings: "<<br<<" "<<bs<<" "<<cn;
HWaccess->dc_openSerial(br,bs,cn,1);
//CB_baudSel->setCurrentIndex(br); // im BR auswahlfenster diese Baud vorgeben
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
connectButton->setChecked(true); // connect Taste "druecken"
}
myTO->start(100); // restart myTO->start(100); // restart
myStep++; myStep++;
} else } else
@ -410,9 +420,13 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
if (!myTO->isActive()) if (!myTO->isActive())
{ {
if (HWaccess->dc_isPortOpen()) if (HWaccess->dc_isPortOpen())
{
myStep++; myStep++;
else } else
myStep=99; // stop automatic connection and wait for manual start {
myStep=6; // 13.12.23: start Autoconnect cycle
qDebug()<<"CArunGui: port is still closed, restarting..";
}
myTO->start(100); myTO->start(100);
} }
} else } else
@ -434,7 +448,10 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
if (HWaccess->dc_readAnswTestResponse()) if (HWaccess->dc_readAnswTestResponse())
myStep++; // response was correct myStep++; // response was correct
else else
myStep=99; // stop automatic connection and wait for manual start {
myStep=6; // 13.12.23: start Autoconnect cycle
qDebug()<<"CArunGui: got no answer from DC, retry..";
}
myTO->start(100); myTO->start(100);
} }
@ -445,23 +462,38 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
HWaccess->dc_autoRequest(1); HWaccess->dc_autoRequest(1);
AutSendButton->setChecked(true); // taste "druecken" AutSendButton->setChecked(true); // taste "druecken"
myStep++; myStep++;
myTO->start(2000);
} else } else
if (myStep==5) if (myStep==5)
{ {
// got next screen: if (!myTO->isActive())
//myNextStep=2; // nicht bei CArun {
myStep++; if (HWaccess->sys_areDCdataValid())
{
qDebug()<<"CArunGui: DC is connected";
myStep=7; // OK, connection is up and running
} else
{
qDebug()<<"CArunGui: auto request is not running, retry...";
myStep++;
myTO->start(100);
}
}
} else } else
if (myStep==6) if (myStep==6)
{ {
// stop here, everything done // restart autoconnect cycle
myTO->start(100); // restart
myStep=0;
} else } else
if (myStep==7) if (myStep==7)
{ {
// stay here, DC connection is up and running
} else } else
{ {
@ -470,7 +502,6 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
if (myNextStep) if (myNextStep)
{ {
//qDebug()<<"fenster1 working: "<< myNextStep;
*nextScreen=myNextStep; *nextScreen=myNextStep;
myNextStep=0; myNextStep=0;
} }