dr.bizar
08-07-2003, 05:15 PM
Hi all i'm playing around with some VB.
I've been looking at some old post - heres what buggles me:
1) I dont get how to specify the command lenght´.
Eg. 1F 00 10 40 00 03 00 01 66 33 18
Where 00 03 is the command length - and i some commands
the command length is 00 04, even thou the sommand
seems to be the same length ? - don't get it :(
2) But my biggest problem is:
When i send a command recieve the ACK + the "data"
But second time i send the command i recieve some error
responce. this happens even if i increase the SQ nr.
I've tried clearing my mscomm buffers but to no avail. :confused:
Plz- help me
Don't know if it's any help but heres the code:
----------------------------------------------------------------------------------
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_Load()
MSComm1.Settings = "9600,O,8,1"
MSComm1.CommPort = 1
MSComm1.RTSEnable = True
MSComm1.InputLen = 0
End Sub
Private Sub command1_Click()
reset.Enabled = False
fixcom
Launch ("1F 00 10 40 00 03 00 01 66 33 18")
Sleep (2000)
infotext.Text = MSComm1.Input
command.Enabled = True
End Sub
Sub Launch(H As String)
Dim strHexList() As String
Dim loop1 As Long
Dim bytSend As Byte
'split the string into an array based on the space character
strHexList = Split(H, " ")
'loop through each item in the array
For loop1 = 0 To UBound(strHexList)
'convert the hex text into a byte
bytSend = CByte("&H" & strHexList(loop1))
'send the data
Main.MSComm1.Output = Chr(bytSend)
Next 'loop1
End Sub
Sub fixcom()
If Main.MSComm1.PortOpen = False Then
Main.MSComm1.PortOpen = True
End If
Main.MSComm1.InBufferCount = 0
Main.MSComm1.OutBufferCount = 0
End Sub
------------------------------------------------------------------------------
Any advice are most welcome
Cheers
I've been looking at some old post - heres what buggles me:
1) I dont get how to specify the command lenght´.
Eg. 1F 00 10 40 00 03 00 01 66 33 18
Where 00 03 is the command length - and i some commands
the command length is 00 04, even thou the sommand
seems to be the same length ? - don't get it :(
2) But my biggest problem is:
When i send a command recieve the ACK + the "data"
But second time i send the command i recieve some error
responce. this happens even if i increase the SQ nr.
I've tried clearing my mscomm buffers but to no avail. :confused:
Plz- help me
Don't know if it's any help but heres the code:
----------------------------------------------------------------------------------
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_Load()
MSComm1.Settings = "9600,O,8,1"
MSComm1.CommPort = 1
MSComm1.RTSEnable = True
MSComm1.InputLen = 0
End Sub
Private Sub command1_Click()
reset.Enabled = False
fixcom
Launch ("1F 00 10 40 00 03 00 01 66 33 18")
Sleep (2000)
infotext.Text = MSComm1.Input
command.Enabled = True
End Sub
Sub Launch(H As String)
Dim strHexList() As String
Dim loop1 As Long
Dim bytSend As Byte
'split the string into an array based on the space character
strHexList = Split(H, " ")
'loop through each item in the array
For loop1 = 0 To UBound(strHexList)
'convert the hex text into a byte
bytSend = CByte("&H" & strHexList(loop1))
'send the data
Main.MSComm1.Output = Chr(bytSend)
Next 'loop1
End Sub
Sub fixcom()
If Main.MSComm1.PortOpen = False Then
Main.MSComm1.PortOpen = True
End If
Main.MSComm1.InBufferCount = 0
Main.MSComm1.OutBufferCount = 0
End Sub
------------------------------------------------------------------------------
Any advice are most welcome
Cheers