Results 1 to 2 of 2

Thread: error responce when i send command twice - Why ?

  1. #1

    error responce when i send command twice - Why ?

    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.
    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

  2. #2
    Join Date
    Jul 2003
    Location
    The Netherlands
    Posts
    254
    Just a wild guess - but in the case you get the command length wrong, the phone might interpret the second packet wrongly by mis-placing bytes.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •