資源簡(jiǎn)介
使用多線程進(jìn)行串口編程,獲取串口數(shù)據(jù),利用互斥鎖和信號(hào)量在不同的線程中安全地操作數(shù)據(jù),希望該demo能幫助你快速理解并掌握上述知識(shí)。

代碼片段和文件信息
/*
?*?DJI_Utility.cpp
?*
?*??Created?on:?2018年1月25日
?*??????Author:?yibin
?*/
#include?“DJI_Utility.hpp“
DJI_lock::DJI_lock()
{
pthread_mutex_init(?&m_lock?NULL?);
}
DJI_lock::~DJI_lock()
{
}
void?DJI_lock::enter()
{
pthread_mutex_lock(?&m_lock?);
}
void?DJI_lock::leave()
{
pthread_mutex_unlock(?&m_lock?);
}
DJI_event::DJI_event()
{
sem_init(?&m_sem?0?0?);
}
DJI_event::~DJI_event()
{
}
int?DJI_event::set_event()
{
int?ret?=?sem_post(?&m_sem?);
return?ret;
}
int?DJI_event::wait_event()
{
int?ret?=?sem_wait(?&m_sem?);
return?ret;
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????????441??2018-01-26?21:05??SerialinLinux.h
?????文件????????2843??2018-01-26?21:05??SerialinLinux.cpp
?????文件?????????193??2018-01-26?21:05??PrintBLH.hpp
?????文件?????????243??2018-01-26?21:05??PrintBLH.cpp
?????文件????????2353??2018-01-26?21:05??main.cpp
?????文件?????????400??2018-01-26?21:05??DJI_Utility.hpp
?????文件?????????562??2018-01-26?21:05??DJI_Utility.cpp
評(píng)論
共有 條評(píng)論