<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>DataBuffer on Loupe Documentation</title>
    <link>/libraries/databuffer.html</link>
    <description>Recent content in DataBuffer on Loupe Documentation</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language><atom:link href="/libraries/databuffer/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Usage</title>
      <link>/libraries/databuffer/usage.html</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>/libraries/databuffer/usage.html</guid>
      <description>&lt;h2 id=&#34;installation&#34;&gt;Installation&lt;/h2&gt;
&lt;p&gt;Install with the &lt;a href=&#34;../../tools/lpm.html&#34;&gt;Loupe Package Manager&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;lpm install databuffer
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;DataBuffer depends only on &lt;strong&gt;sys_lib&lt;/strong&gt;, which ships with Automation Studio.&lt;/p&gt;
&lt;h2 id=&#34;declaration&#34;&gt;Declaration&lt;/h2&gt;
&lt;p&gt;Declare one &lt;a href=&#34;../../libraries/databuffer/typesandenums.html#datbufbuffer_typ&#34;&gt;&lt;code&gt;datbufBuffer_typ&lt;/code&gt;&lt;/a&gt; variable per buffer, as a task or global variable. The examples on this page use the following variables; other application variables are left undeclared.&lt;/p&gt;
&lt;h3 id=&#34;c&#34;&gt;C&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-c&#34; data-lang=&#34;c&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;datbufBuffer_typ myBuf;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;UINT status;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;st&#34;&gt;ST&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-c&#34; data-lang=&#34;c&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;VAR
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	myBuf : datbufBuffer_typ;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	status : UINT;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;END_VAR
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;initialization&#34;&gt;Initialization&lt;/h2&gt;
&lt;p&gt;A buffer must be initialized with &lt;a href=&#34;../../libraries/databuffer/functions.html#datbufinitbuffer&#34;&gt;&lt;code&gt;datbufInitBuffer&lt;/code&gt;&lt;/a&gt; before any other function is called on it. Initialization allocates &lt;code&gt;maxLength&lt;/code&gt; bytes of memory for the buffer&amp;rsquo;s data and clears it to zero.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Functions</title>
      <link>/libraries/databuffer/functions.html</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>/libraries/databuffer/functions.html</guid>
      <description>&lt;p&gt;All functions take the buffer by address in &lt;code&gt;pBuffer&lt;/code&gt; and return a &lt;code&gt;UINT&lt;/code&gt; status: &lt;code&gt;0&lt;/code&gt; on success, otherwise a &lt;a href=&#34;../../libraries/databuffer/typesandenums.html#datbuf_err_enum&#34;&gt;&lt;code&gt;DATBUF_ERR_enum&lt;/code&gt;&lt;/a&gt; value.&lt;/p&gt;
&lt;h2 id=&#34;datbufinitbuffer&#34;&gt;datbufInitBuffer&lt;/h2&gt;
&lt;p&gt;Initializes a buffer. All members of the buffer are reset, &lt;code&gt;maxLength&lt;/code&gt; bytes of memory are allocated for the data with &lt;code&gt;TMP_alloc&lt;/code&gt;, and the new memory is zeroed.&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;Direction&lt;/th&gt;
          &lt;th style=&#34;text-align: left&#34;&gt;Name&lt;/th&gt;
          &lt;th style=&#34;text-align: left&#34;&gt;Type&lt;/th&gt;
          &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;In&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;pBuffer&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;UDINT&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;Address of the &lt;a href=&#34;../../libraries/databuffer/typesandenums.html#datbufbuffer_typ&#34;&gt;&lt;code&gt;datbufBuffer_typ&lt;/code&gt;&lt;/a&gt; to initialize&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;In&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;maxLength&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;UDINT&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;Size of the data storage to allocate, in bytes. Must be greater than &lt;code&gt;0&lt;/code&gt;.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;Return&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;status&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;UINT&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;0&lt;/code&gt; on success, otherwise a &lt;code&gt;DATBUF_ERR_enum&lt;/code&gt; value&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th style=&#34;text-align: left&#34;&gt;Error&lt;/th&gt;
          &lt;th style=&#34;text-align: left&#34;&gt;Cause&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;DATBUF_ERR_INVALIDINPUT&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;pBuffer&lt;/code&gt; is &lt;code&gt;0&lt;/code&gt;, or &lt;code&gt;maxLength&lt;/code&gt; is &lt;code&gt;0&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;DATBUF_ERR_MEMALLOC&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;The memory could not be allocated&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Call this function once per buffer, in the &lt;code&gt;_INIT&lt;/code&gt; routine. &lt;code&gt;TMP_alloc&lt;/code&gt; may only be called in &lt;code&gt;_INIT&lt;/code&gt; or &lt;code&gt;_EXIT&lt;/code&gt;, so this function must not be called cyclically. The library does not free the allocated memory, so calling it again on a buffer that is already initialized allocates a new block and the old one stays allocated until the controller restarts. B&amp;amp;R notes that allocations larger than about 70,000 bytes can cause cycle time violations in task class 1.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Types and Enums</title>
      <link>/libraries/databuffer/typesandenums.html</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>/libraries/databuffer/typesandenums.html</guid>
      <description>&lt;h2 id=&#34;datbufbuffer_typ&#34;&gt;datbufBuffer_typ&lt;/h2&gt;
&lt;p&gt;A data buffer. Declare one variable of this type per buffer and pass its address to the library functions. The members are maintained by the library; read them, but do not write them directly.&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th style=&#34;text-align: center&#34;&gt;Name&lt;/th&gt;
          &lt;th style=&#34;text-align: left&#34;&gt;Type&lt;/th&gt;
          &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;pData&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;UDINT&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;Address of the buffer&amp;rsquo;s data storage. &lt;code&gt;0&lt;/code&gt; until the buffer is initialized.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;currentLength&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;UDINT&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;Number of bytes of data currently in the buffer&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style=&#34;text-align: center&#34;&gt;maxLength&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;UDINT&lt;/td&gt;
          &lt;td style=&#34;text-align: left&#34;&gt;Size of the data storage in bytes, as passed to &lt;code&gt;datbufInitBuffer&lt;/code&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&#34;datbuf_err_enum&#34;&gt;DATBUF_ERR_enum&lt;/h2&gt;
&lt;p&gt;Status values returned by the library functions. A return value of &lt;code&gt;0&lt;/code&gt; means success.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>