ITransport.cpp
Go to the documentation of this file.
00001 #include "ITransport.h"
00002 
00003 void ITransport::enableLogging(
00004     bool enable)
00005 {
00006   m_enableLogging = enable;
00007   if (m_enableLogging) {
00008     m_file.open("transport.log");
00009   } else {
00010     m_file.close();
00011   }
00012 }
00013 
00014 void ITransport::logPacket(
00015   const uint8_t* data,
00016   uint32_t length)
00017 {
00018     m_file << "sendPacket: ";
00019     for (size_t i = 0; i < length; ++i) {
00020         m_file << std::hex << (int)data[i] << " ";
00021     }
00022     if (length > 0) {
00023       uint8_t byte = data[0];
00024       int port = ((byte >> 4) & 0xF);
00025       int channel = ((byte >> 0) & 0x3);
00026       m_file << " (port: " << port << " channel: " << channel << ")";
00027     }
00028     m_file << std::endl;
00029 }
00030 
00031 void ITransport::logAck(
00032   const Ack& ack)
00033 {
00034     m_file << "received: ";
00035     for (size_t i = 0; i < ack.size; ++i) {
00036         m_file << std::hex << (int)ack.data[i] << " ";
00037     }
00038     m_file << std::endl;
00039 }


crazyflie_cpp
Author(s): Wolfgang Hoenig
autogenerated on Wed Jun 12 2019 19:20:44