hey guys i need a favor . i have written a code to read data from the RS232 port and store that data in a file. The code is shown below
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<dos.h>
unsigned int port1=0x3f8;
unsigned char rfid[14];
void main()
{
unsigned short c=0;
int i=0;
clrscr();
outportb(port1+1,0x00u);
outportb(port1+3,0x80u);
outportb(port1+3,0x03u);
outportb(port1+2,0xc7u);
while(i<13)
{
c= inportb(port1+5);
if(c&1)
{
rfid[i] = inportb(port1);
i++;
}
}
for(i=0;i<13;i++)
{
putchar(rfid[i]);
}
FILE *fp;
int i=0;
fp = fopen("tag.txt", "w");
if (fp == NULL)
{
printf("Error trying to open the file\n");
exit(0);
}
for (i=0; i<=13; i++)
fprintf(fp, "%c", rfid[i]);
getch();
}
i want this code to run infinte times that is the reading of the data from rs232 and saving should be done continuously. Please modify the code and help me out.