lorry
驱动牛犊
驱动牛犊
  • 注册日期2004-02-10
  • 最后登录2007-03-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
阅读:1046回复:1

谢谢

楼主#
更多 发布于:2004-05-12 19:07
以下 程序应该包含哪里的文件?

如何编译

为什么编译的时候头文件老出错?

自己写的,有什么错误,谢谢指点

谁能提供linux下与d12通信的最简单的程序

static int vender=0x1234,product=0x5678;
static int
device_open(struct inode * inode, struct file * file)
{

MOD_INC_USE_COUNT;

return 0;
}

static int
device_close(struct inode * inode, struct file * file)
{
MOD_DEC_USE_COUNT;

return 0;
}
static void *
device_probe(struct u s b_device *dev, unsigned int ifnum)
{
if (vendor != 0 || product != 0)
info(\"U S B Vendorroduct - %x:%x\\n\", vendor, product);


if (dev->descriptor.idVendor == vendor&&dev>descriptor.idProduct ==produc
t )
printk(\"U S B INSERT\");
}


static void
device_disconnect(struct u s b_device *dev, void *ptr)
{
if (dev->descriptor.idVendor == vendor&&dev>descriptor.idProduct
==product )
printk(\"U S B DELETE\");

}

static struct
file_operations u s b_device_fops = {
NULL, /* seek */
NULL,,
NULL,
NULL, /* readdir */
NULL, /* poll */
NULL, /* ioctl */
NULL, /* mmap */
device_open,
NULL, /* flush */
device_close,
NULL,
NULL, /* fasync */
};

static struct
u s b_driver device_driver = {
\"u s bdevice\",
device_probe,
device_disconnect,
{ NULL, NULL },
&u s b_device_fops,
48
};

int
u s b_device_init(void)
{
if (u s b_register(&device_driver) < 0)
return -1;

info(\"U S B support registered.\");
return 0;
}


void
u s b_device_cleanup(void)
{
u s b_deregister(&device_driver);
}

#ifdef MODULE

int
init_module(void)
{
return u s b_device_init();
}

void
cleanup_module(void)
{
u s b_device_cleanup();
}


chopin_1998
驱动牛犊
驱动牛犊
  • 注册日期2004-04-01
  • 最后登录2005-03-30
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2004-05-17 21:47
这位哥哥,在南京吗?

谁能提供linux下与d12通信的最简单的程序:
我是准备这么实现:使用厂商请求。在固件里实现,Linux驱动里,您可以使用usb_control_msg()实现。

您的这段代码,根据您的编译指令不同,可能需要不同的头文件。您应该可以这样:
#include <linux/kernel.h>
#include <linux.module.h>


gcc -D__KERNEL__ -DMODULE -O -Wall -c <codename.c>


您的板子搞定了吗?我的固件还有些问题呢。13585109003(SMS only unless U\'r in Nanjing)



Linux Power!
游客

返回顶部