わかった!マイクロコントローラーが 0 から 1023 までの ADC 値を送信するプログレス バーに受信データを表示する 1 つのアプリケーションを作成したいのですが、これを作成する方法がわかりません。シリアル ポート ターミナルを作成しました。
パブリック クラス Form1
RSPort をアレイとして暗くする
Delegate Sub SetTextCallback(ByVal [text] As String)
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) MyBase.Load を処理します
RSPort = IO.Ports.SerialPort.GetPortNames()
LBaud.SelectedIndex = 1
i = 0 の場合、UBound(RSPort) へ
LPort.Items.Add(RSPort(i))
次
LPort.Text = LPort.Items.Item(0)
bDisconnect.Enabled = False
サブ終了
Private Sub bConnect_Click (ByVal sender As Object, ByVal e As EventArgs) bConnect.Click を処理します
SerialPort1.PortName = LPort.Text
SerialPort1.BaudRate = LBaud.Text
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.StopBits = IO.Ports.StopBits.One
SerialPort1.DataBits = 8
SerialPort1.Open()
bConnect.Enabled = False
bDisconnect.Enabled = True
サブ終了
Private Sub bDisconnect_Click (ByVal sender As Object, ByVal e As EventArgs) bDisconnect.Click を処理します
SerialPort1.Close()
bConnect.Enabled = True
bDisconnect.Enabled = False
サブ終了
Private Sub SerialPort1_DataReceived (オブジェクトとしての ByVal 送信者、System.IO.Ports.SerialDataReceivedEventArgs としての ByVal e) SerialPort1.DataReceived を処理します
ReceivedText(SerialPort1.ReadExisting())
サブ終了
Private Sub ReceivedText(ByVal [テキスト] As String)
If rtbReceived.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Invoke(x, New Object() {(テキスト)})
そうしないと
rtbReceived.Text &= [テキスト]
終了条件
サブ終了
Private Sub LBaud_SelectedIndexChanged (sender As Object, e As EventArgs) LBaud.SelectedIndexChanged を処理します
SerialPort1.IsOpen = False の場合
SerialPort1.BaudRate = LBaud.Text
そうしないと
MsgBox("ポートが閉じている場合のみ", vbCritical)
終了条件
サブ終了
Private Sub LPort_SelectedIndexChanged (sender As Object, e As EventArgs) LPort.SelectedIndexChanged を処理します
SerialPort1.IsOpen = False の場合
SerialPort1.PortName = LPort.Text
そうしないと
MsgBox("ポートが閉じている場合のみ", vbCritical)
終了条件
サブ終了
クラス終了
データウィッチを表示するには、この「1023101509410888085208510828075706520558048704290374」と同じように見えます。これを進行状況バーに表示したいのですが、すべての番号が1つずつ受信されます...英語で申し訳ありません私はルーマニア人です...