91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 9.94M
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發布日期: 2024-04-14
  • 語言: C/C++
  • 標簽: VC++??c++??VC??

資源簡介

VC++ 串口實例

資源截圖

代碼片段和文件信息

/*
** FILENAME CSerialPort.cpp
**
** PURPOSE This?class?can?read?write?and?watch?one?serial?port.
** It?sends?messages?to?its?owner?when?something?happends?on?the?port
** The?class?creates?a?thread?for?reading?and?writing?so?the?main
** program?is?not?blocked.
**
** CREATION?DATE 15-09-1997
** LAST?MODIFICATION 12-11-1997
**
** AUTHOR Remon?Spekreijse
**
**
*/

#include?“stdafx.h“
#include?“SerialPort.h“

#include?
?
//
//?Constructor
//
CSerialPort::CSerialPort()
{
m_hComm?=?NULL;

//?initialize?overlapped?structure?members?to?zero
m_ov.Offset?=?0;
m_ov.OffsetHigh?=?0;

//?create?events
m_ov.hEvent?=?NULL;
m_hWriteEvent?=?NULL;
m_hShutdownEvent?=?NULL;

m_szWriteBuffer?=?NULL;

m_bThreadAlive?=?FALSE;
}

//
//?Delete?dynamic?memory
//
CSerialPort::~CSerialPort()
{
do
{
SetEvent(m_hShutdownEvent);
}?while?(m_bThreadAlive);

TRACE(“Thread?ended\n“);

delete?[]?m_szWriteBuffer;
}

