linux 嵌入式驱动程序测试实例

#include #include #include #include #include #include #include int main() { int fd,i,nwrite,nread; char *buf = "hello/n"; char read_buf[6] = {0}; fd = open("/dev/fs",O_RDWR); if( fd <= 0 ) { perror("open"); exit(1); }else printf("open ok!"); nwrite = write(fd,buf,strlen(buf)); if( nwrite < 0 ) { perror("write"); exit(1); } nread = read(fd,read_buf,6); if( nread < 0 ) { perror("read"); exit(1); } else printf("read is %s/n",read_buf); close(fd); exit(0); } //查看结果 // /var/log/messages

你可能感兴趣的:(linux,测试,嵌入式,include)