+ -
当前位置:首页 → 问答吧 → 驱动问题,,大家讨论下

驱动问题,,大家讨论下

时间:2006-08-09

来源:互联网

最近在写电机的驱动,,但是用户态的数据怎么也进不了内核态.大家看看

int motor_drv_write (struct inode *inode, struct file *filp, const char *buf,int count){

int value;

(int *)buf;

copy_from_user(&value,buf,count);

printk("The command is %d\n",value);
}

应用程序为:

main()
{
int fd;
int a=4;
int retval;
fd=open("/dev/motor_drv",O_RDWR);

retval=write(fd,&a,1 );
delay(1000000);
}

我的想法是如果传值成功的话应该打印出:4 的.

作者: clm615   发布时间: 2006-08-09

热门下载

更多