Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Test and Performance Tools Platform (TPTP) » sending command to agentcontroller
sending command to agentcontroller [message #94953] Wed, 04 April 2007 21:33 Go to next message
Natasha D'Silva is currently offline Natasha D'SilvaFriend
Messages: 25
Registered: July 2009
Junior Member
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 #95001 is a reply to message #94953] Thu, 05 April 2007 18:03 Go to previous messageGo to next message
Igor Alelekov is currently offline Igor AlelekovFriend
Messages: 139
Registered: July 2009
Senior Member
Hi, Natasha

I'll try your sample later.
But currently I don't see in your java client code by what means you
expect to get a responce from the agent.

Regards,
Igor
Re: sending command to agentcontroller [message #95017 is a reply to message #95001] Thu, 05 April 2007 18:35 Go to previous messageGo to next message
Natasha D'Silva is currently offline Natasha D'SilvaFriend
Messages: 25
Registered: July 2009
Junior Member
Hi,
I set up a simple handler as follows:
handler = new ICommandHandler(){
public void incomingCommand(INode node, ICommandElement command) {
System.out.println("Got a command");
System.out.println(command.getInterfaceID());
if (command instanceof ICommandFragment){
String data = ((ICommandFragment)command).getCommandData();
System.out.println(data);
}
}
And then,
agent.sendCommand("<message>this is a sample command</message>",
handler);

The above handler is able to receive the command returned by the agent, but
I still get the access violation error after returning from processCommand:
First-chance exception at 0x0033f662 in SampleAgent.exe: 0xC0000005: Access
violation writing location 0x00000004.
Unhandled exception at 0x0033f662 in SampleAgent.exe: 0xC0000005: Access
violation writing location 0x00000004.
"Igor Alelekov" <igor.alelekov@intel.com> wrote in message
news:8505199775fd4c6040ea80f3624ccf8d$1@www.eclipse.org...
> Hi, Natasha
>
> I'll try your sample later.
> But currently I don't see in your java client code by what means you
> expect to get a responce from the agent.
>
> Regards,
> Igor
>
Re: sending command to agentcontroller [message #95090 is a reply to message #95017] Mon, 09 April 2007 06:43 Go to previous messageGo to next message
Igor Alelekov is currently offline Igor AlelekovFriend
Messages: 139
Registered: July 2009
Senior Member
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
Re: sending command to agentcontroller [message #95153 is a reply to message #95090] Mon, 09 April 2007 15:15 Go to previous messageGo to next message
Natasha D'Silva is currently offline Natasha D'SilvaFriend
Messages: 25
Registered: July 2009
Junior Member
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
>
Re: sending command to agentcontroller [message #95198 is a reply to message #95153] Tue, 10 April 2007 10:47 Go to previous messageGo to next message
Igor Alelekov is currently offline Igor AlelekovFriend
Messages: 139
Registered: July 2009
Senior Member
Hi Natasha,
Could you submit your client and agent samples which generate an error?
Regards, Igor
Re: sending command to agentcontroller [message #96369 is a reply to message #95198] Wed, 18 April 2007 21:42 Go to previous message
Natasha D'Silva is currently offline Natasha D'SilvaFriend
Messages: 25
Registered: July 2009
Junior Member
Hi Igor,
Sorry for the delay in replying,
I am not getting that error anymore. I tried with my agent and added the
iid attribute and it seems to be working fine. Thanks.

"Igor Alelekov" <igor.alelekov@intel.com> wrote in message
news:279c2bd86cf9d97f6347b788eaf0779c$1@www.eclipse.org...
> Hi Natasha,
> Could you submit your client and agent samples which generate an error?
> Regards, Igor
>
Previous Topic:execution statistics TPTP 4.4
Next Topic:Unable to get SampleClient working on RHEL4 Linux-EM64T platform
Goto Forum:
  


Current Time: Tue Mar 19 11:05:13 GMT 2024

Powered by FUDForum. Page generated in 0.02705 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top