PDA

View Full Version : Detection usb device connection/disconnection



binaural
18th June 2009, 19:38
Hi,

I'm trying to find some solution how to check in application is usb device (know vendor and product id) was plugged/unplugged. Any example?

Thanks

M

QbelcorT
19th June 2009, 05:34
Hi,
I made a response to this awhile back, see this thread. http://www.qtcentre.org/forum/f-qt-programming-2/t-hot-plug-and-button-event-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();
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();

saleh1
26th August 2012, 08:58
hi
could you send me full source code application that could be detect a device in Linux when connect to USB and show name ,id vendor and serial number in table view with check mark box that user can add the device by check mark each device and also one push button to add device in data base.and authorize(that entered in database) flash only could be mount in system.
please answer my question as soon as possible.
this in urgent question

( sorry for bad English writing):(

best regard

Talei
26th August 2012, 09:13
Do You want 50$ with source code also, or just source is enough?

saleh1
26th August 2012, 10:08
hi Talei

how to deliver your money and take the source code.? I have not master or credit card

please send me a brief and sample code and snap shot of GUI of your program to ensure that exactly what i want, also please send your post address ,email.telephone number. to send money

thanks

spirit
26th August 2012, 11:13
hi Talei

how to deliver your money and take the source code.? I have not master or credit card

please send me a brief and sample code and snap shot of GUI of your program to ensure that exactly what i want, also please send your post address ,email.telephone number. to send money

thanks

Gosh. First of all it was sarcasm. Second - use private messages if you want to buy something.
Unbelievable.

saleh1
26th August 2012, 13:46
hi spirit

unfortunately I must be said
you have low IQ a or you are Naive.

getting email adders is usage of this Transaction . and It's just approach and prepare Working conditions for you and the other .!
:cool::;)
have nice time.!;)

spirit
26th August 2012, 16:04
hi spirit

unfortunately I must be said
you have low IQ a or you are Naive.

getting email adders is usage of this Transaction . and It's just approach and prepare Working conditions for you and the other .!
:cool::;)
have nice time.!;)

Dude, watch your mouth! You are the last person who will teach me how to transactions and other stuff work.
If you can't get what sarcasm is then __you__ have low IQ a or you are Naive.
This forum has nothing to do with buy & sell.
If you want to provide job opportunity use correct forum ("Jobs").

saleh1
26th August 2012, 18:02
OK
thank you for your help man !:D
Then I'm trying to be careful of your Advice.
Good luck;)

getraju22
18th September 2012, 11:59
Thanks for the stuff