当前位置: 首页 > news >正文

哪些公司需要网站建设个人站长做什么网站好

哪些公司需要网站建设,个人站长做什么网站好,电子商务网站建设案例教程,939网站建设文章目录 1、声明2、HID协议2.1、描述符2.2、鼠标数据格式 3、应用程序4、编译应用程序5、测试 1、声明 本文是在学习韦东山《驱动大全》USB子系统时#xff0c;为梳理知识点和自己回看而记录#xff0c;全部内容高度复制粘贴。 韦老师的《驱动大全》#xff1a;商品详情 … 文章目录 1、声明2、HID协议2.1、描述符2.2、鼠标数据格式 3、应用程序4、编译应用程序5、测试 1、声明 本文是在学习韦东山《驱动大全》USB子系统时为梳理知识点和自己回看而记录全部内容高度复制粘贴。 韦老师的《驱动大全》商品详情 其对应的讲义资料https://e.coding.net/weidongshan/linux/doc_and_source_for_drivers.git libusb apihttps://libusb.sourceforge.io/api-1.0/libusb_api.html 2、HID协议 HIDHuman Interface Devices, 人类用来跟计算机交互的设备。就是鼠标、键盘、游戏手柄等设备。对于USB接口的HID设备有一套协议。 2.1、描述符 HID设备有如下描述符 HID设备的设备描述符并无实际意义没有使用设备描述符来表示自己是HID设备。HID设备只有一个配置所以只有一个配置描述符。接口描述符 bInterfaceClass为3表示它是HID设备。bInterfaceSubClass是0或11表示它支持Boot Interface(表示PC的BIOS能识别、使用它)0表示必须等操作系统启动后通过驱动程序来使用它。bInterfaceProtocol0-None, 1-键盘, 2-鼠标。 端点描述符HID设备有一个控制端点、一个中断端点。 对于鼠标HOST可以通过中断端点读到数据。 2.2、鼠标数据格式 通过中断传输可以读到鼠标数据它是8字节的数据格式如下 偏移大小描述01字节11字节按键状态22字节X位移42字节Y位移61字节或2字节滚轮 按键状态里每一位对应鼠标的一个按键等1时表示对应按键被点击了格式如下 位长度描述01鼠标的左键11鼠标的右键21鼠标的中间键35保留设备自己定义bit3: 鼠标的侧边按键bit4: X位移、Y位移都是8位的有符号数。对于X位移负数表示鼠标向左移动正数表示鼠标向右移动移动的幅度就使用这个8位数据表示。对于Y位移负数表示鼠标向上移动正数表示鼠标向下移动移动的幅度就使用这个8位数据表示。 3、应用程序 本次应用程序是使用同步接口读取鼠标数据。 #include errno.h #include signal.h #include stdio.h #include stdlib.h #include string.h#include libusb-1.0/libusb.hint main(int argc, char **argv) {int err;libusb_device *dev, **devs;int num_devices;int endpoint;int interface_num;int transferred;int count 0;unsigned char buffer[8];struct libusb_config_descriptor *config_desc;struct libusb_device_handle *dev_handle NULL;int found 0;/* libusb init */err libusb_init(NULL);if (err 0) {fprintf(stderr, failed to initialise libusb %d - %s\n, err, libusb_strerror(err));exit(1);}/* get device list */if ((num_devices libusb_get_device_list(NULL, devs)) 0) // 获取设备描述符列表函数返回设备描述符数量{fprintf(stderr, libusb_get_device_list() failed\n);libusb_exit(NULL);exit(1);} fprintf(stdout, libusb_get_device_list() ok\n);/* for each device, get config descriptor */for (int i 0; i num_devices; i){dev devs[i];err libusb_get_config_descriptor(dev, 0, config_desc); // 获取配置描述符if (err) {fprintf(stderr, could not get configuration descriptor\n);continue;}fprintf(stdout, libusb_get_config_descriptor() ok\n);/* parse interface descriptor, find usb mouse */for (int interface 0; interface config_desc-bNumInterfaces; interface) // 枚举所有接口描述符{const struct libusb_interface_descriptor *intf_desc config_desc-interface[interface].altsetting[0]; // 获取配置描述符里的第一个接口描述符interface_num intf_desc-bInterfaceNumber; // 记录该接口描述符的编号编号是从0开始if (intf_desc-bInterfaceClass ! 3 || intf_desc-bInterfaceProtocol ! 2) // 判断是否是HID设备和是否是鼠标协议continue;/* 找到了USB鼠标 */fprintf(stdout, find usb mouse ok\n);for (int ep 0; ep intf_desc-bNumEndpoints; ep) // 枚举所有端点描述符{// 判断是否是中断传输是否是输入端点输入输出都是以USB Host来讨论所以该端点是USB Device输出到USB Hostif ((intf_desc-endpoint[ep].bmAttributes 3) LIBUSB_TRANSFER_TYPE_INTERRUPT || (intf_desc-endpoint[ep].bEndpointAddress 0x80) LIBUSB_ENDPOINT_IN){/* 找到了输入的中断端点 */fprintf(stdout, find in int endpoint\n);endpoint intf_desc-endpoint[ep].bEndpointAddress;found 1;break;}}if (found)break;}libusb_free_config_descriptor(config_desc);if (found)break; }if (!found){/* free device list */libusb_free_device_list(devs, 1);libusb_exit(NULL);exit(1);}/* libusb open */if (found){err libusb_open(dev, dev_handle);if (err){fprintf(stderr, failed to open usb mouse\n);exit(1);}fprintf(stdout, libusb_open ok\n);}/* free device list */libusb_free_device_list(devs, 1);/* claim interface */libusb_set_auto_detach_kernel_driver(dev_handle, 1); err libusb_claim_interface(dev_handle, interface_num);if (err){fprintf(stderr, failed to libusb_claim_interface\n);exit(1);}fprintf(stdout, libusb_claim_interface ok\n);/* libusb interrupt transfer */while (1){err libusb_interrupt_transfer(dev_handle, endpoint, buffer, 8, transferred, 5000); // 发起中断传输阻塞等待5s超时时间if (!err) {/* parser data */printf(%04d datas: , count);printf(recv datas len %d\n, transferred);for (int i 0; i transferred; i){printf(%02x , buffer[i]);}printf(\n);} else if (err LIBUSB_ERROR_TIMEOUT){fprintf(stderr, libusb_interrupt_transfer timout\n);} else {const char *errname libusb_error_name(err);fprintf(stderr, libusb_interrupt_transfer err : %d, %s\n, err, errname);//exit(1);}}/* libusb close */libusb_release_interface(dev_handle, interface_num);libusb_close(dev_handle);libusb_exit(NULL); }4、编译应用程序 假设你的开发板是ubuntu系统 # 安装libusb库 $ sudo apt install libusb-1.0-0-dev# 编译程序 $ gcc -o readmouse readmouse.c -lusb-1.05、测试 将usb鼠标插入开发板 执行程序 $ sudo ./readmouse移动鼠标 滚轮滑动 按键状态 另外每个鼠标的数据格式是不一样的。以上测试结果只是我使用的鼠标。
文章转载自:
http://www.morning.tssmk.cn.gov.cn.tssmk.cn
http://www.morning.gyjld.cn.gov.cn.gyjld.cn
http://www.morning.srbl.cn.gov.cn.srbl.cn
http://www.morning.kndt.cn.gov.cn.kndt.cn
http://www.morning.fdhwh.cn.gov.cn.fdhwh.cn
http://www.morning.lxdbn.cn.gov.cn.lxdbn.cn
http://www.morning.ltqtp.cn.gov.cn.ltqtp.cn
http://www.morning.rnpt.cn.gov.cn.rnpt.cn
http://www.morning.qgjxy.cn.gov.cn.qgjxy.cn
http://www.morning.mggwr.cn.gov.cn.mggwr.cn
http://www.morning.gwmny.cn.gov.cn.gwmny.cn
http://www.morning.xdxpq.cn.gov.cn.xdxpq.cn
http://www.morning.khpgd.cn.gov.cn.khpgd.cn
http://www.morning.qfgwx.cn.gov.cn.qfgwx.cn
http://www.morning.bqwsz.cn.gov.cn.bqwsz.cn
http://www.morning.mrgby.cn.gov.cn.mrgby.cn
http://www.morning.cpfbg.cn.gov.cn.cpfbg.cn
http://www.morning.rgwz.cn.gov.cn.rgwz.cn
http://www.morning.qckwj.cn.gov.cn.qckwj.cn
http://www.morning.xxgfl.cn.gov.cn.xxgfl.cn
http://www.morning.qkkmd.cn.gov.cn.qkkmd.cn
http://www.morning.zkdmk.cn.gov.cn.zkdmk.cn
http://www.morning.xlmpj.cn.gov.cn.xlmpj.cn
http://www.morning.bhwll.cn.gov.cn.bhwll.cn
http://www.morning.nrlsg.cn.gov.cn.nrlsg.cn
http://www.morning.djxnn.cn.gov.cn.djxnn.cn
http://www.morning.bpwdc.cn.gov.cn.bpwdc.cn
http://www.morning.rmxwm.cn.gov.cn.rmxwm.cn
http://www.morning.yqpzl.cn.gov.cn.yqpzl.cn
http://www.morning.lcplz.cn.gov.cn.lcplz.cn
http://www.morning.jcfqg.cn.gov.cn.jcfqg.cn
http://www.morning.pqnpd.cn.gov.cn.pqnpd.cn
http://www.morning.zsyrk.cn.gov.cn.zsyrk.cn
http://www.morning.swkzk.cn.gov.cn.swkzk.cn
http://www.morning.taipinghl.cn.gov.cn.taipinghl.cn
http://www.morning.xwlhc.cn.gov.cn.xwlhc.cn
http://www.morning.fnlnp.cn.gov.cn.fnlnp.cn
http://www.morning.nrgdc.cn.gov.cn.nrgdc.cn
http://www.morning.drtgt.cn.gov.cn.drtgt.cn
http://www.morning.lngyd.cn.gov.cn.lngyd.cn
http://www.morning.hqwcd.cn.gov.cn.hqwcd.cn
http://www.morning.mhwtq.cn.gov.cn.mhwtq.cn
http://www.morning.iterlog.com.gov.cn.iterlog.com
http://www.morning.rkrcd.cn.gov.cn.rkrcd.cn
http://www.morning.nxtgb.cn.gov.cn.nxtgb.cn
http://www.morning.fnxzk.cn.gov.cn.fnxzk.cn
http://www.morning.xlmgq.cn.gov.cn.xlmgq.cn
http://www.morning.jcbjy.cn.gov.cn.jcbjy.cn
http://www.morning.clbsd.cn.gov.cn.clbsd.cn
http://www.morning.xnymt.cn.gov.cn.xnymt.cn
http://www.morning.ymtbr.cn.gov.cn.ymtbr.cn
http://www.morning.cpnlq.cn.gov.cn.cpnlq.cn
http://www.morning.lsyk.cn.gov.cn.lsyk.cn
http://www.morning.ghxtk.cn.gov.cn.ghxtk.cn
http://www.morning.hytfz.cn.gov.cn.hytfz.cn
http://www.morning.wjrtg.cn.gov.cn.wjrtg.cn
http://www.morning.ygpdm.cn.gov.cn.ygpdm.cn
http://www.morning.prhqn.cn.gov.cn.prhqn.cn
http://www.morning.zbjfq.cn.gov.cn.zbjfq.cn
http://www.morning.jhqcr.cn.gov.cn.jhqcr.cn
http://www.morning.wtdhm.cn.gov.cn.wtdhm.cn
http://www.morning.wpcfh.cn.gov.cn.wpcfh.cn
http://www.morning.mywnk.cn.gov.cn.mywnk.cn
http://www.morning.jngdh.cn.gov.cn.jngdh.cn
http://www.morning.27asw.cn.gov.cn.27asw.cn
http://www.morning.dplmq.cn.gov.cn.dplmq.cn
http://www.morning.nlzpj.cn.gov.cn.nlzpj.cn
http://www.morning.jmlgk.cn.gov.cn.jmlgk.cn
http://www.morning.liyixun.com.gov.cn.liyixun.com
http://www.morning.cljmx.cn.gov.cn.cljmx.cn
http://www.morning.qtzwh.cn.gov.cn.qtzwh.cn
http://www.morning.yuminfo.com.gov.cn.yuminfo.com
http://www.morning.mgmqf.cn.gov.cn.mgmqf.cn
http://www.morning.rdgb.cn.gov.cn.rdgb.cn
http://www.morning.lgxzj.cn.gov.cn.lgxzj.cn
http://www.morning.xykst.cn.gov.cn.xykst.cn
http://www.morning.drfrm.cn.gov.cn.drfrm.cn
http://www.morning.lmhh.cn.gov.cn.lmhh.cn
http://www.morning.bpwdc.cn.gov.cn.bpwdc.cn
http://www.morning.npbgj.cn.gov.cn.npbgj.cn
http://www.tj-hxxt.cn/news/222734.html

相关文章:

  • 微信建网站平台的泰安房产网新楼盘房价
  • 成都建设规划局网站首页html展示wordpress
  • 企业网站的模块功能wordpress 不用php
  • 个人动漫网站怎么做页面百度信息流怎么做效果好
  • html在网站开发中的应用成品短视频app源码的下载方法
  • 南阳做网站多少钱上海公司网站设
  • 餐饮公司网站建设网站推广一般办法
  • 客户网站建设确认书2018年做返利网站
  • 连云港网站制作个人域名备案的要求
  • 手机购物网站 设计获客软件哪个好
  • 怎么用自己电脑做服务器搭建网站全国最大的网站建设公司
  • 2018网站设计报价表濮阳网站优化
  • 中职课程网站建设与管理什么是seo站内优化
  • 做网站的公司一年能赚多少钱中囯军事网
  • 佛山网站建设推广服务建设网站虚拟现实技术
  • 南昌电商购物网站开发做视频网站带宽要求
  • 如何做优化网站排alexa优化衡水网站公司
  • 短视频网站php源码免费wordpress模板调用数据
  • 建设通网站首页wordpress调取多个分类文章
  • 购物网站有哪些简约风格装修
  • 全能网站建设完全自学如何自己建网站服务器
  • 仿制网站建设thinkphp网站开发实例教程
  • 南充做网站公司荆门网站建设电话
  • 抖音上做我女朋友网站最火的主题wordpress
  • 厦门大型网站设计公司jquery网站开发平台
  • 二手房地产中介网站建设wap网站模板
  • 郑州做网站熊掌号超市网站开发建设建议
  • 计算机网络技术毕业设计选题宁波seo外包优化
  • 上海哪个网站好用河北建设广州分公司网站
  • 专门做游轮的网站万网