Hi,
I have the following code that is searching for available COM ports on the computer. It works fine on all the 5 computers that I have tried excluding one. On this one computer it will not pick up a USB-to-Serial-Adapter plugged into COM13. Windows does recognize the device as connected to COM13.
All computers have been running windows XP.
Does anybody have any thoughts on what could be going wrong?
Any thoughts appreciated.
//********************************************************************************************************************
//
// Finds all the available serial COM ports on the PC which is running this application.
//
// Returns true if at least one COM port is found. Returns false if no COM ports are found.
//
// This function is run from within MainWindow::findCorrectCOMPort
//
//********************************************************************************************************************
bool MainWindow::findAvailableCOMPorts()
{
const int MAX_COM_PORT = 100; // The maximum number of COM ports that will be searched for.
availablePorts.clear(); // Clears the ports found in the previous search.
QextSerialPort testPort;
testPort.setBaudRate(BAUD9600);
testPort.setFlowControl(FLOW_OFF);
testPort.setParity(PAR_NONE);
testPort.setDataBits(DATA_8);
testPort.setStopBits(STOP_1);
for (int i = 1; i < MAX_COM_PORT; i++)
{
testPortName
= QString("COM%1").
arg(i
);
testPort.setPortName(testPortName);
{
availablePorts.append(testPortName);
testPort.close();
}
}
if (availablePorts.isEmpty())
{
QMessageBox::information(this,tr
("Information Message"),tr
("No available COM ports found") );
return false;
}
else
{
qDebug() << "availablePorts:" << availablePorts;
return true;
}
} // End of bool findAvailableCOMPorts()
//********************************************************************************************************************
//
// Finds all the available serial COM ports on the PC which is running this application.
//
// Returns true if at least one COM port is found. Returns false if no COM ports are found.
//
// This function is run from within MainWindow::findCorrectCOMPort
//
//********************************************************************************************************************
bool MainWindow::findAvailableCOMPorts()
{
const int MAX_COM_PORT = 100; // The maximum number of COM ports that will be searched for.
QString testPortName;
availablePorts.clear(); // Clears the ports found in the previous search.
QextSerialPort testPort;
testPort.setBaudRate(BAUD9600);
testPort.setFlowControl(FLOW_OFF);
testPort.setParity(PAR_NONE);
testPort.setDataBits(DATA_8);
testPort.setStopBits(STOP_1);
for (int i = 1; i < MAX_COM_PORT; i++)
{
testPortName = QString("COM%1").arg(i);
testPort.setPortName(testPortName);
if (testPort.open(QIODevice::ReadWrite))
{
availablePorts.append(testPortName);
testPort.close();
}
}
if (availablePorts.isEmpty())
{
QMessageBox::information(this,tr("Information Message"),tr("No available COM ports found") );
return false;
}
else
{
qDebug() << "availablePorts:" << availablePorts;
return true;
}
} // End of bool findAvailableCOMPorts()
To copy to clipboard, switch view to plain text mode
Thanks for looking
Bookmarks