arunanncyda
26th November 2014, 06:06
Hi
Im my program, activating the the GPRS using Qprocess start function, while executing this program will activate the GPRS. But the application is creating two more process PID with same application name & that two process will not be terminating. kindly help me how to solve this problem.
void GPRSCall::activateGPRS() {
QProcess *activateProcess;
activateProcess = new QProcess();
connect(activateProcess,SIGNAL(readyReadStandardOu tput()),this,SLOT(readGPRS()));
activateProcess->start("pppd call gprs-airtel",QIODevice::ReadOnly);
}
void GPRSCall::readGPRS()
{
str = activateProcess->readAllStandardOutput();
qDebug() << str;
if(str.contains("local IP address")) {
QString ipAddress=getip("ppp0");
emit gprsResponse(tr("GPRS Activated Successfully<br>IP : ")+ipAddress);
activateProcess->disconnect(activateProcess,SIGNAL(readyReadStandar dOutput()),this,SLOT(readGPRS()));
} else if(str.contains("script failed") || str.contains("Serial link disconnected")) {
emit gprsResponse(tr("GPRS Activation Failed"));
activateProcess->disconnect(activateProcess,SIGNAL(readyReadStandar dOutput()),this,SLOT(readGPRS()));
} else if(str.contains("ttyUSB0 is locked")) {
emit gprsResponse(tr("GPRS Activation Failed"));
}
else if(str.contains("Modem hangup")) {
emit gprsResponse(tr("Modem Hangup"));
activateProcess->disconnect(activateProcess,SIGNAL(readyReadStandar dOutput()),this,SLOT(readGPRS()));
}
}
/*Obtains the IP Address from the conncted network interrface*/
QString GPRSCall::getip(QString dev)
{
QNetworkInterface iface = QNetworkInterface::interfaceFromName(dev);
QList<QNetworkAddressEntry> ipList = iface.addressEntries();
for (int i = 0; i < ipList.size(); ++i)
return ipList.at(i).ip().toString();
return "No Link";
}
/********************GPRS Deactivation********************/
/*GPRS Disconnect Script is called from a process in ReadOnly Mode*/
void GPRSCall::deactivateGPRS()
{
connect(deactivateProcess,SIGNAL(readyReadStandard Output()),this,SLOT(closeGPRS()));
deactivateProcess->start("sh /opt/Resources/gprs_disconnect.sh",QIODevice::ReadOnly);
delay(1);///add Stopping PPP interface to readyreadstandarouuput method...
}
/***************Read Deactivation Script Output***************/
/*Invoked form Disconnect Script to read its output and display
the status to the user*/
void GPRSCall::closeGPRS()
{
str = deactivateProcess->readAllStandardOutput();
if(str.contains("Stopping PPP interface ")) {
emit gprsResponse(tr("GPRS Deactivation Success"));
deactivateProcess->disconnect(deactivateProcess,SIGNAL(readyReadStand ardOutput()),this,SLOT(closeGPRS()));
}
}
Note : USing QT 4.8.1 version & Linux 2.6.36.4 armv5tejl GNU/Linux
Im my program, activating the the GPRS using Qprocess start function, while executing this program will activate the GPRS. But the application is creating two more process PID with same application name & that two process will not be terminating. kindly help me how to solve this problem.
void GPRSCall::activateGPRS() {
QProcess *activateProcess;
activateProcess = new QProcess();
connect(activateProcess,SIGNAL(readyReadStandardOu tput()),this,SLOT(readGPRS()));
activateProcess->start("pppd call gprs-airtel",QIODevice::ReadOnly);
}
void GPRSCall::readGPRS()
{
str = activateProcess->readAllStandardOutput();
qDebug() << str;
if(str.contains("local IP address")) {
QString ipAddress=getip("ppp0");
emit gprsResponse(tr("GPRS Activated Successfully<br>IP : ")+ipAddress);
activateProcess->disconnect(activateProcess,SIGNAL(readyReadStandar dOutput()),this,SLOT(readGPRS()));
} else if(str.contains("script failed") || str.contains("Serial link disconnected")) {
emit gprsResponse(tr("GPRS Activation Failed"));
activateProcess->disconnect(activateProcess,SIGNAL(readyReadStandar dOutput()),this,SLOT(readGPRS()));
} else if(str.contains("ttyUSB0 is locked")) {
emit gprsResponse(tr("GPRS Activation Failed"));
}
else if(str.contains("Modem hangup")) {
emit gprsResponse(tr("Modem Hangup"));
activateProcess->disconnect(activateProcess,SIGNAL(readyReadStandar dOutput()),this,SLOT(readGPRS()));
}
}
/*Obtains the IP Address from the conncted network interrface*/
QString GPRSCall::getip(QString dev)
{
QNetworkInterface iface = QNetworkInterface::interfaceFromName(dev);
QList<QNetworkAddressEntry> ipList = iface.addressEntries();
for (int i = 0; i < ipList.size(); ++i)
return ipList.at(i).ip().toString();
return "No Link";
}
/********************GPRS Deactivation********************/
/*GPRS Disconnect Script is called from a process in ReadOnly Mode*/
void GPRSCall::deactivateGPRS()
{
connect(deactivateProcess,SIGNAL(readyReadStandard Output()),this,SLOT(closeGPRS()));
deactivateProcess->start("sh /opt/Resources/gprs_disconnect.sh",QIODevice::ReadOnly);
delay(1);///add Stopping PPP interface to readyreadstandarouuput method...
}
/***************Read Deactivation Script Output***************/
/*Invoked form Disconnect Script to read its output and display
the status to the user*/
void GPRSCall::closeGPRS()
{
str = deactivateProcess->readAllStandardOutput();
if(str.contains("Stopping PPP interface ")) {
emit gprsResponse(tr("GPRS Deactivation Success"));
deactivateProcess->disconnect(deactivateProcess,SIGNAL(readyReadStand ardOutput()),this,SLOT(closeGPRS()));
}
}
Note : USing QT 4.8.1 version & Linux 2.6.36.4 armv5tejl GNU/Linux