TScript:send Command

From TouchDesigner 099 Wiki


send [-d | -o | -h | -s typetag(s) OSCAddress] [-r] [-n] [-z] [-x] [-p datpath] path value1 value2...

This will output a string of one or more bytes to a communication DAT. The bytes can either be individually specified for binary communication, or one or more strings of ASCII characters.

When specifying binary data, the values can be specified as decimal values, hexadecimal values, or octal values. The convertbase() expression can also be used to convert values from one base to another.

When sending a string of ASCII characters, unless another terminating character is specified, a null character will be appended to the sent data. You can override this with the -x option.

This command will work with the following DATs:

For connectionless network protocols such as UDP, the * In nodes will only be able to send a reply once they have received a message from the Out node.

When working with binary data, it is best to set incoming format of the communication DAT to One Row Per Byte and turn on the Value column. The Message column will simply be an ASCII representation of the data. The Value column, however will contain the decimal representation of each byte received. So for example, if the bytes returned were hex 03 and hex 0F, under the Value column you would see the values 3 and 15, as those are the decimal values of those bytes, respectively.


Options

-d Treat values as series of decimal values.
-o Treat values as series of octal values.
-h Treat values as series of hex values.
-r Append a carriage return to the string.
-n Append a line feed to the string.
-z Append a zero (null character) to the string. This is done automatically for strings when no other terminating charcter is specified nor OSC format is specifed.(-o, -h, -s etc.)
-x Disables automatically appending a null character to strings.
-s typetag OSCAddress Treat values as parameters to an OSC message. You can specify multiple tags to match up with multiple values to send

The following types are recognized:

  • f float
  • i integer
  • s string
  • ? automatic (replaced by s,f or i)
-p datpath Send the contents of the specified DAT. When sending the contents of a table DAT and sending as bytes, each cell of the table is parsed into individual bytes, else each cell of the table is separated by a space and each row is terminated by the specified terminator character. (This does not apply to OSC formatted messages.)

Examples

send -d /project1/serial1 65 66 67

will output three binary values: 65, 66 and 67. This is equivalent to sending 3 ASCII characters: "ABC"

send -h /project1/serial1 41	

will output a single hexadecimal value of hex 41. This is equivalent to sending ASCII character "A" or decimal value 65.

send -z /project1/tcpipout1 "ABC"

will output "ABC\0". Note the null character send at the end of the string.

send    /project1/tcpipout1 A B

will output two bytes ASCII characters "A" and ASCII character "B"

send -p text1 tcpipout1

wil output the contents of DAT text1 text1.

send -p table1 tcpipout1	

will output all of table1 (columns will be separated by spaces)

send -z -p table1 tcpipout1

will output all of table1 with a null character after each row


OSC Examples:

output a float, string and integer as an OSC message to OSC address "/abc"

send -s fsi /abc udpout1 0.5 apple 3

same as above, but automatically specify the parameters

send -s ? /abc  udpout1 0.5 apple 3

parameters are a string followed by a one or more floats

send -s sf /abc  udpout1 apple 1.0 2 3 4.5 6.7