Added qDebug() which are commented out:
ser_ISR100ms() open_serial_port close_serial_port
This commit is contained in:
parent
e7723f669f
commit
591fd89cb5
32
src/com.cpp
32
src/com.cpp
@ -93,29 +93,34 @@ T_com::~T_com()
|
|||||||
|
|
||||||
void T_com::ser_ISR100ms()
|
void T_com::ser_ISR100ms()
|
||||||
{
|
{
|
||||||
|
//qDebug() << "~~>LIB" << "ENTER...";
|
||||||
// call every 100ms to check if user(HMI) wants to connect or disconnect
|
// 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)
|
uint8_t chkConn = gpi_getSerialConn(); // from global GUI buffer (Sdata)
|
||||||
|
|
||||||
|
//qDebug() << "~~>LIB" << "checking connect button... " << chkConn;
|
||||||
|
|
||||||
switch (chkConn)
|
switch (chkConn)
|
||||||
{
|
{
|
||||||
case 0: // 0 button "connect" was just released
|
case 0: // 0 button "connect" was just released
|
||||||
|
//qDebug() << "close serial port" << chkConn;
|
||||||
closeSerialPort();
|
closeSerialPort();
|
||||||
gpi_serialChanged(); // set chkConn to 2, thus getting edge
|
gpi_serialChanged(); // set chkConn to 2, thus getting edge
|
||||||
break;
|
break;
|
||||||
case 1: // 1 button "connect" was just pressed
|
case 1: // 1 button "connect" was just pressed
|
||||||
|
//qDebug() << "open serial port" << chkConn;
|
||||||
open_Serial_Port();
|
open_Serial_Port();
|
||||||
gpi_serialChanged(); // set chkConn to 2, thus getting edge
|
gpi_serialChanged(); // set chkConn to 2, thus getting edge
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (CatSerial->isOpen())
|
if (CatSerial->isOpen()) {
|
||||||
gpi_serialIsOpen(true);
|
gpi_serialIsOpen(true);
|
||||||
else
|
} else {
|
||||||
gpi_serialIsOpen(false);
|
gpi_serialIsOpen(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//qDebug() << "LEAVE " << chkConn;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------
|
||||||
@ -124,17 +129,24 @@ void T_com::ser_ISR100ms()
|
|||||||
|
|
||||||
char T_com::open_Serial_Port()
|
char T_com::open_Serial_Port()
|
||||||
{
|
{
|
||||||
|
//qDebug() << "ENTER";
|
||||||
|
|
||||||
bool ret;
|
bool ret;
|
||||||
QString myString=nullptr, myPortName=nullptr, myBaudStr=nullptr;
|
QString myString=nullptr, myPortName=nullptr, myBaudStr=nullptr;
|
||||||
int myBaudNr;
|
int myBaudNr;
|
||||||
|
|
||||||
if (CatSerial->isOpen())
|
if (CatSerial->isOpen()) {
|
||||||
|
qDebug() << "!!!IS OPEN!!!";
|
||||||
return 0; // opening twice is not allowed
|
return 0; // opening twice is not allowed
|
||||||
|
}
|
||||||
|
|
||||||
//qDebug() << "connecting..." << myPortName;
|
//qDebug() << "connecting..." << myPortName;
|
||||||
myPortName=gpi_getComPortName(); // was selected and stored from GUI
|
myPortName=gpi_getComPortName(); // was selected and stored from GUI
|
||||||
CatSerial->setPortName(myPortName);
|
CatSerial->setPortName(myPortName);
|
||||||
myBaudNr=gpi_getBaudNr(); // was selected and stored from GUI
|
myBaudNr=gpi_getBaudNr(); // was selected and stored from GUI
|
||||||
|
|
||||||
|
//qDebug() << "myPortName" << myPortName << ", myBaudNr" << myBaudNr;
|
||||||
|
|
||||||
switch (myBaudNr)
|
switch (myBaudNr)
|
||||||
{
|
{
|
||||||
// 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
|
// 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());
|
myString.append(CatSerial->errorString());
|
||||||
qDebug() << myString;
|
qDebug() << myString;
|
||||||
gpi_setTxt4comStateLine(myString);
|
gpi_setTxt4comStateLine(myString);
|
||||||
|
|
||||||
|
//qDebug() << "LEAVE";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -182,11 +197,14 @@ char T_com::open_Serial_Port()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//qDebug() << "LEAVE";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void T_com::closeSerialPort()
|
void T_com::closeSerialPort()
|
||||||
{
|
{
|
||||||
|
//qDebug() << "ENTER";
|
||||||
|
|
||||||
if (CatSerial->isOpen())
|
if (CatSerial->isOpen())
|
||||||
{
|
{
|
||||||
qDebug() << "closing connection";
|
qDebug() << "closing connection";
|
||||||
@ -195,6 +213,8 @@ void T_com::closeSerialPort()
|
|||||||
gpi_setTxt4RsDiagWin("closed");
|
gpi_setTxt4RsDiagWin("closed");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//qDebug() << "LEAVE";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user