44 lines
1.0 KiB
C
44 lines
1.0 KiB
C
|
#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;
|
|||
|
}
|
|||
|
|
|||
|
|