more debug packet msgs

main
Tom Early 4 years ago
parent 69228ee3fe
commit 4a8066bd53

@ -109,17 +109,29 @@ void CController::ReadReflectorThread()
switch (packet->GetCodecIn()) switch (packet->GetCodecIn())
{ {
case ECodecType::dstar: case ECodecType::dstar:
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Ref packet to dstar device:");
#endif
add_dst_mux.lock(); add_dst_mux.lock();
dstar_device.AddPacket(packet); dstar_device.AddPacket(packet);
add_dst_mux.unlock(); add_dst_mux.unlock();
break; break;
case ECodecType::dmr: case ECodecType::dmr:
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Ref packet to dmr device:");
#endif
add_dmr_mux.lock(); add_dmr_mux.lock();
dmr_device.AddPacket(packet); dmr_device.AddPacket(packet);
add_dmr_mux.unlock(); add_dmr_mux.unlock();
break; break;
case ECodecType::c2_1600: case ECodecType::c2_1600:
case ECodecType::c2_3200: case ECodecType::c2_3200:
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Ref packet to Codec2 vocoder:");
#endif
c2_mux.lock(); c2_mux.lock();
codec2_queue.push(packet); codec2_queue.push(packet);
c2_mux.unlock(); c2_mux.unlock();
@ -155,6 +167,10 @@ void CController::AudiotoCodec2(std::shared_ptr<CTranscoderPacket> packet)
} }
// put the M17 data into the packet // put the M17 data into the packet
packet->SetM17Data(m17data); packet->SetM17Data(m17data);
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Encoded M17:");
#endif
// we might be all done... // we might be all done...
if (packet->AllCodecsAreSet()) if (packet->AllCodecsAreSet())
{ {
@ -210,6 +226,10 @@ void CController::Codec2toAudio(std::shared_ptr<CTranscoderPacket> packet)
add_dmr_mux.lock(); add_dmr_mux.lock();
dmr_device.AddPacket(packet); dmr_device.AddPacket(packet);
add_dmr_mux.unlock(); add_dmr_mux.unlock();
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Sent to both dstar and dmr device:");
#endif
} }
void CController::ProcessC2Thread() void CController::ProcessC2Thread()
@ -251,9 +271,10 @@ void CController::SendToReflector(std::shared_ptr<CTranscoderPacket> packet)
// send the packet over the socket // send the packet over the socket
socket.Send(packet->GetTCPacket()); socket.Send(packet->GetTCPacket());
// the socket will automatically close after sending // the socket will automatically close after sending
//#ifdef DEBUG #ifdef DEBUG
//AppendWave(packet); if (packet->IsLast())
//#endif Dump(packet, "Sent to reflector:");
#endif
} }
void CController::RouteDstPacket(std::shared_ptr<CTranscoderPacket> packet) void CController::RouteDstPacket(std::shared_ptr<CTranscoderPacket> packet)
@ -264,6 +285,10 @@ void CController::RouteDstPacket(std::shared_ptr<CTranscoderPacket> packet)
add_dmr_mux.lock(); add_dmr_mux.lock();
dmr_device.AddPacket(packet); dmr_device.AddPacket(packet);
add_dmr_mux.unlock(); add_dmr_mux.unlock();
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Routed to dmr:");
#endif
} }
else if (packet->AllCodecsAreSet()) else if (packet->AllCodecsAreSet())
{ {
@ -280,6 +305,10 @@ void CController::RouteDmrPacket(std::shared_ptr<CTranscoderPacket> packet)
add_dst_mux.lock(); add_dst_mux.lock();
dstar_device.AddPacket(packet); dstar_device.AddPacket(packet);
add_dst_mux.unlock(); add_dst_mux.unlock();
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Routed to dstar:");
#endif
} }
else if (packet->AllCodecsAreSet()) else if (packet->AllCodecsAreSet())
{ {
@ -322,54 +351,29 @@ void CController::AppendM17(const std::shared_ptr<CTranscoderPacket> packet) con
void CController::Dump(const std::shared_ptr<CTranscoderPacket> p, const std::string &title) const void CController::Dump(const std::shared_ptr<CTranscoderPacket> p, const std::string &title) const
{ {
std::string codec; std::stringstream line;
switch (p->GetCodecIn()) line << title << ": Mod='" << p->GetModule() << "' SID=" << std::showbase << std::hex << ntohs(p->GetStreamId()) << std::noshowbase;
{
case ECodecType::dstar: ECodecType in = p->GetCodecIn();
codec.assign("DStar"); if (p->DStarIsSet())
break; line << " D-Star";
case ECodecType::dmr: if (ECodecType::dstar == in)
codec.assign("DMR"); line << '*';
break; if (p->DMRIsSet())
case ECodecType::c2_1600: line << " DMR";
codec.assign("C2-1600"); if (ECodecType::dmr == in)
break; line << '*';
case ECodecType::c2_3200: if (p->M17IsSet())
codec.assign("C2-3200"); line << " M17";
break; if (ECodecType::c2_1600 == in)
default: line << "**";
codec.assign("NONE"); else if (ECodecType::c2_3200 == in)
break; line << '*';
}
std::cout << title << ": Module='" << p->GetModule() << "' Stream ID=" << std::showbase << std::hex << ntohs(p->GetStreamId()) << std::noshowbase << " Codec in is " << codec;
if (p->IsSecond()) if (p->IsSecond())
std::cout << " IsSecond"; line << " IsSecond";
if (p->IsLast()) if (p->IsLast())
std::cout << " IsLast"; line << " IsLast";
std::cout << std::endl;
std::cout << line.str() << std::dec << std::endl;
// if (p->DStarIsSet())
// {
// std::cout << "DStar data: ";
// for (unsigned int i=0; i<9; i++)
// std::cout << std::setw(2) << std::setfill('0') << unsigned(*(p->GetDStarData()+i));
// std::cout << std::endl;
// }
// if (p->DMRIsSet())
// {
// std::cout << "DMR Data: ";
// for (unsigned int i=0; i<9; i++)
// std::cout << std::setw(2) << std::setfill('0') << unsigned(*(p->GetDMRData()+i));
// std::cout << std::endl;
// }
// if (p->M17IsSet())
// {
// std::cout << "M17 Data: ";
// for (unsigned int i=0; i<16; i++)
// std::cout << std::setw(2) << std::setfill('0') << unsigned(*(p->GetM17Data()+i));
// std::cout << std::endl;
// }
std::cout << std::dec;
} }
#endif #endif

@ -38,7 +38,7 @@
extern CController Controller; extern CController Controller;
CDV3003::CDV3003(Encoding t) : type(t), fd(-1), ch_depth(0), sp_depth(0), current_vocoder(0) CDV3003::CDV3003(Encoding t) : type(t), fd(-1), ch_depth(0), sp_depth(0)
{ {
} }
@ -138,14 +138,14 @@ bool CDV3003::OpenDevice(const std::string &ttyname, int baudrate)
if (SetBaudRate(baudrate)) if (SetBaudRate(baudrate))
return true; return true;
#ifdef DEBUG #ifdef DEBUG
std::cout << ttyname << " baudrate it set to " << baudrate << std::endl; std::cout << ttyname << " baudrate it set to " << baudrate << std::endl;
#endif #endif
devicepath.assign(ttyname); devicepath.assign(ttyname);
#ifdef DEBUG #ifdef DEBUG
std::cout << "Opened " << devicepath << " using fd " << fd << std::endl; std::cout << "Opened " << devicepath << " using fd " << fd << std::endl;
#endif #endif
if (InitDV3003()) if (InitDV3003())
return true; return true;
@ -183,9 +183,9 @@ bool CDV3003::InitDV3003()
std::cerr << "InitDV3003: invalid response to reset" << std::endl; std::cerr << "InitDV3003: invalid response to reset" << std::endl;
return true; return true;
} }
#ifdef DEBUG #ifdef DEBUG
std::cout << "Successfully reset " << devicepath << std::endl; std::cout << "Successfully reset " << devicepath << std::endl;
#endif #endif
// ********** turn off parity ********* // ********** turn off parity *********
ctrlPacket.header.payload_length = htons(4); ctrlPacket.header.payload_length = htons(4);
@ -211,9 +211,9 @@ bool CDV3003::InitDV3003()
return true; return true;
} }
#ifdef DEBUG #ifdef DEBUG
std::cout << "Successfully disabled parity on " << devicepath << std::endl; std::cout << "Successfully disabled parity on " << devicepath << std::endl;
#endif #endif
// ********* Product ID and Version ************* // ********* Product ID and Version *************
ctrlPacket.header.payload_length = htons(1); ctrlPacket.header.payload_length = htons(1);
@ -313,9 +313,9 @@ bool CDV3003::ConfigureVocoder(uint8_t pkt_ch, Encoding type)
dump("Configuration response was:", &responsePacket, sizeof(responsePacket)); dump("Configuration response was:", &responsePacket, sizeof(responsePacket));
return true; return true;
}; };
#ifdef DEBUG #ifdef DEBUG
std::cout << devicepath << " channel " << (unsigned int)(pkt_ch - PKT_CHANNEL0) << " is now configured for " << ((Encoding::dstar == type) ? "D-Star" : "DMR") << std::endl; std::cout << devicepath << " channel " << (unsigned int)(pkt_ch - PKT_CHANNEL0) << " is now configured for " << ((Encoding::dstar == type) ? "D-Star" : "DMR") << std::endl;
#endif #endif
return false; return false;
} }
@ -377,6 +377,7 @@ bool CDV3003::GetResponse(SDV3003_Packet &packet)
void CDV3003::FeedDevice() void CDV3003::FeedDevice()
{ {
keep_running = true; keep_running = true;
uint8_t current_vocoder = 0;
while (keep_running) while (keep_running)
{ {
in_mux.lock(); in_mux.lock();
@ -422,6 +423,7 @@ void CDV3003::FeedDevice()
SendAudio(current_vocoder, packet->GetAudio()); SendAudio(current_vocoder, packet->GetAudio());
sp_depth++; sp_depth++;
#ifdef DEBUG #ifdef DEBUG
if (packet->IsLast())
std::cout << "Sent audio to " << devicepath << std::endl; std::cout << "Sent audio to " << devicepath << std::endl;
#endif #endif
} }

@ -116,7 +116,6 @@ private:
const Encoding type; const Encoding type;
int fd; int fd;
std::atomic<unsigned int> ch_depth, sp_depth; std::atomic<unsigned int> ch_depth, sp_depth;
uint8_t current_vocoder;
std::atomic<bool> keep_running; std::atomic<bool> keep_running;
CPacketQueue vocq[3]; // we need a queue for each vocoder CPacketQueue vocq[3]; // we need a queue for each vocoder
std::mutex voc_mux[3]; std::mutex voc_mux[3];

Loading…
Cancel
Save

Powered by TurnKey Linux.