Mail Archives: djgpp/1999/07/09/12:26:05
From: | Young Fan <youngcfan AT hotmail DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Setting baud rate of serial port
|
Date: | Fri, 09 Jul 1999 11:33:42 -0400
|
Organization: | Nortel
|
Lines: | 44
|
Message-ID: | <37861656.79C0AF5B@hotmail.com>
|
NNTP-Posting-Host: | pwdld0av.ca.nortel.com
|
Mime-Version: | 1.0
|
X-Mailer: | Mozilla 4.03 [en] (Win95; I)
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hello,
This is a follow-up of my previous posting ("Your help would be
appreciated..."). I am wondering how I can set the baud rate of the
serial port. I am using outp to send 1's and 0's to pin 4 of COM 2,
using outp((unsigned short)(0x2f8+4),(unsigned char)0x0F);. If I do not
set the baud rate, the signals are sent approximately every 1 to 3
microseconds. At 9600 baud, the duration of each 1 or 0 should be about
104 usecs. How would I set the baud rate? Is there anything else I would
need to do before sending the signals, such as initializing the port --
and then how would I do that? It's supposed to be 8 data bits, no
parity, 1 stop bit, but I'm already inserting the stop bit by myself.
I'm pretty sure this is wrong, but this is what I'm doing:
ioctl(0x2f8+4,(('X'<<8)+7),224);
...since this wouldn't work:
ioctl(0x2f8+4,TXSBAUD,_COM_9600);
...which I tried because this was in bios.h:
#define _COM_9600 224 /* 9600 baud. */
...and this was in sys/ioctl.h:
enum tty_ioctl {
TXISATTY = ('X'<<8), /* quick path for isatty */
TXTTYNAME, /* quick path for ttyname */
TXGETLD, /* get line discipline */
TXSETLD, /* set line discipline */
TXGETCD, /* get control disciplines */
TXADDCD, /* add control discipline */
TXDELCD, /* delete control discipline */
TXSBAUD, /* set integer baud rate */
TXGBAUD, /* get integer baud rate */
TXSETIHOG, /* set the input buffer limit */
TXSETOHOG, /* set the output buffer limit */
TXGPGRP, /* get p grp with posix security */
TXSPGRP /* set p grp with posix security */
};
Please help! Thanks in advance.
- Raw text -