WDT
28th July 2010, 19:16
Hi all
I'm new to Qt and an intermediate C++ (well I think so anyways) dev.
I'm trying to port some code over from C# to do with driver development for a HiD board and trying to use Qt and C++ data types as opposed to the MFC ones like, QFile instead of HANDLE and unsigned long instead of DWORD. So far so good I have managed to get to the point of opening the device which is where I've hit an impasse.
bool hid_device::init_device(QString devPathname)
{
QString errorMessage;
QMessageBox msgBox;
HIDD_ATTRIBUTES mDeviceAttribs;
qDebug() << devPathname;
//devicehandle is of type QFILE
deviceHandle.setFileName(devPathname);
if(!deviceHandle.open(QIODevice::ReadWrite))
{
unsigned long lastErr = GetLastError(); //ulong = DWORD
errorMessage = errorMessage.setNum(lastErr);
msgBox.setText("Unable to Open the Device for IO operations. Error code: " +QString::number(lastErr));
msgBox.exec();
return false;
}
HidD_GetAttributes(&deviceHandle, &mDeviceAttribs);
this->ProductID = mDeviceAttribs.ProductID;
this->VendorID = mDeviceAttribs.VendorID;
this->VersionNumber = mDeviceAttribs.VersionNumber;
deviceHandle.close();
return true;
}
Attempting to open the device always returns an error: ERROR_PATH_NOT_FOUND.
I know the QString I'm passing to the device is the one returned from the setupDi* DDK function so it's valid. (I have anyone done HiD dev in Qt and can point me anywhere? Please remember I'm new to Qt and I'm just porting some code over as a way of learning the framework. I'll tidy up my programming later when I start getting used to thinking in QT.
Thanks for your time.
I'm new to Qt and an intermediate C++ (well I think so anyways) dev.
I'm trying to port some code over from C# to do with driver development for a HiD board and trying to use Qt and C++ data types as opposed to the MFC ones like, QFile instead of HANDLE and unsigned long instead of DWORD. So far so good I have managed to get to the point of opening the device which is where I've hit an impasse.
bool hid_device::init_device(QString devPathname)
{
QString errorMessage;
QMessageBox msgBox;
HIDD_ATTRIBUTES mDeviceAttribs;
qDebug() << devPathname;
//devicehandle is of type QFILE
deviceHandle.setFileName(devPathname);
if(!deviceHandle.open(QIODevice::ReadWrite))
{
unsigned long lastErr = GetLastError(); //ulong = DWORD
errorMessage = errorMessage.setNum(lastErr);
msgBox.setText("Unable to Open the Device for IO operations. Error code: " +QString::number(lastErr));
msgBox.exec();
return false;
}
HidD_GetAttributes(&deviceHandle, &mDeviceAttribs);
this->ProductID = mDeviceAttribs.ProductID;
this->VendorID = mDeviceAttribs.VendorID;
this->VersionNumber = mDeviceAttribs.VersionNumber;
deviceHandle.close();
return true;
}
Attempting to open the device always returns an error: ERROR_PATH_NOT_FOUND.
I know the QString I'm passing to the device is the one returned from the setupDi* DDK function so it's valid. (I have anyone done HiD dev in Qt and can point me anywhere? Please remember I'm new to Qt and I'm just porting some code over as a way of learning the framework. I'll tidy up my programming later when I start getting used to thinking in QT.
Thanks for your time.