Hi!
I want to transmit and receive data on serial port (currently i'm working on a single PC with its Tx and Rx pins short). I'm using following program (in Turbo C), but to no use. Can anyone help me out with this code?
#include <bios.h>
#include<stdio.h>
#include<iostream.h>
#include <conio.h>
#define COM1 0
#define DATA_READY 0x100
#define SETTINGS ( 0xE0 | 0x08 | 0x00 | 0x03) //(baud_9600 | ODD_PARITY | COM_STOP1 | COM_CHR8)
int main(void)
{
clrscr();
int out, status;
char in,x;
bioscom(0, SETTINGS, COM1); /*initialize the port*/
cprintf("Data sent to you: ");
while (1)
{
status = bioscom(3, 0, COM1); /*wait until get a data*/
if (status & DATA_READY)
if ((out = bioscom(2, 0, COM1) & 0x7F) != 0) /*input a data*/
{
cout<<"the data received is "<<out<<endl;
putch(out);
}
if (in=getch())
{ cout<<"key was pressed"<<in<<endl;
if (in == 27) /* ASCII of Esc*/
{
break;
}
else
{cout<<"we are aobut to transmit"<<endl<<in<<endl;
bioscom(1, in , COM1); /*output a data*/}
}
}
return 0;
}
Thanx
I want to transmit and receive data on serial port (currently i'm working on a single PC with its Tx and Rx pins short). I'm using following program (in Turbo C), but to no use. Can anyone help me out with this code?
#include <bios.h>
#include<stdio.h>
#include<iostream.h>
#include <conio.h>
#define COM1 0
#define DATA_READY 0x100
#define SETTINGS ( 0xE0 | 0x08 | 0x00 | 0x03) //(baud_9600 | ODD_PARITY | COM_STOP1 | COM_CHR8)
int main(void)
{
clrscr();
int out, status;
char in,x;
bioscom(0, SETTINGS, COM1); /*initialize the port*/
cprintf("Data sent to you: ");
while (1)
{
status = bioscom(3, 0, COM1); /*wait until get a data*/
if (status & DATA_READY)
if ((out = bioscom(2, 0, COM1) & 0x7F) != 0) /*input a data*/
{
cout<<"the data received is "<<out<<endl;
putch(out);
}
if (in=getch())
{ cout<<"key was pressed"<<in<<endl;
if (in == 27) /* ASCII of Esc*/
{
break;
}
else
{cout<<"we are aobut to transmit"<<endl<<in<<endl;
bioscom(1, in , COM1); /*output a data*/}
}
}
return 0;
}
Thanx