c串口助手源碼
㈠ 求C++ C語言大神幫忙弄一個串口通信的代碼
這是我以前寫的一個串口通訊文件,全部貼出來了,希望對你有幫助,包括設置,發送,接受數據,你可以好好看看,祝你成功
// 串口Dlg.cpp : 實現文件
//
#include "stdafx.h"
#include "串口.h"
#include "串口Dlg.h"
#include "afxdialogex.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 用於應用程序「關於」菜單項的 CAboutDlg 對話框
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg();
// 對話框數據
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 實現
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// C串口Dlg 對話框
C串口Dlg::C串口Dlg(CWnd* pParent /*=NULL*/)
: CDialogEx(C串口Dlg::IDD, pParent)
, m_Selection(0)
, m_recv(_T(""))
, m_send(_T(""))
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void C串口Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_MSCOMM1, m_CMscomm);
DDX_Control(pDX, IDC_COMBO2, m_CComboBox);
DDX_Text(pDX, IDC_RECV, m_recv);
DDX_Text(pDX, IDC_SEND, m_send);
}
BEGIN_MESSAGE_MAP(C串口Dlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, &C串口Dlg::OnBnClickedButton1)
ON_CBN_SELCHANGE(IDC_COMBO2, &C串口Dlg::OnSelchangeCombo2)
ON_WM_LBUTTONDBLCLK()
ON_BN_CLICKED(IDC_BUTTON2, &C串口Dlg::OnBnClickedButton2)
ON_WM_DRAWITEM()
END_MESSAGE_MAP()
// C串口Dlg 消息處理程序
BOOL C串口Dlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// 將「關於...」菜單項添加到系統菜單中。
// IDM_ABOUTBOX 必須在系統命令范圍內。
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 設置此對話框的圖標。當應用程序主窗口不是對話框時,框架將自動
// 執行此操作
SetIcon(m_hIcon, TRUE); // 設置大圖標
SetIcon(m_hIcon, FALSE); // 設置小圖標
// TODO: 在此添加額外的初始化代碼
m_CMscomm.put_CommPort(2);
if(m_CMscomm.get_PortOpen())
m_CMscomm.put_PortOpen(0);//解除佔用
m_CMscomm.put_PortOpen(1);//打開串口
static CString str("9600,n,8,1");
m_CMscomm.get_Input();
m_CMscomm.put_RThreshold(1);
m_CMscomm.put_Settings(str);
static char ch[10];
CString str1("com");
for(int i=1;i<10;i++)
{
itoa(i,ch,10);
m_CComboBox.AddString(str1+ch);
}
m_CComboBox.SetCurSel(0);
return TRUE; // 除非將焦點設置到控制項,否則返回 TRUE
}
void C串口Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialogEx::OnSysCommand(nID, lParam);
}
}
// 如果向對話框添加最小化按鈕,則需要下面的代碼
// 來繪制該圖標。對於使用文檔/視圖模型的 MFC 應用程序,
// 這將由框架自動完成。
void C串口Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 用於繪制的設備上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 使圖標在工作區矩形中居中
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 繪制圖標
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialogEx::OnPaint();
}
CWindowDC dc(this);
CFont font; //設置字體
CBrush brush;
brush.CreateSolidBrush(255);
font.CreatePointFont(150,_T("華文行楷"));
dc.SelectObject(&font);
dc.SelectObject(&brush);
//dc.TextOut(250,300,_T("大族激光軟體中心"));
}
//當用戶拖動最小化窗口時系統調用此函數取得游標
//顯示。
HCURSOR C串口Dlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void C串口Dlg::OnBnClickedButton1()
{
static char ch1[10];
CString str("");
if(m_CMscomm.get_PortOpen())
m_CMscomm.put_PortOpen(false);
m_CMscomm.put_CommPort(m_Selection+1);
m_CMscomm.put_PortOpen(m_Selection+1);
str.Format("打開串口%d成功",m_Selection+1);
if(m_CMscomm.get_PortOpen())
{
MessageBox(str);
}
else
{
MessageBox("不能打串口");
}
//MessageBox(ch1);
// TODO: 在此添加控制項通知處理程序代碼
}
void C串口Dlg::OnSelchangeCombo2()
{
// TODO: 在此添加控制項通知處理程序代碼
//int m_Selection;
m_Selection=m_CComboBox.GetCurSel();
}
void C串口Dlg::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息處理程序代碼和/或調用默認值
/*short m_short=m_CMscomm.get_CommPort();
CString str;
str.Format(_T("當前打開埠:%d"),m_short+1);
MessageBox(str);
CDialogEx::OnLButtonDblClk(nFlags, point);*/
}
BEGIN_EVENTSINK_MAP(C串口Dlg, CDialogEx)
ON_EVENT(C串口Dlg, IDC_MSCOMM1, 1, C串口Dlg::OnCommMscomm1, VTS_NONE)
END_EVENTSINK_MAP()
void C串口Dlg::OnCommMscomm1()
{
VARIANT variant_inp;
COleSafeArray safearray_inp;
LONG len,k;
BYTE rxdata[2048]; //設置BYTE數組 An 8-bit integerthat is not signed.
CString strtemp; if(m_CMscomm.get_CommEvent()==2) //事件值為2表示接收緩沖區內有字元
{ ////////以下你可以根據自己的通信協議加入處理代碼
variant_inp=m_CMscomm.get_Input(); //讀緩沖區
safearray_inp=variant_inp; //VARIANT型變數轉換為ColeSafeArray型變數
len=safearray_inp.GetOneDimSize(); //得到有效數據長度
for(k=0;k<len;k++) safearray_inp.GetElement(&k,rxdata+k);//轉換為BYTE型數組
for(k=0;k<len;k++) //將數組轉換為Cstring型變數
{ BYTE bt=*(char*)(rxdata+k); //字元型
strtemp.Format("%c",bt); //將字元送入臨時變數strtemp存放
m_send+=strtemp; //加入接收編輯框對應字元串
}
}
UpdateData(FALSE);
}
void C串口Dlg::OnBnClickedButton2()
{
UpdateData();
m_CMscomm.put_Output((COleVariant) m_send);
SetWindowLong(m_hWnd,GWL_EXSTYLE,GetWindowLong(m_hWnd,GWL_EXSTYLE) | WS_EX_ACCEPTFILES);
}
void C串口Dlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: 在此添加消息處理程序代碼和/或調用默認值
MessageBox("sfsfe");
CDialogEx::OnDrawItem(nIDCtl, lpDrawItemStruct);
}
㈡ 求一個C語言編程的簡單串口接收數據程序,能讓我參考一下
你好!!
給你一個完整的串口通訊常式,已經調試通過的!
㈢ 各位大俠幫忙:求串口調試源碼,最好是C或VB的
是用VB調試精靈的源代碼改過來的,以16進制方式顯示發送:
Option Explicit
Dim intTime As Integer
Private strSendText As String '發送文本數據
Private bytSendByte() As Byte '發送二進制數據
Private blnReceiveFlag As Boolean
Private blnAutoSendFlag As Boolean
Private intPort As Integer
Private strSet As String
Private intReceiveLen As Integer
Private bytReceiveByte() As Byte
Private strAscii As String '設置初值
Private strHex As String
Private intHexWidth As Integer
Private intLine As Integer
Private m As Integer
Private strAddress As String
'字元表示的十六進制數轉化為相應的整數,錯誤則返回 -1
Function ConvertHexChr(str As String) As Integer
Dim test As Integer
test = Asc(str)
If test >= Asc("0") And test <= Asc("9") Then
test = test - Asc("0")
ElseIf test >= Asc("a") And test <= Asc("f") Then
test = test - Asc("a") + 10
ElseIf test >= Asc("A") And test <= Asc("F") Then
test = test - Asc("A") + 10
Else
test = -1 '出錯信息
End If
ConvertHexChr = test
End Function
'字元串表示的十六進制數據轉化為相應的位元組串,返回轉化後的位元組數
Function strHexToByteArray(strText As String, bytByte() As Byte) As Integer
Dim HexData As Integer '十六進制(二進制)數據位元組對應值
Dim hstr As String * 1 '高位字元
Dim lstr As String * 1 '低位字元
Dim HighHexData As Integer '高位數值
Dim LowHexData As Integer '低位數值
Dim HexDataLen As Integer '位元組數
Dim StringLen As Integer '字元串長度
Dim Account As Integer
Dim n As Integer
'計數
'txtSend = "" '設初值
HexDataLen = 0
strHexToByteArray = 0
StringLen = Len(strText)
Account = StringLen \ 2
ReDim bytByte(Account)
For n = 1 To StringLen
Do '清除空格
hstr = Mid(strText, n, 1)
n = n + 1
If (n - 1) > StringLen Then
HexDataLen = HexDataLen - 1
Exit For
End If
Loop While hstr = " "
Do
lstr = Mid(strText, n, 1)
n = n + 1
If (n - 1) > StringLen Then
HexDataLen = HexDataLen - 1
Exit For
End If
Loop While lstr = " "
n = n - 1
If n > StringLen Then
HexDataLen = HexDataLen - 1
Exit For
End If
HighHexData = ConvertHexChr(hstr)
LowHexData = ConvertHexChr(lstr)
If HighHexData = -1 Or LowHexData = -1 Then '遇到非法字元中斷轉化
HexDataLen = HexDataLen - 1
Exit For
Else
HexData = HighHexData * 16 + LowHexData
bytByte(HexDataLen) = HexData
HexDataLen = HexDataLen + 1
End If
Next n
If HexDataLen > 0 Then '修正最後一次循環改變的數值
HexDataLen = HexDataLen - 1
ReDim Preserve bytByte(HexDataLen)
Else
ReDim Preserve bytByte(0)
End If
If StringLen = 0 Then '如果是空串,則不會進入循環體
strHexToByteArray = 0
Else
strHexToByteArray = HexDataLen + 1
End If
End Function
Private Sub cmdManualSend_Click()
If Not Me.MSComm.PortOpen Then
Me.MSComm.CommPort = intPort
Me.MSComm.Settings = strSet
Me.MSComm.PortOpen = True
End If
Call ctrTimer_Timer
If Not blnAutoSendFlag Then
Me.MSComm.PortOpen = False
End If
End Sub
Private Sub cmdAutoSend_Click()
If blnAutoSendFlag Then
Me.ctrTimer.Enabled = False
If Not blnReceiveFlag Then
Me.MSComm.PortOpen = False
End If
Me.cmdAutoSend.Caption = "自動發送"
Else
If Not Me.MSComm.PortOpen Then
Me.MSComm.CommPort = intPort
Me.MSComm.Settings = strSet
Me.MSComm.PortOpen = True
End If
Me.ctrTimer.Interval = intTime
Me.ctrTimer.Enabled = True
Me.cmdAutoSend.Caption = "停止發送"
End If
blnAutoSendFlag = Not blnAutoSendFlag
End Sub
Private Sub ctrTimer_Timer()
Dim longth As Integer
strSendText = Me.txtSend.Text
longth = strHexToByteArray(strSendText, bytSendByte())
If longth > 0 Then
Me.MSComm.Output = bytSendByte
End If
End Sub
'輸入處理,處理接收到的位元組流,並保存在全局變數
Private Sub InputManage(bytInput() As Byte, intInputLenth As Integer)
Dim n As Integer '定義變數及初始化
ReDim Preserve bytReceiveByte(intReceiveLen + intInputLenth)
For n = 1 To intInputLenth Step 1
bytReceiveByte(intReceiveLen + n - 1) = bytInput(n - 1)
Next n
intReceiveLen = intReceiveLen + intInputLenth
End Sub
'為輸出准備文本,保存在全局變數
'總行數保存在intLine
Public Sub GetDisplayText()
Dim n As Integer
Dim intValue As Integer
Dim intHighHex As Integer
Dim intLowHex As Integer
Dim strSingleChr As String * 1
Dim intAddress As Integer
Dim intAddressArray(8) As Integer
Dim intHighAddress As Integer
strAscii = "" '設置初值
strHex = ""
strAddress = ""
'獲得16進制碼和ASCII碼的字元串
For n = 1 To intReceiveLen
intValue = bytReceiveByte(n - 1)
If intValue < 32 Or intValue > 128 Then '處理非法字元
strSingleChr = Chr(46) '對於不能顯示的ASCII碼,
Else '用"."表示
strSingleChr = Chr(intValue)
End If
strAscii = strAscii + strSingleChr
intHighHex = intValue \ 16
intLowHex = intValue - intHighHex * 16
If intHighHex < 10 Then
intHighHex = intHighHex + 48
Else
intHighHex = intHighHex + 55
End If
If intLowHex < 10 Then
intLowHex = intLowHex + 48
Else
intLowHex = intLowHex + 55
End If
strHex = strHex + Chr$(intHighHex) + Chr$(intLowHex) + " "
If (n Mod intHexWidth) = 0 Then
strAscii = strAscii + Chr$(13) + Chr$(10)
strHex = strHex + Chr$(13) + Chr$(10)
Else
End If
Next n
txtAsc = strAscii 'Ascii
txtHex = strHex '16進制
'獲得地址字元串
intLine = intReceiveLen \ intHexWidth
If (intReceiveLen - intHexWidth * intLine) > 0 Then
intLine = intLine + 1
End If
'設置換行
For n = 1 To intLine
intAddress = (n - 1) * intHexWidth
intHighAddress = 8
intAddressArray(0) = intAddress
For m = 1 To intHighAddress
intAddressArray(m) = intAddressArray(m - 1) \ 16
Next m
For m = 1 To intHighAddress
intAddressArray(m - 1) = intAddressArray(m - 1) - intAddressArray(m) * 16
Next m
For m = 1 To intHighAddress
If intAddressArray(intHighAddress - m) < 10 Then
intAddressArray(intHighAddress - m) = intAddressArray(intHighAddress - m) + Asc("0")
Else
intAddressArray(intHighAddress - m) = intAddressArray(intHighAddress - m) + Asc("A") - 10
End If
strAddress = strAddress + Chr$(intAddressArray(intHighAddress - m))
Next m
strAddress = strAddress + Chr$(13) + Chr$(10)
Next n
txtAdd = strAddress '地址
End Sub
Private Sub cmdReceive_Click()
If blnReceiveFlag Then
If Not blnReceiveFlag Then
Me.MSComm.PortOpen = False
End If
Me.cmdReceive.Caption = "開始接收"
Else
If Not Me.MSComm.PortOpen Then
Me.MSComm.CommPort = intPort
Me.MSComm.Settings = strSet
Me.MSComm.PortOpen = True
End If
Me.MSComm.InputLen = 0
Me.MSComm.InputMode = 0
Me.MSComm.InBufferCount = 0
Me.MSComm.RThreshold = 1
Me.cmdReceive.Caption = "停止接收"
End If
blnReceiveFlag = Not blnReceiveFlag
End Sub
Private Sub Form_Load()
intHexWidth = 8
txtAdd = ""
txtHex = ""
txtAsc = ""
txtSend = "11"
txtAdd.Width = 1335
txtHex.Width = 2535
txtAsc.Width = 1215
'設置默認發送接收關閉狀態
blnAutoSendFlag = False
blnReceiveFlag = False
'接收初始化
intReceiveLen = 0
'默認發送方式為16進制
'intOutMode = 1
'初始化串列口
intPort = 1
intTime = 1000
strSet = "9600,n,8,1"
Me.MSComm.InBufferSize = 1024
Me.MSComm.OutBufferSize = 512
If Not Me.MSComm.PortOpen Then
Me.MSComm.CommPort = intPort
Me.MSComm.Settings = strSet
Me.MSComm.PortOpen = True
End If
Me.MSComm.PortOpen = False
End Sub
Private Sub cmdClear_Click()
Dim bytTemp(0) As Byte
ReDim bytReceiveByte(0)
intReceiveLen = 0
Call InputManage(bytTemp, 0)
Call GetDisplayText
Call disPlay
End Sub
Private Sub MsComm_OnComm()
Dim bytInput() As Byte
Dim intInputLen As Integer
Select Case Me.MSComm.CommEvent
Case comEvReceive
If blnReceiveFlag Then
If Not Me.MSComm.PortOpen Then
Me.MSComm.CommPort = intPort
Me.MSComm.Settings = strSet
Me.MSComm.PortOpen = True
End If
'此處添加處理接收的代碼
Me.MSComm.InputMode = comInputModeBinary '二進制接收
intInputLen = Me.MSComm.InBufferCount
ReDim bytInput(intInputLen)
bytInput = Me.MSComm.Input
Call InputManage(bytInput, intInputLen)
Call GetDisplayText
'Call disPlay
If Not blnReceiveFlag Then
Me.MSComm.PortOpen = False
End If
End If
End Select
End Sub
Private Sub disPlay()
txtHex = ""
txtAsc = ""
txtAdd = ""
End Sub
㈣ 能給我c/c++串口通信典型應用實例編程實踐的電子版嗎,還有源代碼
我當時用的這個人的代碼:
/*
Mole:SerialPort.H
Purpose:
Copyright(c)1999-2008byPJNaughter.
Allrightsreserved.
Copyright/UsageDetails:
(commercial,shareware,freewareorotherwise)
.
.Ifyouwanttodistributesource
codewithyourapplication,.Thisis
.
*/
/////////////////////Macros/Structsetc////////////////////////////////////
#pragmaonce
#ifndef__SERIALPORT_H__
#define__SERIALPORT_H__
#ifndefCSERIALPORT_EXT_CLASS
#defineCSERIALPORT_EXT_CLASS
#endif
///////////////////////////Classes///////////////////////////////////////////
classCSERIALPORT_EXT_CLASSCSerialException:publicCException
{
public:
//Constructors/Destructors
CSerialException(DWORDdwError);
//Methods
#ifdef_DEBUG
virtualvoidDump(CDumpContext&dc)const;
#endif
virtualBOOLGetErrorMessage(__out_ecount_z(nMaxError)LPTSTRlpszError,__inUINTnMaxError,__out_optPUINTpnHelpContext=NULL);
CStringGetErrorMessage();
//Datamembers
DWORDm_dwError;
protected:
DECLARE_DYNAMIC(CSerialException)
};
classCSERIALPORT_EXT_CLASSCSerialPort
{
public:
//Enums
enumFlowControl
{
NoFlowControl,
CtsRtsFlowControl,
CtsDtrFlowControl,
DsrRtsFlowControl,
DsrDtrFlowControl,
XonXoffFlowControl
};
enumParity
{
NoParity=0,
OddParity=1,
EvenParity=2,
MarkParity=3,
SpaceParity=4
};
enumStopBits
{
OneStopBit,
OnePointFiveStopBits,
TwoStopBits
};
//Constructors/Destructors
CSerialPort();
virtual~CSerialPort();
//GeneralMethods
voidOpen(intnPort,DWORDdwBaud=9600,Parityparity=NoParity,BYTEDataBits=8,
StopBitsstopBits=OneStopBit,FlowControlfc=NoFlowControl,BOOLbOverlapped=FALSE);
voidOpen(LPCTSTRpszPort,DWORDdwBaud=9600,Parityparity=NoParity,BYTEDataBits=8,
StopBitsstopBits=OneStopBit,FlowControlfc=NoFlowControl,BOOLbOverlapped=FALSE);
voidClose();
voidAttach(HANDLEhComm);
HANDLEDetach();
operatorHANDLE()const{returnm_hComm;};
BOOLIsOpen()const{returnm_hComm!=INVALID_HANDLE_VALUE;};
#ifdef_DEBUG
voidDump(CDumpContext&dc)const;
#endif
//Reading/WritingMethods
DWORDRead(void*lpBuf,DWORDdwCount);
voidRead(void*lpBuf,DWORDdwCount,OVERLAPPED&overlapped,DWORD*pBytesRead=NULL);
voidReadEx(void*lpBuf,DWORDdwCount);
DWORDWrite(constvoid*lpBuf,DWORDdwCount);
voidWrite(constvoid*lpBuf,DWORDdwCount,OVERLAPPED&overlapped,DWORD*pBytesWritten=NULL);
voidWriteEx(constvoid*lpBuf,DWORDdwCount);
voidTransmitChar(charcChar);
voidGetOverlappedResult(OVERLAPPED&overlapped,DWORD&dwBytesTransferred,BOOLbWait);
voidCancelIo();
DWORDBytesWaiting();
BOOLDataWaiting(DWORDdwTimeout);
//ConfigurationMethods
voidGetConfig(COMMCONFIG&config);
staticvoidGetDefaultConfig(intnPort,COMMCONFIG&config);
voidSetConfig(COMMCONFIG&Config);
staticvoidSetDefaultConfig(intnPort,COMMCONFIG&config);
//MiscRS232Methods
voidClearBreak();
voidSetBreak();
voidClearError(DWORD&dwErrors);
voidGetStatus(COMSTAT&stat);
voidGetState(DCB&dcb);
voidSetState(DCB&dcb);
voidEscape(DWORDdwFunc);
voidClearDTR();
voidClearRTS();
voidSetDTR();
voidSetRTS();
voidSetXOFF();
voidSetXON();
voidGetProperties(COMMPROP&properties);
voidGetModemStatus(DWORD&dwModemStatus);
//Timeouts
voidSetTimeouts(COMMTIMEOUTS&timeouts);
voidGetTimeouts(COMMTIMEOUTS&timeouts);
voidSet0Timeout();
voidSet0WriteTimeout();
voidSet0ReadTimeout();
//EventMethods
voidSetMask(DWORDdwMask);
voidGetMask(DWORD&dwMask);
voidWaitEvent(DWORD&dwMask);
BOOLWaitEvent(DWORD&dwMask,OVERLAPPED&overlapped);
//QueueMethods
voidFlush();
voidPurge(DWORDdwFlags);
();
voidTerminateOutstandingReads();
voidClearWriteBuffer();
voidClearReadBuffer();
voidSetup(DWORDdwInQueue,DWORDdwOutQueue);
//Overridables
virtualvoidOnCompletion(DWORDdwErrorCode,DWORDdwCount,LPOVERLAPPEDlpOverlapped);
//Staticmethods
(DWORDdwError=0);
protected:
//Typedefs
typedefBOOL(WINAPICANCELIO)(HANDLE);
typedefCANCELIO*LPCANCELIO;
//Staticmethods
staticvoidWINAPI_OnCompletion(DWORDdwErrorCode,DWORDdwCount,LPOVERLAPPEDlpOverlapped);
//Membervariables
HANDLEm_hComm;//Handletothecommsport
HANDLEm_hEvent;//
HINSTANCEm_hKernel32;//Kernel32handle
LPCANCELIOm_lpfnCancelIo;//CancelIOfunctionpointer
};
#endif//__SERIALPORT_H__