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

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!!!
Who is Participating?
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
ipdickyAuthor Commented:
Thank you very much!!! I try it and the reseult is positive.
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.

All Courses

From novice to tech pro — start learning today.