From 25eb4692034aed3dede8e15684e75956578a4b75 Mon Sep 17 00:00:00 2001 From: Siegfried Kienzle Date: Thu, 15 Jun 2017 18:22:49 +0200 Subject: [PATCH] add thread for rfid_reader --- project/rfid/rfid_reader.cpp | 8 ++++---- project/rfid/rfid_reader.hpp | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/project/rfid/rfid_reader.cpp b/project/rfid/rfid_reader.cpp index 664aa43..86d1f86 100644 --- a/project/rfid/rfid_reader.cpp +++ b/project/rfid/rfid_reader.cpp @@ -2,14 +2,12 @@ #include #include #include -#include #include rfid_reader::rfid_reader() { - mfrc.PCD_Init(); - loop(); - std::this_thread::sleep_for(1s); + mfrc.PCD_Init(); + thread = std::thread(&rfid_reader::loop, this); } uint32_t rfid_reader::last_id() const @@ -43,5 +41,7 @@ void rfid_reader::loop() printf("%X\n", last_id()); #endif + std::this_thread::sleep_for(1s); + } } diff --git a/project/rfid/rfid_reader.hpp b/project/rfid/rfid_reader.hpp index 41aa968..d950345 100644 --- a/project/rfid/rfid_reader.hpp +++ b/project/rfid/rfid_reader.hpp @@ -2,6 +2,7 @@ #define RFIDREADER_HPP_ #include +#include #include "MFRC522.h" @@ -17,6 +18,7 @@ public: private: MFRC522 mfrc; uint32_t uid; + std::thread thread; };