I have a problem with a simple application reading a GPS NMEA 2.0 device through the serial port. On the idle event, my delegate function is invoked and reads the serial port, parses the GPS data (no looping in the parsing fucntion) and undates some text fields as well as a compass control. All is well when I randomly generate the GPS text data. In other words, there is a constant and consistant updating of the windows form, with no user interactions. However, when ever, I use the command ReadLine(), the program does not update the windows form, unless I create a mouse event over the form, like move mouse, right click, ect... (any will do). I did some breakpoint checking, and it appears as though the message pump has suspended, unless it receieves a message, which should not happen. If all I do is comment out the ReadLine() function, everything works peachy. BTW, when communicating with the GPS device, the parsing works fine, and there are no comm port exceptions (have a delegate for that, which is utilized by ).
gpsPort.ErrorReceived +=
gcnew System::IO::Ports::SerialErrorReceivedEventHandler(this,&Form1::gpsError);
System::IO::Ports::SerialPort::ReadLine() polling problem
kawing0510
msFlash
To avoid this, use the DataReceived event to read the modem's response or use the ReadTimeout property. Or make sure your communications are debugged so the modem always sends a response that includes the NewLine character so you'll never block too long.
Idanle
I use the idle event and the System::EventtHandler. Seems to work well for most applications so far (except this one)
System::Windows::Forms::Application::Idle +=
gcnew System::EventHandler(this,&Form1::getGpsData);Is this a problem
The delegate function getGpsData directly updates the form controls.
I can try using the DataReceived event and Control.Invoke (delegate).
Karthik Juneni
Seeing the Application.Run() call highlighted in green when you pause the program is normal, it indicates that your app is pumping messages as it should and is not hung in ReadLine() or one of your event handlers. What event do you use to execute the code that calls ReadLine()
digitalsuperman