<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>MQX Software SolutionsのトピックWhy we need &amp;quot;Write Offset&amp;quot; variable in the buffer structure?</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Why-we-need-quot-Write-Offset-quot-variable-in-the-buffer/m-p/1209192#M18624</link>
    <description>&lt;P&gt;Currently, I'm working on the TWR-K70F120M in which I'm trying to understand the "httpsrv" example from the following path-&amp;gt;(E:\Freescale\Freescale_MQX_4_1\rtcs\example\httpsrv\buil \uv4\httpsrv_twrk70f120m)&lt;/P&gt;&lt;P&gt;When I put the IP address 192.168.1.202 in the browser I observed that some data is gettings changed automatically so, I wanted to manipulate the data that's why&amp;nbsp; when I started debugging one thing i noticed is after the following line,&lt;BR /&gt;&lt;BR /&gt;length = send(session-&amp;gt;sock, session-&amp;gt;buffer.data, session-&amp;gt;buffer.offset, 0);&lt;BR /&gt;&lt;BR /&gt;Data is getting changed, so while understanding I came across the following structure,&lt;/P&gt;&lt;P&gt;typedef struct httpsrv_buffer&lt;BR /&gt;{&lt;BR /&gt;uint32_t offset; /* Write offset */&lt;BR /&gt;char* data; /* Buffer data */&lt;BR /&gt;}HTTPSRV_BUFF_STRUCT;&lt;BR /&gt;&lt;BR /&gt;So here I tried to find out in the RTCS documents but it was not there. Can anyone please help me to understand why there is offset used? why do we need a "write offset" variable?&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Omkar Dixit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 09 Jan 2021 06:18:56 GMT</pubDate>
    <dc:creator>omkardixit</dc:creator>
    <dc:date>2021-01-09T06:18:56Z</dc:date>
    <item>
      <title>Why we need "Write Offset" variable in the buffer structure?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Why-we-need-quot-Write-Offset-quot-variable-in-the-buffer/m-p/1209192#M18624</link>
      <description>&lt;P&gt;Currently, I'm working on the TWR-K70F120M in which I'm trying to understand the "httpsrv" example from the following path-&amp;gt;(E:\Freescale\Freescale_MQX_4_1\rtcs\example\httpsrv\buil \uv4\httpsrv_twrk70f120m)&lt;/P&gt;&lt;P&gt;When I put the IP address 192.168.1.202 in the browser I observed that some data is gettings changed automatically so, I wanted to manipulate the data that's why&amp;nbsp; when I started debugging one thing i noticed is after the following line,&lt;BR /&gt;&lt;BR /&gt;length = send(session-&amp;gt;sock, session-&amp;gt;buffer.data, session-&amp;gt;buffer.offset, 0);&lt;BR /&gt;&lt;BR /&gt;Data is getting changed, so while understanding I came across the following structure,&lt;/P&gt;&lt;P&gt;typedef struct httpsrv_buffer&lt;BR /&gt;{&lt;BR /&gt;uint32_t offset; /* Write offset */&lt;BR /&gt;char* data; /* Buffer data */&lt;BR /&gt;}HTTPSRV_BUFF_STRUCT;&lt;BR /&gt;&lt;BR /&gt;So here I tried to find out in the RTCS documents but it was not there. Can anyone please help me to understand why there is offset used? why do we need a "write offset" variable?&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Omkar Dixit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jan 2021 06:18:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Why-we-need-quot-Write-Offset-quot-variable-in-the-buffer/m-p/1209192#M18624</guid>
      <dc:creator>omkardixit</dc:creator>
      <dc:date>2021-01-09T06:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why we need "Write Offset" variable in the buffer structure?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Why-we-need-quot-Write-Offset-quot-variable-in-the-buffer/m-p/1254144#M18625</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From API httpsrv_write, you can see the offset usage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;int32_t httpsrv_write(HTTPSRV_SESSION_STRUCT *session, char *src, int32_t length)&lt;BR /&gt;{&lt;BR /&gt;uint32_t space = HTTPSRV_SES_BUF_SIZE_PRV - session-&amp;gt;buffer.offset;&lt;BR /&gt;int32_t retval = length;&lt;BR /&gt;uint32_t n_send;&lt;/P&gt;
&lt;P&gt;RTCS_ASSERT(session != NULL);&lt;BR /&gt;RTCS_ASSERT(src != NULL);&lt;/P&gt;
&lt;P&gt;/* User buffer is bigger than session buffer - send user data directly */&lt;BR /&gt;if (length &amp;gt; HTTPSRV_SES_BUF_SIZE_PRV)&lt;BR /&gt;{&lt;BR /&gt;/* If there are some data already buffered send them to client first */&lt;BR /&gt;if (httpsrv_ses_flush(session) == RTCS_ERROR)&lt;BR /&gt;{&lt;BR /&gt;return(RTCS_ERROR);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;return(httpsrv_send(session, src, length, 0));&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;/* No space in buffer - make some */&lt;BR /&gt;if &lt;BR /&gt;(&lt;BR /&gt;(space &amp;lt; length) &amp;amp;&amp;amp; &lt;BR /&gt;(httpsrv_ses_flush(session) == RTCS_ERROR)&lt;BR /&gt;)&lt;BR /&gt;{&lt;BR /&gt;return(RTCS_ERROR);&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;/* Now we can save user data to buffer and eventually send them to client */&lt;BR /&gt;space = HTTPSRV_SES_BUF_SIZE_PRV - session-&amp;gt;&lt;STRONG&gt;buffer.offset&lt;/STRONG&gt;;&lt;BR /&gt;n_send = (space &amp;lt; length) ? space : length;&lt;BR /&gt;_mem_copy(src, session-&amp;gt;buffer.data+session-&amp;gt;&lt;STRONG&gt;buffer.offset&lt;/STRONG&gt;, n_send);&lt;BR /&gt;session-&amp;gt;&lt;STRONG&gt;buffer.offset&lt;/STRONG&gt; += n_send;&lt;BR /&gt;&lt;BR /&gt;if (session-&amp;gt;&lt;STRONG&gt;buffer.offset&lt;/STRONG&gt; &amp;gt;= HTTPSRV_SES_BUF_SIZE_PRV)&lt;BR /&gt;{&lt;BR /&gt;if (httpsrv_ses_flush(session) == RTCS_ERROR)&lt;BR /&gt;{&lt;BR /&gt;return(RTCS_ERROR);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;retval = n_send;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;return(retval);&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 08:49:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Why-we-need-quot-Write-Offset-quot-variable-in-the-buffer/m-p/1254144#M18625</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2021-03-30T08:49:56Z</dc:date>
    </item>
  </channel>
</rss>

