GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 30-Apr-2008, 05:09
ommm ommm is offline
New Member
 
Join Date: Apr 2008
Posts: 1
ommm is on a distinguished road

about bioscom(1,in,COM1)


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.

CPP / C++ / C 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);
}

Now after compiling it gives zero errors.
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
Last edited by LuciWiz : 30-Apr-2008 at 11:53. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 10-May-2008, 17:43
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 400
Peter_APIIT is on a distinguished road

Re: about bioscom(1,in,COM1)


CPP / C++ / C Code:
if(status & DATA_READY)

What is serial communication ? How you send data to hardware module(Driver)?
__________________
Linux is the best OS in the world.
 

Recent GIDBlog2nd Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 16:07.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.