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

  • 大小: 3.13MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2023-11-16
  • 語言: 其他
  • 標(biāo)簽: 串口通訊??

資源簡介

控制臺串口通訊程序 可以輸入 16進(jìn)制的字符 然后接受到的數(shù)據(jù)以16進(jìn)制的格式顯示出來 多線程異步 控制臺串口通訊類 及其實例

資源截圖

代碼片段和文件信息

#include?“StdAfx.h“
#include?“ConsoleSerialPort.h“


CConsoleSerialPort::CConsoleSerialPort(void)
{
m_comm=NULL;
m_overlapped.Offset=0;
m_overlapped.OffsetHigh=0;
m_overlapped.hEvent=NULL;
m_write_event=NULL;
m_shutdown_event=NULL;
m_sz_write_buffer=NULL;
m_n_write_size=1;
m_thread_alive=FALSE;
m_thread=NULL;
}


CConsoleSerialPort::CConsoleSerialPort(CContral?*?parent)
{
m_comm=NULL;
m_overlapped.Offset=0;
m_overlapped.OffsetHigh=0;
m_overlapped.hEvent=NULL;
m_write_event=NULL;
m_shutdown_event=NULL;
m_sz_write_buffer=NULL;
m_n_write_size=1;
m_thread_alive=FALSE;
m_thread=NULL;
m_parent=parent;
}


CConsoleSerialPort::~CConsoleSerialPort(void)
{
do?
{
SetEvent(m_shutdown_event);
}?while?(m_thread_alive);
delete?[]?m_sz_write_buffer;
}


