Qt 获取usb设备信息 hacking
2015-12-31 08:46
495 查看
/************************************************************************** * 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()); }
相关文章推荐
- Qt连接MySQL失败
- qTip2 Events详细说明
- Qt的信号槽,一个老MFC的经验
- 自学QT之菜单按钮(按钮菜单)即带有菜单的按钮
- QT怎样在QTableWidge显示图片
- Windows中Qt+OpenCV配置
- Qt的Model/View (二)
- Qt Model/View( 一)
- Qt plugin系统的几点说明
- Qt中将QTableView中的数据导出为Excel文件
- QTP入门——玩玩小飞机
- QTableView另类打印解决方案(复用render函数去解决print问题)
- Qt的Model/View Framework解析(数据是从真正的“肉(raw)”里取得,Model提供肉,所以读写文件、操作数据库、网络通讯等一系列与数据打交道的工作就在model中做了)
- QT平台连接MySQL数据库
- qt里产生随机数
- Qt学习(14)
- QT 多种状态的背景图片, 放在同一张图上, border-image 进行分割,拉伸
- Qt文件操作:遍历文件夹中 指定格式的文件,并添加文件名到comboBox上
- qt 下的一个小日志系统
- Qt之开机自启动及拥有管理员权限