Board index » cppbuilder » RS232 Communications with C++ v5.02

RS232 Communications with C++ v5.02


2006-07-06 03:18:25 AM
cppbuilder9
Is there a simple example of how to program a serial port with C++ 5.02?
I have tried the following
#include <bios.h>
#include <conio.h>
#define COM1 0
#define DATA_READY 0x100
#define TRUE 1
#define FALSE 0
#define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00)
int main(void)
{
int in, out, status, DONE = FALSE;
bioscom(0, SETTINGS, COM1);
cprintf("... BIOSCOM [ESC] to exit ...\n");
while (!DONE)
{
status = bioscom(3, 0, COM1);
if (status & DATA_READY)
if ((out = bioscom(2, 0, COM1) & 0x7F) != 0)
putch(out);
if (kbhit())
{
if ((in = getch()) == '\x1B')
DONE = TRUE;
bioscom(1, in, COM1);
}
}
return 0;
}
This returns an undefined function error for bioscom.
is there some other call i should be using? I have Borland C++ 5.02 and Win
2k. The program i write i plan on deploying on a old dos 6.2 machine.
Upgrading the target system would be a problem.
Thanks in advance
Brian
 
 

Re:RS232 Communications with C++ v5.02

The function bioscom is a thin wrapper which calls the code in the BIOS in
your motherboard's read only memory chips. That function does not handle
the serial port with interrupts and is therefore limited in speed to perhaps
as much as 300 baud depending upon machine speed.
You want to test while running DOS and want to provide an interrupt driven
serial handler. While you can write such an interrupt handler in C or C++,
even on a fast machine it is going to be speed limited. Ideally such a
handler would be written in assembly language.
TI445 is a Borland Technical Info documnet which provides an example that
does the handler in C. Here is a link to it:
ftp.nsk.su/pub/text-doc/ti/bc_cpp/ti445.zip
If you instead decided to write Win32 code, then there are Windows supplied
functions with which you can do the serial communications and no interrupt
service routine need be supplied. Borland C++ 4.5 and up should be able to
create such a program.
. Ed
Quote
Brian wrote in message
news:44ac1079$ XXXX@XXXXX.COM ...

Is there a simple example of how to program a serial port
with C++ 5.02?

I have tried the following

#include <bios.h>
#include <conio.h>

#define COM1 0
#define DATA_READY 0x100
#define TRUE 1
#define FALSE 0

#define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00)

int main(void)
{
int in, out, status, DONE = FALSE;

bioscom(0, SETTINGS, COM1);
cprintf("... BIOSCOM [ESC] to exit ...\n");
while (!DONE)
{
status = bioscom(3, 0, COM1);
if (status & DATA_READY)
if ((out = bioscom(2, 0, COM1) & 0x7F) != 0)
putch(out);
if (kbhit())
{
if ((in = getch()) == '\x1B')
DONE = TRUE;
bioscom(1, in, COM1);
}
}
return 0;
}


This returns an undefined function error for bioscom.
is there some other call i should be using? I have Borland
C++ 5.02 and Win 2k. The program i write i plan on deploying
on a old dos 6.2 machine. Upgrading the target system would
be a problem.
 

Re:RS232 Communications with C++ v5.02

"Brian" < XXXX@XXXXX.COM >wrote in message
Quote
Is there a simple example of how to program a serial port with C++ 5.02?
Here is a link to a super article about how to use the Win32 Communication
features to support RS-232:
www.tetraedre.com/advanced/serial/msdn_serial.htm
I found this document originally in Microsoft's development library but
can't find it there anymore. Fortunately, people have copied it to other
places.
I have used this document extensively and the code runs flawlessly.
Alan
 

{smallsort}

Re:RS232 Communications with C++ v5.02

Hi,
"newsgroups.borland.com" < XXXX@XXXXX.COM >wrote in message
Quote


I found this document originally in Microsoft's development library but
can't find it there anymore. Fortunately, people have copied it to other
places.

How about:
msdn.microsoft.com/library/default.asp
regards, Matt
 

Re:RS232 Communications with C++ v5.02

Brian:
Two things will allow you to do what you request, and they do it well...
Let google guide you to winio and asmio...
Warmest regards,
John
"Brian" < XXXX@XXXXX.COM >wrote in message
Quote
Is there a simple example of how to program a serial port with C++ 5.02?

I have tried the following

#include <bios.h>
#include <conio.h>

#define COM1 0
#define DATA_READY 0x100
#define TRUE 1
#define FALSE 0

#define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00)

int main(void)
{
int in, out, status, DONE = FALSE;

bioscom(0, SETTINGS, COM1);
cprintf("... BIOSCOM [ESC] to exit ...\n");
while (!DONE)
{
status = bioscom(3, 0, COM1);
if (status & DATA_READY)
if ((out = bioscom(2, 0, COM1) & 0x7F) != 0)
putch(out);
if (kbhit())
{
if ((in = getch()) == '\x1B')
DONE = TRUE;
bioscom(1, in, COM1);
}
}
return 0;
}


This returns an undefined function error for bioscom.
is there some other call i should be using? I have Borland C++ 5.02 and
Win
2k. The program i write i plan on deploying on a old dos 6.2 machine.
Upgrading the target system would be a problem.

Thanks in advance
Brian