WiresX debugging

pull/1/head
Tom Early 5 years ago
parent 052cdfc6a5
commit b596ca7ee5

@ -49,7 +49,7 @@ CWiresxCmdHandler::CWiresxCmdHandler()
CWiresxCmdHandler::~CWiresxCmdHandler() CWiresxCmdHandler::~CWiresxCmdHandler()
{ {
// kill threads // kill thread
Close(); Close();
// empty queue // empty queue
@ -95,10 +95,12 @@ void CWiresxCmdHandler::Close(void)
void CWiresxCmdHandler::Thread() void CWiresxCmdHandler::Thread()
{ {
std::cout << "Starting WiresX Command Handler" << std:: endl;
while (keep_running) while (keep_running)
{ {
Task(); Task();
} }
std::cout << "WiresX Command Handler has stopped" << std::endl;
} }
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -120,7 +122,7 @@ void CWiresxCmdHandler::Task(void)
// any cmd in our queue ? // any cmd in our queue ?
if ( !m_CmdQueue.empty() ) if ( !m_CmdQueue.empty() )
{ {
// yes, get the command // yes, get a command
Cmd = m_CmdQueue.front(); Cmd = m_CmdQueue.front();
// check that the command is at least one second old // check that the command is at least one second old
// so that the so delayed processing of the command // so that the so delayed processing of the command
@ -148,7 +150,7 @@ void CWiresxCmdHandler::Task(void)
cModule = ' '; cModule = ' ';
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), PROTOCOL_YSF); std::shared_ptr<CClient>client = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), PROTOCOL_YSF);
if ( client != nullptr ) if ( client )
{ {
cModule = client->GetReflectorModule(); cModule = client->GetReflectorModule();
} }
@ -178,7 +180,7 @@ void CWiresxCmdHandler::Task(void)
// change client's module // change client's module
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), PROTOCOL_YSF); std::shared_ptr<CClient>client = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), PROTOCOL_YSF);
if ( client != nullptr ) if ( client )
{ {
client->SetReflectorModule(cModule); client->SetReflectorModule(cModule);
} }
@ -206,14 +208,14 @@ void CWiresxCmdHandler::Task(void)
break; break;
case WIRESX_CMD_UNKNOWN: case WIRESX_CMD_UNKNOWN:
default: default:
std::cout << "Wires-X non implemented command from " << Cmd.GetCallsign() << " at " << Cmd.GetIp() << std::endl; std::cout << "Wires-X non implemented command from " << Cmd.GetCallsign() << " at " << Cmd.GetIp() << " cmd=" << Cmd.GetCmd() << " arg=" << Cmd.GetArg() << std::endl;
break; break;
} }
} }
else else
{ {
// if nothing to do, sleep a bit // if nothing to do, sleep a bit
CTimePoint::TaskSleepFor(10); CTimePoint::TaskSleepFor(100);
} }
} }

@ -181,8 +181,7 @@ void CYsfProtocol::Task(void)
} }
else if ( IsValidwirexPacket(Buffer, &Fich, &Callsign, &iWiresxCmd, &iWiresxArg) ) else if ( IsValidwirexPacket(Buffer, &Fich, &Callsign, &iWiresxCmd, &iWiresxArg) )
{ {
//std::cout << "YSF Wires-x frame" << std::endl; std::cout << "Got a WiresX command from " << Callsign << " at " << Ip << " cmd=" <<iWiresxCmd << " arg=" << iWiresxArg << std::endl;
// prepare the cmd object
WiresxCmd = CWiresxCmd(Ip, Callsign, iWiresxCmd, iWiresxArg); WiresxCmd = CWiresxCmd(Ip, Callsign, iWiresxCmd, iWiresxArg);
// and post it to hadler's queue // and post it to hadler's queue
m_WiresxCmdHandler.GetCmdQueue()->push(WiresxCmd); m_WiresxCmdHandler.GetCmdQueue()->push(WiresxCmd);

Loading…
Cancel
Save

Powered by TurnKey Linux.