driver/1-chr-dev/app.c

44 lines
1.0 KiB
C
Raw Normal View History

2024-01-30 13:39:31 +00:00
#include "stdio.h"
#include "unistd.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "stdlib.h"
#include "string.h"
/***************************************************************
Copyright © ALIENTEK Co., Ltd. 1998-2029. All rights reserved.
: chrdevbaseApp.c
:
: V1.0
: chrdevbase驱测试APP
: 使./chrdevbase /dev/chrdevbase <1>|<2>
argv[2] 1:
argv[2] 2:
: www.openedv.com
: V1.0 2019/1/30
***************************************************************/
static char usrdata[] = {"usr data!"};
/*
* @description : main主程序
* @param - argc : argv数组元素个数
* @param - argv :
* @return : 0 ;
*/
int main(int argc, char *argv[])
{
int file;
file = open("/dev/test_dev",O_RDWR);
char a[]="hello";
write(file,a,sizeof(a));
char b[1024];
read(file,b,sizeof(a));
printf("%s\n",b);
close(file);
return 0;
}