Hi,
I made a response to this awhile back, see this thread. http://www.qtcentre.org/forum/f-qt-p...ent-18311.html
I am using QtEmbedded Linux. I got the USB device info (vendor id, etc) from the /proc/scsi/usb-storage file. I use a thread to monitor the existence of that file, amongst other things. Here is just a snippet of parsing that file, just for the vendor name so I can display it on a QLabel
responseConnection->hide();
QDir usbInfoDir
(USBINFODIR
);
if(!usbInfoDir.
entryList(QDir::Files).
isEmpty()) {
qDebug() << usbInfoDir;
fileInfo.
setFileName(USBINFODIR
+ usbInfoDir.
entryList(QDir::Files).
first());
qWarning() << "Can't Get File" << fileInfo.fileName();
out << in.read(100) << endl;
usbInfo = usbInfoRaw.section(':',1,3);
usbInfo.remove("Vendor:",Qt::CaseInsensitive);
usbInfo.remove("Product:",Qt::CaseInsensitive);
usbInfo.remove("usb-storage",Qt::CaseInsensitive);
usbInfo.remove("Serial Number",Qt::CaseInsensitive);
usbInfo = usbInfo.simplified();
usbInfo.append(" ");
}
else
qWarning() << "No File in Usb-storage";
usbInfo.append(textDetect);
uiResponseWin->label->setText(usbInfo);
responseWindow->show();
responseConnection->hide();
QFile fileInfo;
QString usbInfoRaw, usbInfo;
QDir usbInfoDir(USBINFODIR);
if(!usbInfoDir.entryList(QDir::Files).isEmpty())
{
qDebug() << usbInfoDir;
fileInfo.setFileName(USBINFODIR + usbInfoDir.entryList(QDir::Files).first());
if(!fileInfo.open(QIODevice::ReadOnly | QIODevice::Text))
qWarning() << "Can't Get File" << fileInfo.fileName();
QTextStream in(&fileInfo);
QTextStream out(&usbInfoRaw);
out << in.read(100) << endl;
usbInfo = usbInfoRaw.section(':',1,3);
usbInfo.remove("Vendor:",Qt::CaseInsensitive);
usbInfo.remove("Product:",Qt::CaseInsensitive);
usbInfo.remove("usb-storage",Qt::CaseInsensitive);
usbInfo.remove("Serial Number",Qt::CaseInsensitive);
usbInfo = usbInfo.simplified();
usbInfo.append(" ");
}
else
qWarning() << "No File in Usb-storage";
usbInfo.append(textDetect);
uiResponseWin->label->setText(usbInfo);
responseWindow->show();
To copy to clipboard, switch view to plain text mode
Bookmarks