Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I must have done a work around in the past but I can't remember how I did it!
I have a program that talks to a bit of hardware via a virtual serial port. The item needs to zero before sense can be read from it. It dies not always zero so power cycling the 'thing' is about the only way. In power cycling the virtual serial port disappears. This then causes issues with the program, which can be got around by closing the COM port and reopening the COM port. What I am trying to is to send the command 'P'+\r+\n wait for the reply and close the port.
Bang Cross threading issue...
How did I get around this before??

What I have tried:

C#
private void port_DataReceived_1(object sender,SerialDataReceivedEventArgs e)
{
   InputData = myComPort.ReadExisting();
   // MessageBox.Show(InputData);
   //rtbIncoming.Text = InputData;
   //rtbIncoming.SelectionStart = rtbIncoming.Text.Length;
   //rtbIncoming.ScrollToCaret();
  if (InputData != String.Empty)
  {
      this.BeginInvoke(new SetTextCallback(SetText), new object[]{ InputData});
  }
    //added 05/12/2023
    /* MessageBox.Show("here!");*/
     btnOpen_Click(null, null);   //causes a bang!
}
Posted
Comments
Andre Oosthuizen 5-Dec-23 14:15pm    
"How did I get around this before?", that is a good question.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900