RS232포트를 직접 (어셈블러로) 컨트롤 하는데 이상한 문제가 있습니다. 도와주세요ㅠㅠ
일단 XP에서 다음의 방식으로 RS232포트를 억세스해서 UART로 들어오는 신호를 읽고 있습니다.
그런데 다음의 코드가(물론 드라이버로 올렸으며 outportb와 같은 함수는 없기에 적절한 함수로 제가 만들었습니다.
out dx, ...와 같은 형식으로) 텔넷을 띄우고서는 정상동작을 하는데 혼자 돌리면 LSR(lineStatusRegister)가 0xFF가 나오면서
동작을 안합니다. 먼저 읽기만 실험해 봤습니다. 뭐가 문제인지요... 또는 설정 부분에서 빠진 부분이 있나요???
전문가 분들의 도움 부탁드립니다.
#include
#include
#include
#define PORT1 0x3F8
/* Defines Serial Ports Base Address */
/* COM1 0x3F8 */
/* COM2 0x2F8 */
/* COM3 0x3E8 */
/* COM4 0x2E8 */
void main(void)
{
int c;
int ch;
outportb(PORT1 + 1 , 0); /* Turn off interrupts - Port1 */
/* PORT 1 - Communication Settings */
outportb(PORT1 + 3 , 0x80); /* SET DLAB ON */
outportb(PORT1 + 0 , 0x03); /* Set Baud rate - Divisor Latch Low Byte */
/* Default 0x03 = 38,400 BPS */
/* 0x01 = 115,200 BPS */
/* 0x02 = 57,600 BPS */
/* 0x06 = 19,200 BPS */
/* 0x0C = 9,600 BPS */
/* 0x18 = 4,800 BPS */
/* 0x30 = 2,400 BPS */
outportb(PORT1 + 1 , 0x00); /* Set Baud rate - Divisor Latch High Byte */
outportb(PORT1 + 3 , 0x03); /* 8 Bits, No Parity, 1 Stop Bit */
outportb(PORT1 + 2 , 0xC7); /* FIFO Control Register */
outportb(PORT1 + 4 , 0x0B); /* Turn on DTR, RTS, and OUT2 */
printf("\nSample Comm's Program. Press ESC to quit \n");
// do {
c = inportb(PORT1 + 5); /* Check to see if char has been */
/* received. */
if (c & 1) {ch = inportb(PORT1); /* If so, then get Char */
printf("%c",ch);} /* Print Char to Screen */
// if (kbhit()){ch = getch(); /* If key pressed, get Char */
// outportb(PORT1, ch);} /* Send Char to Serial Port */
// } while (ch !=27); /* Quit when ESC (ASC 27) is pressed */
}
댓글 달기