资源简介
嵌入式设备 linux usb hid 设备连接 PC进行数据传输与封包的应用程序。
带有makefile文件,编译时需要修改为自己的交叉编译,才能运行。
字符数字特殊字符等数据内容与pc之间的传输。
代码片段和文件信息
/* hid_gadget_test */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define BUF_LEN 512
char *mytstnum=“112234567890\r“;
char *mytstchar0=“aabbcccdefghijklmnopqrstuvwsyzzzz\r“;
char *mytstchar1=“AABBCCCDEFGHIJKLMNOPQRSTUVWSYZZZZ\r“;
char *mytstspecchar0=“‘‘‘-=\\[];‘./\r“;
char *mytstspecchar1=“~~!!@#$%^&*()_+|{}:\“<>?\r“;
struct options {
const char *opt;
unsigned char val;
};
static struct options knum1[] = {
{.opt = “1“ .val = 0x1e}
{.opt = “2“ .val = 0x1f}
{.opt = “3“ .val = 0x20}
{.opt = “4“ .val = 0x21}
{.opt = “5“ .val = 0x22}
{.opt = “6“ .val = 0x23}
{.opt = “7“ .val = 0x24}
{.opt = “8“ .val = 0x25}
{.opt = “9“ .val = 0x26}
{.opt = “0“ .val = 0x27}
{.opt = NULL}
};
static struct options knum2[] = {
{.opt = “1“ .val = 0x59}
{.opt = “2“ .val = 0x5a}
{.opt = “3“ .val = 0x5b}
{.opt = “4“ .val = 0x5c}
{.opt = “5“ .val = 0x5d}
{.opt = “6“ .val = 0x5e}
{.opt = “7“ .val = 0x5f}
{.opt = “8“ .val = 0x60}
{.opt = “9“ .val = 0x61}
{.opt = “0“ .val = 0x62}
{.opt = NULL}
};
//00 00 start
static struct options special[] = {
{.opt = “‘“ .val = 0x35}
{.opt = “-“ .val = 0x2d}
{.opt = “=“ .val = 0x2e}
{.opt = “[“ .val = 0x2f}
{.opt = “]“ .val = 0x30}
{.opt = “\\“ .val = 0x31}
{.opt = “;“ .val = 0x33}
{.opt = “\‘“ .val = 0x34}
{.opt = ““ .val = 0x36}
{.opt = “.“ .val = 0x37}
{.opt = “/“ .val = 0x38}
{.opt = NULL}
};
//02 00 start
static struct options shift_special[] = {
{.opt = “~“ .val = 0x35}
{.opt = “!“ .val = 0x1e}
{.opt = “@“ .val = 0x1f}
{.opt = “#“ .val = 0x20}
{.opt = “$“ .val = 0x21}
{.opt = “%“ .val = 0x22}
{.opt = “^“ .val = 0x23}
{.opt = “&“ .val = 0x24}
{.opt = “*“ .val = 0x25}
{.opt = “(“ .val = 0x26}
{.opt = “)“ .val = 0x27}
{.opt = “_“ .val = 0x2d}
{.opt = “+“ .val = 0x2e}
{.opt = “{“ .val = 0x2f}
{.opt = “}“ .val = 0x30}
{.opt = “|“ .val = 0x31}
{.opt = “:“ .val = 0x33}
{.opt = “\““ .val = 0x34}
{.opt = “<“ .val = 0x36}
{.opt = “>“ .val = 0x37}
{.opt = “\?“ .val = 0x38}
{.opt = “ “ .val = 0x2c}
{.opt = “\r“ .val = 0x28}//return
{.opt = NULL}
};
static struct options kmod[] = {
{.opt = “--left-ctrl“ .val = 0x01}
{.opt = “--right-ctrl“ .val = 0x10}
{.opt = “--left-shift“ .val = 0x02}
{.opt = “--right-shift“ .val = 0x20}
{.opt = “--left-alt“ .val = 0x04}
{.opt = “--right-alt“ .val = 0x40}
{.opt = “--left-meta“ .val = 0x08}
{.opt = “--right-meta“ .val = 0x80}
{.opt = NULL}
};
int keyboard_fill_one_report(char report[8] char *ch)
{
char chcmp[2];
char *tok;
int key = 0;
int i = 0;
memset(chcmp02*sizeof(char));
chcmp[0]=*ch;
tok=chcmp;
if(tok != NULL){
//*hold = 1;
if(isalnum(tok[0])) //0~9 a~z A~Z
{
if (islower(tok[0])) { //a~z
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
-rw-rw-r-- 177 2018-05-26 12:42 test_for_hid\Makefile
-rwxrwxr-x 11439 2018-05-26 12:45 test_for_hid\myhid_g
-rw-rw-r-- 6190 2018-05-26 12:45 test_for_hid\gadget_hid.c
drwxrwxr-x 0 2018-05-26 12:45 test_for_hid
----------- --------- ---------- ----- ----
17806 4
- 上一篇:2018年中国科技核心期刊目录自然科学卷
- 下一篇:VC通用控件背景透明的方法
相关资源
- 用qml简单的文本编辑器,可以跨平台
- SMSC-USB 2240读卡器
- LINUX下的一个多线程的服务器和客户端
- tcpdump-4.9.0-5.el7.x86_64.rpm
- Linux C利用多进程或多线程模拟实现生
- linux下用freetype2显示汉字
- lsof-4.82-4.el6.x86_64.rpm
- Linux操作系统设计实践报告一
- ch340-usb转ttl驱动
- 等保主机安全基线合规--配置指导li
- linux ls命令 源代码
- linux 系统调用 实现文件复制
- usb摄像头设计原理图
- linux kernel系统函数调用层次图
- linux Ubuntu系统网络调试助手.rar
- LINUX日常代码集锦
- vas5054usb驱动
- Using 9P2000 Under Linux
- \\基于WDF过滤驱动的USB存储设备监控系
- adv7610驱动
- 打造linux下的Source Insight
- v4l2 USB摄像头图像采集程序C
- iperf-3.3.tar.gz
- Linux 下的exfat文件系统驱动,内核版本
- usb控制注册表
- Linux 个人防火墙的设计与实现课程设
- 接口封装库,USB3.0microB,USB-B,SMA,
- zmodem协议linux下的源代码
- qt字符设备驱动,简单易学
- 官网JDK1.7.0Linux_32位.txt
评论
共有 条评论