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

This commit is contained in:
Thomas Sax 2023-12-13 15:17:14 +01:00
parent 7b1ea963e2
commit f6f90fe770

View File

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