mirror of
https://github.com/nostar/urfd.git
synced 2026-11-08 04:19:39 +00:00
M17 Packet sending a DEBUG help
This commit is contained in:
1 parent
d3a72ec0c4
commit
1a6b3291f7
3 files changed
+50
No files matched your search
@@ -248,6 +248,9 @@ void CM17Protocol::HandleQueue(void)
|
||||
else if ( packet->IsDvFrame() )
|
||||
{
|
||||
EncodeM17Packet(frame, m_StreamsCache[module].m_dvHeader, (CDvFramePacket &)*packet.get(), m_StreamsCache[module].m_iSeqCounter++);
|
||||
#ifdef DEBUG
|
||||
Dump("Last M17 Packet:", frame.magic, sizeof(SM17Frame));
|
||||
#endif
|
||||
}
|
||||
|
||||
// push it to all our clients linked to the module and who are not streaming in
|
||||
|
||||
@@ -336,3 +336,46 @@ void CProtocol::Send(const char *buf, const CIp &Ip, uint16_t port) const
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void CProtocol::Dump(const char *title, const uint8_t *data, int length)
|
||||
{
|
||||
std::cout << title << std::endl;
|
||||
|
||||
unsigned int offset = 0U;
|
||||
|
||||
while (length > 0) {
|
||||
|
||||
unsigned int bytes = (length > 16) ? 16U : length;
|
||||
|
||||
for (unsigned i = 0U; i < bytes; i++) {
|
||||
if (i)
|
||||
std::cout << " ";
|
||||
std::cout << std::hex << std::setw(2) << std::right << std::setfill('0') << int(data[offset + i]);
|
||||
}
|
||||
|
||||
for (unsigned int i = bytes; i < 16U; i++)
|
||||
std::cout << " ";
|
||||
|
||||
std::cout << " *";
|
||||
|
||||
for (unsigned i = 0U; i < bytes; i++) {
|
||||
unsigned char c = data[offset + i];
|
||||
|
||||
if (::isprint(c))
|
||||
std::cout << c;
|
||||
else
|
||||
std::cout << '.';
|
||||
}
|
||||
|
||||
std::cout << '*' << std::endl;
|
||||
|
||||
offset += 16U;
|
||||
|
||||
if (length >= 16)
|
||||
length -= 16;
|
||||
else
|
||||
length = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -133,4 +133,8 @@ protected:
|
||||
|
||||
// debug
|
||||
CTimer m_DebugTimer;
|
||||
|
||||
#ifdef DEBUG
|
||||
void Dump(const char *title, const uint8_t *pointer, int length);
|
||||
#endif
|
||||
};
|
||||
Reference in new issue
Block a user