Buffers

Edit

Introduction #

A buffer is basically a space within the system memory that is used to store small packets of data for just about anything. Since it is held in system memory, it is very fast to access. You can think of it as a temporary place to put things that need to be worked on or processed.

Buffer within memory
Buffer within memory

Buffers are created by allocating a space in the system memory, calculated in bytes , which is then reserved for your application as long as it is running or until you delete the buffer.

Data Types

Buffer Type Description
Unsigned 8bits A single byte value. This is a positive value from 0 to 255.
Signed 8bits A single byte value. This can be a positive or negative value from -128 to 127 (0 is classed as positive).
Unsigned 16bits 2 bytes value. This is a positive value from 0 to 65,535.
Signed 16bits 2 bytes value. This can be a positive or negative value from -32,768 to 32,767 (0 is classed as positive).
Unsigned 32bits 4 bytes value. This is a positive value from 0 to 4,294,967,295.
Signed 32bits 4 bytes value. This can be a positive or negative value from -2,147,483,648 to 2,147,483,647 (0 is classed as positive).
Float 32bits 4 bytes value. This can be a positive or negative value from -2,147,483,648 to 2,147,483,647 that can contain decimal point numbers.
Float 64bits 8 bytes value. This can be a positive or negative value from 1-2^63 and 2^63 that can contain decimal point numbers.
Boolean A boolean value. Can only be either 1 or 0 (true or false).
String A string (text), finalized with a null terminating character.
Text A string(text) without the final null terminating character. Cannot be used for Buffer: Peak or Read commands (as the the length of a string is found by searching for the (first) null.)


Edit

Buffer: Create #

Creates a new buffer with the given name.

When creating a buffer, you should always try to create it to a size that is appropriate to the type, with the general rule being that it should be created to accommodate the maximum size of data that it is to store.

Buffer types:

  • Fixed - A buffer of a fixed size in bytes. The size is set when the buffer is created and cannot be changed again. LioranBoard will crash when you reach the limit size.
  • Grow - A buffer that will grow dynamically as data is added. You create it with an initial size (which should be an approximation of the size of the data expected to be stored), and then it will expand to accept further data that overflows this initial size.
  • Wrap - A buffer where the data will wrap. When the data being added reaches the limit of the buffer size, the overwrite will be placed back at the start of the buffer, and further writing will continue from that point.
Buffer types
Buffer types
Box Name Type Description
Buffer Name String Name of the buffer to create
Size Size of the buffer in bytes.  
Type dropdown menu Fixed, Grow or Wrap


Edit

Buffer: Write #

Writes data to a buffer at the position of the read/write head.

Writing data to a buffer will advance the position of the head by however many bytes it wrote.

Box Name Type Description
Buffer Name String Name of the buffer


Edit

Buffer: Read #

Read data from a buffer at the position of the read/write head.
Reading data from a buffer will advance the position of the head by however many bytes it read.

Box Name Type Description
Buffer Name String Name of the buffer


Edit

Buffer: Load #

Loads any file as a buffer into LioranBoard.
Read/Write head position will be set to 0 (beginning of the file).

Box Name Type Description
Buffer Name String Name of the buffer
Path String File name to load. Can be relative path. If you want to load names.txt from your Receiver folder, you can just use the file name itself.


Edit

Buffer: Save #

With this command you can save the contents (raw data) of a buffer to a file, ready to be read back into memory using the Buffer: Load command.

Box Name Type Description
Buffer Name String Name of the buffer
Path String File name to save the buffer into.


Edit

Buffer: Delete #

Deletes a buffer you created or loaded, releasing the resources used to create it and removing any data that it may currently contain.

Box Name Type Description
Buffer Name String Name of the buffer


Edit

Buffer: Set Size #

Change the size of a buffer to a new size, for example to prevent overflow.

Box Name Type Description
Buffer Name String Name of the buffer
Size Int New size of the buffer.


Edit

Buffer: Set Position #

Sets the position of the read/write head of a buffer.
When you write or read from a buffer, data is not reshuffled. Rather, the head pointer is adjusted.
Whenever you use Buffer: Write command, head pointer advances. Whenever you use Buffer: Read command, head pointer also advances.

Box Name Type Description
Buffer Name String Name of the buffer
Position Int Value to set the position of the head to.


Edit

Buffer: Get Size #

Returns the size of a buffer.

Box Name Type Description
Buffer Name String Name of the buffer
Variable String Variable to save the size value in.


Edit

Buffer: Get Position #

Return the position of a buffer’s read/write head.

Box Name Type Description
Buffer Name String Name of the buffer
Variable String Variable to save the position value in.


Edit

Buffer: Exists #

Check if a buffer exists and save the result in a variable.
Use this command before using Buffer: Delete command, as it will crash LioranBoard if you try to delete a non existing buffer.

Result:

  • 0 - Buffer doesn’t exist
  • 1 - Buffer exists
Box Name Type Description
Buffer Name String Name of the buffer
Variable String Variable to save the result in.


Edit

Buffer: SHA1 Hash #

Returns the SHA1 hash from a buffer. The data will be analyzed from 0 to the size of the buffer.
SHA1 hash is like a file’s digital signature. You can verify a file’s integrity by checking its hash value. If even one byte in the file changes (i.e. the file is modified in any way), its hash value will be different.
Very useful command to periodically detect for any file changes.

Box Name Type Description
Buffer Name String Name of the buffer
Variable String Variable to save the SHA1 string in.


Edit

Buffer: Base64 Encode #

Turns a whole buffer into a base64 string.

Box Name Type Description
Buffer Name String Name of the buffer
Variable String Variable to save the string value in


Edit

Buffer: Base64 Decode #

Creates a new buffer from a base64 string.

Box Name Type Description
Buffer Name String Name of the buffer
Base64 String String A base64 string to decode and turn into a buffer.