?? lineterm.vb
字號:
Imports JH.CommBase
Public Class LineTerm
Inherits CommLine
Public Sub SendCommand(ByVal s As String)
Send(s)
End Sub
Public Sub TransactCommand(ByVal s As String)
Dim r As String
r = Transact(s)
Console.WriteLine("RESPONSE: " + r)
Prompt()
End Sub
Public Sub Prompt()
Console.WriteLine("Type string to send and press ENTER. Empty string to close com port.")
End Sub
Protected Overrides Function CommSettings() As CommBaseSettings
Dim cs As New CommLineSettings()
cs.SetStandard("COM1:", 19200, Handshake.none)
cs.rxFilter = New ASCII() {ASCII.LF, ASCII.SOH}
cs.rxTerminator = ASCII.CR
cs.txTerminator = New ASCII() {ASCII.CR}
Setup(cs)
Return cs
End Function
Protected Overrides Sub OnRxLine(ByVal s As String)
Console.WriteLine("RECEIVED: " + s)
Prompt()
End Sub
Protected Overrides Sub OnTxDone()
Console.WriteLine("TRANSMISSION COMPLETE")
Prompt()
End Sub
End Class
Module Module1
Sub Main()
Dim t As New LineTerm()
Dim c As String
Console.WriteLine("Press ENTER to open com port")
Console.ReadLine()
If t.Open() Then
Console.WriteLine("COM PORT OPEN")
t.Prompt()
While True
c = Console.ReadLine().Trim
If c = "" Then Exit While
t.SendCommand(c)
't.TransactCommand(c)
End While
t.Close()
End If
Console.WriteLine("COM PORT CLOSED")
Console.WriteLine("Press ENTER to close program.")
Console.ReadLine()
End Sub
End Module
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -