End Google Ads 201810 - BS.net 01 -->
Hi - I am trying to send a simple string over an established Bluetooth connection using serial port. The probelm here is I don't know if what I am doing is correct as neither application are throwing any exceptions. Here is the code for the remote application
private void btnConnect_Click(object sender, EventArgs e)
{
try
{
SerialPort inPort = new SerialPort("COM2", 9600);
inPort.Open();
string message = "Hello";
inPort.Write(message);
inPort.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
On the other end I have used an event handler:
private void DataReceviedHandler(object sender, SerialDataReceivedEventArgs e)
{
try
{
SerialPort inPort = new SerialPort("COM7", 9600);
inPort.Open();
string mess = inPort.ReadLine();
MessageBox.Show("This worked...");
inPort.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
When I click on the button on the external application nothing happens? Any ideas????
مواقع النشر (المفضلة)