Home > Back-end >  Delphi COMPORT serial port control, abnormal program exits?
Delphi COMPORT serial port control, abnormal program exits?

Time:09-28

Hello, ask if you are using a USB serial port, after open the serial port in program, used in the program, the USB transit problems or being pulled out, the USB port will null and void, at this time, the exception occurs, how to deal with this?

For writing packets to a serial port, and then waiting for receiving,,,, etc in the process of the USB cable is set aside, then there will be abnormal will pop-up dialog box,,,

2. When on the serial port, USB line is pulled out, and then after the closing procedures, will throw an exception,,,


I want to make program intercepted anomaly; Then prompts that friendly point, see some PC serial port, are all very quiet to deal with such incidents, only show the current string is invalid, write failure, etc.,

CodePudding user response:

Only when the initialization configuration in a general serial port using a serial port, serial port under normal or not, a serial port itself does not provide this kind of event. The hardware serial port on the computer if there is, there is always, pulled out a serial port line, just can't communication, serial port is can open and close.
USB serial port mapping, the hardware itself does not exist, only the USB mapping, can be seen as "soft serial port", converter, pull the serial no.
If you want to real-time detection, stupid point method, is to use a serial port, under test to see if there is a serial port.

CodePudding user response:

Well, use place, is added to the exception handling, but there is no serial port operation, is also open the serial port, estimated logic to change:

The open serial.
Write/read
The close serial.

The read time out
The close serial;
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
So, it is estimated that only happens in the read while you wait for serial data packets, suddenly pulled out, estimates that also can capture? !

The original is:
- changing the serial port: combobox port number, open a serial port, and then write is to write directly,
Like the above the OPEN and CLOSE in pairs? Look back a try,

Thank you for your reply

CodePudding user response:

Comport bugs, hard-drawn connector is shut out, after a few years don't update, also take their own to see the source code to modify,
  • Related