CSerialPort教程(5) - cmake方式使用CSerialPort


如需转载请标明出处:http://blog.csdn.net/itas109
QQ技术交流群:129518033

文章目录

  • CSerialPort教程(5) - cmake方式使用CSerialPort
    • 前言
    • 1. cmake构建console控制台的CSerialPort项目
    • 2. cmake构建QT的CSerialPort项目
    • 3. cmake构建MFC的CSerialPort项目

环境:

系统:windows 10 64位
QT: 5.12.9 LTS
MFC: vs2008、vs2017

前言

CSerialPort项目是基于C++的轻量级开源跨平台串口类库,用于实现跨平台多操作系统的串口读写。

CSerialPort项目的开源协议自 V3.0.0.171216 版本后采用GNU Lesser General Public License v3.0

为了让开发者更好的使用CSerialPort进行开发,特编写基于4.x版本的CSerialPort教程系列。

本文将介绍如何以cmake方式使用CSerialPort,包括但不限于console控制台项目、QT项目以及MFC项目。

CSerialPort项目地址:

  • https://github.com/itas109/CSerialPort
  • https://gitee.com/itas109/CSerialPort

1. cmake构建console控制台的CSerialPort项目

$ cd CommConsole
$ git clone https://github.com/itas109/CSerialPort

目录结构如下:

CommConsole $ tree
.
+--- CMakeLists.txt
+--- CSerialPort
|   +--- include
|   |   +--- CSerialPort
|   |   |   +--- SerialPort.h
|   |   |   +--- SerialPortInfo.h
|   +--- src
|   |   +--- SerialPort.cpp
|   |   +--- SerialPortBase.cpp
|   |   +--- SerialPortInfo.cpp
|   |   +--- SerialPortInfoBase.cpp
|   |   +--- SerialPortInfoWinBase.cpp
|   |   +--- SerialPortWinBase.cpp
+--- main.cpp

构建命令

mkdir bin
cd bin
set path=D:\Qt\Qt5.12.9\Tools\mingw730_64\bin;%path%
cmake .. -G "MinGW Makefiles" -DCMAKE_PREFIX_PATH=D:\Qt\Qt5.12.9\5.12.9\mingw73_64
cmake --build .

main.cpp

