8#ifndef DESIGNLAB_SERIAL_COMMUNICATION_THREAD_H_
9#define DESIGNLAB_SERIAL_COMMUNICATION_THREAD_H_
14#include <boost/thread.hpp>
49 std::vector<std::string>
GetReadData(
const int num)
const;
54 boost::mutex::scoped_lock lock(mutex_);
60 boost::mutex::scoped_lock lock(mutex_);
65 static constexpr float kThreadPeriod = 0.01f;
66 static constexpr int kBufferSize = 1024;
67 static constexpr int kComPortNumber = 3;
82 HANDLE serial_handle_{ INVALID_HANDLE_VALUE };
84 std::vector<std::string> read_data_;
85 std::string write_data_;
87 bool end_flag_{
false };
89 mutable boost::mutex mutex_;
void SetWriteData(const std::string &str)
指定した文字列をシリアル通信で送信する. この時,排他制御を行う.
SerialCommunicationThread()=default
void EndThread()
シリアル通信のスレッドを終了する.
~SerialCommunicationThread()=default
std::string GetTopReadData() const
シリアル通信で受信した最新の文字列を取得する. この時,排他制御を行う.
std::vector< std::string > GetAllReadData() const
シリアル通信で受信した文字列を全て取得する. この時,排他制御を行う.
std::vector< std::string > GetReadData(const int num) const
シリアル通信で受信した文字列の中から指定した数だけ取得する. この時,排他制御を行う.