Added qDebug() which are commented out:

ser_ISR100ms()
    open_serial_port
    close_serial_port
This commit is contained in:
Gerhard Hoffmann 2023-04-05 14:13:17 +02:00
parent e7723f669f
commit 591fd89cb5

View File

@ -93,29 +93,34 @@ T_com::~T_com()
void T_com::ser_ISR100ms()
{
//qDebug() << "~~>LIB" << "ENTER...";
// call every 100ms to check if user(HMI) wants to connect or disconnect
//qDebug() << "~~>LIB" << "checking connect button... " ;
uint8_t chkConn = gpi_getSerialConn(); // from global GUI buffer (Sdata)
//qDebug() << "~~>LIB" << "checking connect button... " << chkConn;
switch (chkConn)
{
case 0: // 0 button "connect" was just released
//qDebug() << "close serial port" << chkConn;
closeSerialPort();
gpi_serialChanged(); // set chkConn to 2, thus getting edge
break;
case 1: // 1 button "connect" was just pressed
//qDebug() << "open serial port" << chkConn;
open_Serial_Port();
gpi_serialChanged(); // set chkConn to 2, thus getting edge
break;
}
if (CatSerial->isOpen())
if (CatSerial->isOpen()) {
gpi_serialIsOpen(true);
else
} else {
gpi_serialIsOpen(false);
}
//qDebug() << "LEAVE " << chkConn;
}
// -------------------------------------------------------------------------------------------------------------
@ -124,17 +129,24 @@ void T_com::ser_ISR100ms()
char T_com::open_Serial_Port()
{
//qDebug() << "ENTER";
bool ret;
QString myString=nullptr, myPortName=nullptr, myBaudStr=nullptr;
int myBaudNr;
if (CatSerial->isOpen())
if (CatSerial->isOpen()) {
qDebug() << "!!!IS OPEN!!!";
return 0; // opening twice is not allowed
}
//qDebug() << "connecting..." << myPortName;
myPortName=gpi_getComPortName(); // was selected and stored from GUI
CatSerial->setPortName(myPortName);
myBaudNr=gpi_getBaudNr(); // was selected and stored from GUI
//qDebug() << "myPortName" << myPortName << ", myBaudNr" << myBaudNr;
switch (myBaudNr)
{
// 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
@ -167,6 +179,9 @@ char T_com::open_Serial_Port()
myString.append(CatSerial->errorString());
qDebug() << myString;
gpi_setTxt4comStateLine(myString);
//qDebug() << "LEAVE";
return 0;
} else
{
@ -182,11 +197,14 @@ char T_com::open_Serial_Port()
}
return 0;
//qDebug() << "LEAVE";
return 0;
}
void T_com::closeSerialPort()
{
//qDebug() << "ENTER";
if (CatSerial->isOpen())
{
qDebug() << "closing connection";
@ -195,6 +213,8 @@ void T_com::closeSerialPort()
gpi_setTxt4RsDiagWin("closed");
}
//qDebug() << "LEAVE";
}