bool?CConsoleSerialPort::init_port(unsigned?int?port?/*?=1?*/?unsigned?int?baud/*?=9600?*/char?parity/*?=‘N‘?*/?unsigned?int?databits/*?=8?*/unsigned?int?stopbits?/*?=1?*/DWORD?dwCommEvents?/*?=?EV_RXCHAR?*/unsigned?int?write_buffer_size/*?=1024?*/)
{
assert(port>0&&port<9);
if?(m_thread_alive)
{
do
{
SetEvent(m_shutdown_event);
}?while?(m_thread_alive);
}
if?(m_overlapped.hEvent!=NULL)
ResetEvent(m_overlapped.hEvent);
m_overlapped.hEvent=CreateEvent(NULLTRUEFALSENULL);
if?(m_write_event!=NULL)
ResetEvent(m_write_event);
m_write_event=CreateEvent(NULLTRUEFALSENULL);
if?(m_shutdown_event!=NULL)
ResetEvent(m_shutdown_event);
m_shutdown_event=CreateEvent(NULLTRUEFALSENULL);

m_event_array[0]=m_shutdown_event;
m_event_array[1]=m_overlapped.hEvent;
m_event_array[2]=m_write_event;
InitializeCriticalSection(&m_mm_sync);
m_port=port;
if?(m_sz_write_buffer!=NULL)
delete?[]m_sz_write_buffer;
m_sz_write_buffer=new?char[write_buffer_size];
m_n_write_size=write_buffer_size;
m_dw_commEvents=dwCommEvents;
bool?bResult=false;
WCHAR?*?szPort=new?WCHAR[50];
WCHAR?*?szBaud=new?WCHAR[50];
EnterCriticalSection(&m_mm_sync);
if?(m_comm!=NULL)
{
CloseHandle(m_comm);
m_comm=NULL;
}
wsprintf(szPort_T(“COM%d“)port);
wsprintf(szBaud_T(“baud=%d?parity=%c?data=%d?stop=%d“)baudparitydatabitsstopbits);
m_comm=CreateFile(szPortGENERIC_WRITE|GENERIC_READ0NULLOPEN_EXISTINGFILE_FLAG_OVERLAPPED0);
if?(m_comm?==INVALID_HANDLE_VALUE)
{
delete?[]?szPort;
delete?[]?szBaud;
return?false;
}
m_comm_time_out.ReadIntervalTimeout=1000;
m_comm_time_out.ReadTotalTimeoutMultiplier=1000;
m_comm_time_out.ReadTotalTimeoutConstant=1000;
m_comm_time_out.WriteTotalTimeoutMultiplier=1000;
m_comm_time_out.WriteTotalTimeoutConstant=1000;
if?(SetCommTimeouts(m_comm&m_comm_time_out))
{
if?(SetCommMask(m_commdwCommEvents))
{
if?(GetCommState(m_comm&m_dcb))
{
m_dcb.EvtChar?=‘q‘;
m_dcb.fRtsControl=RTS_CONTROL_ENABLE;
if?(BuildCommDCB(szBaud&m_dcb))
{
if?(SetCommState(m_comm&m_dcb))
;
else
process

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

?????文件?????743760??2011-02-20?02:01??Serialcommunication\Debug\msvcp100d.dll

?????文件????1505104??2011-02-20?02:01??Serialcommunication\Debug\msvcr100d.dll

?????文件??????58368??2013-05-07?09:45??Serialcommunication\Debug\Serialcommunication.exe

?????文件?????545124??2013-05-07?09:45??Serialcommunication\Debug\Serialcommunication.ilk

?????文件?????691200??2013-05-07?09:45??Serialcommunication\Debug\Serialcommunication.pdb

?????文件????2359296??2013-05-07?09:45??Serialcommunication\ipch\serialcommunication-9a27186f\serialcommunication-6ef59e62.ipch

?????文件??????10379??2013-05-07?09:42??Serialcommunication\Serialcommunication\ConsoleSerialPort.cpp

?????文件???????1550??2013-05-06?13:55??Serialcommunication\Serialcommunication\ConsoleSerialPort.h

?????文件???????9241??2013-05-04?15:58??Serialcommunication\Serialcommunication\ConsoleSerialPortback.cpp

?????文件???????1412??2013-05-04?13:05??Serialcommunication\Serialcommunication\ConsoleSerialPortback.h

?????文件???????1637??2013-05-03?13:54??Serialcommunication\Serialcommunication\ReadMe.txt

?????文件???????1564??2013-05-05?08:36??Serialcommunication\Serialcommunication\Serialcommunication.cpp

?????文件???????4546??2013-05-04?13:27??Serialcommunication\Serialcommunication\Serialcommunication.vcxproj

?????文件???????1523??2013-05-04?12:47??Serialcommunication\Serialcommunication\Serialcommunication.vcxproj.filters

?????文件????????143??2013-05-03?13:54??Serialcommunication\Serialcommunication\Serialcommunication.vcxproj.user

?????文件??????18408??2013-05-04?10:08??Serialcommunication\Serialcommunication\SerialPort.cpp

?????文件???????2791??2013-05-04?09:46??Serialcommunication\Serialcommunication\SerialPort.h

?????文件????????224??2013-05-03?13:54??Serialcommunication\Serialcommunication\stdafx.cpp

?????文件????????233??2013-05-03?13:54??Serialcommunication\Serialcommunication\stdafx.h

?????文件????????236??2013-05-03?13:54??Serialcommunication\Serialcommunication\targetver.h

?????文件???10309632??2013-05-07?09:45??Serialcommunication\Serialcommunication.sdf

?????文件????????924??2013-05-03?13:54??Serialcommunication\Serialcommunication.sln

????..A..H.?????18432??2013-05-07?09:45??Serialcommunication\Serialcommunication.suo

?????目錄??????????0??2013-05-07?09:45??Serialcommunication\ipch\serialcommunication-9a27186f

?????目錄??????????0??2013-05-07?09:45??Serialcommunication\Debug

?????目錄??????????0??2013-05-07?09:45??Serialcommunication\ipch

?????目錄??????????0??2013-05-07?09:46??Serialcommunication\Serialcommunication

?????目錄??????????0??2013-05-07?09:45??Serialcommunication

-----------?---------??----------?-----??----

?????????????16285727????????????????????28

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

評論

共有 條評論