• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1613
  • Last Modified:

Reseting the com port when 8005 error

Hi, I am using the MSComm control and I receiving a 8005 error as if the port is open.  The situation is that I am trying to close the port just before trying to open it and then I received the 8012 as if the port is already close. If I comment the close script and run the code again it said that the port is open.  How the port is open if when I try to close it, it said is close?  If there a way to force close the port before try to open it?
It does not make sence that the port is open and also close at the same time.  I am not an expert programmer but...

2 Solutions

Port Mapper is a freeware tool which helps home users open/close ports in their routers and gateways securely. It automatically maps and manages ports in the router, enabling online multiplayer game play without disturbing the gaming session. Port Mapper is more secure than manually opening and closing ports, because it opens the ports only when needed and automatically closes them when you are finished playing. Port Mapper works with your Internet gateway/router in such a way that you can have control on the programs that communicate over your network. Using Port Mapper, you can expose applications to your friends over the internet in a safe manner
Without seeing your code, I could only find VB6 code, but it uses this
    frmMain.MSComm1.CommPort = Count
    frmMain.MSComm1.PortOpen = True
    If Err.Number = 8005 Then
        'The port is already open
        'The port exists, so add it to the list.
        NumberOfPorts = NumberOfPorts + 1
        CommPorts(NumberOfPorts) = "COM" & CStr(Count)
    ElseIf frmMain.MSComm1.PortOpen = True Then
        'If the port opens, it exists.
        'Close it and add to the list.
        frmMain.MSComm1.PortOpen = False
        NumberOfPorts = NumberOfPorts + 1
        CommPorts(NumberOfPorts) = "COM" & CStr(Count)
    End If


Forced accept.

EE Admin
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now