Subj : RS232 Serial Communication problem (Text capturing form telephone system) To : borland.public.cpp.borlandcpp From : "JH Conradie" Date : Wed Jul 09 2003 01:38 pm To anyone who can help!!!! I purchased my Turbo C++ compiler back in 1992/93 and at that time registered it at Softsource, PO Box 783244, Sandton, 2146, South Africa. My Serial No on Disk 1 is "EA 143 A1006 5698" I am currently trying to write a program in C, but as I have very little experience with serial communications, I'm stuck right at the beginning. I've consulted a couple of books and did a few searches on the internet, but nothing seems to work, and I know the answer is very simple but I'm just overlooking something. Background information: I am using Turbo C++ Ver3.0 for Dos. My program should do the following simple task: We have a Jupiter PBX telephone system, connected to the serial port of a Epson LX300 printer. The printer receives all the outgoing call information. (Plain text only). The serial port is configured as follows: 1200bps, 7 data bits, even parity, 1 stop bit What I need to do is to capture the text intended for the printer and save it to a file and then process the information. I don't have a problem with the processing of the information in the text file, but I don't get the capturing procedure to work. There are only three wires connected to the printer's serial port: (25 Pin connector) Pin 3 - RX Data, Pin 4 - Request to send (Always positive according to the printer's manual) Pin 7 - Signal Ground (Return path for data control characters according to the printer's manual) If I run the program listed below, the status of the port shows that no data is received: Port status: 24624 - 0110 0000 0000 0000 After the first read of the port the status of the port changes to 12803 or sometimes to 657. Port status: 12803 - 0011 0010 0000 0011 (Overrun error) Port status: 657 - 0000 0010 1001 0001 (Overrun error) In both cases an overrun error is reported. My conclusion is that I have to control the RTS-line (Pin 4 on the connector) or I have to pulse Pin7 - Signal Ground and I don't know how to manipulate the voltage level on a pin of a port. I've tried HyperTerminal in Windows 95. But HyperTerminal tries to initialize the modem in the PBX system and no text is received - I've tried all the available terminal types. Then I downloaded a trial version of Telix from the internet and that works perfectly in its Terminal mode when it is configured for 1200baud, even parity, 7 data bits, 1 stop bit and the terminal type is ANSI-BBS. All flow control options were disabled (Xon/Xoff, CTS/RTS, DSR/DTR). At least this confirms that my cable is wired correctly. I would appreciate it if anyone can help me with solving this problem! Thank you Johan I copied moest of this program form Turbo C's help system. It works fine when 2 PC's are connected with a RS232 null modem cable. #include #include #include #define COM_CHR7 0x02 /* 7 data bits */ #define COM_CHR8 0x03 /* 8 data bits */ #define COM_CHR8 0x03 /* 8 data bits */ #define COM_STOP1 0x00 /* 1 stop bit */ #define COM_STOP2 0x04 /* 2 stop bits */ #define COM_NOPARITY 0x00 /* No parity */ #define COM_ODDPARITY 0x08 /* Odd parity */ #define COM_EVENPARITY 0x18 /* Even parity */ #define COM_110 0x00 /* 110 baud */ #define COM_150 0x20 /* 150 baud */ #define COM_300 0x40 /* 300 baud */ #define COM_600 0x60 /* 600 baud */ #define COM_1200 0x80 /* 1200 baud */ #define COM_2400 0xA0 /* 2400 baud */ #define COM_4800 0xC0 /* 4800 baud */ #define COM_9600 0xE0 /* 9600 baud */ #define COM1 0 #define DATA_READY 0x100 /*1 0000 0000*/ #define TRUE 1 #define FALSE 0 #define SETTINGS ( COM_1200 | COM_EVENPARITY | COM_CHR7 | COM_STOP1) int main(void) { int in, out, status, DONE = FALSE; char ch; FILE *stream; bioscom(0, SETTINGS, COM1); /*Initialise COM1 for 1200,7bits,even,1 stop*/ clrscr(); cprintf("... BIOSCOM [ESC] to exit ...\r\n"); while (!DONE) { status = bioscom(3, 0, COM1); /*Returns status of com1 port*/ if (status & DATA_READY) { if ((out = bioscom(2, 0, COM1) & 0x7F) != 0) /*mask the 7 data bits*/ putch(out); /*output to VDU*/ if (out == 13) cprintf("\r\n"); /* open a file for append */ stream = fopen("TEL_LOG.TXT", "a+"); fputc(out,stream); /*Write received data to file*/ fclose(stream); } if (kbhit()) { if ((in = getch()) == '\x1B') /*if ESc is hit*/ DONE = TRUE; /*bioscom(1, in, COM1); send value of "in" to Com1*/ bioscom(1,in, COM1); } } return 0; } --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.478 / Virus Database: 275 - Release Date: 06/05/03 .