Hi all,
I m doing one c program for serial communication.In that i want to send request to one hardware module, after receiving my request that h/w send me one frame with predefined format.
Now after compiling it gives zero errors.Code:/* Program SERIALCOMMUNICATION.C is used for PC to PC or PC to Hardware Communication. */ #include<bios.h> #include<stdio.h> #include<string.h> #include<conio.h> #include<time.h> #define COM3 2 #define DATA_READY 0x100 #define SETTINGS ( 0xE0 | 0x03 | 0x00 | 0x00) //baud 9600 | 8 data bits | no parity | 1 stop bit void main() { int status; unsigned char out,in; char another,option; FILE *rfile,*wfile; int DONE=0,i=0,p=0,k=0; int Count=0; unsigned char rcvdata[80]; char sendrequest[21]="Start,SendRequest,End"; time_t timer; struct tm *tblock; timer = time(NULL); printf("\n"); clrscr(); bioscom(0, SETTINGS, COM3); printf("\n\n************************************** *******************\n\n"); printf("\t1. Send Request For Current Time Frame\n"); printf("\t2. Escape"); printf("\n\n************************************** ********************\n\n"); printf("Your Choice If you want,Otherwise wait for next Frame? :\n"); rfile=fopen("RECEIVE.TXT","a"); wfile=fopen("SEND.TXT","a"); while (!DONE) { status = bioscom(3, 0, COM3); if(status & DATA_READY) { if((out =(unsigned char)bioscom(2, 0, COM3)) != 0)// input message byte. { if((int)out==8 && Count>0) { Count=Count-1; } else { rcvdata[Count]=out; //Store char in buffer Count++; } } if(out==13) { fprintf(rfile,"\n"); for(i=0;i<Count-1;i++) fprintf(rfile,"%c",rcvdata[i]); for(p=0;p<Count-1;p++) printf("%c",rcvdata[p]); printf("\n"); Count=0; } } if (kbhit()) //character entered { option=getche(); switch(option) { case '1' : printf("\nSend Request:"); /* converts date/time to a structure */ tblock = localtime(&timer); fprintf(wfile,"\nRequest sent at:%s:", asctime(tblock)); for(k=0;k<21;k++) { bioscom(1,sendrequest[k],COM3); printf("%c",sendrequest[k]); fprintf(wfile,"%c",sendrequest[k]); } printf("\n"); fprintf(wfile,"\n"); break; case '2' : case 27 : DONE=1; break; default : printf("\nPress Correct option i.e. either 1 or 2\n"); } } } fclose(rfile); fclose(wfile); }
When I execute this program, it receives all things (hardware sent) but send nothing,not a single char.
Please tell me if anything wrong in my code
Thanks in advance



LinkBack URL
About LinkBacks


