C # serial port operations for asynchronous data reception
Source: Internet
Author: User
Using C # to call a traditional 32-bit API for serial port operations, the entire structure is particularly simple. To receive data, you only need to define the data receiving event.
Upload source code I will not, need source code please contact me (dyj057@gmail.com. You can also teach me how to upload source code.
Using System;
Using System. Runtime. InteropServices;
/// <Summary>
/// (C) 2003-2005 C2217 Studio reserves all rights
///
/// File name: IbmsSerialPort. cs
/// File ID:
/// File description:
/// Encapsulate the function of the dynamic link library IbmsSerialPort. dll, which is provided in the. NET environment
/// Functions of receiving and sending data asynchronously through the serial port.
///// Current version: 1.0
///
/// Author: Deng Yangjun
/// Creation date: 2005-2-2
/// Last modification date: 2005-2-2
///
/// Historical modification records:
///
/// </Summary>
Namespace Ibms. Tool. IO
{
/// <Summary>
/// An event is generated when the serial port receives data.
/// SPRecvDataArgs is the parameter of the event. The RecvData parameter contains the received data.
/// Usage:
/// </Summary>
Public class SPRecvDataArgs: EventArgs
{
/// <Summary>
/// A byte array consisting of received data
/// </Summary>
Private byte [] recvData;
/// <Summary>
/// Constructor. A byte [] containing data is required as the initialization parameter to instantiate SPRecvDataArgs.
/// </Summary>
/// <Param name = "recvData"> received data </param>
Public SPRecvDataArgs (byte [] recvData)
{
If (recvData = null)
{
Throw (new ArgumentNullException ());
}
This. recvData = recvData;
}
/// <Summary>
/// Return the received data content
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.