K
Kevin.M.Jonas
I have the following method that handles the data received event:
private void _port_DataReceived(object sender,
SerialDataReceivedEventArgs e)
{
string data = _port.ReadExisting();
_log.LogToFile(data, true);
}
The LogToFile function logs data to a file. The second parameter
indicate if the file should timestamp the message.
On the initial test of this method I got the following result:
[9/19/2008 4:40:04 PM]10??I 1
[9/19/2008 4:40:04 PM] 1909081
[9/19/2008 4:40:04 PM]640?
This is not what I expected. I converting an old VB 6.0 program to
C#. If I add Thread.Sleep(500) before the ReadExisting() I get the
string I was expecting:
[9/19/2008 4:57:47 PM]10??I 1 1909081657?
Notice in the first try it is sending 8 bytes at a time. Is there
anyway to avoid using Thread.Sleep to achieve this?
private void _port_DataReceived(object sender,
SerialDataReceivedEventArgs e)
{
string data = _port.ReadExisting();
_log.LogToFile(data, true);
}
The LogToFile function logs data to a file. The second parameter
indicate if the file should timestamp the message.
On the initial test of this method I got the following result:
[9/19/2008 4:40:04 PM]10??I 1
[9/19/2008 4:40:04 PM] 1909081
[9/19/2008 4:40:04 PM]640?
This is not what I expected. I converting an old VB 6.0 program to
C#. If I add Thread.Sleep(500) before the ReadExisting() I get the
string I was expecting:
[9/19/2008 4:57:47 PM]10??I 1 1909081657?
Notice in the first try it is sending 8 bytes at a time. Is there
anyway to avoid using Thread.Sleep to achieve this?