Skip to main content

Stream


DUELink Scripting language is built to be ASCII human-friendly. This works great; however, there are instances where speed or raw binary data is required, like when writing or reading a buffer.

A direct benefit of streams is in giving a language, such as Python an easy way to transfer buffers to and from the module.


Usage

This is an example to send a buffer to the module. This example is for Python but other languages work almost exactly the same.

duelink.Stream.WriteBytes("b1", byte_array, 64) # write first 64 byte elements from byte_array to b1
duelink.Stream.WriteFloats("a1", float_array, 64) # write first 64 float elements from float_array to a1

Similarly, you can also read a buffer from the module.

duelink.Stream.ReadBytes("b1", byte_array, 64) # read 64 byte elements from b1 to byte_array
duelink.Stream.ReadFloats("a1", float_array, 64) # read 64 byte elements from a1 to float_array
tip

Stream can't be used directly by typing in ASCII commands, like when using the Console or a terminal.


Mechanism

Understanding and utilizing Stream mechanism is only needed by advanced users. See the source code of one of the provided libraries for reference.

A Stream command initiates the request. Once this command is received and accepted by the device, the & symbol will be returned indicating readiness. The host can now send the entire binary data, exactly to the required byte count.