-
-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(CSerialPortHotPlugTest): add CSerialPortHotPlugTest
- Loading branch information
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#*************************************************************************** | ||
# @file CMakeLists.txt | ||
# @author itas109 (itas109@qq.com) \n\n | ||
# Blog : https://blog.csdn.net/itas109 \n | ||
# Github : https://github.com/itas109 \n | ||
# Gitee : https://gitee.com/itas109 \n | ||
# QQ Group : 129518033 | ||
# @brief Lightweight cross-platform serial port library based on C++ | ||
# @copyright The CSerialPort is Copyright (C) 2014 itas109 <itas109@qq.com>. | ||
# You may use, copy, modify, and distribute the CSerialPort, under the terms | ||
# of the LICENSE file. | ||
############################################################################ | ||
|
||
cmake_minimum_required(VERSION 2.8.12) | ||
|
||
project(CSerialPortHotPlug) | ||
|
||
set(CSerialPortRootPath "${CMAKE_CURRENT_SOURCE_DIR}/../..") | ||
include_directories(${CSerialPortRootPath}/include) | ||
|
||
add_executable( ${PROJECT_NAME} CSerialPortHotPlugTest.cpp ) | ||
|
||
if (WIN32) | ||
target_link_libraries( ${PROJECT_NAME} user32) | ||
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 () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdio.h> | ||
|
||
#include "CSerialPort/SerialPortHotPlug.hpp" | ||
|
||
class MyListener : public itas109::CSerialPortHotPlugListener | ||
{ | ||
public: | ||
MyListener(){} | ||
|
||
void onHotPlugEvent(const char *portName, int isAdd) | ||
{ | ||
printf("portName: %s, isAdded: %d\n", portName, isAdd); | ||
} | ||
}; | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
MyListener listener; | ||
|
||
itas109::CSerialPortHotPlug m_serialPortHotPlug; | ||
m_serialPortHotPlug.connectHotPlugEvent(&listener); | ||
printf("CSerialPortHotPlug...\n"); | ||
|
||
while (true); | ||
|
||
return 0; | ||
} |