//
//?Initialize?the?port.?This?can?be?port?1?to?4.
//
BOOL?CSerialPort::InitPort(CWnd*?pPortOwner //?the?owner?(CWnd)?of?the?port?(receives?message)
???UINT??portnr //?portnumber?(1..4)
???UINT??baud //?baudrate
???char??parity //?parity?
???UINT??databits //?databits?
???UINT??stopbits //?stopbits?
???DWORD?dwCommEvents //?EV_RXCHAR?EV_CTS?etc
???UINT??writebuffersize) //?size?to?the?writebuffer
{
//assert(portnr?>?0?&&?portnr? assert(pPortOwner?!=?NULL);

//?if?the?thread?is?alive:?Kill
if?(m_bThreadAlive)
{
do
{
SetEvent(m_hShutdownEvent);
}?while?(m_bThreadAlive);
TRACE(“Thread?ended\n“);
}

//?create?events
if?(m_ov.hEvent?!=?NULL)
ResetEvent(m_ov.hEvent);
m_ov.hEvent?=?CreateEvent(NULL?TRUE?FALSE?NULL);

if?(m_hWriteEvent?!=?NULL)
ResetEvent(m_hWriteEvent);
m_hWriteEvent?=?CreateEvent(NULL?TRUE?FALSE?NULL);

if?(m_hShutdownEvent?!=?NULL)
ResetEvent(m_hShutdownEvent);
m_hShutdownEvent?=?CreateEvent(NULL?TRUE?FALSE?NULL);

//?initialize?the?event?objects
m_hEventArray[0]?=?m_hShutdownEvent; //?highest?priority
m_hEventArray[1]?=?m_ov.hEvent;
m_hEventArray[2]?=?m_hWriteEvent;

//?initialize?critical?section
InitializeCriticalSection(&m_csCommunicationSync);

//?set?buffersize?for?writing?and?save?the?owner
m_pOwner?=?pPortOwner;

if?(m_szWriteBuffer?!=?NULL)
delete?[]?m_szWriteBuffer;
m_szWriteBuffer?=?new?char[writebuffersize];

m_nPortNr?=?portnr;

m_nWriteBufferSize?=?writebuffersize;
m_dwCommEvents?=?dwCommEvents;

BOOL?bResult?=?FALSE;
char?*szPort?=?new?char[50];
char?*szBaud?=?new?char[50];

//?now?it?critical!
EnterCriticalSection(&m_csCommunicationSync);

//?if?the?port?is?already?opened:?close?it
if?(m_hComm?!=?NULL)
{
CloseHandle(m_hComm);
m_hComm?=?NULL;
}

//?prepare?port?strings
sprintf(szPort?“COM%d“?portnr);
sprintf(szBaud?“baud=%d?parity=

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件?????130048??2012-12-27?16:23??SerialPortTest-簡單的例子\Debug\SerialPortTest.exe

?????文件????1147012??2012-12-27?16:23??SerialPortTest-簡單的例子\Debug\SerialPortTest.ilk

?????文件????3648512??2012-12-27?16:23??SerialPortTest-簡單的例子\Debug\SerialPortTest.pdb

?????文件???????5590??2012-12-27?16:23??SerialPortTest-簡單的例子\SerialPortTest\Debug\BuildLog.htm

?????文件?????????65??2012-12-27?16:23??SerialPortTest-簡單的例子\SerialPortTest\Debug\mt.dep

?????文件??????37742??2012-12-27?16:04??SerialPortTest-簡單的例子\SerialPortTest\Debug\SerialPort.obj

?????文件????????920??2012-12-27?16:04??SerialPortTest-簡單的例子\SerialPortTest\Debug\SerialPortTest.exe.embed.manifest

?????文件????????984??2012-12-27?16:04??SerialPortTest-簡單的例子\SerialPortTest\Debug\SerialPortTest.exe.embed.manifest.res

?????文件????????861??2012-12-27?16:23??SerialPortTest-簡單的例子\SerialPortTest\Debug\SerialPortTest.exe.intermediate.manifest

?????文件??????22702??2012-12-27?16:17??SerialPortTest-簡單的例子\SerialPortTest\Debug\SerialPortTest.obj

?????文件???25296896??2012-12-27?16:04??SerialPortTest-簡單的例子\SerialPortTest\Debug\SerialPortTest.pch

?????文件??????23288??2012-12-27?16:23??SerialPortTest-簡單的例子\SerialPortTest\Debug\SerialPortTest.res

?????文件??????34119??2012-12-27?16:18??SerialPortTest-簡單的例子\SerialPortTest\Debug\SerialPortTestDlg.obj

?????文件?????465535??2012-12-27?16:04??SerialPortTest-簡單的例子\SerialPortTest\Debug\stdafx.obj

?????文件?????912384??2012-12-27?16:18??SerialPortTest-簡單的例子\SerialPortTest\Debug\vc90.idb

?????文件????2002944??2012-12-27?16:18??SerialPortTest-簡單的例子\SerialPortTest\Debug\vc90.pdb

?????文件???????3017??2012-12-27?15:52??SerialPortTest-簡單的例子\SerialPortTest\ReadMe.txt

????.......?????21630??2003-07-24?09:52??SerialPortTest-簡單的例子\SerialPortTest\res\SerialPortTest.ico

?????文件????????370??2012-12-27?15:52??SerialPortTest-簡單的例子\SerialPortTest\res\SerialPortTest.rc2

?????文件????????824??2012-12-27?16:00??SerialPortTest-簡單的例子\SerialPortTest\resource.h

?????文件??????17562??2012-11-19?16:25??SerialPortTest-簡單的例子\SerialPortTest\SerialPort.cpp

?????文件???????3020??2012-11-19?15:05??SerialPortTest-簡單的例子\SerialPortTest\SerialPort.h

?????文件??????42960??2017-09-20?10:04??SerialPortTest-簡單的例子\SerialPortTest\SerialPortTest.aps

?????文件???????1751??2012-12-27?15:52??SerialPortTest-簡單的例子\SerialPortTest\SerialPortTest.cpp

?????文件????????489??2012-12-27?15:52??SerialPortTest-簡單的例子\SerialPortTest\SerialPortTest.h

?????文件???????5380??2012-12-27?16:23??SerialPortTest-簡單的例子\SerialPortTest\SerialPortTest.rc

?????文件???????5682??2012-12-27?16:04??SerialPortTest-簡單的例子\SerialPortTest\SerialPortTest.vcproj

?????文件???????1411??2017-09-20?10:04??SerialPortTest-簡單的例子\SerialPortTest\SerialPortTest.vcproj.acer-PC.acer.user

?????文件???????1405??2012-12-27?16:25??SerialPortTest-簡單的例子\SerialPortTest\SerialPortTest.vcproj.ZHOU.Administrator.user

?????文件???????3513??2012-12-27?16:18??SerialPortTest-簡單的例子\SerialPortTest\SerialPortTestDlg.cpp

............此處省略15個文件信息

評論

共有 條評論