Linux-hexdump命令调试event驱动

hexdump: 查看文件的内容,比如二进制文件中包含的某些字符串,通常用来调试驱动用

描述

我们以event1为例,当我们insmod挂载了键盘驱动后,出现一个event1设备,

此时没有按键按下,所以event1里面的数据是没有的,那么数据又是从来哪里来?

通过键盘驱动的read函数,若有按键按下,就会上传按键数据给用户层hexdump

因为键盘驱动的input_handler 是:evdev_handler

所以键盘驱动的read函数是: evdev_handler->evdev_fops->evdev_read

进入evdev_read()函数,如下图所示:
这里写图片描述
evdev_event_to_user()这个函数从字面上来看,显然就是用来上传给用户层的函数,其中buffer是函数参数,指向用户层,

所以数据就是event.

我们来看看event的结构体:input_event

struct input_event {
struct timeval time;  //事件发生的时间
__u16 type;            //  哪类事件, 比如键盘事件
__u16 code;     // 对应的事件里支持的哪个变量,比如按键K
__s32 value;   // 对应的变量里的数值, 比如松开按键则是1,反之为0
};

把 time里的成员展开如下:

struct input_event {
long   tv_sec; /* seconds */          //秒
long   tv_usec;    /* microseconds */     //微妙

__u16 type;            //  哪类事件, 比如键盘事件
__u16 code;     // 对应的事件里支持的哪个变量,比如按键K
__s32 value;   // 对应的变量里的数值, 比如松开按键则是1,反之为0
};

所以我们hexdump调试任何输入子系统event XX驱动时,有信息就会打印上面数据

调试键盘驱动

