2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by zortec
0
'Declare Rs232 class variables
Private m_CommPort  As New Rs232 
 
'Set default values for the public properties
m_CommPort. Open(m_ModemPort, 115200, 8, Rs232.DataParity.Parity_None, Rs232.DataStopBit.StopBit_1, 4096)

' Write an AT Command to the Port
m_CommPort.Write(Encoding.ASCII.GetBytes("AT" & Chr(13)))

' Sleep long enough for the modem to respond and timer to fire
System.Threading.Thread.Sleep(200)

'  Free CPU usage with DoEvents()
Application.DoEvents()

' Close Comm Port
m_CommPort.Close()
Private Sub tmrReadCommPort_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrReadCommPort.Tick
   Try    ' As long as there is information, read one byte at a time and output it.
     While (m_CommPort. Read(1) <> -1)
     ' Write the output to the screen.
       WriteMessage(Chr(m_CommPort.InputStream(0)), False)
     End While
      Catch exc As Exception
      ' An exception is raised when there is no information to read.
      ' Don't do anything here, just let the exception go.
   End Try
End Sub

Edited by zortec: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.