Difference between revisions of "Component: Circular Buffer Free Sim (Buffer)"

From Flowcode Help
Jump to navigationJump to search
(Created page with "{| style="width:50%" |- | width="20%" style="color:gray;" | Author | Matrix Ltd |- | width="20%" style="color:gray;" | Version | 1.5 |- | width="20%" style="color:gray...")
 
 
(9 intermediate revisions by the same user not shown)
Line 17: Line 17:
 
==Component Source Code==
 
==Component Source Code==
  
Please click here for the component source code: [https://www.flowcode.co.uk/wikicopy/componentsource/FC_Comp_Source_CircularBuffer_FreeSim.fcfx FC_Comp_Source_CircularBuffer_FreeSim.fcfx]
+
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_CircularBuffer_FreeSim.fcfx FC_Comp_Source_CircularBuffer_FreeSim.fcfx]
 +
 
 +
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_CircularBuffer_FreeSim.fcfx FC_Comp_Source_CircularBuffer_FreeSim.fcfx]
  
 
==Detailed description==
 
==Detailed description==
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
  
Line 26: Line 40:
  
 
==Examples==
 
==Examples==
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
  
Line 31: Line 57:
 
''<span style="color:red;">No additional examples</span>''
 
''<span style="color:red;">No additional examples</span>''
  
==Downloadable macro reference==
 
  
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
==Macro reference==
 +
 +
===FlushBuffer===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LookForValue'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''FlushBuffer'''
 
|-
 
|-
| colspan="2" | Scans the buffer for an array of specific values. Returns 0 if the value is not found. Returns 1 if the value is found.&nbsp;
+
| colspan="2" | Clears the contents of the buffer and re-initialises the index locations.&nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" | Value
+
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
 +
 
 +
 
 +
===GetByte===
 +
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
| colspan="2" | Value to look for&nbsp;
+
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetByte'''
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| colspan="2" | Reads the next available byte from the circular buffer, Returns 255/512 if the buffer is empty.&nbsp;
| width="90%" | NumChars
 
 
|-
 
|-
| colspan="2" | &nbsp;
 
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | RemoveContent
+
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
 +
 
 +
 
 +
===GetConsoleHandle===
 +
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
| colspan="2" | 0=Leave data alone, 1=Remove data from buffer&nbsp;
+
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetConsoleHandle'''
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| colspan="2" | Gets the handle to the console allowing data displaying on the panel etc.&nbsp;
| width="90%" | ResetFind
 
 
|-
 
|-
| colspan="2" | 0=Continue the find from the last operation, 1=Start again&nbsp;
 
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-h32-icon.png]] - HANDLE
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===GetIndexedByte===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 84: Line 130:
  
  
 +
===GetNumberBytes===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WaitForValue'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetNumberBytes'''
 +
|-
 +
| colspan="2" | Returns the number of valid data bytes currently inside the buffer.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
 +
 
 +
 
 +
===LookForValue===
 +
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LookForValue'''
 
|-
 
|-
| colspan="2" | Waits for an array of values to appear in the circular buffer. Returns 0 to indicate a timeout. Returns 1 to indicate the data has been found.&nbsp;
+
| colspan="2" | Scans the buffer for an array of specific values. Returns 0 if the value is not found. Returns 1 if the value is found.&nbsp;
 
|-
 
|-
 
|-
 
|-
Line 95: Line 156:
 
| width="90%" | Value
 
| width="90%" | Value
 
|-
 
|-
| colspan="2" | &nbsp;
+
| colspan="2" | Value to look for&nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | NumChars
 
| width="90%" | NumChars
 
|-
 
|-
| colspan="2" | Number of characters to try and look for&nbsp;
+
| colspan="2" | &nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | RemoveContent
 
| width="90%" | RemoveContent
 
|-
 
|-
| colspan="2" | 0=Leave the buffer contents untouched, 1=Remove values as you go&nbsp;
+
| colspan="2" | 0=Leave data alone, 1=Remove data from buffer&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Timeout
+
| width="90%" | ResetFind
 
|-
 
|-
| colspan="2" | Max amount of time to wait in milliseconds before returning 0=WaitForever&nbsp;
+
| colspan="2" | 0=Continue the find from the last operation, 1=Start again&nbsp;
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
Line 117: Line 178:
  
  
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
+
===PeekByte===
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetNumberBytes'''
 
|-
 
| colspan="2" | Returns the number of valid data bytes currently inside the buffer.&nbsp;
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetConsoleHandle'''
 
|-
 
| colspan="2" | Gets the handle to the console allowing data displaying on the panel etc.&nbsp;
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-h32-icon.png]] - HANDLE
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 156: Line 192:
  
  
 +
===PutByte===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 174: Line 211:
  
  
 +
===WaitForValue===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetByte'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WaitForValue'''
 +
|-
 +
| colspan="2" | Waits for an array of values to appear in the circular buffer. Returns 0 to indicate a timeout. Returns 1 to indicate the data has been found.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 +
| width="90%" | Value
 +
