problem with development

Started by ophelie6989, November 17, 2009, 06:52:50 PM

Previous topic - Next topic

Victor Kirhenshtein

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

ophelie6989

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

Victor Kirhenshtein

You have missed code for actual message reception. Instead of


// 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


// 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

ophelie6989

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

Victor Kirhenshtein

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