Hello,
I'm trying to read a single byte from a com port using _bios_serialcom function. I'm using windows vista and borland C++ 5.02 compiler. Here is my code:
Code:
/* PC-to-AVR communication – by sakis papamichalis */
/* An application for PC which receives a single byte from a mikrocontroller */
#include <stdio.h>
#include <conio.h>
#include <bios.h>
#define SETTINGS (_COM_9600 | _COM_CHR8 | _COM_NOPARITY | _COM_STOP1)
/* baud rate = 9600, 8 data bits, no parity bit, 1 stop bit */
void main(void)
{
unsigned in,out,status;
int port;
printf("Select Port (Enter 0 for COM1 and 1 for COM2):");
scanf("%d",&port);
//_bios_serialcom(_COM_INIT,port,SETTINGS);
out=_bios_serialcom(_COM_RECEIVE,port,0);
printf("\nData Received:");
for(;;)
{
}
}
A microcontroller send the byte to com port of PC but the result is nothing.(I have checked that microcontroller sends the byte right with hyper terminal). I need to use it in a larger program which will read data from com port and then shows them to the monitor. So, you think that is something wrong in my code?
I have seen that _bios_serialcom works only in DOS OS. Is there any other way to read data from com port in borland?
I'm a little bit confused with comuter programming because i'm familiar with C programming for microcontrollers.
Thanks for any help