Nate Smith
08-04-2005, 03:05 AM
I am trying to develop an application in Visual Basic 2005 Beta 2 which communicates with a Basic Stamp processor.· The bulk of this communication consists of a 1 byte command character, then 12 bytes of data.· I am having issues with the Stamp receiving all of the data from the VB program.· I have verified that the Vb app is indeed sending all the data that the stamp is looking for(through a virtual serial port emulator), and have been able to send the data successfully through the debug window.· I am currently running communications via SERIN/SEROUT at 2400/8/N/1/Inverted (16780).· The VB and Stamp code are below:
----START VB2005 CODE---
Using com As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort(sCommPort)
ConfigurePort(com) 'Set port settings to 2400 8/N/1
com.NewLine = Chr(13)
com.Write("S")
For Each c As Char In value
com.Write(c)
Next
'now, send the alarm
com.DiscardInBuffer()
com.Write("N")
For X As Integer = 1 To 10000 : Next X
value = Format(AlarmTime, "HH mm ss MM dd yyyy")
For Each c As Char In value
com.Write(c)
Next
End Using
------START BS2 COMM CODE-----
mainLoop:
· TOGGLE hbeat
· SERIN 16,pcComm,500,checkAlarm,[STR cmd\1]
· SELECT cmd
··· CASE "S"
····· 'set time
····· GOSUB readTimeFromPC
····· GOSUB setCurrentTime
··· CASE ELSE
····· GOTO checkAlarm
· ENDSELECT
GOTO mainLoop
readTimeFromPC:
····· SERIN 16,pcComm,[DEC hh]
····· TOGGLE hbeat
····· SERIN 16,pcComm,[DEC mm]
····· 'DEBUGIN DEC2 mm
····· TOGGLE hbeat
····· SERIN 16,pcComm,[DEC ss]
····· 'DEBUGIN DEC2 ss
····· TOGGLE hbeat
····· SERIN 16,pcComm,[DEC mo]
····· 'DEBUGIN DEC2 mo
····· TOGGLE hbeat
····· SERIN 16,pcComm,[DEC dd]
····· 'DEBUGIN DEC2 dd
····· TOGGLE hbeat
····· SERIN 16,pcComm,[DEC yr.HIGHBYTE, DEC yr.LOWBYTE]
····· 'DEBUGIN DEC2 yr.HIGHBYTE, DEC2 yr.LOWBYTE
····· TOGGLE hbeat
····· SEROUT 16,pcComm,["OK",CR]
RETURN
----START VB2005 CODE---
Using com As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort(sCommPort)
ConfigurePort(com) 'Set port settings to 2400 8/N/1
com.NewLine = Chr(13)
com.Write("S")
For Each c As Char In value
com.Write(c)
Next
'now, send the alarm
com.DiscardInBuffer()
com.Write("N")
For X As Integer = 1 To 10000 : Next X
value = Format(AlarmTime, "HH mm ss MM dd yyyy")
For Each c As Char In value
com.Write(c)
Next
End Using
------START BS2 COMM CODE-----
mainLoop:
· TOGGLE hbeat
· SERIN 16,pcComm,500,checkAlarm,[STR cmd\1]
· SELECT cmd
··· CASE "S"
····· 'set time
····· GOSUB readTimeFromPC
····· GOSUB setCurrentTime
··· CASE ELSE
····· GOTO checkAlarm
· ENDSELECT
GOTO mainLoop
readTimeFromPC:
····· SERIN 16,pcComm,[DEC hh]
····· TOGGLE hbeat
····· SERIN 16,pcComm,[DEC mm]
····· 'DEBUGIN DEC2 mm
····· TOGGLE hbeat
····· SERIN 16,pcComm,[DEC ss]
····· 'DEBUGIN DEC2 ss
····· TOGGLE hbeat
····· SERIN 16,pcComm,[DEC mo]
····· 'DEBUGIN DEC2 mo
····· TOGGLE hbeat
····· SERIN 16,pcComm,[DEC dd]
····· 'DEBUGIN DEC2 dd
····· TOGGLE hbeat
····· SERIN 16,pcComm,[DEC yr.HIGHBYTE, DEC yr.LOWBYTE]
····· 'DEBUGIN DEC2 yr.HIGHBYTE, DEC2 yr.LOWBYTE
····· TOGGLE hbeat
····· SEROUT 16,pcComm,["OK",CR]
RETURN