Results 1 to 5 of 5

Thread: can not open comport

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    2

    can not open comport

    Hi, I'm newbie and I don't know what the problem is. Sometimes program can not open serial port. For example the code below, was working just fine for com9 yesterday, now it's not. It tries to run "MSComm1.PortOpen = True" the goes to error. Same error occurs for some other ports, time to time. Can you help me?



    Private Sub cmdBasla_Click()
    On Error GoTo hata
    MSComm1.CommPort = Val(Replace(Combo1.Text, "Comm", ""))

    If MSComm1.PortOpen = False Then MSComm1.PortOpen = True
    cmdBasla.Enabled = False
    Exit Sub
    hata:
    Call subLogEkle("cmdBasla_Click " & Err.Description)
    End Sub

  2. #2
    New Member
    Join Date
    Feb 2009
    Location
    Australia
    Posts
    6

    Re: can not open comport

    Are you sure that the port is not already opened by another application? If the port has been opened already by another app (eg. Hyperterminal) it will generate an error.

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    2

    Re: can not open comport

    No I'm not sure. I do not run HyperTerminal but some programs (eq virtual daemon manager) run at startup. Does it use comport? By the way, this occurs for several ports, not just for one.

  4. #4
    New Member
    Join Date
    Feb 2009
    Location
    Australia
    Posts
    6

    Re: can not open comport

    Its hard to guess what is going on from here. Have you tried stripping out the code and putting it into a small exe project? If you remove as many layers of complexity as you can, you can establish at what layer the problem begins. If you write a tiny program that does nothing but open the port and you still have a problem then it might be an issue with your OS or hardware.

    I have done a lot of work using the mscomm object, and I have found it to be very stable. Have you tried using another piece of commercial software to test the com ports? You might find PortMon (http://technet.microsoft.com/en-us/s.../bb896644.aspx) useful. I have found it extremely helpful. You can see a lot more of what is happening outside your code.

    Good luck.

  5. #5
    New Member
    Join Date
    Feb 2009
    Location
    Australia
    Posts
    6

    Re: can not open comport

    More thoughts.

    When you write the test program just put the code onto Form_Load, and use a hard wired literal for the port number. Make sure that the port opens from hyperterminal first. If you can't get a connection from hyperterminal there is no point in trying from VB.

    You also need to make sure that the port settings are correct. I think the default is 9600,8,1,none. You need to check the device specs to make sure you have them set correctly.

Posting Permissions

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



Click Here to Expand Forum to Full Width