China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-23 14:53
中国DOS联盟论坛 » 站务公告 & 版主讨论 » [Suggestion] Strong recommendation! View 2,424 Replies 4
Original Poster Posted 2003-11-20 00:00 ·  中国 陕西 西安 电信
初级用户
★★
忍者
Credits 376
Posts 86
Joined 2003-10-16 00:00
22-year member
UID 11361
Gender Male
Status Offline
The programming section needs experts to step in. A lot of questions are still questions to this day and still haven't been answered!
SOS: How do you define a serial port in C? It seems nobody knows!
以C语言软件开发为主:http://sunny1979.icpcn.com
Floor 2 Posted 2003-11-21 00:00 ·  中国 河南 信阳 联通
元老会员
★★★★★
步行的人
Credits 9,654
Posts 3,351
Joined 2003-03-11 00:00
23-year member
UID 1113
Gender Male
From 湖北
Status Offline
I'm not very familiar with this area.. so I don't dare say much..
弄花香满衣,掬水月在手。
明月鹭鸟飞, 芦花白马走。
我自一过后,野渡现横舟。
青云碧空在,净瓶水不流。
http://dos.e-stone.cn/guestbook/index.asp
======中國DOS聯盟=====
我的新网页http://rsds.7i24.com欢迎光顾
Floor 3 Posted 2003-11-24 00:00 ·  中国 陕西 西安 电信
初级用户
★★
忍者
Credits 376
Posts 86
Joined 2003-10-16 00:00
22-year member
UID 11361
Gender Male
Status Offline
Can anyone help me?
以C语言软件开发为主:http://sunny1979.icpcn.com
Floor 4 Posted 2003-11-24 00:00 ·  中国 台湾 中华电信(HiNet)数据中心
初级用户
Credits 168
Posts 16
Joined 2003-11-21 00:00
22-year member
UID 13141
Gender Male
Status Offline
What is a "serial port"? Can you explain it?
Floor 5 Posted 2003-11-25 00:00 ·  中国 安徽 芜湖 电信
初级用户
Credits 146
Posts 11
Joined 2003-06-22 00:00
23-year member
UID 5691
Gender Male
Status Offline
Controlling the serial port under TC for DOS
To send data through the serial port in Trubo C for DOS, you need to know the serial port address first, and only then can you send characters directly to that address.
The program is as follows:
#include
#include
#include
#include
#include
#include
#include
typedef short SHORT;

#define WAITIME 30000
#define DBUF 0X0 /* DATA BUFFER REGISTER */
#define LSR 0x5 /* line status register */

static SHORT portaddress={0x3f8,0x2f8,0x3e8,0x2e8};
/* serial port addresses COM1 COM2 COM3 COM4 */
static SHORT portadd; /*serial port number*/

/*send data to the specified address*/
void Out_func( port, c )
SHORT port;
char c;
{
SHORT i = 0;

do
{
i++;
if (i == WAITIME) break;
}
while (!(inp(port+LSR) & 0x20)); /* 0x3ed */
/* wait until trans preparation */

if (i < WAITIME)
outp(port+DBUF,c);
}

/*break a continuous string into individual characters and send them*/
void Out_Array( num, str )
SHORT num;
char *str;
{
SHORT i;
char *p;

p = str;
for ( i = 0; i<num; i++, p++ )
Out_func( portadd, *p );
}

/*initialize the serial port*/
void light_init()
{
Out_func( portadd, 0x1b );
Out_func( portadd, 0x40 );

/*send clear-screen command*/
Out_func( portadd, 0x0c );
}
Forum Jump: