Menu

SendDirectCommand & no response package

Help
Nik Blu
2010-01-26
2013-04-25
  • Nik Blu

    Nik Blu - 2010-01-26

    Hi there,

    I have the following problem: When I send a direct command with NXT::SendDirectCommand, I get the following behaviour:
    a) when the response bool is set to TRUE: The command is executed, but no response package is written back into the buffer.
    b) when the response bool is set to FALSE: Command is not (seemingly?) executed and no response package is written back into the buffer (does not bother me that much but I still think it is strange that the command is not executed - at least not in the case of playing a sound (s. snippet).

    I used the following snippet to check functionality (connection already being established):
    //command buffer
    ViByte dc_buf = {0x02, FALSE, 'W','o','o','p','s','.','r','s','o','\0'}; //play woops sound once
    //Buffer for response
    ViByte re_buf={'\0'}; //MAX_MESSAGE_SIZE is set to 64
    ViBoolean response = TRUE;
    NXT::SendDirectCommand(&comm,response,dc_buf,sizeof(dc_buf),re_buf,sizeof(re_buf));
    //prepare response output
    std::wstringstream wsstr;
    wsstr << L"Byte0: 0x" << std::hex << re_buf << L" Byte1: 0x" << re_buf << L" Byte2: 0x" << re_buf<< L" Byte 3: 0x" << re_buf<< L" Byte 4: 0x" << re_buf;
    std::wstring wstr = wsstr.str();
    c_listout.InsertString(-1,wstr.c_str()); //c_listaout is just a listbox where I display my output
    Also, I observed the output buffer during runtime, it just stays as it was initialized. I also tried setting the response buffer to different sizes (3,4, 64, sizeof(…)) and initializing it with different chars as well as not initializing as well - to no avail, result is always the same.
    I do not know if it matters but I am using a Bluetooth connection (which itself seems to work fine) which is always on Port 0.

    I am working with Windows XP SP3, VS2008 Professional and use MFC, no CLR.

    Any idea what could cause the buffer not to be written into? I am thankful for every hint…

     
  • Nik Blu

    Nik Blu - 2010-01-26

    and  I use NXT++ version 0.6 of course :)

     
  • Nik Blu

    Nik Blu - 2010-01-27

    Hm, at least the problem b) is solved, I just forgot to set the response buffer to NULL and its size to 0.

    After continued research in the net I had the impression that the Bluetooth connection is responsible for the problem - in some forum I read that the standard NXT firmware drops any response per default. But I also tried the code above via USB connection and the problem remains -command is executed, though no response package…

     
  • Nik Blu

    Nik Blu - 2010-01-27

    Update: I replaced the line
    NXT::SendDirectCommand(&comm,response,dc_buf,sizeof(dc_buf),re_buf,sizeof(re_buf))
    with
    result = comm.nxtPtr->sendDirectCommand(TRUE, dc_buf, sizeof(dc_buf), re_buf, sizeof(re_buf),comm.status);
    and result is 3 after execution, meaning that 3 bytes have been written to the buffer. But the buffer remains in its initialized state. Starting to get desperate over here :(

     
  • Nik Blu

    Nik Blu - 2010-01-28

    I obviously forgot to mention the NXT version. I use NXT with Robolab2.9 and thus the Firmware Robolab 6.0C (i.e. 6.12).

     
  • Kami T

    Kami T - 2011-02-18

    I've had a similar problem when working directly with the fantom library, does anyone have a solution for this?

     

Log in to post a comment.