test_parport.c

来自「一个基于s3c2410嵌入式系统的并口实验(包括驱动程序和测试程序)」· C语言 代码 · 共 36 行

C
36
字号
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <syslog.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <syslog.h>
#include <signal.h>


int main()
{
	int parport_fd,count;	
	unsigned char buf[2];
	parport_fd = open("/dev/parport",O_RDWR);
	if (parport_fd <= 0){
		printf("open parport device error\n");
		return 0;
	}
	buf[0]=0xa5;buf[1]=0x03;
	count = write(parport_fd,buf,2);
	printf("Write %d char to parprot\n",count);
	read(parport_fd,buf,1);
	printf("Read %02x from parport\n",buf[0]);
		
	close(parport_fd);
	return 0;
}

	

⌨️ 快捷键说明

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