RS232 - Recive = Send????

H

Henning M

Hi all,

Im trying to send a command to my uprocessor project, but when i try to read
the answer for the uPU I get the same commed I just send to it???
It is as if the command isn't send before I close the connection?

Can it have something to do with Async/sync read/write????

Everything works when I just type the commands i Hyper Terminal
I get the respond as I should...

Here is the code I use...

Dim obj_RS232 As New Rs232()
Dim char_input As Char

obj_RS232.Open(1, 19200, 8, Rs232.DataParity.Parity_None,
Rs232.DataStopBit.StopBit_1, 128)
obj_RS232.Write("DSTATUS" & vbCr)

txtb_result.Clear()

Do
obj_RS232.Read(1)
char_input = obj_RS232.InputStreamString()
txtb_result.Text &= char_input
Loop While Not (char_input = vbCr)

obj_RS232.Close()

Hope someone can help.

/Henning
 
D

Dick Grier

Hi,

Generally, when you appear to have received what you sent, the fault lies
with the cable between your PC and the device. If a RS-232 serial port is
floating (not connected) often there is enough cross-talk between the Tx and
Rx circuitry to give the result that you see.

So, the first step is to check the connection (such as using HyperTerminal).
After that, I suggest that you download DesktopSerialIO from my homepage.
It is free (as is the class that you are using, of course). However, it is
more flexible, and easier to use -- IMO. Also, I provide a simple terminal
example in the download that may be instructive.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
H

Henning M

Hi, Dick,

Thanks for the responds, I will look into youre DesktopSerialIO. Are your
DesktopSerialIO free to be used for commertial software?

And as mentioned earlier "everything DO work when I use Hyper Terminal"

Any other idears, about what could be wrong.

/Henning
 
D

Dick Grier

Hi,
Are your
DesktopSerialIO free to be used for commertial software?
<<

Yes.

If your code works with HyperTerminal, then it will work with
DesktopSerialIO. Some devices require that RTS be set to True. Set the
RTSEnable property to True.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
H

Henning M

Hi again,

I have now figured out somthing more.
I tried to read more than one line after sending a command!! and guess
what.. I got the respondse I want?

Exampel.
I send:
"DSTATUS" & vbcr
I recive
"DSTATUS" & vbcr
and if I read yet another line I get
"DISKX is turned on" & vbcr
As I should...

I don't like that I have to read the first line and then discard it, before
beeing able to read the real responds to my command!
What goes wrong? How does the send command turn up in the inputbuffer?

Thanks for the help so far.

/Henning
 
D

Dick Grier

Hi,

Your connected device may be echoing them. If so, you have to parse them
out (a simple proceedure).

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
H

Henning M

I just found out 5 min ago, that that is exacly what is happening...

The hardware echoes the command...

Thanks for all your help Dick

/Henning
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top