Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to trigger Serial port data recieved event with bluetooth c#
    text
    copied!<p>I have device that can connect to my laptop via blue-tooth as COM5. The device has a Pulse sensor. I want to draw data coming from sensor to graph. However when i connected to COM5 the serialport_Datarecieved event is not triggered. I tried device using matlab. It takes and draws data but i cant get data in c#. I checked the connection status of device and it is ok. I tried to change DtrEnabled and RtsEnapled properties but not worked.</p> <pre><code> private void Form1_Load(object sender, EventArgs e) { cmbPortList.Items.AddRange(SerialPort.GetPortNames()); cmbPortList.Sorted = true; cmbPortList.SelectedIndex = 0; this.serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(serialPort1_DataReceived); } private void btnOpenPort_Click(object sender, EventArgs e) { try { serialPort1.PortName = cmbPortList.Text; serialPort1.BaudRate = 9600; serialPort1.DataBits = 8; serialPort1.ReadTimeout = 500; serialPort1.WriteTimeout = 500; serialPort1.Handshake = Handshake.None; if (!serialPort1.IsOpen) { btnRun.Enabled = true; serialPort1.Open(); } } catch (Exception ex) { serialPort1.Close(); } } private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) { while (serialPort1.BytesToRead &gt; 0) { Thread.Sleep(50); byte[] buffer = new byte[serialPort1.BytesToRead]; serialPort1.Read(buffer, 0, buffer.Length); } } </code></pre> <p>I cant read any data in buffer. There is led is flashing while device is not connected with via blue-tooth. So i am absolutely sure i connected to device. Is problem about Bluetooth or code? Should i use another library to communicate blue tooth device? I have read links below. <a href="https://stackoverflow.com/questions/13876274/serialport-fires-datareceived-event-after-close">SerialPort fires DataReceived event after close</a> <a href="https://stackoverflow.com/questions/8907490/serialport-datareceived-event-does-not-fire">SerialPort not receiving any data</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload