sbufferget

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

reads bytes out of a struct buffer

Description

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

Example Illustration

 missing image of sbufferget(b,n)

Syntax

[b,rbytes,err]=sbufferget(b,n)

Input Parameter

b: struct buffer
n: number of bytes to get

Output Parameter

b: updated buffer
rbytes: array with received bytes
err: error number




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 function, sbufferget, is designed to read a specified number of bytes from a buffer structure. It is part of a series of functions for managing a buffer, including creating, writing, and retrieving data.

Input Parameters

Output Results

Algorithm Steps

  1. Retrieve buffer information using sbufferinfo, which provides the current state of the buffer.
  2. Initialize err as false.
  3. Check if the buffer contains fewer bytes than requested (n). If so, issue a warning, set err to true, and exit the function.
  4. Calculate the indices of the bytes to be read using mod1, which handles circular buffer indexing.
  5. Extract the bytes from the buffer using the calculated indices and store them in rbytes.
  6. Optionally, overwrite the extracted bytes in the buffer with zeros for ASCII tests.
  7. Update the buffer's byte count (b.anz) by subtracting the number of bytes read.
  8. Update the buffer's read position (b.r) to the last index of the read bytes.
Algorithm explaination created using ChatGPT on 2025-08-18 23:31. (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