HDLCd-Tools
HdlcdPacketDataPrinter.h
Go to the documentation of this file.
1 
22 #ifndef HDLCD_PACKET_DATA_PRINTER_H
23 #define HDLCD_PACKET_DATA_PRINTER_H
24 
25 #include <iostream>
26 #include <iomanip>
27 #include "HdlcdPacketData.h"
28 
29 void HdlcdPacketDataPrinter(const HdlcdPacketData& a_PacketData) {
30  // Print a hexdump of the provided data buffer. It should contain a packet to be printed in one line.
31  if (a_PacketData.GetWasSent()) {
32  std::cout << "<<< Sent: ";
33  } else {
34  std::cout << ">>> Rcvd: ";
35  } // else
36 
37  const std::vector<unsigned char> l_Buffer = a_PacketData.GetData();
38  for (auto it = l_Buffer.begin(); it != l_Buffer.end(); ++it) {
39  std::cout << std::hex << std::setw(2) << std::setfill('0') << int(*it) << " ";
40  } // for
41 
42  if (a_PacketData.GetWasSent() == false) {
43  if (a_PacketData.GetInvalid()) {
44  std::cout << "(BROKEN)";
45  } else {
46  std::cout << "(CRC OK)";
47  } // else
48  } // if
49 
50  std::cout << std::endl;
51 }
52 
53 #endif // HDLCD_PACKET_DATA_PRINTER_H
void HdlcdPacketDataPrinter(const HdlcdPacketData &a_PacketData)
const std::vector< unsigned char > & GetData() const
bool GetInvalid() const
bool GetWasSent() const
Copyright (c) 2016, Florian Evers, florian-evers@gmx.de All rights reserved.