,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47
,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63
,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79
,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95
,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111
,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127
,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
,168,184,242,243,244,245,246,247,248,249,250,251,252,253,254,255
};
if ((file1 = fopen(wr_file, "rt"))== NULL)
{
printf("Cannot open file \"%s\" !\n",wr_file);
return;
}
if ((file3 = fopen("reciev.txt", "wt"))== NULL)
{
printf("Cannot open file \"%s\" !\n",wr_file);
return;
}
printf("\n");
for(i=0;i<=256;i++)
putchar(fgetc(file1));
printf(" ...(etc)");
fsetpos(file1,0);
o_sym (0x30);
printf("\nEnter author's name\n");
gets(author);
printf("Enter title\n");
gets(title);
strcpy(header,author);
strcat(header," \"");
strcat(header,title);
strcat(header,"\"");
printf("\nHeader: %s",header);
i=0;
while(header[i]!='\0')
{
o_sym(win[(int)header[i]&0xff]);
i++;
}
o_sym(0x07);
printf("\nWriting file \"%s\"...",wr_file);
//flag: 01 - detect space
// -01 - skip symbol
while(!(feof(file1)))
{
rec_sym=fgetc(file1);
if(feof(file1)) break;
if(code==1)
rec_sym=win[(int)rec_sym&0xff];
if((rec_sym==' ')||(rec_sym=='-')||(rec_sym=='\n'))
{
if(rec_sym=='-')
{
rec_sym=fgetc(file1);
if(feof(file1)) break;
if(code==1) rec_sym=(char)win[(int)rec_sym&0xff];
if(rec_sym!='\n')
{
Inv('-');
flag=0;
}
else
flag=-1;
if(rec_sym==' ')
flag=1;
}
if(rec_sym=='\n')
rec_sym=' ';
if((flag==1)||(flag==-1))//rec_sym==' '
flag=-1;
else
flag=1;
}
else
flag=0;
if(flag!=-1)
Inv(rec_sym);
}
o_sym (0x07);
fclose(file1);fclose(file3);
printf("\nFile writing successfully complete");
}
int o_sym(char symbol)
{
long timeout;
timeout=clock();
if(timeout==-1)
printf("\nTime not available");
//printf("\nTimeout=%d",timeout);
do {
if((clock()-timeout)>1)
{
printf("\nWarning!Timeout!");
return -1;
}
}while((inportb(STATUS)&0x20)==0);
outportb(OUT_REG,symbol);
return 0;
}
char i_sym()
{
long timeout;
int errcode;
timeout=clock();
do{
if((clock()-timeout)>1000)
{
printf("\nTimeout. The symbol may be lost!");
return 0;
}
errcode=inportb(STATUS);
}while((errcode&0x01)==0);
return inportb(IN_REG);
}
void Inv(char insym)
{
char invalidate;
fputc(insym,file3);
o_sym(insym);
do
invalidate=i_sym();
while((invalidate!=insym)&&(invalidate!=0));//waiting confirm
}
Приложение Г
Файл reader.ini
[PORT]
COM2
[CODE]
DOS
Приложение Д
Схема электрическая принципиальная устройства для чтения электронных книг
Приложение Е
Расчет стоимости комплектующих устройства для чтения электронных книг