Transmit data between 2 com ports

Das Forum fĂĽr Programmierer und Systemadmins. Von Shell-, Perl- und PHP-Scripts bis zur objektorientierten Programmierung mit C++.

Transmit data between 2 com ports

Beitragvon hector » Fr 21 Mär, 2003 21:05

Hello, programmers,

last weekend I tried to write a dialog based MFC-Application in visual c++ 6.0 in which a user should write any kind of text in one textfield, press Write-button and recieve entered text in one other. It is just an exercise to get some COM-port-skills in visual c++ because I work with siemens c161 chip. But i doesn´t matter at the moment.This should go over rs232 ports. From COM1 toCOM2. In this case I created a cable to establish a handshake-connection with simple hardware protocol betweenCOM1 and COM2 at the same pc. My cable is created as follows:
first connector: second connector:
Pin 2 RXD Pin 2 RXD
Pin 3 TXD Pin 3 TXD
Pin 7 RTS Pin 7 RTS
Pin 8 CTS Pin 8 CTS
RXD and TXD are crossed and RTS and CTS are crossed too.
In dialog-application I placed two text-fields one button called "connect RS232" and a button called "send data". Clicking "connect RS232" the programm calls function CreateFile(...);
Then you can enter any text in first textfield an press "send data" calling function onsenddata(); containing writefile(); and readfile(...); functions. After this onsenddata(...); writes recieved array to second textfield with SetWindowText(...);

And now my issue:
If I try to send an array like "hello", I recieve a text in second textfield like "iiiiiiiiiiiiiiiiiiiihello".
What could be the reason for this? I dont think that it is the OVERLAPPED option in function CreateFile();
Maybe someone of you could help me. Thank you.
hector
 

ZurĂĽck zu PROGRAMMIER FORUM

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 20 Gäste