C # ---- Serial Port Data Ysi instance

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.