资源简介
嵌入式设备 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通用控件背景透明的方法
相关资源
- Learning Linux Binary Analysis
- TPC-ZK系列USB学生实验指导书
- 蓝牙源代码应用于LINUX
- usb hid调试工具
- HID调试助手
- USB.Over.Network.Server 注册机
- uboot到linux logo显示不间断 补丁
- WPF USB 网络 串口 通信软件
- UNIX/LINUX编程实践教程的源码
- Linux任务管理器
- linux应用层的华容道游戏源代码
- USB转串口驱动,FT232R驱动程序,最新
- WinCE下CP210x的驱动程序
- hidusage.h hidpi.h 等USB开发用头文件
- ubuntu9.10 可加载内核模块和字符设备驱
- MP3文件ID3v2ID3v2APEv2标签读取
- 操作系统实验——虚存管理实验
- linux下的发包工具sendip
- 尚观培训linux许巍关于c 的笔记和讲义
- 尚观培训linux董亮老师关于数据结构的
- 基于JM20329的SATA转USB 1394
- 430系列单片机USBFET下载驱动
- linux 线程池源码 c 版
- linux C 电梯程序练习
- CY7C68013A固件程序(用于摄像机采集)
- linux下用多进程同步方法解决生产者
- usb调试程序 对USB设备进行数据的读写
- Linux 操作系统实验(全)
- Linux From Scratch 中文手册
- USB 驱动 让电脑与arm进行通信
评论
共有 条评论