How to use VB.Net 2005 to send SMS via serial connect to GSM modem

Posted on 2006-05-13
Last Modified: 2007-12-19
Here is my code
Private WithEvents port As SerialPort

Public Sub New()
    port = New SerialPort("COM1")

    port.Parity = Parity.None
    port.StopBits = StopBits.One
    port.DataBits = 8
    port.Handshake = Handshake.None
        ' Open the serial port
    Catch ex As Exception
        RaiseEvent SMSError(SMSStatus.PortOpenError)
    End Try
End Sub

Public Sub Send(ByVal toTel as String, ByVal msg As String)
    SendString("AT+CMGS=""" + toTel + """" + vbCrLf)
    SendString(msg + Chr(26) + Chr(90))
End Sub

Private Sub SendString(ByVal str As String)
    Catch ex As System.Exception
        RaiseEvent SMSError(SMSStatus.SMSSendError)
    End Try
End Sub

Private Sub port_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles port.DataReceived
    Dim recString As String = port.ReadLine()
    Debug.WriteLine("rec: " + recString)
End Sub

I have two questioins:
1) I try to use a null modem cable and hyper terminal to test the output of my program, I get the output has a different from hyper terminal to hyper terminal config (type the AT command from one hyper terminal and receive from another hyper terminal).  At hyper terminal to hyper terminal config, the Ctrl-Z is show a arrow only, but the output of my program is a arrow followed by a "Z" char.  How to send a correct Ctrl-Z out?

2) The DataReceived event n trigger even I try to type something at hyper terminal that at the other end of null modem cable

Thanks in advance!!!
Question by:ipdicky
    LVL 69

    Accepted Solution


    Author Comment

    Thank you very much!!! I try it and the reseult is positive.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now