By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,244 Members | 2,155 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,244 IT Pros & Developers. It's quick & easy.

RS232 - Recive = Send????

P: n/a
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

Apr 22 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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.
Apr 22 '06 #2

P: n/a
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
"Dick Grier" <dick_grierNOSPAM@.msn.com> wrote in message
news:eo**************@TK2MSFTNGP04.phx.gbl...
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.

Apr 22 '06 #3

P: n/a
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.
Apr 23 '06 #4

P: n/a
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

"Dick Grier" <dick_grierNOSPAM@.msn.com> wrote in message
news:eo**************@TK2MSFTNGP04.phx.gbl...
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.

Apr 24 '06 #5

P: n/a
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.
Apr 24 '06 #6

P: n/a
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

"Dick Grier" <dick_grierNOSPAM@.msn.com> wrote in message
news:uV**************@TK2MSFTNGP05.phx.gbl...
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.

Apr 24 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.