www.webdeveloper.com
Results 1 to 6 of 6

Thread: Get info from the "str"

  1. #1
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    6

    Get info from the "str"

    Hello.

    I have this function and I need to know what there is in the "str"
    -------------
    function sendPut(str, content) {
    var xhr = new XMLHttpRequest();
    xhr.open("PUT", "http://" + ipPort + "/" + str);
    xhr.send(content);
    }
    --------
    I haver tried
    document.writeln( str );
    and
    document.getElementById
    in different ways but not got any "str" data on my website.

    Anybody know ??

    MagI

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,356
    Although I don't think your function will work, you can see the value of 'str' (if it is displayable) with an 'alert()' function
    Code:
    function sendPut(str, content) {  alert('Contents of "str": '+str);
      var xhr = new XMLHttpRequest();
      xhr.open("PUT", "http://" + ipPort + "/" + str);
      xhr.send(content);
    }
    BTW, you should enclose your code between [ code] and [ /code] tags (without the spaces)
    to make it easier to see your question. It also retains formatting of indentation, if any.

  3. #3
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    6
    --
    Hi.

    The sendPut function work.
    It is a working android code by google and it is called "Cellbots"
    http://www.cellbots.com/
    http://goo.gl/qKs4p
    Here is the code
    http://code.google.com/p/cellbots/so...ava%2Fcellbots
    And here is the index.html code with my function.
    http://code.google.com/p/cellbots/so...ets/index.html


    The code "alert('Contents of "str": '+str);" worked almost.
    It alert "command.php" from the "sendAction" function.
    The command.php have this wiki.
    http://code.google.com/p/cellbots/so...mentation.wiki

    But I need to know what is in the "str"
    It is supposed to be a mailbox message using message wrapping and have this kind of structure
    ----------------
    * Byte 0: 0x80 (direct command with no response from the NXT)
    * Byte 1: 0x09 (message command type)
    * Byte 2: 0x01 (Mailbox number, 0-9)
    * Byte 3: Message Size (including null terminating character)
    * Byte 4-N: Message data, where N = Message size + 3 and ends with a null terminating character
    -----------------

    http://goo.gl/PiqRI
    You can read about the message wrapping in PDF Appendix 3 / page 9.

    Thanks for your input but this is a hard one.

    Is it possible to get the data out of the command.php ?

    Regards Magnus
    --

  4. #4
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,356
    This must be something special on the site as normal JS would need a server to put the information to.
    I'm assuming google is providing this space for you.

    Have you alerted the 'content', similar to the command for the 'str'.
    It may have special code that make it unreadable with ASCII characters.

  5. #5
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    6
    --

    The "cellbots" app make the phone work as a network camera server so the index.html / sendPut send the command to the phone
    and then it is transferred to the lego mindstorm nxt robot by bluetooth.


    I tried to change "str" to "content"

    Code:
    function sendPut(str, content) {
            alert('Contents of "content": '+content);
            var xhr = new XMLHttpRequest();
            xhr.open("PUT", "http://" + ipPort + "/" + str);
            xhr.send(content);
        }
    And the alert wrote the key commands f/b/l/r and so on.

    So the "str" that give the "command.php" is the best candidate.

    There should be some way to get the info from the command.php.

    Any suggestion anytime is gladly received.



    Regards MagI

    --

  6. #6
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    6
    --

    So I guess it activates the phone server to receive a command by the

    http://" + ipPort + "/" + command.php
    and then send the content = "f" or "b" or "l" or "r"
    and it is in the phone the content is made to a mailbox message using message wrapping and have this kind of structure
    ----------------
    * Byte 0: 0x80 (direct command with no response from the NXT)
    * Byte 1: 0x09 (message command type)
    * Byte 2: 0x01 (Mailbox number, 0-9)
    * Byte 3: Message Size (including null terminating character)
    * Byte 4-N: Message data, where N = Message size + 3 and ends with a null terminating character
    -----------------

    I have tried to find the command.php file in the cellbots files but have had no luck.
    Maybe the command.php is in the android files?

    What do you think?

    Regards MagI

    --

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles