garmin USB: linux USB host驱动

本文以Garmin USB设备为例,介绍了如何在Linux系统下编译加载USB驱动模块,包括生成garmin_usb.ko并使用insmod安装,通过lsmod检查模块状态,以及在插入USB设备后如何识别新增的设备节点skel0。应用程序通过open、read、write函数与设备交互。注意,设备端需有正确端点描述符以避免probe过程失败。

以garmin usb为例:

1)编译生成garmin_usb.ko文件,使用insmod命令安装模块

2)使用lsmod命令可查看内核已经安装好模块:garmin_usb

3)插入USB设备后,使用ls /dev,会发现多了skel0设备节点文件(该设备文件在代 码中使用device_create()自动产生,不需要再单独使用mknod命令产生)

4)编写应用程序,使用open、read、write来操作读写数据

注: device端需要有相应的端点描述符。否者在probe过程中会失败。

源码:

1. garmin_usb.c

/*
 * USB Skeleton driver - 2.2
 *
 * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
 *
 *	This program is free software; you can redistribute it and/or
 *	modify it under the terms of the GNU General Public License as
 *	published by the Free Software Foundation, version 2.
 *
 * This driver is based on the 2.6.3 version of drivers/usb/usb-skeleton.c
 * but has been r
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hello-linux

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值