locked
Sending Message from PC to mobile using GSM modem RRS feed

  • Question

  • User83884090 posted

    Hi,

    I am doing the coding for send SMS from PC to Mobile Using GSM Modem in ASP.Net Framework 3.
    I am having SAMBA GSM modem and i am using the following code that is working fine.
       This coding is working fine in first time only. If i click the same button again that will through the following error "A device attached to the system is not functioning" If i restart the system that working fine for first time. I think some objects are referred inside please any body help to solve this problem.

     

    *****Coding Starting***************************************************

        Protected Sub BtnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSend.Click
            Dim atcCommand As String
            Dim sphnPhoneNo As String
            Dim cescQuote As Char
            Dim s As String
            Dim objGsmModem As New System.IO.Ports.SerialPort("COM3")
            With objGsmModem
                .PortName = "COM3"
                .BaudRate = "9600"
                .StopBits = IO.Ports.StopBits.One
                .DataBits = 8
                .Parity = IO.Ports.Parity.None
                '.ReadBufferSize = 10000
                .ReadTimeout = 1000
                '.WriteBufferSize = 10000
                .WriteTimeout = 1000
                .Handshake = Handshake.RequestToSend
                .RtsEnable = True
                .DtrEnable = True
                .Open()
                'for reading sms
                'atcCommand = "AT+CMGR=8"        'to read from inbox
                '.Write(atcCommand + vbCrLf)     'execute command on buffer
                'TextBox1.Text = .ReadExisting()

                'for writing sms

                s = .ReadExisting()
                .Write("AT+CMGF=1" + vbCrLf)
                s = .ReadExisting()

                cescQuote = Char.ConvertFromUtf32(34)
                sphnPhoneNo = "+919840496050"
                atcCommand = "AT+CMGS=" + cescQuote + sphnPhoneNo + cescQuote + vbCrLf + "WORLD" + Char.ConvertFromUtf32(26)
                '  .Write(atcCommand + vbCrLf)
                .WriteLine(atcCommand + vbCrLf)
                s = .ReadExisting()
                .WriteLine("Thank God From App SRN" + Chr(26))
                TextBox1.Text = .ReadExisting()

                .DiscardOutBuffer()
                .DiscardInBuffer()
                .Close()
                .Dispose()
            End With

        End Sub

    *********Coding End ********************************************************

    Monday, June 18, 2007 8:15 AM

All replies

  • User113421904 posted

    Hi,

    Could you paste the stack trace?

    Seems you can not even connect to your modem. I think you can use HyperTerminal to verify if it is able to connect to your modem.

    Wednesday, June 20, 2007 8:27 AM