BS2 comm with VB
Archiver
Posts: 46,084
does anyone know how i can improve this code. I have to put a pause
in the tranmission to VB comm port, othewise it combines a lot of
data mutiple times before VB takes a reading. I have the timer on
quickest interval. the code of the BS and VB timer are below. thanks
*********** BS2 Code:
main:
debug "BOF"
gosub sub_tx_delay
debug dec 25
gosub sub_tx_delay
debug dec 255
gosub sub_tx_delay
debug dec 5
gosub sub_tx_delay
debug "EOF"
gosub sub_tx_delay
goto main
sub_tx_delay:
pause 50
return
************ VB Code:
If MSComm1.InBufferCount > 0 Then
bytes = MSComm1.Input
If bytes = "BOF" Then
counter1 = 0
counter1 = counter1 + 1
Do
If MSComm1.InBufferCount > 0 Then
bytes = MSComm1.Input
Data(counter).Caption = bytes
counter = counter + 1
End If
Loop Until counter > 3
If Data(counter - 1).Caption <> "EOF" Then
Label_tx_status.Caption = "Failed, no EOF"
good_tx = 0
Else
Label_tx_status.Caption = "Good " & Str(good_tx)
good_tx = good_tx + 1
If good_tx > 250 Then good_tx = 0
End If
counter = 0
End If
If counter1 > 5 Then
Label_tx_status.Caption = "Failed, no BOF"
counter1 = 0
good_tx = 0
End If
End If
in the tranmission to VB comm port, othewise it combines a lot of
data mutiple times before VB takes a reading. I have the timer on
quickest interval. the code of the BS and VB timer are below. thanks
*********** BS2 Code:
main:
debug "BOF"
gosub sub_tx_delay
debug dec 25
gosub sub_tx_delay
debug dec 255
gosub sub_tx_delay
debug dec 5
gosub sub_tx_delay
debug "EOF"
gosub sub_tx_delay
goto main
sub_tx_delay:
pause 50
return
************ VB Code:
If MSComm1.InBufferCount > 0 Then
bytes = MSComm1.Input
If bytes = "BOF" Then
counter1 = 0
counter1 = counter1 + 1
Do
If MSComm1.InBufferCount > 0 Then
bytes = MSComm1.Input
Data(counter).Caption = bytes
counter = counter + 1
End If
Loop Until counter > 3
If Data(counter - 1).Caption <> "EOF" Then
Label_tx_status.Caption = "Failed, no EOF"
good_tx = 0
Else
Label_tx_status.Caption = "Good " & Str(good_tx)
good_tx = good_tx + 1
If good_tx > 250 Then good_tx = 0
End If
counter = 0
End If
If counter1 > 5 Then
Label_tx_status.Caption = "Failed, no BOF"
counter1 = 0
good_tx = 0
End If
End If
Comments
activex control for doing comm programming, there doesn't seem to be much
info on the msdn site.
I am trying a simple experiment with an led, and trying to turm it on/off
through vb, and can't seem to get it working consistantly.
*******************************************************************
William (Bill) Tyler
Senior I/T Specialist
Enterprise Services for Microsoft Technologies, App Dev
IBM Global Services, Austin, TX
Office: 512.473.8073
T/L: 595.8073
Pager: 800.946.4646 pin:1464080
"superdroid2001" <cpayne@d...> on 03/09/2002 09:22:01 PM
Please respond to basicstamps@yahoogroups.com
To: basicstamps@yahoogroups.com
cc:
Subject: [noparse][[/noparse]basicstamps] BS2 comm with VB
does anyone know how i can improve this code. I have to put a pause
in the tranmission to VB comm port, othewise it combines a lot of
data mutiple times before VB takes a reading. I have the timer on
quickest interval. the code of the BS and VB timer are below. thanks
*********** BS2 Code:
main:
debug "BOF"
gosub sub_tx_delay
debug dec 25
gosub sub_tx_delay
debug dec 255
gosub sub_tx_delay
debug dec 5
gosub sub_tx_delay
debug "EOF"
gosub sub_tx_delay
goto main
sub_tx_delay:
pause 50
return
************ VB Code:
If MSComm1.InBufferCount > 0 Then
bytes = MSComm1.Input
If bytes = "BOF" Then
counter1 = 0
counter1 = counter1 + 1
Do
If MSComm1.InBufferCount > 0 Then
bytes = MSComm1.Input
Data(counter).Caption = bytes
counter = counter + 1
End If
Loop Until counter > 3
If Data(counter - 1).Caption <> "EOF" Then
Label_tx_status.Caption = "Failed, no EOF"
good_tx = 0
Else
Label_tx_status.Caption = "Good " & Str(good_tx)
good_tx = good_tx + 1
If good_tx > 250 Then good_tx = 0
End If
counter = 0
End If
If counter1 > 5 Then
Label_tx_status.Caption = "Failed, no BOF"
counter1 = 0
good_tx = 0
End If
End If
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/