Syntax
[f,l,u]=sbufferinfo(b)
Input Parameter
Output Parameter
f : | | number of free bytes |
l : | | maximum number of bytes |
u : | | number of used bytes |
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, sbufferinfo
, is designed to provide information about a buffer structure in MATLAB. It is part of a library for handling USB interfaces.
Input Parameters
- b: A struct representing the buffer. This struct is expected to have at least the following fields:
- len: The total capacity of the buffer in bytes.
- anz: The number of bytes currently used in the buffer.
- r: The read index, indicating the current position in the buffer.
- buf: The actual buffer data, typically an array or similar structure.
Output Results
- f: The number of free bytes in the buffer, calculated as
f = l - u
.
- l: The maximum number of bytes the buffer can hold, directly taken from
b.len
.
- u: The number of bytes currently used in the buffer, directly taken from
b.anz
.
Algorithm Steps
- Retrieve the total buffer length
l
from b.len
.
- Retrieve the number of used bytes
u
from b.anz
.
- Calculate the number of free bytes
f
as f = l - u
.
- If no output arguments are specified (
nargout == 0
), print the buffer size, used bytes, and free bytes to the console using fprintf
.
- Calculate the buffer indices
bi
using a custom function mod1
, which adjusts the indices based on the buffer's read position and length.
- Display the buffer contents using
b.buf'
, which transposes the buffer data for display.
Algorithm explaination created using ChatGPT on 2025-08-18 23:03. (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