test.c

来自「基于linux嵌入式系统的flash驱动以及测试程序和Makefile文件」· C语言 代码 · 共 70 行

C
70
字号
#include <sys/ioctl.h>#include <unistd.h>#include <stdio.h>#include <fcntl.h>#define DEVICE_AAA "/dev/flash"int main(){  int ret; int fd; char buf[20]; char c[4]; int fileno;     //The No. of the file being accessed, /******************************************* The file No. assignment:0~14 Chen Dahong15~18  Zhoutong19~29 Li Yangchun *********************************************/   unsigned long para;   //This parament has no use c[0]=c[1]=c[2]=c[3]=0xff; fd=open("/dev/flash",O_RDWR); printf("fd=%d\n",fd); ioctl(fd,30,&para);  //before access file in flash, input the number  ret=write(fd,"UPDATEFIRMWARE",14); // printf("ret=%d\n",ret); write(fd,c,4); // printf("ret=%d\n",ret); return 0; for(;;){   int r; r=read(fd,buf,5); for(ret=0;ret<r;ret++)printf( "%x ",buf[ret]); printf("  r=  %d\n",r); if(r<5)break; }return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?