Home All Groups Group Topic Archive Search About

Q: Vb.net serial port help

Author
28 Jul 2006 8:21 AM
*.dpG
Hi
I have some questions about serial port in vb.net.... I try only to
recieve data, and I'm using this to open port
--------------------------------------------------------------------------------------------------------------

With sPort
                .PortName = "COM1"
                .BaudRate = 9600
                .Parity = IO.Ports.Parity.None
                .DataBits = 8
                .StopBits = IO.Ports.StopBits.One
                .RtsEnable = True
                .DtrEnable = True
                .ReadTimeout = 1500

            End With
            sPort.Open()
and I have this event handler
txtBox.Invoke(New myDelegate(AddressOf updateTextBox), New Object() {})
and this sub and delegate
Public Sub updateTextBox()
        With txtBox
            .AppendText(sPort.ReadExisting)
            .ScrollToCaret()
        End With
    End Sub
This code is from vb.net 2005 example
------------------------------------------------------------------------------------------------------------------
When I recive some data from hyper terminal, this works fine..... But
when i try to recive data from eg. t central i have bunch of ??????. I
try to use in With
..Encoding = System.Text.Encoding.GetEncoding(28591)
..Encoding = System.Text.Encoding.GetEncoding(1252)
..Encoding = System.Text.Encoding.ASCII
but not work for me, HT recive this data OK.....
Can anybody help me with this problem.


regards

Author
28 Jul 2006 2:47 PM
Dick Grier
Hi,

Download the VB.NET example code from my homepage.  I think this will get
you started.  You haven't shown all of your code, so it is a little hard to
tell exactly what the problem might be.

However, "????" generally indicates that there is some non-ASCII data in the
serial stream.  My example will allow you to display this data as HEX, so
that you can determine what actually is present.

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.
Author
28 Jul 2006 3:04 PM
Dick Grier
BTW, the code on my homepage may not include the Hex Display function (I
don't recall).  So, if you download it, and don't see it -- contact me
offline, and I'll send you an update.

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.
Author
31 Jul 2006 9:33 PM
*.dpG
Dick Grier je napisao/la:
Show quoteHide quote
> BTW, the code on my homepage may not include the Hex Display function (I
> don't recall).  So, if you download it, and don't see it -- contact me
> offline, and I'll send you an update.
>
> 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.

Thanks  Dick's for the reply And you Reny..
Dick your's example is help me very much, and all home page, thank you
for second time ...

regards