DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: mscomm problem to send at commad

  1. #1
    Join Date
    Oct 2007
    Posts
    19

    mscomm problem to send at commad

    hello
    need help sending atcommands in vb..
    i made small code but its seems buggy
    can't get buffer or connection..

    Private Sub Command1_Click()
    Dim command As String
    Dim i As Integer
    On Error GoTo erroreporta
    Command1.Caption = "Disconnect"

    i = COM1

    If Combo1.Text = "" Then
    MsgBox "please select port first"
    Combo1.SetFocus
    Command1.Caption = "connect"
    Exit Sub
    End If
    If MSComm1.PortOpen = True Then
    cmdOn.Visible = True
    cmdOn.Caption = "OPEN"
    Exit Sub
    End If

    If MSComm1.PortOpen = True Then
    MSComm1.PortOpen = False & MsgBox("already open")
    End If
    MSComm1.CommPort = 1
    MSComm1.Settings = "38400,n,8,1"
    MSComm1.InputLen = 50

    MSComm1.Output = "xxxxxcommand " & Chr$(13)

    If MSComm1.InBufferCount > 0 Then
    MSComm1.PortOpen = False
    GoTo erroreporta
    Else
    Do
    'nulla
    Loop Until MSComm1.InBufferCount >= 50
    received = MSComm1.Input
    Text1.Text = Mid(received, 11, 15)
    MSComm1.PortOpen = False
    Exit Sub
    End If
    cambioporta:
    If i = 256 Then
    MsgBox "Telefono non rilevato, collegarlo o reinstallare i dirvers. Il keygen funzionerà ugualmente se già si conosce l'IMEI del telefonino.", vbExclamation, "ERRORE"
    End If

    portok:

    erroreporta:
    If Err.Number = 8002 Then
    MsgBox "nothing found"
    Command1.Caption = "connect"
    Resume cambioporta
    MSComm1.PortOpen = False

    End If
    Text1.Text = MSComm1.CommEvent
    Text2.Text = MSComm1.InBufferCount


    End Sub
    don't know why but after sending command to port1
    MSComm1.Output = "xxxxxcommand " & Chr$(13)
    its land to error report
    If Err.Number = 8002 Then
    and port get nothing ..

    any clue or example to do it more easily??

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Is it generating an 8002 error or another error?

  3. #3
    Join Date
    Oct 2007
    Posts
    19
    Quote Originally Posted by Hack
    Is it generating an 8002 error or another error?
    hello no its not its just land to error report
    and i think its because of port selection?

    in simple words i made combo1 and listed all available port there.
    with command click i put some statement if combo is empty show msg.
    all that ok
    but after that its not focus on port selected on it.
    may be missing code or something?

    i want command1 click monitor port of combo1.text and use that with port open and use that to send command.

    any help?

    ps: thanks once again for last time and this time in advance.

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Are you sure you are getting valid ports in your drop down combo?

    How is that being populated?

  5. #5
    Join Date
    Oct 2007
    Posts
    19
    Quote Originally Posted by Hack
    Are you sure you are getting valid ports in your drop down combo?

    How is that being populated?
    i send you pm with link for my project files.
    Last edited by stanner_austin; 10-17-2008 at 09:05 AM.

  6. #6
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    I don't want a link to your project files.

    I would like to assist you in solving your problem, publically.

  7. #7
    Join Date
    Oct 2007
    Posts
    19
    ok solved that problem
    with this
    public declaration.
    and one copy paste modul

    on forum load this use
    Dim i As Integer

    Combo1.Clear

    For i = 1 To 50
    If COMAvailable(i) Then
    Combo1.AddItem i
    End If
    Next
    Combo1.ListIndex = 0

    worked now.

    few more problem are.

    command1 is acting for connect to port and sending one atcommand.
    response should be come and i expected if not should show
    msg box with error bla bla...
    that's unknown for me any help?

    and

    textbox is working for display status log.
    like port selected
    then its should show connecting like that.
    any way to make textbox2 show always in next line with any public declaration?

  8. #8
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    What is COMAvailable?

    When run some code that I had tucked away in my code library to load an available com ports into a listbox, I came up with two.

    COM1
    COM4

    These will differ from machine to machine, but I dont recall ever encountering a machine that had 50 com ports available.

  9. #9
    Join Date
    Jan 2008
    Posts
    73
    As Hack asked... What is COMAvailable? I can't find it in your code.
    Last edited by CDRIVE; 10-19-2008 at 04:54 PM.

  10. #10
    Join Date
    Oct 2007
    Posts
    19
    its from module
    i have used copy paste source to do that.

  11. #11
    Join Date
    Jan 2008
    Posts
    73
    Quote Originally Posted by stanner_austin
    its from module
    i have used copy paste source to do that.
    That tells us where it is but it doesn't tell us what it is.

  12. #12
    Join Date
    Oct 2007
    Posts
    19
    its for listing port only which are able to use or possible to send command.
    attached for you..

    i still need some help if possible
    text box not able to display received response in hex or ascii.
    only showing "???‹?????????????????????ت??????"

    response is 58byte and knowed..

    i have try richtextbox also result is same.

    as i searched google from 2days i found need to make something which convert binary to ascii and binary to hex..
    but found nothing good to do it..

    any one help regarding this?

    thanks in advance too close to finish project.
    Attached Files Attached Files

  13. #13
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Binary to ASCII Converter

    Binary To Hex

    BTW...your attachment is an interesting combination of two different file compression software packages. Module1.rar.zip - the results is that Winzip (which is what I have) does not recognize the format and it opens empty.

  14. #14
    Join Date
    Oct 2007
    Posts
    19
    hack my friend.
    i think u know..
    ur vbb or what ever used in making forum don't allow rar extension to upload atlast for me don't know for other.
    so i renamed rar.zip
    but file is really rar. just remove .zip
    hehehe

    and i don't get idea with this link.
    i mean convert is every one know ..
    but my problem is my data in buffer which i defined and showed in textbox
    but textbox is showing only response which i posted in my last post.
    rich text also same.

    any module or public code which help to convert binary to hex or ascii
    and display response in text box?

  15. #15
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    The links are the ways to accomplish the conversions that you need. (I can't open .rar files)

Similar Threads

  1. Memory problem with Borland C3.1
    By AZ1699 in forum C++
    Replies: 11
    Last Post: 11-16-2007, 01:23 PM
  2. Replies: 1
    Last Post: 10-18-2007, 02:50 PM
  3. Reliability Problem
    By elise in forum Java
    Replies: 0
    Last Post: 10-30-2002, 05:40 AM
  4. Replies: 0
    Last Post: 07-12-2001, 03:25 AM
  5. ADO Commad with Sto. Proc. Problem
    By Leopoldo Rodriguez in forum VB Classic
    Replies: 1
    Last Post: 06-27-2000, 02:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center