Computing.Net > Forums > Programming > Test Serial Port in VB6

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Test Serial Port in VB6

Reply to Message Icon

Name: concentriq
Date: September 18, 2002 at 20:13:34 Pacific
OS: WinXP
CPU/Ram: PIII550 512MB
Comment:

If someone could help me, please, its driving me nuts.

So, I have two programs on two separate computers communicating via serial port. it works great, provided that both programs have same serial port settings (e.g. port number, baud rate, parity, ect...) I would like to add a routine which checks if communication between two programs via serial port was established, and data can be sent back and forth. to setup communication, i used MSComm control, and it has some properties which would let you do it (DCHolding, CTSHolding, ect...). As I understand those properties require actual pin corresponding to the property to be in the connector. All serial cables I have gotten a hold of, only had 3 lines in them (send, receive and ground). IS there any way to find out whether the proper communication was established between two programs using only those three lines, before sending and receiving data. I only have control over one program as far as the code, so I cant send and receive a test character. all the checking has to be done prior to sending data. I know that it is not a typical question, however, if anyone has the answer, PLEASE share. Ive been looking for a sloution for 2 days now.



Sponsored Link
Ads by Google

Response Number 1
Name: tech-fred
Date: September 18, 2002 at 21:57:17 Pacific
Reply:

Typically if you use only 3 wires (send,
receive, and ground), you would have to
jumper RTS/CTS and DTR/DSR flow controls.
You can shut off the requirements for flow
control in software. But unless the speed
is very slow you will probably have buffer
overrun and lose data. You can test if
you are sending data by running a terminal
program (Hyperterm) in the other computer
and watch for characters. I would
recommend setting the baud rate low (2400
baud) when testing, then gradually
increasing speed. To get the highest speed
you will have to implement flow control.
3-wire connections are typically used by
interactive terminals where the output
typically is less than 1 screen.

Also remember if you connect computer to
computer you need a null-cable.


0

Response Number 2
Name: concentriq
Date: September 19, 2002 at 06:52:09 Pacific
Reply:

thanks for responding.
the flow control is set to none. and the speed is set to 1200, which is plenty for sending few characters back and forth. as far as the testing connection goes, I would like to avoid using other programs (hyperterm as you mentioned) to test the connection, but rather add a few lines of code which would tell me that its OK to send/receive data BEFORE I do any sending/receiving. the other program (the one I have no control over), was written to use 3 wire serial cable, so I have to comply on my end.


0

Response Number 3
Name: tech-fred
Date: September 19, 2002 at 17:50:04 Pacific
Reply:

You can't test for a ready condition if
you don't use any handshaking (hardware or
software).
With 3 wires.
You can test you receive buffer for received
characters, but you cannot test if the other
side is ready to receive (unless it
continuously sends a signal that it is
available or some otherform of software
handshaking).

Assuming the other program is well-behaved.
It must give a standard response sequence.
Your program tests and clears the receive
buffer. Send a sequence to the other
computer, wait for response. Process response
and repeat as needed. This is similar to
dialing a modem send AT command and wait
for expected response. Program logic
branches according to received results. Save
data, different command, etc.
At 1200 baud and using a buffered serial
port your computer should be able to process
the data stream with no problem. Provided
you don't run another application.


0

Response Number 4
Name: concentriq
Date: September 19, 2002 at 19:08:41 Pacific
Reply:

tech-fred, thank you for all your replies. its a great pity that it is impossible to do with 3 line serial cable. Unfortunately the communication is initiated on my end, and the idea was to check for ready condition before sending anything. Since we are on the topic, maybe you can answer me the following: suppose I did have more than 3 lines in the cable, A. which line would I need to sufficiently check for ready condition? B. is there a way to check if that particualr line is physically present? C. suppose the line is present, how would I then check for ready condition on both ends? Your comments are much appreciated.


0

Response Number 5
Name: tech-fred
Date: September 19, 2002 at 21:48:33 Pacific
Reply:


Do you know the response characteristics of
the device you are sending to? Does it echo
the received characters?

What is the input buffer of the device that
you are sending to? I once had to use
pacing (send characters one by one because
strings would overflow the input buffer).

Is there a command syntax for the device?
Like a modem does it has fixed responses
to certain commands? Or is it like a
multimeter, where it returns a value of
range x to y?

Actually I think communications is possible
if you can determine the state of the device
at any given time. Just don't send too much
too fast and wait for it to respond.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Test Serial Port in VB6

how to program for serial port in C www.computing.net/answers/programming/how-to-program-for-serial-port-in-c/8494.html

Use PS/2 Port for serial comm. in VB6 www.computing.net/answers/programming/use-ps2-port-for-serial-comm-in-vb6/2219.html

Serial communication in VB6 www.computing.net/answers/programming/serial-communication-in-vb6/6701.html