For example, the time of this article is.
Because the actual device uses the network transmission to the virtual serial port mode, problems still occur after on-site installation.
I finally figured it out from.
// Open a new serial port connection sp. open (); // discard the data sp from the accept buffer of the serial driver. discardinbuffer (); // discard the data sp from the transmission buffer of the serial driver. discardoutbuffer (); // write a specified number of bytes to the serial port sp. write (WBB, 0, WBB. length); // The current thread is suspended for 500 ms system. threading. thread. sleep (20000); // read data timeout sp. readtimeout = 10000; // read the received data sp. read (RDB, 0, RDB. length); // convert the read record to string [] rdstr = new string [RDB. length];
This thread suspends the operation and is never used as a decoration ....
If it takes time to transmit data, you must extend the suspension time.