![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-24 22:49 |
47,812 topics / 349,910 posts / today 1 new / 48,262 members |
| 站务公告 & 版主讨论 » [Suggestion] Strong recommendation! |
| Printable Version 2,769 / 4 |
| Floor1 sunny1979 | Posted 2003-11-20 00:00 |
| 初级用户 Posts 86 Credits 376 | |
|
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! |
|
| Floor2 如是大师 | Posted 2003-11-21 00:00 |
| 元老会员 Posts 3,351 Credits 9,654 From 湖北 | |
|
I'm not very familiar with this area.. so I don't dare say much..
|
|
| Floor3 sunny1979 | Posted 2003-11-24 00:00 |
| 初级用户 Posts 86 Credits 376 | |
|
Can anyone help me?
|
|
| Floor4 GhostJ | Posted 2003-11-24 00:00 |
| 初级用户 Posts 16 Credits 168 | |
|
What is a "serial port"? Can you explain it?
|
|
| Floor5 jddj007 | Posted 2003-11-25 00:00 |
| 初级用户 Posts 11 Credits 146 | |
|
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 ); } |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |