This document outlines the different character formats that can be used the in the
Serial, USB HID, Socket Client,
Socket Server, Execute,
and Write Text modules. All of these modules have the ability to
specify a custom string of characters to either transmit or to be used as incoming data that is
to be parsed into variables. Because there are many ways this data can be represented other
than just using straight text there are many escape symbols that can be used to achieve
different variable parsing.
The default string sequence used in all the sequence entry boxes is ASCII text. To modify ASCII text to
become a binary version of the string
sequence you can use the modifier '\' similar to the C/C++ syntax. For example the hexadecimal string :
would transmit 15 15 8 64 184 4 as single byte binary numbers to the device. While the text string
would transmit the ASCII codes 48 102 48 102 48 56 52 48 etc. as single byte numbers to the device. Also the octal
would transmit 4 8 36 as single byte numbers to the device.
Variables can also be included using  to surround the text. Thus
would transmit the binary values (note the '\' before the '[') for left and right variables)
to an SSC type device.
A single '\' will transmit a single byte that represents the variable value. In some cases you want to
send a much larger number. In that case double the '\' using something like
which would transmit a total of 8 bytes (4 bytes per number) that represents an integer 32 bits per value.
If your receiving device uses a different byte order than a PC you can use the division slash to
instead reverse the order of the bytes. For example if the left_motor variable used above
has a value of 66 then
would send the four bytes as 66 0 0 0 whereas
would send the four bytes as 0 0 0 66.
Other special characters worth noting are
<lf> translates to a line feed ASCII code 10
<cr> translates to a carriage return ASCII code 13
<tab> translates to a tab ASCII code 9
To learn more about what expressions can be contained with 's please refer to
the Expressions page.
To receive data in a specific format you would type in the known letters/numbers that would be expected
interlaced with formatting codes that specify how unknown parts are to be read in. This allows you to
specify a format string that indicates how incoming data is to be parsed and ensure that the
expected format is actually seen. For example, you would use something like
which would read binary numbers delimited by a ':' and ended with \r into the two variables binary_input_1
and binary_input_2. But
would read in two ASCII numbers into the two variables.
For ARRAYS such as CIRCLES generated by the Circle shape finder the format of the data will include as
the first number the size of the array. For example in the send sequence if you use:
the text sent will be something like:
where 65 is the total number of numbers (not all are included in this example) of the array. Note that
the size for the CIRCLES array should always be 65 mod 13 = 0.
For binary data if you use
the data sent will be something like:
Note that all numbers are 4 bytes long (due to the double \\ usage) with least significant byte first.
You can also send images as RGB triplet or a single gray (green value) of the
current image. You do this by inserting
into the send text stream. That command will be replaced with the current image. Note that you may
want to include the image dimensions before sending the image unless you always expect an exact size.
- [variable] - send/receive a variable as ascii text. See Expressions that show more about variable calculations.
- \\[variable] - send/receive a 4 byte binary value (intel format)
- //[variable] - send/receive a 4 byte binary value (mac format)
- \[variable] - send/receive a single byte binary value
- \b[variable] - send/receive a single byte binary value
- \w[variable] - send/receive a two byte binary value
- \d[variable] - send/receive a four byte binary integer value
- \f[variable] - send/receive a four byte binary float/decimal value
- \F[variable] - send/receive an eight byte binary float/decimal value
- \5[variable] - receive an 5 byte text string (replace 5 with appropriate number)
- \i[variable] - send variable value as an integer ascii string
- \x0f - send a hexidecimal byte value (15 in this case)
- \x0f0f - send a hexidecimal two byte value (3855 in this case)
- \o11 - send a octal byte value (9 in this case)
- \o1234 - send a octal two byte value (668 in this case)
- [[ - send a '[' single character without parsing for any variables
- \\ - send a '\' single character without parsing for escape characters
- <gray_image> - send current image as single gray channel
- <rgb_image> - send current image as RGB triplet
- <cr> - send/receive a carriage return (decimal 13, hex 0D)
- <lf> - send/receive a line feed (decimal 10, hex 0A)
- <tab> - send/receive a tab (decimal 9, hex 09)
- <sp> - send/receive a space (decimal 32, hex 20)
|Text_Formats Related Forum Posts||Last post||Posts||Views|