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

代碼片段和文件信息
/*
?*?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;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????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
- 上一篇:c語言圖形學鼠標點擊畫橢圓
- 下一篇:利用MFC實現簡單的住房系統
評論
共有 條評論