|-
 +
| colspan="2" | &nbsp;
 
|-
 
|-
| colspan="2" | Reads the next available byte from the circular buffer, Returns 255/512 if the buffer is empty.&nbsp;
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | NumChars
 
|-
 
|-
 +
| colspan="2" | Number of characters to try and look for&nbsp;
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
+
| width="90%" | RemoveContent
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
 
|-
 
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
+
| colspan="2" | 0=Leave the buffer contents untouched, 1=Remove values as you go&nbsp;
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''FlushBuffer'''
 
 
|-
 
|-
| colspan="2" | Clears the contents of the buffer and re-initialises the index locations.&nbsp;
+
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Timeout
 
|-
 
|-
 +
| colspan="2" | Max amount of time to wait in milliseconds before returning 0=WaitForever&nbsp;
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
 
 
  
  

Latest revision as of 13:09, 7 February 2023

Author Matrix Ltd
Version 1.5
Category Buffer


Circular Buffer Free Sim component

Circular buffer component allowing easy and efficient first in first out (FIFO) style data byte storage. Useful when used with a comms component to capture data as it comes in ready for processing when we have time. Also features macros to allow you to check for specific incoming responses such as "OK" or "ERROR".

Component Source Code

Please click here to download the component source project: FC_Comp_Source_CircularBuffer_FreeSim.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_CircularBuffer_FreeSim.fcfx

Detailed description

No detailed description exists yet for this component

Examples

No additional examples






Macro reference

FlushBuffer

Fc9-comp-macro.png FlushBuffer
Clears the contents of the buffer and re-initialises the index locations. 
Fc9-void-icon.png - VOID Return


GetByte

Fc9-comp-macro.png GetByte
Reads the next available byte from the circular buffer, Returns 255/512 if the buffer is empty. 
Fc9-u16-icon.png - UINT Return


GetConsoleHandle

Fc9-comp-macro.png GetConsoleHandle
Gets the handle to the console allowing data displaying on the panel etc. 
Fc9-h32-icon.png - HANDLE Return


GetIndexedByte

Fc9-comp-macro.png GetIndexedByte
Gets the value of a single byte at a known location in the buffer. Leaves the buffer contents and pointers untouched. 
Fc9-u16-icon.png - UINT address
 
Fc9-u8-icon.png - BYTE Return


GetNumberBytes

Fc9-comp-macro.png GetNumberBytes
Returns the number of valid data bytes currently inside the buffer. 
Fc9-u16-icon.png - UINT Return


LookForValue

Fc9-comp-macro.png LookForValue
Scans the buffer for an array of specific values. Returns 0 if the value is not found. Returns 1 if the value is found. 
Fc9-string-icon.png - STRING Value
Value to look for 
Fc9-u8-icon.png - BYTE NumChars
 
Fc9-u8-icon.png - BYTE RemoveContent
0=Leave data alone, 1=Remove data from buffer 
Fc9-u8-icon.png - BYTE ResetFind
0=Continue the find from the last operation, 1=Start again 
Fc9-u8-icon.png - BYTE Return


PeekByte

Fc9-comp-macro.png PeekByte
Reads the next available byte from the circular buffer without advancing the current index, Returns 255/512 if the buffer is empty. 
Fc9-u16-icon.png - UINT Return


PutByte

Fc9-comp-macro.png PutByte
Add byte to the next free location inside the circular buffer. If the data goes into the buffer correctly then return 1. Otherwise the buffer is full and the return value will equal 0. 
Fc9-u8-icon.png - BYTE Data
 
Fc9-u8-icon.png - BYTE Return


WaitForValue

Fc9-comp-macro.png WaitForValue
Waits for an array of values to appear in the circular buffer. Returns 0 to indicate a timeout. Returns 1 to indicate the data has been found. 
Fc9-string-icon.png - STRING Value
 
Fc9-u8-icon.png - BYTE NumChars
Number of characters to try and look for 
Fc9-u8-icon.png - BYTE RemoveContent
0=Leave the buffer contents untouched, 1=Remove values as you go 
Fc9-u16-icon.png - UINT Timeout
Max amount of time to wait in milliseconds before returning 0=WaitForever 
Fc9-u8-icon.png - BYTE Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-21-icon.png Buffer Size
Sets the number of byte elements inside the circular buffer. 
Fc9-type-16-icon.png Storage Type
When buffer is full this property decides what to do. Store first x values - Will retain the information inside the buffer, new data will be discarded. Store last x values - Will discard the oldest location in the buffer and overwrite with new data. 
Fc9-type-16-icon.png Memory Type
 
Fc9-type-16-icon.png Return Type
Specifies the way the receive function indicates a timeout. 8 Bit mode - Timeout is represented by the value 255. 16 Bit mode - Timeout is represented by the value 512 allowing the value 255 to represent valid data 
Fc9-type-7-icon.png Console
Decides if the contents of the buffer are shown in a console tab.