Serial Port communication in VC++

R

Thread Starter

Rajesh Jain

I am not able to send data and receive data via the Com ports. I have connected the com1 port of my computer to the com1 port of another. i used MFC for sending and receiving data (in VC++ 6.0).
I used writefile for writing and read file for reading. I am not able to send and receive data. What exactly happens at the buffers when i send data. Can u please help us out.
 
D

Darrell Jones

Verify that the cable you are using is a Null Modem cable. If it is try testing ports via rs 232 tester.
 
S

Simon Martin

You have to set up the comms correctly (SetCommsPort if I remember correctly). Mail me outside the list if you want me to send you a class that handles de serial port, or go to
www.codeguru.com and see what they have, or see the terminal example in the VC tutorial.

Debian GNU User
Simon Martin
Project Manager
Isys
mailto: smar[email protected]

There is a chasm of carbon and silicon the software cannot bridge
 
P

Prianggada I. Tanaya

Hello Rajesh,

It seems to me that you program a serial communication under Win32. Before you go further, please check your cable. Make sure that the port is ok, you can tested by placing your mouse to COM2 or COM1, depend on which port you are using for communication.

ReadFile(), and WriteFile() are Win32 routine to read/write to, among other serial port. Have you check the initialization flag? Check every flags
on reading/writing before your program executes other lines.

Ok, I hope this give some idea.
Regards
++ indra ++
 
R

Robert McDonald

If your using the file functions to access the serial ports it's very likely the ports are setup for hardware handshake. If so you need to link
out the handshake lines (RTS - request to send & CTS - clear to send) to allow each port to transmit a character. These are pins 4 & 5 on a 25 pin connector and 7 & 8 on 9 pin connector.

Check both computers are set for same baud rate, parity and stop bits.

Also, you need to ensure the transmit pin on one computer is hooked to the receive pin on the other computer. (or as another responder put it, use a null modem hookup)

That's about it.

Good luck.
Rob..com Inc.
 
G

g. amar kumar

When your send data througth com1 port that
data will stored at output buffer and received
at destination in input buffer.If you do not
taken proper care for control flow by using
either hardware/software methods their is
chance of missing data.
 
Top