日期:2014-05-16  浏览次数:20658 次

ldd3中的scull驱动程序应该如何测试?
我在网上找到一个测试方法如下:
cat   /dev/scull0   是读
ll   > /dev/scull0是写

请问这两个指令是什么意思?有ll这个命令吗?如果这个命令是写,那么写的数据是什么呢?

------解决方案--------------------
cat :显示一个文件内容
ll :是ls -l 的别名,为了方便而设

cat 显示文件前必须读
ls -l 就是显示当前目录的内容,即写当前内容的字符
------解决方案--------------------
驱动测试是要写用户空间程序的。

通过用户空间的open ,read, write分别测试驱动的各部分功能。

下面是我以前写的测试程序,跟scull类似,稍微修改应该就可以用了

/*************************************************************************
*fileName: test.c
*description: test the myscull.c
*author: Hzc
*create time: 2007-04-20
*modify info: -
*************************************************************************/
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>

/* device path */
char path[] = "/dev/myscull0 ";
char buf[128];
int main()
{
int f = open(path, O_RDWR);
if (f == -1)
{
printf( "device open error!\n ");
return 1;
}

printf( "Input a string to write device \n ");
scanf( "%s ", buf);
write(f, buf, 4); /* device wirte */

printf( "Read the string from device...\n ");
read(f, buf, 128); /* device read */
printf( "%s\n ", buf);

close(f);
}