⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_demo.c

📁 UP-NETARM3000下教材实例源码,其中提供了多个实验内容源码,使用ARM相应开发环境即可
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <unistd.h>#include <sys/ioctl.h>void showbuf(char *buf);int MAX_LEN=32;int main(){	int fd;	int i;	char buf[255];		for(i=0; i<MAX_LEN; i++){		buf[i]=i;	}	fd=open("/dev/demo",O_RDWR);	if(fd < 0){		printf("####DEMO  device open fail####\n");		return (-1);	}	printf("write %d bytes data to /dev/demo \n",MAX_LEN);	showbuf(buf);	write(fd,buf,MAX_LEN);	printf("Read %d bytes data from /dev/demo \n",MAX_LEN);	read(fd,buf,MAX_LEN);	showbuf(buf);		ioctl(fd,1,NULL);	ioctl(fd,4,NULL);	close(fd);	return 0;}void showbuf(char *buf){	int i,j=0;	for(i=0;i<MAX_LEN;i++){		if(i%4 ==0)			printf("\n%4d: ",j++);		printf("%4d ",buf[i]);	}	printf("\n*****************************************************\n");}

⌨️ 快捷键说明

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