visual basic to the basic stamp 2-sx using MSCOMM
Archiver
Posts: 46,084
Hi,
I'm trying to write a simple VB program that sends a number to the
BS2-Sx (on the standard basic stamp 2 carrier board) and read a
string.
This is my stamp code:
'{$STAMP BS2sx}
i var byte
serin 16, 16624, [noparse][[/noparse]dec i]
debug "received", CR
END
This is my vb code:
Private Sub Form_Load()
' All the code for reading
If MSComm1.PortOpen = False Then
'check to see if the Commport isn't already open
'cmdOpen.Enable = False
'Disable button
MSComm1.PortOpen = True
'open the Commport
Dim SerData As Integer
SerData = 23
MSComm1.Output = Str(SerData)
'check to see if anything is in the buffer
Dim data As String
Dim count As Integer
'variable to hold characters
count = 0
Do
If MSComm1.InBufferCount > 0 Then
'check to see if anything is in the buffer
data = MSComm1.Input
Debug.Print data
count = count + 1
'empty the input buffer into bytes
End If
Loop Until count = 10
End If
End Sub
When I execute the VB code, why is it that I get 23 printed on my
debug window as opposed to received ?
I'm using the ActiveX control MSCOMM and I have the same problem
with MSComm for visual c++. I have set DTREnable to false to
avoid resetting the stamp.
Can anyone please point me in the right direction ?
Thanks,
Jim
I'm trying to write a simple VB program that sends a number to the
BS2-Sx (on the standard basic stamp 2 carrier board) and read a
string.
This is my stamp code:
'{$STAMP BS2sx}
i var byte
serin 16, 16624, [noparse][[/noparse]dec i]
debug "received", CR
END
This is my vb code:
Private Sub Form_Load()
' All the code for reading
If MSComm1.PortOpen = False Then
'check to see if the Commport isn't already open
'cmdOpen.Enable = False
'Disable button
MSComm1.PortOpen = True
'open the Commport
Dim SerData As Integer
SerData = 23
MSComm1.Output = Str(SerData)
'check to see if anything is in the buffer
Dim data As String
Dim count As Integer
'variable to hold characters
count = 0
Do
If MSComm1.InBufferCount > 0 Then
'check to see if anything is in the buffer
data = MSComm1.Input
Debug.Print data
count = count + 1
'empty the input buffer into bytes
End If
Loop Until count = 10
End If
End Sub
When I execute the VB code, why is it that I get 23 printed on my
debug window as opposed to received ?
I'm using the ActiveX control MSCOMM and I have the same problem
with MSComm for visual c++. I have set DTREnable to false to
avoid resetting the stamp.
Can anyone please point me in the right direction ?
Thanks,
Jim
Comments
you are telling your stamp to print "recieved" versus what it has actually
recieved from the Visual Basic program. Change the last line in your stamp
code to say
Change - debug "received", CR
To - debug "dec i", CR
That is what it looks like to me. You may not need the quotes around your
var
in the debug statement.
<DAVE>
"jamesryfler" <jamesryfler@y...> on 09/19/2002 07:38:10 AM
Please respond to basicstamps@yahoogroups.com
To: basicstamps@yahoogroups.com
cc:
Subject: [noparse][[/noparse]basicstamps] visual basic to the basic stamp 2-sx using MSCOMM
Hi,
I'm trying to write a simple VB program that sends a number to the
BS2-Sx (on the standard basic stamp 2 carrier board) and read a
string.
This is my stamp code:
'{$STAMP BS2sx}
i var byte
serin 16, 16624, [noparse][[/noparse]dec i]
debug "received", CR
END
This is my vb code:
Private Sub Form_Load()
' All the code for reading
If MSComm1.PortOpen = False Then
'check to see if the Commport isn't already open
'cmdOpen.Enable = False
'Disable button
MSComm1.PortOpen = True
'open the Commport
Dim SerData As Integer
SerData = 23
MSComm1.Output = Str(SerData)
'check to see if anything is in the buffer
Dim data As String
Dim count As Integer
'variable to hold characters
count = 0
Do
If MSComm1.InBufferCount > 0 Then
'check to see if anything is in the buffer
data = MSComm1.Input
Debug.Print data
count = count + 1
'empty the input buffer into bytes
End If
Loop Until count = 10
End If
End Sub
When I execute the VB code, why is it that I get 23 printed on my
debug window as opposed to received ?
I'm using the ActiveX control MSCOMM and I have the same problem
with MSComm for visual c++. I have set DTREnable to false to
avoid resetting the stamp.
Can anyone please point me in the right direction ?
Thanks,
Jim
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Port 16 creates a half duplex connection to the PC. As a result, your PC
sees the very data it transmits and hence the '23'. You will need to collect
all the data the PC receives and discard the portions that are echoes.
One alternative may be to use 'microGUI':
http://www.rhombus-tek.com/software.html
which offers Drag & Drop communication between a Stamp and PC. In addition
to handling half duplex communication it takes of the Master/Slave issues
and also provides Sliders, Bars , LEDs, Gauges etc almost instantly.
David H Lawrence
Simple Multi-tasking, Co-Processors, Compilers, and microGUI
mailto:david@r...
http://www.rhombus-tek.com
Original Message
From: "jamesryfler" <jamesryfler@y...>
To: <basicstamps@yahoogroups.com>
Sent: Thursday, September 19, 2002 5:38 AM
Subject: [noparse][[/noparse]basicstamps] visual basic to the basic stamp 2-sx using MSCOMM
> Hi,
>
> I'm trying to write a simple VB program that sends a number to the
> BS2-Sx (on the standard basic stamp 2 carrier board) and read a
> string.
>
> This is my stamp code:
> '{$STAMP BS2sx}
> i var byte
> serin 16, 16624, [noparse][[/noparse]dec i]
> debug "received", CR
>
> END
>
> This is my vb code:
>
> Private Sub Form_Load()
>
>
> ' All the code for reading
> If MSComm1.PortOpen = False Then
> 'check to see if the Commport isn't already open
>
> 'cmdOpen.Enable = False
> 'Disable button
> MSComm1.PortOpen = True
> 'open the Commport
>
> Dim SerData As Integer
> SerData = 23
> MSComm1.Output = Str(SerData)
>
> 'check to see if anything is in the buffer
>
> Dim data As String
> Dim count As Integer
> 'variable to hold characters
> count = 0
> Do
> If MSComm1.InBufferCount > 0 Then
> 'check to see if anything is in the buffer
>
> data = MSComm1.Input
> Debug.Print data
> count = count + 1
> 'empty the input buffer into bytes
>
> End If
> Loop Until count = 10
> End If
>
> End Sub
>
> When I execute the VB code, why is it that I get 23 printed on my
> debug window as opposed to received ?
>
> I'm using the ActiveX control MSCOMM and I have the same problem
> with MSComm for visual c++. I have set DTREnable to false to
> avoid resetting the stamp.
>
> Can anyone please point me in the right direction ?
>
> Thanks,
>
> Jim
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.384 / Virus Database: 216 - Release Date: 8/21/02