title: Baud Rate changing Break Command in vb.net
body: <p>I am using AirCable Serial5 Bluetooth adapter for RS232 to Bluetooth transfer. I need to change Baudrate from lower 9600 to 115200. I talked with AirCable supplier and he said that, for that I have to send Baud changing Break command(0x85) to serial COM port. I don't know how to send break command with baud changing HEX code in VB.NET</p>
  
  <pre><code>Imports System
  Imports System.IO.Ports
  Imports System.Text
  Imports System.Threading
  
  Public Class Form1
      Private Sp As New SerialPort
      Private comBuffer As Byte()
      Private Delegate Sub UpdateFormDelegate()    
      Private UpdateFormDelegate1 As UpdateFormDelegate    
      Dim m As Integer    
  
      Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load    
          With Sp    
              .PortName = "COM8"    
              .BaudRate = 9600    
              .DataBits = 8    
              .Parity = Parity.None    
              .StopBits = StopBits.One    
              .Handshake = Handshake.None    
  
          End With    
          Try    
              Sp.Open()    
          Catch ex As Exception    
              MessageBox.Show(ex.Message)    
          End Try    
  
          AddHandler Sp.DataReceived, AddressOf Sp_DataReceived    
  
          Sp.Write("s r0x90 115200" + vbCr)    
          Thread.Sleep(100)    
  
      End Sub    
  
      Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing    
          Sp.Write("s r0x90 9600" + vbCr)    
          Thread.Sleep(100)    
      End Sub    
  
      Private Sub getBD_Click(sender As System.Object, e As System.EventArgs) Handles getBD.Click    
          Sp.Write("g r0x90" + vbCr)    
          Thread.Sleep(100)    
  
      End Sub
  
      Private Sub Sp_DataReceived(ByVal Sender As Object, ByVal e As SerialDataReceivedEventArgs)    
  
          'Handles serial port data received events     
          UpdateFormDelegate1 = New UpdateFormDelegate(AddressOf UpdateDisplay)    
          Dim n As Integer = Sp.BytesToRead 'find number of bytes in buffer    
          m = n    
          comBuffer = New Byte(n - 1) {} 're dimension storage buffer     
          Sp.Read(comBuffer, 0, n) 'read data from the buffer     
  
          Me.Invoke(UpdateFormDelegate1) 'call the delegate     
      End Sub    
  
      Private Sub UpdateDisplay()     
          ' updates label text    
  
          'Label1.Text = ""    
          Dim b As Integer = 0    
  
          Do Until b = m    
  
              Dim array() As Byte = {CStr(comBuffer(b))}    
              Dim value As String = System.Text.ASCIIEncoding.ASCII.GetString(array)    
              Label1.Text += value    
              b += 1    
          Loop    
      End Sub     
  
      Private Sub snd_Click(sender As System.Object, e As System.EventArgs) Handles snd.Click    
          Dim x As String    
          x = cmdBox.Text    
          Sp.Write(x + vbCr)    
          Thread.Sleep(100)    
      End Sub    
  
  End Class    
  </code></pre>
  
  <p>Please let me know if you have any questions.</p>