pcout.c

来自「用于读写并口数据」· C语言 代码 · 共 50 行

C
50
字号
#define J 10240
#define EPP_DATA 0x37c
#define EPP_ADD  0x37b
#define EPP_STATE 0x379
#define EPP_CTROL 0x37a
#include <stdio.h>
#include<conio.h>
#include<stdlib.h>


main()
{
	unsigned short Data_out=0;
	unsigned char Data_OH,Data_OL;


//open the binary file for read
	char outfile[10];
	FILE *out;
	int j=0;
	printf("Enter the outfile name:\n");
	scanf("%s",outfile);
	if((out=fopen(outfile,"rb"))==NULL)
	{
		printf("cannot open outfile\n");
		exit(0);
	}

	for(j=0;j<J;j++)
	{
		do
		{
	 		Data_out=fgetc(out);
			Data_OH=(unsigned char)(Data_out>>8);
//pin 16(address 0x04;location bit 2)presents the topNDIn
			_outp(EPP_CTROL,0x04);
			_outp(EPP_ADD,Data_OH);
			Data_OL=(unsigned char)Data_out;
			_outp(EPP_DATA,Data_OL);
		}
		while(!feof(out));
	};
//close binary file
	fclose(out);
}




⌨️ 快捷键说明

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