Setupcomm and PurgeComm function of serial port

Source: Internet
Author: User

Setupcomm This function initializes the communication parameters for a specified communication device. BOOL Setupcomm (HANDLE hfile,dword dwinqueue,dword dwoutqueue), parameter Hfile[in] communication device handle. The CreateFile function returns this handle. Dwinqueue[in] Specifies the recommended size, in bytes, of the internal input buffer to the device. Dwoutqueue[in] Specifies the recommended size, in bytes, of the internal output buffer to the device. return value

Non-zero indicates success. Zero indicates failure. To get more error information, call the GetLastError function


PurgeComm () function--empty buffer This function prototype: BOOL PurgeComm (HANDLE hfile,dword dwFlags) HANDLE hfile//serial handle DWORD dwFlags// Action parameters to be completed dwflags specifies the action to be completed, which can be a combination of the following values: Purge_txabort terminates all in-progress character output operations, completes an overlapped I/O operation that is in the waiting state, and generates an event indicating that the write operation was completed Purge_ Rxabort terminates all ongoing character input operations, completes an in-progress overlapped I/O operation, and has an appropriately set event purge_txclear This command directs the device driver to clear the output buffer, often with purge_txabort Command flags used together with Purge_rxclear This command is used by the device driver to clear the input buffer and is often used with the Purge_rxabort command flag

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Setupcomm and PurgeComm function of serial port

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.