sbuffercreate

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - USB Interface
Introduced first in SolidGeometry 2.8, Creation date: 2015-12-08, Last change: 2025-09-14

creates a struct buffer for async read/write

Description

len = length of buffer
anz = number of used bytes of buffer
buf = data bytes of buffer
The basic functions are:
sbuffercreate - create a buffer
sbufferinfo - status info about the buffer
sbufferwrite - write data into the buffer
sbufferget - read data out of the buffer


See Also: sbuffercreate , sbufferinfo , sbufferwrite , sbufferget

Example Illustration

 missing image of sbuffercreate(n)

Syntax

b=sbuffercreate([n])

Input Parameter

n: number of bytes; default is 256

Output Parameter

b: buffer struct




Copyright 2015-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This algorithm is a MATLAB function named sbuffercreate that creates a buffer structure for asynchronous read/write operations. It is part of the SG-Library and was developed by Tim Lueth. The function is designed to initialize a buffer with a specified or default size.

Input Parameters

Output

Algorithm Steps

  1. Initialize the default buffer size n to 256.
  2. Check if an input argument is provided and is not empty. If so, set n to the provided value.
  3. Create a structure b with the following fields:
    • len: Set to n, representing the length of the buffer.
    • anz: Initialized to 0, representing the number of used bytes in the buffer.
    • buf: An array of unsigned 8-bit integers (uint8) with a size of n, initialized to zeros. This array holds the data bytes of the buffer.
    • w: Set to 4, possibly representing a write pointer or index.
    • r: Set to 4, possibly representing a read pointer or index.
Algorithm explaination created using ChatGPT on 2025-08-18 22:54. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21