The data received in my C # application is lost due to the fact that the collector array is rewritten rather than added.
char[] pUartData_c;
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
pUartData_c = serialPort1.ReadExisting().ToCharArray();
bUartDataReady_c = true;
}
catch ( System.Exception ex )
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
This example pUartData_coverwrites each time new data is received. On some systems, this is not a problem because the data arrives quickly enough. However, on other systems, the data in the receive buffer is not complete. How to add received data to pUartData_c, rather than overwrite it. I am using Microsoft Visual C # 2008 Express Edition. Thank.
source
share