#include <iostream>#include "CSerialPort/SerialPort.h"
#include "CSerialPort/SerialPortInfo.h"#include <vector>
using namespace itas109;
using namespace std;class mySlot : public has_slots<>
{
public:mySlot(CSerialPort *sp){recLen = -1;p_sp = sp;};void OnSendMessage(){// readrecLen = p_sp->readAllData(str);if (recLen > 0){str[recLen] = '\0';std::cout << "receive data : " << str << ", receive size : " << recLen << std::endl;}};private:mySlot(){};private:CSerialPort *p_sp;char str[1024];int recLen;
};int main()
{CSerialPort sp;mySlot receive(&sp);std::cout << "Version : " << sp.getVersion() << std::endl << std::endl;vector<SerialPortInfo> m_availablePortsList = CSerialPortInfo::availablePortInfos();if (0 == m_availablePortsList.size()){std::cout << "No valid port" << std::endl;return 0;}sp.init(m_availablePortsList[0].portName, // windows:COM1 Linux:/dev/ttyS0itas109::BaudRate9600, itas109::ParityNone, itas109::DataBits8, itas109::StopOne);sp.open();if (sp.isOpened()){std::cout << "open " << m_availablePortsList[0].portName << " success" << std::endl;}else{std::cout << "open " << m_availablePortsList[0].portName << " failed" << std::endl;return 0;}// 绑定接收函数sp.readReady.connect(&receive, &mySlot::OnSendMessage);// 写入数据sp.writeData("itas109", 7);for (;;);return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.12)project(CommConsole LANGUAGES CXX)# add by itas109
set(CSerialPortRootPath "${PROJECT_SOURCE_DIR}/CSerialPort")
include_directories(${CSerialPortRootPath}/include)
list(APPEND CSerialPortSourceFiles ${CSerialPortRootPath}/src/SerialPort.cpp ${CSerialPortRootPath}/src/SerialPortBase.cpp ${CSerialPortRootPath}/src/SerialPortInfo.cpp ${CSerialPortRootPath}/src/SerialPortInfoBase.cpp)
if (WIN32)list(APPEND CSerialPortSourceFiles ${CSerialPortRootPath}/src/SerialPortInfoWinBase.cpp ${CSerialPortRootPath}/src/SerialPortWinBase.cpp)
else (UNIX)list(APPEND CSerialPortSourceFiles ${CSerialPortRootPath}/src/SerialPortInfoUnixBase.cpp ${CSerialPortRootPath}/src/SerialPortUnixBase.cpp)
endif()
# end by itas109add_executable(${PROJECT_NAME}main.cpp${CSerialPortSourceFiles} # add by itas109
)# add by itas109
if (WIN32)# for function availableFriendlyPortstarget_link_libraries( ${PROJECT_NAME} setupapi)
elseif(APPLE)find_library(IOKIT_LIBRARY IOKit)find_library(FOUNDATION_LIBRARY Foundation)target_link_libraries( ${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
elseif(UNIX)target_link_libraries( ${PROJECT_NAME} pthread)
endif ()
# end by itas109

2. cmake构建QT的CSerialPort项目

新建一个QT项目目,解决方案名称为CommQT

【文件】-【新建文件或项目】-【Application(Qt)】-【Qt Widgets Application】-【choose…】-【名称: CommQT】-【Build system: CMake】

CommQT解决方案目录下载CSerialPort源码

$ cd CommQT
$ git clone https://github.com/itas109/CSerialPort

目录结构如下:

CommQT $ tree
.
+--- CMakeLists.txt
+--- CSerialPort
|   +--- include
|   |   +--- CSerialPort
|   |   |   +--- SerialPort.h
|   |   |   +--- SerialPortInfo.h
|   +--- src
|   |   +--- SerialPort.cpp
|   |   +--- SerialPortBase.cpp
|   |   +--- SerialPortInfo.cpp
|   |   +--- SerialPortInfoBase.cpp
|   |   +--- SerialPortInfoWinBase.cpp
|   |   +--- SerialPortWinBase.cpp
+--- main.cpp
+--- mainwindow.cpp
+--- mainwindow.h
+--- mainwindow.ui

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.12)project(CommQT LANGUAGES CXX)set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)find_package(Qt5 COMPONENTS Widgets REQUIRED)# add by itas109
set(CSerialPortRootPath "${PROJECT_SOURCE_DIR}/CSerialPort")
include_directories(${CSerialPortRootPath}/include)
list(APPEND CSerialPortSourceFiles ${CSerialPortRootPath}/src/SerialPort.cpp ${CSerialPortRootPath}/src/SerialPortBase.cpp ${CSerialPortRootPath}/src/SerialPortInfo.cpp ${CSerialPortRootPath}/src/SerialPortInfoBase.cpp)
if (WIN32)list(APPEND CSerialPortSourceFiles ${CSerialPortRootPath}/src/SerialPortInfoWinBase.cpp ${CSerialPortRootPath}/src/SerialPortWinBase.cpp)
elseif (UNIX)list(APPEND CSerialPortSourceFiles ${CSerialPortRootPath}/src/SerialPortInfoUnixBase.cpp ${CSerialPortRootPath}/src/SerialPortUnixBase.cpp)
endif ()
# end by itas109add_executable(${PROJECT_NAME}main.cppmainwindow.cppmainwindow.hmainwindow.ui${CSerialPortSourceFiles} # add by itas109
)target_link_libraries(CommQT Qt5::Widgets)# add by itas109
if (WIN32)# for function availableFriendlyPortstarget_link_libraries( ${PROJECT_NAME} setupapi)
elseif(APPLE)find_library(IOKIT_LIBRARY IOKit)find_library(FOUNDATION_LIBRARY Foundation)target_link_libraries( ${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
elseif(UNIX)target_link_libraries( ${PROJECT_NAME} pthread)
endif ()
# end by itas109

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>// add by itas109
#include <QPlainTextEdit>#include "CSerialPort/SerialPort.h"
#include "CSerialPort/SerialPortInfo.h"
using namespace itas109;
// end by itas109QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACEclass MainWindow : public QMainWindow, public has_slots<> // add by itas109
{Q_OBJECTpublic:MainWindow(QWidget *parent = nullptr);~MainWindow();// add by itas109
private:void OnReceive();signals:void emitUpdateReceive(QString str);private slots:void OnUpdateReceive(QString str);// end by itas109private:Ui::MainWindow *ui;// add by itas109QPlainTextEdit * p_plainTextEditReceive;CSerialPort m_serialPort;// end by itas109
};
#endif // MAINWINDOW_H

mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);// add by itas109p_plainTextEditReceive = NULL;p_plainTextEditReceive = new QPlainTextEdit(ui->centralwidget);this->setCentralWidget(p_plainTextEditReceive);vector<SerialPortInfo> portNameList = CSerialPortInfo::availablePortInfos();if (portNameList.size() > 0){p_plainTextEditReceive->moveCursor (QTextCursor::End);p_plainTextEditReceive->insertPlainText(QString("First avaiable Port: %1\n").arg(portNameList[0].portName.c_str()));}else{p_plainTextEditReceive->moveCursor (QTextCursor::End);p_plainTextEditReceive->insertPlainText("No avaiable Port");return;}connect(this,&MainWindow::emitUpdateReceive,this,&MainWindow::OnUpdateReceive,Qt::QueuedConnection);m_serialPort.readReady.connect(this, &MainWindow::OnReceive);#ifdef Q_OS_WINm_serialPort.init(portNameList[0].portName);
#elsem_serialPort.init(portNameList[0].portName);
#endifm_serialPort.open();if (m_serialPort.isOpened()){p_plainTextEditReceive->moveCursor (QTextCursor::End);p_plainTextEditReceive->insertPlainText(QString("open %1 success\n").arg(portNameList[0].portName.c_str()));m_serialPort.writeData("itas109", 7);}else{p_plainTextEditReceive->moveCursor (QTextCursor::End);p_plainTextEditReceive->insertPlainText(QString("open %1 failed\n").arg(portNameList[0].portName.c_str()));}// end by itas109
}MainWindow::~MainWindow()
{delete ui;// add by itas109this->disconnect();// end by itas109
}// add by itas109
void MainWindow::OnReceive()
{char str[1024];int recLen = m_serialPort.readAllData(str);if (recLen > 0){emitUpdateReceive(QString::fromLocal8Bit(str,recLen));}
}void MainWindow::OnUpdateReceive(QString str)
{p_plainTextEditReceive->moveCursor (QTextCursor::End);p_plainTextEditReceive->insertPlainText(str);
}
// end by itas109

main.cpp

#include "mainwindow.h"#include <QApplication>int main(int argc, char *argv[])
{QApplication a(argc, argv);MainWindow w;w.show();return a.exec();
}

mainwindow.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"><class>MainWindow</class><widget class="QMainWindow" name="MainWindow"><property name="geometry"><rect><x>0</x><y>0</y><width>800</width><height>600</height></rect></property><property name="windowTitle"><string>MainWindow</string></property><widget class="QWidget" name="centralwidget"/><widget class="QMenuBar" name="menubar"/><widget class="QStatusBar" name="statusbar"/></widget><resources/><connections/>
</ui>

3. cmake构建MFC的CSerialPort项目

新建一个基于对话框的MFC项目,解决方案名称为CommMFC

$ cd CommMFC
$ git clone https://github.com/itas109/CSerialPort

目录结构如下:

CommMFC $ tree
.
+--- CMakeLists.txt
+--- CommMFC.cpp
+--- CommMFC.h
+--- CommMFC.rc
+--- CommMFCDlg.cpp
+--- CommMFCDlg.h
+--- CSerialPort
|   +--- include
|   |   +--- CSerialPort
|   |   |   +--- SerialPort.h
|   |   |   +--- SerialPortInfo.h
|   +--- src
|   |   +--- SerialPort.cpp
|   |   +--- SerialPortBase.cpp
|   |   +--- SerialPortInfo.cpp
|   |   +--- SerialPortInfoBase.cpp
|   |   +--- SerialPortInfoWinBase.cpp
|   |   +--- SerialPortWinBase.cpp
+--- ReadMe.txt
+--- res
|   +--- CommMFC.ico
|   +--- CommMFC.rc2
+--- Resource.h
+--- stdafx.cpp
+--- stdafx.h
+--- targetver.h

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.12)project(CommMFC)set(MFCFilesCommMFC.cppCommMFC.hCommMFC.rcCommMFCDlg.cppCommMFCDlg.hResource.hstdafx.cppstdafx.htargetver.h
)# add by itas109
set(CSerialPortRootPath "${PROJECT_SOURCE_DIR}/CSerialPort")
include_directories(${CSerialPortRootPath}/include)
list(APPEND CSerialPortSourceFiles ${CSerialPortRootPath}/src/SerialPort.cpp ${CSerialPortRootPath}/src/SerialPortBase.cpp ${CSerialPortRootPath}/src/SerialPortInfo.cpp ${CSerialPortRootPath}/src/SerialPortInfoBase.cpp)
if(WIN32)list(APPEND CSerialPortSourceFiles ${CSerialPortRootPath}/src/SerialPortInfoWinBase.cpp ${CSerialPortRootPath}/src/SerialPortWinBase.cpp)
elseif(UNIX)list(APPEND CSerialPortSourceFiles ${CSerialPortRootPath}/src/SerialPortInfoUnixBase.cpp ${CSerialPortRootPath}/src/SerialPortUnixBase.cpp)
endif()
# end by itas109FIND_PACKAGE(MFC)
IF (NOT MFC_FOUND)MESSAGE(FATAL_ERROR "MFC not found")
endif()add_definitions(-D_AFXDLL)
set(CMAKE_MFC_FLAG 2)add_executable(${PROJECT_NAME} WIN32 ${MFCFiles} ${CSerialPortSourceFiles})# add by itas109
if (WIN32)# for function availableFriendlyPortstarget_link_libraries( ${PROJECT_NAME} setupapi)
elseif(APPLE)find_library(IOKIT_LIBRARY IOKit)find_library(FOUNDATION_LIBRARY Foundation)target_link_libraries( ${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
elseif(UNIX)target_link_libraries( ${PROJECT_NAME} pthread)
endif ()
# end by itas109

CommMFCDlg.h

// CommMFCDlg.h : header file
//#pragma once// add by itas109
#include "CSerialPort/SerialPort.h"
#include "CSerialPort/SerialPortInfo.h"
using namespace itas109;
// end by itas109// CCommMFCDlg dialog
class CCommMFCDlg : public CDialog, public has_slots<> // add by itas109
{
// Construction
public:CCommMFCDlg(CWnd* pParent = NULL);  // standard constructor// Dialog Dataenum { IDD = IDD_COMMMFC_DIALOG };protected:virtual void DoDataExchange(CDataExchange* pDX);  // DDX/DDV support// add by itas109
private:void OnReceive();// end by itas109// Implementation
protected:HICON m_hIcon;// Generated message map functionsvirtual BOOL OnInitDialog();afx_msg void OnPaint();afx_msg HCURSOR OnQueryDragIcon();DECLARE_MESSAGE_MAP()// add by itas109
private:CSerialPort m_serialPort;// end by itas109
};

CommMFCDlg.cpp

// CommMFCDlg.cpp : implementation file
//#include "stdafx.h"
#include "CommMFC.h"
#include "CommMFCDlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#endif// CCommMFCDlg dialogCCommMFCDlg::CCommMFCDlg(CWnd* pParent /*=NULL*/): CDialog(CCommMFCDlg::IDD, pParent)
{m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}void CCommMFCDlg::DoDataExchange(CDataExchange* pDX)
{CDialog::DoDataExchange(pDX);
}BEGIN_MESSAGE_MAP(CCommMFCDlg, CDialog)ON_WM_PAINT()ON_WM_QUERYDRAGICON()//}}AFX_MSG_MAP
END_MESSAGE_MAP()// CCommMFCDlg message handlersBOOL CCommMFCDlg::OnInitDialog()
{CDialog::OnInitDialog();// Set the icon for this dialog.  The framework does this automatically//  when the application's main window is not a dialogSetIcon(m_hIcon, TRUE);          // Set big iconSetIcon(m_hIcon, FALSE);     // Set small icon// TODO: Add extra initialization here// add by itas109CString message;vector<SerialPortInfo> portNameList = CSerialPortInfo::availablePortInfos();if (portNameList.size() > 0){message.Format(_T("First avaiable Port: %s\n"),portNameList[0].portName.c_str());MessageBox(message);}else{MessageBox(_T("No avaiable Port"));return TRUE;}m_serialPort.readReady.connect(this, &CCommMFCDlg::OnReceive);m_serialPort.init(portNameList[0].portName);m_serialPort.open();if (m_serialPort.isOpened()){message.Format(_T("open %s success"),portNameList[0].portName.c_str());MessageBox(message);m_serialPort.writeData("itas109", 7);}else{message.Format(_T("open %s failed"),portNameList[0].portName.c_str());MessageBox(message);}// end by itas109return TRUE;  // return TRUE  unless you set the focus to a control
}// add by itas109
void CCommMFCDlg::OnReceive()
{char str[1024];int recLen = m_serialPort.readAllData(str);if (recLen > 0){str[recLen] = '\0';CString cstr;cstr.Format(_T("OnReceive - data: %s, size: %d"), CString(str), recLen);MessageBox(LPCTSTR(cstr));}
}
// end by itas109// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.void CCommMFCDlg::OnPaint()
{if (IsIconic()){CPaintDC dc(this); // device context for paintingSendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);// Center icon in client rectangleint 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;// Draw the icondc.DrawIcon(x, y, m_hIcon);}else{CDialog::OnPaint();}
}// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CCommMFCDlg::OnQueryDragIcon()
{return static_cast<HCURSOR>(m_hIcon);
}

CommMFC.h

// CommMFC.h : main header file for the PROJECT_NAME application
//#pragma once#ifndef __AFXWIN_H__#error "include 'stdafx.h' before including this file for PCH"
#endif#include "resource.h"       // main symbols// CCommMFCApp:
// See CommMFC.cpp for the implementation of this class
//class CCommMFCApp : public CWinApp
{
public:CCommMFCApp();// Overridespublic:virtual BOOL InitInstance();// ImplementationDECLARE_MESSAGE_MAP()
};extern CCommMFCApp theApp;

CommMFC.cpp

// CommMFC.cpp : Defines the class behaviors for the application.
//#include "stdafx.h"
#include "CommMFC.h"
#include "CommMFCDlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#endif// CCommMFCAppBEGIN_MESSAGE_MAP(CCommMFCApp, CWinApp)ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()// CCommMFCApp constructionCCommMFCApp::CCommMFCApp()
{// TODO: add construction code here,// Place all significant initialization in InitInstance
}// The one and only CCommMFCApp objectCCommMFCApp theApp;// CCommMFCApp initializationBOOL CCommMFCApp::InitInstance()
{CWinApp::InitInstance();// Standard initialization// If you are not using these features and wish to reduce the size// of your final executable, you should remove from the following// the specific initialization routines you do not need// Change the registry key under which our settings are stored// TODO: You should modify this string to be something appropriate// such as the name of your company or organizationSetRegistryKey(_T("Local AppWizard-Generated Applications"));CCommMFCDlg dlg;m_pMainWnd = &dlg;INT_PTR nResponse = dlg.DoModal();if (nResponse == IDOK){// TODO: Place code here to handle when the dialog is//  dismissed with OK}else if (nResponse == IDCANCEL){// TODO: Place code here to handle when the dialog is//  dismissed with Cancel}// Since the dialog has been closed, return FALSE so that we exit the//  application, rather than start the application's message pump.return FALSE;
}

CommMFC.rc

// Microsoft Visual C++ generated resource script.
//
#include "resource.h"#define APSTUDIO_READONLY_SYMBOLS
/
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "afxres.h"/
#undef APSTUDIO_READONLY_SYMBOLS#ifdef APSTUDIO_INVOKED
/
//
// TEXTINCLUDE
//1 TEXTINCLUDE
BEGIN"resource.h\0"
END2 TEXTINCLUDE
BEGIN"#ifndef APSTUDIO_INVOKED\r\n""#include ""targetver.h""\r\n""#endif\r\n""#include ""afxres.h""\r\n""\0"
END3 TEXTINCLUDE
BEGIN"#define _AFX_NO_SPLITTER_RESOURCES\r\n""#define _AFX_NO_OLE_RESOURCES\r\n""#define _AFX_NO_TRACKER_RESOURCES\r\n""#define _AFX_NO_PROPERTY_RESOURCES\r\n""\r\n""#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n""LANGUAGE 9, 1\r\n""#pragma code_page(1252)\r\n""#include ""res\\CommMFC.rc2""  // non-Microsoft Visual C++ edited resources\r\n""#include ""afxres.rc""     // Standard components\r\n""#endif\r\n""\0"
END/
#endif    // APSTUDIO_INVOKED/
//
// Icon
//// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME           ICON         "res\\CommMFC.ico"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#pragma code_page(1252)/
//
// Dialog
//IDD_COMMMFC_DIALOG DIALOGEX  0, 0, 320, 200
STYLE DS_SHELLFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION| DS_MODALFRAME| WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "CommMFC"
FONT 8, "MS Shell Dlg"
BEGINDEFPUSHBUTTON   "OK",IDOK,209,179,50,14PUSHBUTTON      "Cancel",IDCANCEL,263,179,50,14CTEXT           "TODO: Place dialog controls here.",IDC_STATIC,10,96,300,8
END/
//
// Version
//VS_VERSION_INFO     VERSIONINFOFILEVERSION       1,0,0,1PRODUCTVERSION    1,0,0,1FILEFLAGSMASK 0x3fL
#ifdef _DEBUGFILEFLAGS 0x1L
#elseFILEFLAGS 0x0L
#endifFILEOS 0x4LFILETYPE 0x1LFILESUBTYPE 0x0L
BEGINBLOCK "StringFileInfo"BEGINBLOCK "040904e4"BEGINVALUE "CompanyName", "TODO: <Company name>"VALUE "FileDescription", "TODO: <File description>"VALUE "FileVersion",     "1.0.0.1"VALUE "InternalName",    "CommMFC.exe"VALUE "LegalCopyright", "TODO: (c) <Company name>.  All rights reserved."VALUE "OriginalFilename","CommMFC.exe"VALUE "ProductName", "TODO: <Product name>"VALUE "ProductVersion",  "1.0.0.1"ENDENDBLOCK "VarFileInfo"BEGINVALUE "Translation", 0x0409, 1252END
END/
//
// DESIGNINFO
//#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGINIDD_COMMMFC_DIALOG, DIALOGBEGINLEFTMARGIN, 7RIGHTMARGIN, 313TOPMARGIN, 7BOTTOMMARGIN, 193END
END
#endif    // APSTUDIO_INVOKED/
//
// String Table
//#endif#ifndef APSTUDIO_INVOKED
/
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#pragma code_page(1252)
#include "res\\CommMFC.rc2"  // non-Microsoft Visual C++ edited resources
#include "afxres.rc"      // Standard components
#endif
/
#endif    // not APSTUDIO_INVOKED

CommMFC.rc2

//
// CommMFC.RC2 - resources Microsoft Visual C++ does not edit directly
//#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED/
// Add manually edited resources here.../

Resource.h

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by CommMFC.rc
//
#define IDR_MAINFRAME                   128
#define IDD_COMMMFC_DIALOG              102// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS#define _APS_NEXT_RESOURCE_VALUE   129
#define _APS_NEXT_CONTROL_VALUE     1000
#define _APS_NEXT_SYMED_VALUE       101
#define _APS_NEXT_COMMAND_VALUE     32771
#endif
#endif

stdafx.h

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently#pragma once#ifndef _SECURE_ATL
#define _SECURE_ATL 1
#endif#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers
#endif#include "targetver.h"#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h>           // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>                     // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

stdafx.cpp

// stdafx.cpp : source file that includes just the standard includes
// CommMFC.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information#include "stdafx.h"

targetver.h

#pragma once// The following macros define the minimum required platform.  The minimum required platform
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
// your application.  The macros work by enabling all features available on platform versions up to and
// including the version specified.// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER                          // Specifies that the minimum required platform is Windows Vista.
#define WINVER 0x0600           // Change this to the appropriate value to target other versions of Windows.
#endif#ifndef _WIN32_WINNT            // Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600     // Change this to the appropriate value to target other versions of Windows.
#endif#ifndef _WIN32_WINDOWS          // Specifies that the minimum required platform is Windows 98.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif#ifndef _WIN32_IE                       // Specifies that the minimum required platform is Internet Explorer 7.0.
#define _WIN32_IE 0x0700        // Change this to the appropriate value to target other versions of IE.
#endif

License

License under CC BY-NC-ND 4.0: 署名-非商业使用-禁止演绎

如需转载请标明出处:http://blog.csdn.net/itas109
QQ技术交流群:129518033


Reference:

  1. https://github.com/itas109/CSerialPort
  2. https://gitee.com/itas109/CSerialPort
  3. https://blog.csdn.net/itas109

CSerialPort教程(5) - cmake方式使用CSerialPort相关推荐

  1. CSerialPort教程(3) - MFC中使用CSerialPort

    CSerialPort教程(3) - MFC中使用CSerialPort 如需转载请标明出处:http://blog.csdn.net/itas109 QQ技术交流群:129518033 文章目录 C ...

  2. CSerialPort教程(4) - QT中使用CSerialPort

    CSerialPort教程(4) - QT中使用CSerialPort 如需转载请标明出处:http://blog.csdn.net/itas109 QQ技术交流群:129518033 文章目录 CS ...

  3. CSerialPort教程(6) - 以第三库方式使用CSerialPort

    CSerialPort教程(6) - 以第三库方式使用CSerialPort 如需转载请标明出处:http://blog.csdn.net/itas109 QQ技术交流群:129518033 文章目录 ...

  4. CSerialPort教程(2) - CSerialPort源码简介

    CSerialPort教程(2) - CSerialPort源码简介 如需转载请标明出处:http://blog.csdn.net/itas109 QQ技术交流群:129518033 文章目录 CSe ...

  5. CSerialPort教程(1) - CSerialPort项目简介

    CSerialPort教程(1) - CSerialPort项目简介 如需转载请标明出处:http://blog.csdn.net/itas109 QQ技术交流群:129518033 文章目录 CSe ...

  6. so调用so 编译 android,android-5分钟入门-CMake方式使用JNI(.so调用篇)

    上篇中讲到获取编译好的so文件,但是so文件里就一个方法,并且是JNI格式的.现在,先在CNativeFunction.cpp中新增一个非JNI格式的C方法testMethod,返回字符串" ...

  7. linux mysql make_二、linux-mysql -cmake方式安装mysql 5.5

    1.安装解压cmake包 cmake软件 cd /home/oldboy/tools/ tar xf cmake-2.8.8.tar.gz cd cmake-2.8.8 ./configure #CM ...

  8. .net 启动mysql数据库连接_[ASP.net教程]mysql数据库连接方式(.net)

    [ASP.net教程]mysql数据库连接方式(.net) 0 2014-07-17 18:01:00 1.通过ado.net连接(数据库连接串中为中文貌似无法使用) 需要添加MySql.Data.d ...

  9. cmake 生成mysql_采用cmake方式编译安装MySQL

    cmake方式编译安装MySQL 由于MySQL5.5.xx-5.6.xx产品系列特殊性,所以编译方式也和早期的产品编译方式不同,采用cmake(cmake软件需要另外安装)或gmake方式安装编译. ...

最新文章

  1. 完整的Python 3和树莓Pi大师课 Complete Python 3 and Raspberry Pi Masterclass
  2. 2021年全新各方向IT职业技能图谱
  3. oracle+去括号,关于001 TK的几个问题,请大家一起讨论一下
  4. Spring MVC X-Frame-Options
  5. 【C++深度剖析教程14】经典问题解析三之关于赋值的疑问
  6. oracle推式任务发料,Oracle EBS物料清单管理系统简介.pptx
  7. Introduction to Microservices
  8. 为何要进行软件维护?维护的种类及目标?
  9. 引用类型和值类型区别(一)
  10. 11-411/611NLP Lecture 4.Words and Morphology
  11. 孪生网络图像相似度_Siamese network 孪生神经网络一个简单神奇的结构
  12. java角色权限设计
  13. QTcpSocket实现客户端
  14. java 生成纯色图片_浅谈Java设置PPT幻灯片背景——纯色、渐变、图片背景
  15. 智课雅思词汇---九、mon是什么意思
  16. 优秀开源项目之二:流媒体直播系统Open Broadcaster Software
  17. 2-《电子入门趣谈》第一章_一切从单片机开始-1.1单片机概述
  18. xp下电脑关机超级慢
  19. vscode如何打开html
  20. 汉字拼音的一个解决方法(初具使用价值)

热门文章

  1. 微信端解决a标签链接 失效的问题
  2. linux系统下的ip分片程序,Linux下IP分片与重组
  3. 基于stm32f103红外遥控美的空调
  4. pku1222(高斯消元1)
  5. 网络技能大赛云平台部分-JCOS创建用户
  6. SQL进阶之EXISTS谓词的用法
  7. 【华为机试真题 Python实现】2022年4季度最新机试题
  8. JavaWeb Servlet遇到的问题Artifact Servlet06:war exploded: Error during artifact deployment
  9. linux magento,linux开发magento2 常用命令
  10. CBNData数据盛典:理性数据+感性消费透视中国互联网商业