User Tools

Site Tools


dictionary:xtension:senddata

Send Data

Sends data directly to an interface. This is a dangerous verb and should be used only if you already know what you want to send and why.

Usage:

send data (text, a string that will be sent directly to the interface device)
OR
send data bytes (list of numbers, to be sent as bytes through to the device. see format note below)

interface (text, the name of the interface to which you want to send the data)

pause (optional number, the number of seconds to pause after sending this data before sending any more. Fractional seconds are supported.)

Bytes List Format

The bytes list can contain either decimal numbers such as {14, 10, 32, 64} or strings that are evaluated to individual bytes. Each string byte must be prefixed by the format string that tells XTension what format the number is in. If no format character is found it’s assumed to be decimal. Valid format prefixes are “&h” for hex “&h12”, “&h32”, etc. “&o” for octal, “&b” for binary “&b1011010” the most common use for this would be to insert hex data without having to manually convert it to decimal.

The bytes list may also contain large multi-byte numbers along with the formatting information for how you want them added to the byte stream. To do this you’d include a list inside the bytes list. This sub list should have 2 elements. The first is a string starting with “B” for big endian format, or “L” for little endian format. Then any of the standard C style number format types. Supported types are: int8, uint8, int16, uint16, int32, uint32, int64, uint64 and double. So a sub list might look like: {“Buint16”, 88374} which would include the number 88374 as a big endian unsigned 2 byte integer. Include them in the list like: {14, 15, “&h32”, {“Luint64”, 123456780}, 10, 0}

You can combine any number of differently formatted bytes or large numbers in the list you pass to the send data verb.

pause
It is sometimes necessary to send some data and then pause for some time before sending more when dealing with embedded devices. If the device does not support standard handshaking then this can be a problem. Another way to do this would be via the start idler command and breaking the code up into several pieces to be called one from the other via an idler. This will work but can be more work than should truly be necessary. It’s not uncommon to see people using the AppleScript “delay” verb or trying to use our own sheDelay verbs to pause a script. AppleScript in later OS versions does not like to pause and these can cause serious problems or even with delay the script may never continue at all.

As an alternative to these problems I’ve added the pause value. If included the rest of the data in the command is sent and the outgoing queue to that interface is paused for the specified number or fraction of a second. When the time is up any other commands that have been queued up will be sent, unless another pause command is encountered in which case the process starts again.

So if you find yourself needing to do something similar to this:

  send data “hello” interface “myDevice"
  delay 0.5
  send data “there” interface “myDevice"
  delay 0.5
  send data “my friend” interface “myDevice”

please instead try using the pause parameter like this:

  send data “hello” pause 0.5 interface “myDevice"
  send data “there” pause 0.5 interface “myDevice"
  send data “my friend” interface “myDevice”

This will not pause the script which will execute immediately and exit, but the commands will queue up and wait as they go out. NOTE that incoming packets are not paused by this command and so you may receive incoming data while the outgoing queue is paused.

Examples:

send data "AE14" interface "MyRFX"
send data bytes {14,0,0,32,99,128} interface “MyRFXe”
send data bytes {14, 15, “&h32”, {“Luint64”, 123456780}, 10, 0} interface “display output"

Notes:

This can be used extensively with the DIY interface to send data to it. In other cases it may be used for additional setup or configuration that you would like to be different from the XTension defaults. Not all interfaces currently support this, if you find it's not supported somewhere you need it please let us know.

History:

  • the pause parameter was added in XTension build 962
  • the large number format support was added in XTension build 961
dictionary/xtension/senddata.txt · Last modified: 2023/02/13 14:52 by 127.0.0.1