For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > April 2005 > MSComm help









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author MSComm help
Mike D

2005-04-25, 3:55 pm

I am trying to get data from a balance to my vb app using MSComm. I know the
balance is transmitting because I can pick it up in hyperterminal. I need to
get the value from the balance when the balance sends it so I believe I need
the OnComm method but I don't know how.

Any help greatly appreciated.

Thanks
Mike


Here is what I have:
Sub Form_Load()
Dim strBalanceOutput As String

MSComm1.CommPort = 2
' 9600 baud, Odd parity, 7 data, and 1 stop bit.
MSComm1.Settings = "9600,O,7,1"

'Open Com port
MSComm1.PortOpen = True
MSComm1.InputMode = comInputModeText

Text1.Text = strBalanceOutput

End Sub
btpanek09@yahoo.com

2005-04-25, 3:55 pm

Check out this previous thread....
http://groups-beta.google.com/group...d39aeb36e359f27
Most likely the balance is transmitting Binary not Text data...
What kind of output are you seeing in Hyperterminal?

Dick Grier

2005-04-25, 3:55 pm

Hi,

I answered this question elsewhere.

You need to enable OnComm event handling (RThreshold = 1), and add code to
the MSComm OnComm subroutine to capture the data. You also need the
manufacturer's information about the structure of the data to be captured.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.


Mike D

2005-04-25, 3:55 pm

In hyperterminal I am seeing the numbers from the balance so in hyperterminal
I see
N + 72.14 g

So is the balance sending text or does hyperterminal convert?

Mike

"btpanek09@yahoo.com" wrote:

> Check out this previous thread....
> http://groups-beta.google.com/group...d39aeb36e359f27
> Most likely the balance is transmitting Binary not Text data...
> What kind of output are you seeing in Hyperterminal?
>
>

Mike D

2005-04-25, 3:55 pm

Thanks for the reply. The balance docs say there is a 23-byte transmit
buffer and a 40-byte receive buffer.

Mike

"Dick Grier" wrote:

> Hi,
>
> I answered this question elsewhere.
>
> You need to enable OnComm event handling (RThreshold = 1), and add code to
> the MSComm OnComm subroutine to capture the data. You also need the
> manufacturer's information about the structure of the data to be captured.
>
> Dick
>
> --
> Richard Grier (Microsoft Visual Basic MVP)
>
> See www.hardandsoftware.net for contact information.
>
> Author of Visual Basic Programmer's Guide to Serial Communications, 4th
> Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
> www.mabry.com/vbpgser4 to order.
>
>
>

Saga

2005-04-25, 8:55 pm

What you see s what youi're getting <g>
Normally (with due exceptions I imagine) scales send ASCII.

Saga

"Mike D" <MikeD@discussions.microsoft.com> wrote in message
news:4068EFAD-DE27-4790-AD4D-85686C32C6DC@microsoft.com...[color=darkred]
> In hyperterminal I am seeing the numbers from the balance so in
> hyperterminal
> I see
> N + 72.14 g
>
> So is the balance sending text or does hyperterminal convert?
>
> Mike
>
> "btpanek09@yahoo.com" wrote:
>


Dick Grier

2005-04-25, 8:55 pm

OK. But...

The details are critical. The statement, "a 23-byte transmit
buffer and a 40-byte receive buffer," doesn't say anything about what the
data that are sent by the scale represent, nor the data format.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.


Mike D

2005-04-25, 8:55 pm

Dick,

Thanks so much for your time. I think I have found the details
Character Coding = 7-bit ASCII
Data output = 16 or 22 characters
Hardware handshake with 2 characters after CTS

I am stiil unable to get the ON_Comm to fire with this code

Sub Form_Load()
Dim strBalanceOutput As String

MSComm1.CommPort = 2
' 9600 baud, Odd parity, 7 data, and 1 stop bit.
MSComm1.Settings = "9600,O,7,1"

'Open Com port
MSComm1.PortOpen = True
MSComm1.InputMode = comInputModeText

MSComm1.RThreshold = 1
MSComm1.SThreshold = 1


End Sub

Sub MSComm1_OnComm()
MsgBox ("Boo")

End Sub






"Dick Grier" wrote:

> OK. But...
>
> The details are critical. The statement, "a 23-byte transmit
> buffer and a 40-byte receive buffer," doesn't say anything about what the
> data that are sent by the scale represent, nor the data format.
>
> Dick
>
> --
> Richard Grier (Microsoft Visual Basic MVP)
>
> See www.hardandsoftware.net for contact information.
>
> Author of Visual Basic Programmer's Guide to Serial Communications, 4th
> Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
> www.mabry.com/vbpgser4 to order.
>
>
>

Dick Grier

2005-04-25, 8:55 pm

Add RTSEnable = True

You don't need SThreshold (in fact, it never is needed).
--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.


Mike D

2005-04-27, 3:55 pm

I can't get the OnComm event to fire. My balance is sending data to
hyperterminal what am I missing?

Mike


Here is my code:
Dim MSComm1 As New MSComm

Sub Form_Load()
Dim strBalanceOutput As String

MSComm1.CommPort = 2

' 9600 baud, Odd parity, 7 data, and 1 stop bit.
MSComm1.Settings = "9600,O,7,1"

'Open Com port
MSComm1.PortOpen = True
MSComm1.RThreshold = 1
MSComm1.RTSEnable = True

MSComm1.InputMode = comInputModeText

End Sub

Sub MSComm1_OnComm()
MsgBox ("Boo")

End Sub




"Dick Grier" wrote:

> Add RTSEnable = True
>
> You don't need SThreshold (in fact, it never is needed).
> --
> Richard Grier (Microsoft Visual Basic MVP)
>
> See www.hardandsoftware.net for contact information.
>
> Author of Visual Basic Programmer's Guide to Serial Communications, 4th
> Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
> www.mabry.com/vbpgser4 to order.
>
>
>

Mike D

2005-04-27, 3:55 pm

I can't get the ONComm event to fire. I know the balance is sending data
because I can see it in hyperterminal. What am I missing??

Thanks
Mike



Here is my code:
Dim MSComm1 As New MSComm

Sub Form_Load()
Dim strBalanceOutput As String

MSComm1.CommPort = 2

' 9600 baud, Odd parity, 7 data, and 1 stop bit.
MSComm1.Settings = "9600,O,7,1"

'Open Com port
MSComm1.PortOpen = True
MSComm1.RThreshold = 1
MSComm1.RTSEnable = True


MSComm1.InputMode = comInputModeText

End Sub

Sub MSComm1_OnComm()
MsgBox ("Boo")

End Sub



"Dick Grier" wrote:

> Add RTSEnable = True
>
> You don't need SThreshold (in fact, it never is needed).
> --
> Richard Grier (Microsoft Visual Basic MVP)
>
> See www.hardandsoftware.net for contact information.
>
> Author of Visual Basic Programmer's Guide to Serial Communications, 4th
> Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
> www.mabry.com/vbpgser4 to order.
>
>
>

J French

2005-04-28, 3:56 am

On Wed, 27 Apr 2005 06:10:02 -0700, =?Utf-8?B?TWlrZSBE?=
<MikeD@discussions.microsoft.com> wrote:

>I can't get the ONComm event to fire. I know the balance is sending data
>because I can see it in hyperterminal. What am I missing??


Try sticking the MSCOMM control on the Form at design time
- rather than creating it at run time
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com