给出的代码有什么问题?为什么它没有显示rs232的输出,当我们用d-9连接器连接它时,它的针脚编号为2 & 3?C++下的RS-232混淆问题
#include <bios.h>
#include <conio.h>
#define COM1 0
#define DATA_READY 0x100
#define SETTINGS (0x80 | 0x02 | 0x00 | 0x00)
int main(void)
{
int in, out, status;
bioscom(0, SETTINGS, COM1); /*initialize the port*/
cprintf("Data sent to you: ");
while (1)
{
status = bioscom(3, 0, COM1); /*wait until get a data*/
if (status & DATA_READY)
if ((out = bioscom(2, 0, COM1) & 0x7F) != 0) /*input a data*/
putch(out);
if (kbhit())
{
if ((in = getch()) == 27) /* ASCII of Esc*/
break;
bioscom(1, in, COM1); /*output a data*/
}
}
return 0;
}
欢迎 - 你需要缩进代码以使其正确显示,或使用编辑器中的101010按钮。我为你做了这个。 – 2010-02-04 09:03:39
请在正确的标签下以及 – 2010-02-04 09:05:18
为什么标记它c#? – Benny 2010-02-04 09:06:02