Setting binary values

As you might expect, setting a binary value into a speaker device for example is not more complex than reading it. To play a sound on Aibo, you could send to the server a command like this:

speaker = bin 54112 wav 2 16000 16;
..............54112 bytes..............

It is important that the header ends with a semicolon (and nothing else). The binary content starts immediately after the semicolon, so you don't have to add an extra carriage return.

Of course, as we already said it, this kind of binary assignment will obviously not be done from a telnet or URBIRemote client, since you probably want that a program sends the binary content, and you cannot type it yourself in the terminal! (However, we will see in the next section how you can simply play a recorded sound from a telnet client if you need to).

This simple example illustrates a binary assignment and a binary reading in URBI from a telnet client, however it is a "toy" example:

mybin = bin 3;ABC
mybin;
[146711] BIN 3
ABC

Note that you can pass any parameters after the size of the binary data and they will be stored together with the binary content, inside the header:

mybin = bin 3 hello world 33;ABC
mybin;
[146711] BIN 3 hello world 33
ABC

Do not confuse binary data and string data. The above example is different from:

mystring = "ABC";
mystring;
[148991] "ABC"