Results 1 to 10 of 10

Thread: Detection usb device connection/disconnection

  1. #1
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Post Detection usb device connection/disconnection

    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

  2. #2
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Detection usb device connection/disconnection

    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
    Qt Code:
    1. responseConnection->hide();
    2. QFile fileInfo;
    3. QString usbInfoRaw, usbInfo;
    4. QDir usbInfoDir(USBINFODIR);
    5. if(!usbInfoDir.entryList(QDir::Files).isEmpty())
    6. {
    7. qDebug() << usbInfoDir;
    8. fileInfo.setFileName(USBINFODIR + usbInfoDir.entryList(QDir::Files).first());
    9. if(!fileInfo.open(QIODevice::ReadOnly | QIODevice::Text))
    10. qWarning() << "Can't Get File" << fileInfo.fileName();
    11. QTextStream in(&fileInfo);
    12. QTextStream out(&usbInfoRaw);
    13. out << in.read(100) << endl;
    14. usbInfo = usbInfoRaw.section(':',1,3);
    15. usbInfo.remove("Vendor:",Qt::CaseInsensitive);
    16. usbInfo.remove("Product:",Qt::CaseInsensitive);
    17. usbInfo.remove("usb-storage",Qt::CaseInsensitive);
    18. usbInfo.remove("Serial Number",Qt::CaseInsensitive);
    19. usbInfo = usbInfo.simplified();
    20. usbInfo.append(" ");
    21. }
    22. else
    23. qWarning() << "No File in Usb-storage";
    24. usbInfo.append(textDetect);
    25. uiResponseWin->label->setText(usbInfo);
    26. responseWindow->show();
    To copy to clipboard, switch view to plain text mode 
    Last edited by QbelcorT; 19th June 2009 at 04:43.

  3. The following user says thank you to QbelcorT for this useful post:

    saleh1 (26th August 2012)

  4. #3
    Join Date
    Aug 2012
    Posts
    4
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Re: Detection usb device connection/disconnection

    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

  5. #4
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Detection usb device connection/disconnection

    Do You want 50$ with source code also, or just source is enough?
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  6. #5
    Join Date
    Aug 2012
    Posts
    4
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Lightbulb Re: Detection usb device connection/disconnection

    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

  7. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Detection usb device connection/disconnection

    Quote Originally Posted by saleh1 View Post
    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.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  8. #7
    Join Date
    Aug 2012
    Posts
    4
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Cool Re: Detection usb device connection/disconnection

    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 .!
    :
    have nice time.!

  9. #8
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Detection usb device connection/disconnection

    Quote Originally Posted by saleh1 View Post
    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 .!
    :
    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").
    Last edited by spirit; 26th August 2012 at 15:23.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  10. #9
    Join Date
    Aug 2012
    Posts
    4
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Smile Re: Detection usb device connection/disconnection

    OK
    thank you for your help man !
    Then I'm trying to be careful of your Advice.
    Good luck

  11. #10
    Join Date
    Jul 2008
    Posts
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Detection usb device connection/disconnection

    Thanks for the stuff

Similar Threads

  1. QtExtended Porting on ARM Device - Color Problem
    By ramsarvan in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 19th February 2009, 06:32
  2. Replies: 0
    Last Post: 18th October 2008, 23:01
  3. No network when Modem Emulator connect to a real device
    By tommy_tang in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 10th December 2007, 08:24
  4. USB device detection problem
    By yellowmat in forum Qt Programming
    Replies: 1
    Last Post: 19th August 2006, 12:04
  5. how to export images of Qt/Embedded on Device
    By mahe2310 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 23rd March 2006, 12:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.