NetXMS Support Forum  
July 30, 2010, 04:07:54 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Binary packages for you favorite OS / Distribution. Which OS should go first? Help us decide!
 
   Home   Help Search Tags Login Register  
Pages: 1 [2]
  Print  
Author Topic: problem with development  (Read 2282 times)
Victor Kirhenshtein
Lead Developer
Administrator
Hero Member
*****
Posts: 1431


View Profile
« Reply #15 on: December 09, 2009, 12:43:52 pm »

You don't need command 0x0097 to read information from agent. You should use CMD_GET_PARAMETER (0x0041) and set name of the parameter to variable VID_PARAMETER (85). Agent will reply with command CMD_REQUEST_COMPLETED (0x001D). First, check variable VID_RCC (28). If it contains 0, then value of requested parameter will be in variable VID_VALUE (21). For example:

CSCPMessage msg;

msg.SetCode(CMD_GET_PARAMETER);
msg.SetId(requestId);
msg.SetVariable(VID_PARAMETER, "Agent.Version");

<send message and get response into CSCPMessage *response>

DWORD rcc = response->GetVariableLong(VID_RCC);
if (rcc == ERR_SUCCESS)
{
   char buffer[256];
   response->GetVariableStr(VID_VALUE, buffer, 256);
   // Now buffer contains value of requested parameter
}

Best regards,
Victor
Logged
ophelie6989
Newbie
*
Posts: 21


View Profile
« Reply #16 on: December 22, 2009, 06:56:20 pm »

Thank you, i have tried what you told me. For the reception of a message from the agent i have done that:


CSCPMessage *pMsg2=new CSCPMessage(); //classe
   CSCP_MESSAGE *pRawMsg2;//structure
   CSCP_BUFFER *pMsgBuffer;//structure buffer
   
   int iErr;
   TCHAR szBuffer[128];

 
   // Initialize raw message receiving function
   pMsgBuffer = (CSCP_BUFFER *)malloc(sizeof(CSCP_BUFFER));
   RecvNXCPMessage(socketId, pRawMsg2, pMsgBuffer, RECEIVER_BUFFER_SIZE,0,0,0);
   
   // Allocate space for raw message
   pRawMsg2 = (CSCP_MESSAGE *)malloc(RECEIVER_BUFFER_SIZE);
   pMsg2 = new CSCPMessage(pRawMsg2);
 
   
   DWORD rcc = pMsg2->GetVariableLong(VID_RCC);
 
   if (rcc == ERR_SUCCESS)
    {
       
        char buffer[256];
       
       pMsg2->GetVariableStr(VID_VALUE, buffer, 256);
       // Now buffer contains value of requested parameter
       
          int compteur;
        for(compteur=0;compteur<256;compteur++)
        {
    
                printf("%c\n",buffer[compteur]);
    
            }//fin du for
       
       
    }// fin if


But i always don t managed to read informations. I have done a prinft  to see what informations are in the buffer but when i compiled nothing appeared in the buffer.
What do i have to do in order to see the informations that i received from the Agent
Logged
Victor Kirhenshtein
Lead Developer
Administrator
Hero Member
*****
Posts: 1431


View Profile
« Reply #17 on: December 25, 2009, 12:18:18 pm »

You have missed code for actual message reception. Instead of

Code:
// Initialize raw message receiving function
pMsgBuffer = (CSCP_BUFFER *)malloc(sizeof(CSCP_BUFFER));
RecvNXCPMessage(socketId, pRawMsg2, pMsgBuffer, RECEIVER_BUFFER_SIZE,0,0,0);

// Allocate space for raw message
pRawMsg2 = (CSCP_MESSAGE *)malloc(RECEIVER_BUFFER_SIZE);
pMsg2 = new CSCPMessage(pRawMsg2);

you should have something like

Code:
// Initialize raw message receiving function
pMsgBuffer = (CSCP_BUFFER *)malloc(sizeof(CSCP_BUFFER));
RecvNXCPMessage(0, NULL, pMsgBuffer, RECEIVER_BUFFER_SIZE,0,0,0);

CSCP_ENCRYPTION_CONTEXT *nullContext = NULL;
pRawMsg2 = (CSCP_MESSAGE *)malloc(RECEIVER_BUFFER_SIZE);
RecvNXCPMessage(socketId, pRawMsg2, pMsgBuffer, RECEIVER_BUFFER_SIZE,&nullContext,NULL,0);
pMsg2 = new CSCPMessage(pRawMsg2);

Best regards,
Victor
Logged
ophelie6989
Newbie
*
Posts: 21


View Profile
« Reply #18 on: January 04, 2010, 06:19:54 pm »

Hi, thank you and Happy New Year!!
I have done what you said to me but the message send from the agent didn t work again.

I have that:
-----------Envoi du message a l agent-----------
code du message : A

-----------Reception du message de l agent-----------
¨

When i send CMD_GETPAREMETER, i receive ".." with the code that i show you previously.

How can i do to see the parameters?

Thank you again
Logged
Victor Kirhenshtein
Lead Developer
Administrator
Hero Member
*****
Posts: 1431


View Profile
« Reply #19 on: January 08, 2010, 04:12:55 pm »

Hello!

Did you set VID_PARAMETER variable before sending CMD_GET_PARAMETER request? You should have something like

msg.SetVariable(VID_PARAMETER, "Agent.Version");

before converting message into binary format and sending. Also, check VID_RCC variable in response message - may be it contains error.

Best regards,
Victor
Logged
Tags:
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!