Mail Archives: djgpp/1999/07/06/21:01:38
From: | deleveld AT my-deja DOT com
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Source for bioscom at 19.2k and some questions
|
Date: | Mon, 05 Jul 1999 14:25:26 GMT
|
Organization: | Deja.com - Share what you know. Learn what you don't.
|
Lines: | 89
|
Message-ID: | <7lqf8e$kkr$1@nnrp1.deja.com>
|
NNTP-Posting-Host: | 192.87.23.66
|
X-Article-Creation-Date: | Mon Jul 05 14:25:26 1999 GMT
|
X-Http-User-Agent: | Mozilla/3.0 (Win95; I; 16bit)
|
X-Http-Proxy: | 1.0 x35.deja.com:80 (Squid/1.1.22) for client 192.87.23.66
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hello Everyone,
I've been working on some serial communication stuff and
I found that bioscom commands only work up to 9600 baud, and
I wanted to use them at 19.2 kbaud. There is some source
to do this at the end of this post.
What I need to find out now, is how to read from the port
_without_ hardware handshaking. It seems bioscom just calls
INT 14, and that seems to require hardware handshaking. The
reason that I cannot use handshaking is that the device that
I must communicate gets its power from RTS and DTR and they
need to be high and low for the interface to work.
I guess I also need to find out how I can arbitrairly assert
RTS and DTR without affecting the serial comm.
So if anyone knows these things, please post or mail me.
Thanks,
Doug Eleveld
/* Figure out the Port address for a given COM port */
static unsigned short COMPort(const t_comport com)
{
switch(com)
{
case(COM1):
return 0x03F8;
case(COM2):
return 0x02F8;
case(COM3):
return 0x03E8;
case(COM4):
return 0x02E8;
default:
perror("Illegal com port in function COMPort");
exit(1);
}
}
static void forcebaud(const t_comport com, const int baud)
{
int ints_were_enabled;
int divisor;
unsigned char divlow, divhigh;
unsigned short Port = COMPort(com);
unsigned short LCR = 3 + Port; /* The address of the line Control
Register */
unsigned short BRDH = 1 + Port;
unsigned short BRDL = Port;
unsigned char LCRContents;
/* Make sure we have a reasonable baud rate */
if(!baud)
return;
/* Figure out the baud rate divisor */
divisor = 115200 / baud;
divlow = divisor & 0xff;
divhigh = (divisor >> 8) & 0xff;
/* Get the old data from the LCR port */
ints_were_enabled = disable();
LCRContents = inportb(LCR);
/* Mask on bit 7 for DLAB registers */
outportb(LCR, LCRContents | 0x80);
/* Set Baud Rate divisor */
outportb(BRDL, divlow);
outportb(BRDH, divhigh);
/* Put the old data back */
outportb(LCR, LCRContents & 0x7f);
if(ints_were_enabled)
enable();
}
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
- Raw text -