zoukankan      html  css  js  c++  java
  • Qt 获取usb设备信息 hacking

    /**************************************************************************
     *                       Qt 获取usb设备信息 hacking
     * 声明:
     *     本文主要是为了查看之前朋友留下的Qt获取usb设备信息软件运作机制。
     *
     *                                       2015-12-31 深圳 南山平山村 曾剑锋
     *************************************************************************/
    
    一、usbfs 文件系统
        需要在Linux内核中打开usbfs选项:
        ───────────────────────────────────────────────────────────────────────────
        ┌────────────────────────────── USB support ──────────────────────────────┐
        │  Arrow keys navigate the menu.  <Enter> selects submenus --->.          │  
        │  Highlighted letters are hotkeys.  Pressing <Y> includes, <N> excludes, │  
        │  <M> modularizes features.  Press <Esc><Esc> to exit, <?> for Help, </> │  
        │  for Search.  Legend: [*] built-in  [ ] excluded  <M> module  < >       │  
        │ ┌─────────────────────────────────────────────────────────────────────┐ │  
        │ │    --- USB support                                                  │ │  
        │ │    <*>   Support for Host-side USB                                  │ │  
        │ │    [*]     USB verbose debug messages                               │ │  
        │ │    [*]     USB announce new devices                                 │ │  
        │ │            *** Miscellaneous USB options ***                        │ │  
        │ │    [*]     USB device filesystem (DEPRECATED)    <----------- these │ │  
        │ │    [*]     USB device class-devices (DEPRECATED)                    │ │  
        │ │    [ ]     Dynamic USB minor allocation                             │ │  
        │ │    [*]     USB runtime power management (autosuspend) and wakeup    │ │  
        │ │    [*]       OTG support                                            │ │  
        │ └────v(+)─────────────────────────────────────────────────────────────┘ │  
        ├─────────────────────────────────────────────────────────────────────────┤  
        │                    <Select>    < Exit >    < Help >                     │  
        └─────────────────────────────────────────────────────────────────────────┘
    
    二、cat mainwindow.cpp
        #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
        
        void MainWindow::on_pushButton_clicked()
        {
            if(myprocess)
                delete myprocess;
        
            myprocess = new QProcess(this);
            connect(myprocess, SIGNAL(readyReadStandardOutput()),this, SLOT(result()));
            connect(myprocess, SIGNAL(readyReadStandardError()),this, SLOT(result()));
    
            /**
             * If you say Y here (and to "/proc file system support" in the "File     
             * systems" section, above), you will get a file /proc/bus/usb/devices    
             * which lists the devices currently connected to your USB bus or         
             * busses, and for every connected device a file named                    
             * "/proc/bus/usb/xxx/yyy", where xxx is the bus number and yyy the       
             * device number; the latter files can be used by user space programs     
             * to talk directly to the device. These files are "virtual", meaning     
             * they are generated on the fly and not stored on the hard drive.        
             *                                                                        
             * You may need to mount the usbfs file system to see the files, use      
             * mount -t usbfs none /proc/bus/usb                                      
             *                                                                        
             * For the format of the various /proc/bus/usb/ files, please read        
             * <file:Documentation/usb/proc_usb_info.txt>. 
             */
            myprocess->start("cat /proc/bus/usb/devices");
            ui->result->clear();
        }
        void MainWindow::result()
        {
            QString abc = myprocess->readAllStandardOutput();
            ui->result->append(abc.trimmed());
            QString efg = myprocess->readAllStandardError();
            if(efg.length()>1)ui->result->append(efg.trimmed());
        }
  • 相关阅读:
    BZOJ1257:[CQOI2007]余数之和——题解+证明
    BZOJ3781:小B的询问——题解
    BZOJ2038:[2009国家集训队]小Z的袜子——题解
    BZOJ3052 & UOJ58:[WC2013]糖果公园——题解
    BZOJ1086:[SCOI2005]王室联邦——题解
    BZOJ1878:[SDOI2009]HH的项链——题解
    BZOJ2453:维护队列——题解
    美团新零售招聘-高级测试开发(20k-50k/月)
    Shopee招聘-测试开发leader(30k-60k/月)
    蚂蚁金服招聘-无线测试开发(20k-36k/月)
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/5090606.html
Copyright © 2011-2022 走看看