(键盘驱动代码:http://www.cnblogs.com/lifexy/p/7553861.html)
以按开发板的按键 KEY_L,为例(因为数据是从低到高打印的,所以数据是反的):

# hexdump /dev/event1     //按键键盘驱动

/*按下时:*/
//hexdump序列号          秒             微妙         键盘事件    code=KEY_L     value=1(按下)
            07c6 0000      faa2 000b      0001        0026          0001 0000
//hexdump序列号          秒             微妙         同步事件       code        value=0 
           07c6 0000      faac 000b       0000        0000          0000 0000

/*松开时:*/
//hexdump序列号          秒             微妙         键盘事件     code=0x26     value=0(松开)
            07c6 0000     cf67 000d        0001        0026         0000 0000
//hexdump序列号          秒             微妙         同步事件      code         value=0 
            07c6 0000     cf70 000d        0000        0000         0000 0000

调试触摸屏驱动

(触摸屏驱动代码: )

/dev/event0            //触摸屏驱动
# hexdump /dev/event0 
//hexdump序列号          秒             微妙        绝对坐标事件    code=ABS_X   X坐标值 
              0412 0000      6ef0 000c      0003          0000      0239 0000
//hexdump序列号          秒             微妙        绝对坐标事件    code=ABS_Y   Y坐标值
                0412 0000    6f08 000c      0003          0001      01ae 0000
//hexdump序列号          秒             微妙        绝对坐标事件    code=压力     压力值
            0412 0000        6f0c 000c      0003          0018      0001 0000
//hexdump序列号          秒             微妙        键盘事件       code=触摸按键  value=1(按下)
             0412 0000       6f10 000c      0001          014a      0001 0000
//hexdump序列号          秒             微妙        同步事件      
            0412 0000        6f13 000c      0000          0000      0000 0000

//hexdump序列号          秒             微妙        绝对坐标事件    code=压力     压力值
00000b0               023b 0000      872d 000c      0003          0018      0000 0000

//hexdump序列号          秒             微妙        键盘事件      code=触摸按键  value=0(松开)
00000b0            0412 0000         1f5b 000d     0001          014a       0000 0000
//hexdump序列号          秒             微妙        同步事件      
00000c0             0412 0000        1f70 000d     0000          0000       0000 0000
# wpa_supplicant -d -i wlan0 -c /tmp/wifi.conf wpa_supplicant v2.10 random: Trying to read entropy from /dev/random Successfully initialized wpa_supplicant Initializing interface 'wlan0' conf '/tmp/wifi.conf' driver 'default' ctrl_interface 'N/A' bridge 'N/A' Configuration file '/tmp/wifi.conf' -> '/tmp/wifi.conf' Reading configuration file '/tmp/wifi.conf' nl80211: Supported cipher 00-0f-ac:1 nl80211: Supported cipher 00-0f-ac:5 nl80211: Supported cipher 00-0f-ac:2 nl80211: Supported cipher 00-0f-ac:4 nl80211: Supported cipher 00-0f-ac:6 nl80211: Using driver-based off-channel TX nl80211: key_mgmt=0xd0f enc=0x10f auth=0x7 flags=0x800d0c0 rrm_flags=0x0 probe_resp_offloads=0x0 max_stations=0 max_remain_on_chan=5000 max_scan_ssids=9 nl80211: interface wlan0 in phy phy0 nl80211: Set mode ifindex 2 iftype 2 (STATION) nl80211: Subscribe to mgmt frames with non-AP handle 0x56ce68 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=0801 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 08 01 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=06 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=1): 06 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=0a07 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 0a 07 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=0a11 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 0a 11 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=1101 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 11 01 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=1102 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 11 02 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=0505 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 05 05 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=0500 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 05 00 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=1301 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 13 01 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=1305 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 13 05 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x56ce68 match=7e506f9a1a multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=5): 7e 50 6f 9a 1a nl80211: Failed to register Action frame processing - ignore for now rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0 netlink: Operstate: ifindex=2 linkmode=1 (userspace-control), operstate=5 (IF_OPER_DORMANT) Add interface wlan0 to a new radio phy0 nl80211: Regulatory information - country=00 nl80211: 2402-2472 @ 40 MHz 20 mBm nl80211: 2457-2482 @ 20 MHz 20 mBm (no IR) nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR) nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR) nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR) nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR) nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR) nl80211: 57240-63720 @ 2160 MHz 0 mBm nl80211: Added 802.11b mode based on 802.11g information nl80211: Mode IEEE 802.11g: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467[NO_IR] 2472[NO_IR] 2484[DISABLED] nl80211: Mode IEEE 802.11b: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467[NO_IR] 2472[NO_IR] 2484[DISABLED] wlan0: Own MAC address: cc:b8:5e:f5:a6:86 wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key
最新发布
06-06
Configuration file: wifi.conf nl80211: Supported cipher 00-0f-ac:1 nl80211: Supported cipher 00-0f-ac:5 nl80211: Supported cipher 00-0f-ac:2 nl80211: Supported cipher 00-0f-ac:4 nl80211: Supported cipher 00-0f-ac:6 nl80211: Supported cipher 00-0f-ac:8 nl80211: Supported cipher 00-0f-ac:9 nl80211: Supported cipher 00-0f-ac:10 nl80211: Supported cipher 00-0f-ac:11 nl80211: Supported cipher 00-0f-ac:12 nl80211: Supported cipher 00-0f-ac:13 nl80211: Supported vendor command: vendor_id=0x1a11 subcmd=4106 nl80211: Supported vendor command: vendor_id=0x1a11 subcmd=4107 nl80211: Use separate P2P group interface (driver advertised support) nl80211: key_mgmt=0xf0f enc=0xfef auth=0x7 flags=0x8000009a407ac0 rrm_flags=0x0 probe_resp_offloads=0x0 max_station9 nl80211: interface wlan0 in phy phy0 nl80211: Set mode ifindex 5 iftype 3 (AP) nl80211: Setup AP(wlan0) - device_ap_sme=1 use_monitor=0 nl80211: Subscribe to mgmt frames with AP handle 0xb6ba5ed0 (device SME) nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xb6ba5ed0 match=04 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=1): 04 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xb6ba5ed0 match=0501 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 05 01 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xb6ba5ed0 match=0503 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 05 03 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xb6ba5ed0 match=0504 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=2): 05 04 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xb6ba5ed0 match=06 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=1): 06 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xb6ba5ed0 match=08 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=1): 08 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xb6ba5ed0 match=09 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=1): 09 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xb6ba5ed0 match=0a multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=1): 0a nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xb6ba5ed0 match=11 multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=1): 11 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xb6ba5ed0 match=7f multicast=0 nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=1): 7f nl80211: Failed to subscribe for mgmt frames from SME driver - trying to run without it nl80211: Enable Probe Request reporting nl_preq=0xb6ba5ed0 nl80211: Register frame type=0x40 (WLAN_FC_STYPE_PROBE_REQ) nl_handle=0xb6ba5ed0 match= multicast=0 nl80211: Register frame command failed (type=64): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=0): [NULL] nl80211: Failed to enable Probe Request frame reporting in AP mode rfkill: initial event: idx=1 type=1 op=0 soft=0 hard=0 nl80211: Add own interface ifindex 5 (ifidx_reason -1) nl80211: if_indices[16]: 5(-1) phy: phy0 BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits) nl80211: Regulatory information - country=99 nl80211: 5170-5250 @ 80 MHz 20 mBm nl80211: 5735-5835 @ 80 MHz 20 mBm nl80211: Added 802.11b mode based on 802.11g information nl80211: Mode IEEE 802.11g: 2412[DISABLED] 2417[DISABLED] 2422[DISABLED] 2427[DISABLED] 2432[DISABLED] 2437[DISABLE] nl80211: Mode IEEE 802.11a: 5180 5200 5220 5240 5260[DISABLED] 5280[DISABLED] 5300[DISABLED] 5320[DISABLED] 5500[DI] nl80211: Mode IEEE 802.11b: 2412[DISABLED] 2417[DISABLED] 2422[DISABLED] 2427[DISABLED] 2432[DISABLED] 2437[DISABLE] Completing interface initialization Mode: IEEE 802.11a Channel: 36 Frequency: 5180 MHz DFS 0 channels required radar detection nl80211: Set freq 5180 (ht_enabled=0, vht_enabled=0, he_enabled=0, bandwidth=20 MHz, cf1=5180 MHz, cf2=0 MHz) * freq=5180 * he_enabled=0 * vht_enabled=0 * ht_enabled=0 * channel_type=0 nl80211: Failed to set channel (freq=5180): -16 (Resource busy) Could not set channel for kernel driver Interface initialization failed wlan0: interface state UNINITIALIZED->DISABLED wlan0: AP-DISABLED wlan0: Unable to setup interface. hostapd_interface_deinit_free(0xb6c4c950) hostapd_interface_deinit_free: num_bss=1 conf->num_bss=1 hostapd_interface_deinit(0xb6c4c950) wlan0: interface state DISABLED->DISABLED hostapd_bss_deinit: deinit bss wlan0 wlan0: Deauthenticate all stations nl80211: sta_remove -> DEL_STATION wlan0 ff:ff:ff:ff:ff:ff --> -22 (Invalid argument) wlan0: AP-DISABLED hostapd_cleanup(hapd=0xb6ba5510 (wlan0)) wlan0: CTRL-EVENT-TERMINATING hostapd_free_hapd_data: Interface wlan0 wasn't started hostapd_interface_deinit_free: driver=0xbb5b4 drv_priv=0xb6c4cf80 -> hapd_deinit nl80211: deinit ifname=wlan0 disabled_11b_rates=0 nl80211: Remove monitor interface: refcount=0 nl80211: Remove beacon (ifindex=5) netlink: Operstate: ifindex=5 linkmode=0 (kernel-control), operstate=6 (IF_OPER_UP) hostapd_interface_free(0xb6c4c950) hostapd_interface_free: free hapd 0xb6ba5510 hostapd_cleanup_iface(0xb6c4c950) hostapd_cleanup_iface_partial(0xb6c4c950) hostapd_cleanup_iface: free iface=0xb6c4c950
05-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值