I bought a sensor that is able to acquire phisiological parameters; it is connected to my pc with bluetooth protocol, so when it is connected a serial port (named for example COM10) is assigned. Now I'm writing a simple routine to read the data in real time:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SewLib;
using System.IO.Ports;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
SewDevice myDevice;
SerialPort comPort;
public Form1()
{
InitializeComponent();
comPort = new SerialPort("COM10");
myDevice = new SewDevice(ref comPort);
myDevice.OnSamplesReceived += new ReceivedSamplesHandler(ReceiveData);
}
private void btstart_Click(object sender, EventArgs e)
{
eErrorClassOpcodes reply = myDevice.StartStreaming();
if (reply == eErrorClassOpcodes.Ok)
{
// ok device is connected and streaming is started
}
}
This works for me, but now I would to have a non static procedure for the selection of com port: my idea is to cycle beetween all the ports that my pc detect and select only the port with the bluetooth adapter.
Have you any ideas?
Thanks
Andrea