sending command to agentcontroller [message #94953] |
Wed, 04 April 2007 17:33  |
Eclipse User |
|
|
|
Hi all,
I am having some problems with sending a command to the agent controller,
there seems to be an error in BaseAgentImpl::sendCommand
I have an agent written in C++ and I attempt to send it a command through a
Java app with the agent controller using Agent.sendCommand(), as follows
INode node = NodeFactory.createNode("localhost");
.....
IAgentController agentController = node.getAgentController(10006);
IAgent agent = agentController.getAgent("testagent",
TPTPAgentAccess.TPTP_CONTROLLER_ACCESS);
agent.sendCommand("<message>this is a sample command</message>",
handler);
System.out.println("waiting for agent to process command");
Thread.sleep(3000);
agent.releaseAccess();
The main() method of the C++ agent creates an instance of the class,
registers with the Agent controller, and waits for termination, similar to
the TimeCollector example.
The agent receives the command fine, and tries to send a command back to the
agent controller. The AC never gets the command because there is a access
violation error in tptpUtils.dll that causes it to fail after it returns
from Agent::processCommand(CmdBlock *cmd):
int ok = BaseAgentImpl::processCommand(cmd);
if (ok == 0) {
printf("command handled by parent\n");
return 0; //Only send a response if the command is not recognized by
parent -
}
//Get a response ready
char *cmdTxt= "<Cmd src=\'%d\' dest=\'%d\'
ctxt=\'%d\'><message>Hi</message></Cmd>";
char finalCmd[1024];
sprintf(finalCmd, cmdTxt, getAgentID(),
cmd->getSourceID(),cmd->getContextID());
int returnCode = BaseAgentImpl::sendCommand(cmdTxt);
printf("sent response for command\n");
return returnCode;
I notice that I only get this error if BaseAgentImpl::sendCommand is called.
That is, if the command is handled by the parent, there is no error because
sendCommand is never called. I'm not sure if my syntax is incorrect. The
processCommand method exits but then the executable crashes shortly
afterwards.
I'm running the agent controller v 4.3.1, windows xp, c++ agent compiled
using Visual C++ v 7.1 java version 1.5.0_10
Any tips are appreciated, thanks.
|
|
|
|
|
|
Re: sending command to agentcontroller [message #95153 is a reply to message #95090] |
Mon, 09 April 2007 11:15   |
Eclipse User |
|
|
|
Hi Igor,
Thanks for the tip, but I have already tried adding the "iid" attribute to
the commands, both to the initial message and to the response. I also
thought that was the problem but after trying the iid I still get the same
error.
I looked at the TimeCollector.cpp example in the samples directory and
tested its processCommand method in the same way and it doesn't crash, and
I am able to receive a response from the time collector agent. I'm
wondering if it has to do with the supported interfaces defined in the
agent.xml or the access mode?
Could it also be the way my c++ code is compiled?
IAgent timeCollectorAgent =
agentController.getAgent("org.eclipse.tptp.TimeCollector",
"org.eclipse.tptp.platform.execution.client.agent.ICollector ",
TPTPAgentAccess.TPTP_CONTROLLER_ACCESS);
if (timeCollectorAgent != null){
((ICollector) timeCollectorAgent).run();
timeCollectorAgent.sendCommand("<getElapsedTime
iid=\"org.eclipse.tptp.TimeCollector\"></getElapsedTime>",handler);
}
Thanks,
Natasha
"Igor Alelekov" <igor.alelekov@intel.com> wrote in message
news:fdcd42b1d4f375d8c163fe3df0dafb59$1@www.eclipse.org...
> Hi Natasha,
> This is a bug, I opened bugzilla
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=181557 to track this defect.
>
> As a workaround try to add attribute "iid" in your commands, like this:
> <message iid="testagent">this is a sample command</message>.
> Regards,
> Igor
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03235 seconds