17 #ifndef SCIP2_RESPONSE_TIME_SYNC_H 18 #define SCIP2_RESPONSE_TIME_SYNC_H 20 #include <boost/asio.hpp> 43 using Callback = boost::function<void(
44 const boost::posix_time::ptime &,
55 return std::string(
"TM");
58 const boost::posix_time::ptime &time_read,
59 const std::string &echo_back,
60 const std::string &status,
67 cb_(time_read, echo_back, status, timestamp);
68 std::cout << echo_back <<
" errored with " << status << std::endl;
71 if (echo_back[2] ==
'1')
74 if (!std::getline(stream, stamp))
76 std::cerr <<
"Failed to get timestamp" << std::endl;
79 const uint8_t checksum = stamp.back();
83 std::cerr <<
"Wrong timestamp format" << std::endl;
88 auto it = dec.
begin();
90 if ((dec.getChecksum() & 0x3F) + 0x30 != checksum)
92 std::cerr <<
"Checksum mismatch" << std::endl;
97 cb_(time_read, echo_back, status, timestamp);
107 #endif // SCIP2_RESPONSE_TIME_SYNC_H
void registerCallback(Callback cb)
void operator()(const boost::posix_time::ptime &time_read, const std::string &echo_back, const std::string &status, std::istream &stream)
std::string getCommandCode() const
boost::function< void(const boost::posix_time::ptime &, const std::string &, const std::string &, const Timestamp &)> Callback