L
Leif Eirik Olsen
Hi,
VS2008, .net3.5
I have this simple test application running on my iPaq to test reading
serial data from a bluetooth device.
My bluetooth device sends about 7 bytes pr 22ms continously. The bluetooth
device is some in-house electronics, and it should be ok as it has been used
and tested for several years
After every Serialport.Open() it takes about 10s !!!! before the first
SerialPort_DataReceived event is fired. The first time the event is fired, I
*always* get 1694 bytes?? After this the event is fired like expected: about
1 time for every 7 bytes (ex. @0A3C + CRLF)
Can anyone advice on how to prevent, or at least reduce, the 10 sec delay
before the first SerialPort_DataReceived ???
My simple test program uses one SerialPort class with settings :BaudRate
9600, DataBits 8, Handshake None, Parity None, StopBits One, ReadBufferSize
4096
string InData;
public Form1()
{
InitializeComponent();
}
private void pbOpen_Click(object sender, EventArgs e)
{
serialPort1.PortName = "COM6";
serialPort1.Open();
}
private void pbClose_Click(object sender, EventArgs e)
{
serialPort1.Close();
}
public delegate void InvokeDelegate();
public void InvokeMethod()
{
int aLen = InData.Length;
listBox1.Items.Add(aLen.ToString() + " : " + InData);
}
private void serialPort1_DataReceived(object sender,
System.IO.Ports.SerialDataReceivedEventArgs e)
{
InData = serialPort1.ReadExisting();
listBox1.BeginInvoke(new InvokeDelegate(InvokeMethod));
}
private void button1_Click(object sender, EventArgs e)
{
serialPort1.WriteLine(textBox1.Text);
}
private void Form1_Closing(object sender, CancelEventArgs e)
{
if (serialPort1.IsOpen)
serialPort1.Close();
}
Thanks in advance,
Leo
VS2008, .net3.5
I have this simple test application running on my iPaq to test reading
serial data from a bluetooth device.
My bluetooth device sends about 7 bytes pr 22ms continously. The bluetooth
device is some in-house electronics, and it should be ok as it has been used
and tested for several years
After every Serialport.Open() it takes about 10s !!!! before the first
SerialPort_DataReceived event is fired. The first time the event is fired, I
*always* get 1694 bytes?? After this the event is fired like expected: about
1 time for every 7 bytes (ex. @0A3C + CRLF)
Can anyone advice on how to prevent, or at least reduce, the 10 sec delay
before the first SerialPort_DataReceived ???
My simple test program uses one SerialPort class with settings :BaudRate
9600, DataBits 8, Handshake None, Parity None, StopBits One, ReadBufferSize
4096
string InData;
public Form1()
{
InitializeComponent();
}
private void pbOpen_Click(object sender, EventArgs e)
{
serialPort1.PortName = "COM6";
serialPort1.Open();
}
private void pbClose_Click(object sender, EventArgs e)
{
serialPort1.Close();
}
public delegate void InvokeDelegate();
public void InvokeMethod()
{
int aLen = InData.Length;
listBox1.Items.Add(aLen.ToString() + " : " + InData);
}
private void serialPort1_DataReceived(object sender,
System.IO.Ports.SerialDataReceivedEventArgs e)
{
InData = serialPort1.ReadExisting();
listBox1.BeginInvoke(new InvokeDelegate(InvokeMethod));
}
private void button1_Click(object sender, EventArgs e)
{
serialPort1.WriteLine(textBox1.Text);
}
private void Form1_Closing(object sender, CancelEventArgs e)
{
if (serialPort1.IsOpen)
serialPort1.Close();
}
Thanks in advance,
Leo