Results 1 to 7 of 7

Thread: old problem, revisited

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Location
    Botswana
    Posts
    107

    old problem, revisited

    hi everyone. i thought i fixed this problem but it keeps coming back. i have a usb modem connected to my computer (which can send and recieve sms's). my program's main thread is used to read/send sms's and store them in a db. a secondary thread polls the modem looking for new text messages (about once every 3 seconds). after running about an hour (sometimes sooner) the program gets disconnected from the commport (it use to crash the program but ive seemed to fix that) and wont reconnect. heres the relevant code:

    Main Form:
    Code:
    .....
    Delegate Sub TaskDelegate()
    ........
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Try
                If IsConnected = False Then
                    Me.Label12.Text = "Not Connected"
                Else
                    Me.Label12.Text = "Connected"
                End If
    
                If NewMsg = True Then
                    Me.Label10.Text = (CInt(Me.Label10.Text) + 1).ToString
                    NewMsg = False
                Else
    
                End If
    
    
                Dim someClass As New Class2
                Dim td As New TaskDelegate(AddressOf someClass.FindMyPort)
                td.BeginInvoke(Nothing, Nothing)
    
            Catch ex As Exception
                MsgBox("An error has occured.  Please make sure the programs database is closed.")
            End Try
        End Sub

    Class2 thread:

    Code:
    Public Class Class2
    Delegate Sub TaskDelegate()
    
    Public sub ShowMessage (ByRef MsgPDU As SmsDeliverPdu)
    'not important because this is not called if no sms comes in, which they 
    'dont when i test it
    end sub
    
        Public Sub FindMyPort()
            Dim storage = PhoneStorageType.Sim
            Dim MsgLocation As Integer
            Dim counter As Integer = 0
            Dim GetManu As String = ""
    
            Debug.Print("Start Class findmyport")
            Debug.Print(MyPortNumber)
    
    
            comm = New GsmCommMain(MyPortNumber, 9600)
            Dim nullCheck = IsDBNull(comm)
            If nullCheck = True Then
                Debug.Print("port is null")
            Else
                If comm.IsOpen = True Then
                    comm.Close()
                    Thread.CurrentThread.Abort()
                    Exit Sub
                Else
                    Try
    
                        comm.Open()
                        counter = 0
                        Try
                            IsConnected = True
                            Dim messages As DecodedShortMessage() = comm.ReadMessages(PhoneMessageStatus.ReceivedUnread, PhoneStorageType.Sim)
                            For Each DecodedShortMessage In messages
                                MsgLocation = DecodedShortMessage.Index
                                counter = counter + 1
                                Try
                                    comm.DeleteMessage(MsgLocation, PhoneStorageType.Sim)
                                Catch ex As Exception
                                    Debug.Print("error deleting from inbox")
                                    Exit Sub
                                Finally
                                    messages = Nothing
                                End Try
                                ShowMessage(DecodedShortMessage.Data)
                            Next
                        Catch ex As Exception
                            Debug.Print("error gettting inbox")
                            Exit Sub
                        End Try
    
                        If counter > 0 Then
                            NewMsg = True
                        End If
    
                    Catch ex As GsmComm.GsmCommunication.CommException
                        IsConnected = False
                        Debug.Print("error:" & ex.InnerException.Message)
    
                        If comm.IsOpen = True Then
                            comm.Close()
                        End If
                      Finally
                        If comm.IsOpen = True Then
                            comm.Close()
                        End If
                    End Try
                End If
            End If
    
            storage = Nothing
            GetManu = Nothing
            MsgLocation = Nothing
            counter = Nothing
            GC.Collect()
            Debug.Print("exiting sub")
        End Sub
    
    end class
    and here is the error i get after it runs for an hour or so:

    A first chance exception of type 'GsmComm.GsmCommunication.CommException' occurred in GSMCommunication.dll
    error:The process cannot access the port 'COM6' because it is being used by another process.

    what could be using the port? i have no other application running that would use it. is it something to do with the thread? do i need to destroy the thread after its run? if so, how?
    thanks
    jason
    I am using Microsoft Visual Basic 2008 Express Edition. I use Access for my data base

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: old problem, revisited

    Have you tried using netstat to determine what process is using that port?

    Does the modem have some sort of a service running on the PC that could be using that port?

    There's PortReporter to, which can help you determine this.

    http://www.microsoft.com/downloads/d...displaylang=en

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Location
    Botswana
    Posts
    107

    Re: old problem, revisited

    i'll give it a try. i dont think its the program on the modem as i have disabled it.
    I am using Microsoft Visual Basic 2008 Express Edition. I use Access for my data base

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Location
    Botswana
    Posts
    107

    Re: old problem, revisited

    you know of anything that will work on vista?
    I am using Microsoft Visual Basic 2008 Express Edition. I use Access for my data base

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Location
    Botswana
    Posts
    107

    Re: old problem, revisited

    nevermind i found something
    I am using Microsoft Visual Basic 2008 Express Edition. I use Access for my data base

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: old problem, revisited

    Do share what you found. Did it solve your problem or point you in the right way?

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Location
    Botswana
    Posts
    107

    Re: old problem, revisited

    i used ok,portmon.exe i found just on google. this is what i got. its alot of info. if it looks crappy let me know and i can email it in an excel file. the problems seems to be in the end. around the second or third to last line is where the program crashes. after the program closes it pops out the last two lines:

    0.00064212 SMSer.exe IRP_MJ_WRITE QCUSB_COM6_3 SUCCESS Length 3: AT.
    0.00002158 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00003080 SMSer.exe IOCTL_SERIAL_WAIT_ON_MASK QCUSB_COM6_3 SUCCESS
    0.30577881 SMSer.exe IOCTL_SERIAL_WAIT_ON_MASK QCUSB_COM6_3 SUCCESS
    0.00001306 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00001285 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00000684 SMSer.exe IRP_MJ_READ QCUSB_COM6_3 SUCCESS Length 6: ..OK..
    0.00002696 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00002368 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00002710 SMSer.exe IOCTL_SERIAL_PURGE QCUSB_COM6_3 SUCCESS Purge: TXABORT TXCLEAR
    0.00001886 SMSer.exe IOCTL_SERIAL_PURGE QCUSB_COM6_3 SUCCESS Purge: RXABORT RXCLEAR
    0.00098078 SMSer.exe IRP_MJ_WRITE QCUSB_COM6_3 SUCCESS Length 13: AT+CPMS="SM".
    0.00002731 SMSer.exe IOCTL_SERIAL_WAIT_ON_MASK QCUSB_COM6_3 SUCCESS
    0.00002046 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00523453 SMSer.exe IOCTL_SERIAL_WAIT_ON_MASK QCUSB_COM6_3 SUCCESS
    0.00002256 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00001187 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00000908 SMSer.exe IRP_MJ_READ QCUSB_COM6_3 SUCCESS Length 31: ..+CPMS: 2,40,2,40,2,40....OK..
    0.00001578 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00001076 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00002535 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00002570 SMSer.exe IOCTL_SERIAL_PURGE QCUSB_COM6_3 SUCCESS Purge: TXABORT TXCLEAR
    0.00001585 SMSer.exe IOCTL_SERIAL_PURGE QCUSB_COM6_3 SUCCESS Purge: RXABORT RXCLEAR
    0.00120162 SMSer.exe IRP_MJ_WRITE QCUSB_COM6_3 SUCCESS Length 10: AT+CMGF=0.
    0.00002389 SMSer.exe IOCTL_SERIAL_WAIT_ON_MASK QCUSB_COM6_3 SUCCESS
    0.00001725 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00001208 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00001802 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00521624 SMSer.exe IOCTL_SERIAL_WAIT_ON_MASK QCUSB_COM6_3 SUCCESS
    0.00000733 SMSer.exe IRP_MJ_READ QCUSB_COM6_3 SUCCESS Length 6: ..OK..
    0.00001453 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00001055 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00002375 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00002018 SMSer.exe IOCTL_SERIAL_PURGE QCUSB_COM6_3 SUCCESS Purge: TXABORT TXCLEAR
    0.00001390 SMSer.exe IOCTL_SERIAL_PURGE QCUSB_COM6_3 SUCCESS Purge: RXABORT RXCLEAR
    0.00109309 SMSer.exe IRP_MJ_WRITE QCUSB_COM6_3 SUCCESS Length 10: AT+CMGL=0.
    0.00002403 SMSer.exe IOCTL_SERIAL_WAIT_ON_MASK QCUSB_COM6_3 SUCCESS
    0.00001746 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    22.78018631 SMSer.exe IOCTL_SERIAL_WAIT_ON_MASK QCUSB_COM6_3 CANCELLED
    0.00001830 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00001124 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.00000754 SMSer.exe IRP_MJ_READ QCUSB_COM6_3 SUCCESS Length 6: ..OK..
    0.00001481 SMSer.exe IOCTL_SERIAL_GET_COMMSTATUS QCUSB_COM6_3 SUCCESS
    0.29966392 SMSer.exe IRP_MJ_READ QCUSB_COM6_3 TIMEOUT Length 0:
    0.00000852 SMSer.exe IRP_MJ_CREATE QCUSB_COM6_3 SHARING VIOLATION Options: Open
    0.00000747 SMSer.exe IRP_MJ_CREATE QCUSB_COM6_3 SHARING VIOLATION Options: Open
    0.00000691 SMSer.exe IRP_MJ_CREATE QCUSB_COM6_3 SHARING VIOLATION Options: Open
    0.00000796 SMSer.exe IRP_MJ_CREATE QCUSB_COM6_3 SHARING VIOLATION Options: Open
    0.00000838 SMSer.exe IRP_MJ_CREATE QCUSB_COM6_3 SHARING VIOLATION Options: Open
    0.00000719 SMSer.exe IRP_MJ_CREATE QCUSB_COM6_3 SHARING VIOLATION Options: Open
    0.00000789 SMSer.exe IRP_MJ_CREATE QCUSB_COM6_3 SHARING VIOLATION Options: Open
    0.01747094 SMSer.exe IRP_MJ_CLEANUP QCUSB_COM6_3 SUCCESS
    0.00687979 SMSer.exe IRP_MJ_CLOSE QCUSB_COM6_3 SUCCESS

    what could be causing the sharing violation? if im reading this right, no other app is trying to use it
    Last edited by dreamdelerium; Jan 21st, 2009 at 04:43 AM.
    I am using Microsoft Visual Basic 2008 Express Edition. I use Access for my data base

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