8#ifndef DESIGNLAB_SERIAL_COMMUNICATION_THREAD_H_
9#define DESIGNLAB_SERIAL_COMMUNICATION_THREAD_H_
13#include <boost/thread.hpp>
45 std::vector<std::string>
GetReadData(
const int num)
const;
49 boost::mutex::scoped_lock lock(mutex_);
54 boost::mutex::scoped_lock lock(mutex_);
59 static constexpr float kThreadPeriod =
61 static constexpr int kBufferSize =
63 static constexpr int kComPortNumber = 3;
78 HANDLE serial_handle_{INVALID_HANDLE_VALUE};
80 std::vector<std::string> read_data_;
81 std::string write_data_;
83 bool end_flag_{
false};
85 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
シリアル通信で受信した文字列の中から指定した数だけ取得する. この時,排他制御を行う.