📄 drvtest.c
字号:
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include "drv.h"
static int fd = -1;
static int d;
/*
* leddrv application code, the code of Linux application to use driver code
* compile :
* $/usr/local/arm/2.95.3/bin/arm-linux-gcc -o drvtest drvtest.c
* $cp helloworld /tftpboot/examples
* run in target:
* #mount 192.168.1.180:/tftpboot/ /mnt/nfs
* #cd /mnt/nfs/examples
* #insmod drv
* #mknod /dev/drvtest c 100 0
* #./drvtest
*/
int main(int argc, char **argv)
{
int ret;
fd=open("/dev/drvtest",O_RDWR);
if(fd<0)
{
printf("Can't open\n");
return -1;
}
else
{
printf("open OK %x\n", fd);
}
while(1)
{
printf("enter a number:\n");
scanf("%d", &d);
ret = write(fd, &d, 4);
//ret = read(fd, &d, 4);
}
close(fd);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -