Help With Basic Stamp <--> Visual Basic .NET 2005 Express
Alright.. I'm having some problems getting my BS2 to get info from my VB app. Now.. I got this exact vb code to work but I have lost the BASIC code so I hoped this would work.. FOr some reason it does not.. Any ideas?
What happens:
When I send data the power light flashes which I assume means it's reset. This is not soppose to happen. Please help![noparse]:([/noparse]
Basic Stamp Code:
VB CODE:
What happens:
When I send data the power light flashes which I assume means it's reset. This is not soppose to happen. Please help![noparse]:([/noparse]
Basic Stamp Code:
' {$STAMP BS2}
' {$PBASIC 2.5}
command VAR Byte
Main:
command = 0
' Use the programming port to receive
' data at 2400 baud
' Wait for the synch byte (255) and then
' get the PinNumber and PinState
SERIN 16,16780,[noparse][[/noparse]WAIT(255),command]
PAUSE 10000
DEBUG "GOD"
IF command = 2 THEN Laser
PAUSE 500
GOTO Main
Laser:
HIGH 0
PAUSE 2000
LOW 0
GOTO Main
VB CODE:
Public Sub rs232Open()
moRS232 = New Rs232
Try
'// Setup parameters
With moRS232
.Port = 1
.BaudRate = 2400
.DataBit = 8
.StopBit = Rs232.DataStopBit.StopBit_1
.Parity = Rs232.DataParity.Parity_None
.Timeout = 1500
End With
'// Initializes port
moRS232.Open()
'// Set state of RTS / DTS
moRS232.Dtr = 1
moRS232.Rts = 1
'//If chkEvents.Checked Then moRS232.EnableEvents()
'//chkEvents.Enabled = True
Catch Ex As Exception
'e.skypeChatMessage.Chat.SendMessageA("Connection Error")
Call log("||Connection Error")
'MessageBox.Show(Ex.Message, "Connection Error", MessageBoxButtons.OK)
Finally
'btnCloseCom.Enabled = moRS232.IsOpen
'btnOpenCom.Enabled = Not moRS232.IsOpen
If (moRS232.IsOpen) Then
Call log("||Comm Port Opened!")
End If
'btnTx.Enabled = moRS232.IsOpen
'btnRx.Enabled = moRS232.IsOpen
'btnCheck.Enabled = moRS232.IsOpen
End Try
End Sub
Public Sub rs232Close()
moRS232.Close()
If (Not moRS232.IsOpen) Then
Call log("||Comm Port Closed!")
End If
End Sub
Public Sub rs232Write(ByVal data As Integer)
If (Not moRS232.IsOpen) Then
Call log("||Comm Port Not Open")
End If
'Call open_comm(e)
Call log("||Comm Data Sent")
moRS232.PurgeBuffer(Rs232.PurgeBuffers.TxClear Or Rs232.PurgeBuffers.RXClear)
moRS232.Write(Chr(255) & Chr(2))
End Sub

Comments
Tom
Cheers,
Tom
Now what? I don't see DTS
Then, Run 2, 3, 5 to the Stamp programming port.
Tom
Charlie
Post Edited (dy8coke) : 1/6/2006 7:59:25 PM GMT
Ok. I've found another problem.. Can Anyboy Help?
Current Code: (DOES WORK)
' {$STAMP BS2} ' {$PBASIC 2.5} command VAR Byte One: HIGH 1 PAUSE 2000 LOW 1 GOTO Main Two: HIGH 2 PAUSE 2000 LOW 2 GOTO Main Zero: HIGH 0 PAUSE 2000 LOW 0 GOTO Main Main: command = 0 ' Use the programming port to receive ' data at 2400 baud ' Wait for the synch byte (255) and then ' get the PinNumber and PinState SERIN 16,16780,[noparse][[/noparse]WAIT(255),command] PAUSE 10000 BRANCH command, [noparse][[/noparse]Zero, One, Two] PAUSE 500 GOTO MainSHOULD WORK BUT DOESN'T CODE:
' {$STAMP BS2} ' {$PBASIC 2.5} command VAR Byte Main: command = 0 ' Use the programming port to receive ' data at 2400 baud ' Wait for the synch byte (255) and then ' get the PinNumber and PinState SERIN 16,16780,[noparse][[/noparse]WAIT(255),command] PAUSE 10000 BRANCH command, [noparse][[/noparse]Zero, One, Two] PAUSE 500 GOTO Main One: HIGH 1 PAUSE 2000 LOW 1 GOTO Main Two: HIGH 2 PAUSE 2000 LOW 2 GOTO Main Zero: HIGH 0 PAUSE 2000 LOW 0 GOTO MainWhy does it do that? Also, the branch statmentdoesn't work. It always blinks the One: led. Any help?
Post Edited (DiablodeMorte) : 1/6/2006 9:20:05 PM GMT
·as an example.· Also I needed to create a buffer for the output data.
then in the rs232Write sub I used..
······
Charlie