<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Controller Code that Demonstrates Integer Parsing]]></title><description><![CDATA[<p dir="auto">Hi Everyone,</p>
<p dir="auto">I know I was looking at some C++ code on this site awhile back that parsed out the node and payload information from a serial data string.  Would someone be so kind as to direct me to a similar example - code that grabs incoming serial data using the semicolon as a parsing guide?</p>
<p dir="auto">Thanks for any and all suggestions - Baran</p>
]]></description><link>https://forum.mysensors.org/topic/1391/controller-code-that-demonstrates-integer-parsing</link><generator>RSS for Node</generator><lastBuildDate>Fri, 12 Jun 2026 17:12:20 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/1391.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 12 May 2015 02:34:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Controller Code that Demonstrates Integer Parsing on Thu, 21 May 2015 03:23:16 GMT]]></title><description><![CDATA[<p dir="auto">Just assigning a C string to the char array, of length 23.</p>
<p dir="auto">Simulating the message you receive.</p>
]]></description><link>https://forum.mysensors.org/post/14439</link><guid isPermaLink="true">https://forum.mysensors.org/post/14439</guid><dc:creator><![CDATA[BulldogLowell]]></dc:creator><pubDate>Thu, 21 May 2015 03:23:16 GMT</pubDate></item><item><title><![CDATA[Reply to Controller Code that Demonstrates Integer Parsing on Thu, 21 May 2015 03:20:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bulldoglowell" aria-label="Profile: BulldogLowell">@<bdi>BulldogLowell</bdi></a> said:</p>
<blockquote>
<p dir="auto">char myString[23] = "1;0;1;0;17;354";  // this is a C string, not String class...<br />
/<em>or like this:  char</em> myString = "1;0;1;0;17;354";  for example */</p>
</blockquote>
<p dir="auto">Hi Bulldog,</p>
<p dir="auto">Could you explain the sttement (above)?  I understand everything else about the code you posted except this.  I think the "23" means you are allowing 23 spaces for the information but I do not understand the right side of the "=" sign.  This is something like what might come through but why am I defining the payload?  It could be from 20 to 1020 nd I do not understand the code above.  Would you explain what this line is about and how the information in quotes relates to the variables being read in real time?</p>
<p dir="auto">Respectfully - Baran</p>
]]></description><link>https://forum.mysensors.org/post/14438</link><guid isPermaLink="true">https://forum.mysensors.org/post/14438</guid><dc:creator><![CDATA[Baran]]></dc:creator><pubDate>Thu, 21 May 2015 03:20:12 GMT</pubDate></item><item><title><![CDATA[Reply to Controller Code that Demonstrates Integer Parsing on Thu, 14 May 2015 19:14:30 GMT]]></title><description><![CDATA[<p dir="auto">You can look in the SerialGateway code. It parses the commands.</p>
]]></description><link>https://forum.mysensors.org/post/14141</link><guid isPermaLink="true">https://forum.mysensors.org/post/14141</guid><dc:creator><![CDATA[hek]]></dc:creator><pubDate>Thu, 14 May 2015 19:14:30 GMT</pubDate></item><item><title><![CDATA[Reply to Controller Code that Demonstrates Integer Parsing on Thu, 14 May 2015 04:40:10 GMT]]></title><description><![CDATA[<p dir="auto">Greetings,</p>
<p dir="auto">Way too cool!  I appreciate the illustration.  I need to get to sleep but I will play with it tomorrow evening after work.  I just wanted to say thank you for giving me a guide.</p>
<p dir="auto">Respectfully - Baran</p>
]]></description><link>https://forum.mysensors.org/post/14094</link><guid isPermaLink="true">https://forum.mysensors.org/post/14094</guid><dc:creator><![CDATA[Baran]]></dc:creator><pubDate>Thu, 14 May 2015 04:40:10 GMT</pubDate></item><item><title><![CDATA[Reply to Controller Code that Demonstrates Integer Parsing on Thu, 14 May 2015 02:17:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/baran" aria-label="Profile: Baran">@<bdi>Baran</bdi></a> said:</p>
<blockquote>
<p dir="auto">1;0;1;0;17;354</p>
</blockquote>
<p dir="auto">something like this:</p>
<pre><code>char myString[23] = "1;0;1;0;17;354";  // this is a C string, not String class...
/*or like this:  char* myString = "1;0;1;0;17;354";  for example */
int myValue[6]; //array to store all 6 values...


void setup() 
{
  Serial.begin(9600);
  char* token = strtok(myString, ";");  //tokenize the string
  for (int i = 0; i &lt; 6; i++)  // works for your 6 values tokenized by ';'
  {
    myValue[i] = atoi(token); // take the tokenized value and store to the array
    token = strtok(NULL, ";");    // move the pointer to the next value
    Serial.println(myValue[i]);  //just print the value stored to the array
  }
}

void loop() 
{
  //
}
</code></pre>
<p dir="auto">I hope that helps...</p>
<p dir="auto">PS, since your value in the 6th position was greater than a byte, I used int</p>
]]></description><link>https://forum.mysensors.org/post/14088</link><guid isPermaLink="true">https://forum.mysensors.org/post/14088</guid><dc:creator><![CDATA[BulldogLowell]]></dc:creator><pubDate>Thu, 14 May 2015 02:17:55 GMT</pubDate></item><item><title><![CDATA[Reply to Controller Code that Demonstrates Integer Parsing on Wed, 13 May 2015 23:27:21 GMT]]></title><description><![CDATA[<p dir="auto">Hi Bulldog,</p>
<p dir="auto">I am trying to parse typical node output data.  When queried, my nodes send the analog data from each of the eight analog inputs.  A typical output might look like:</p>
<p dir="auto">1;0;1;0;17;354<br />
1;0;1;0;17;422<br />
1;0;1;0;17;423<br />
1;0;1;0;17;519<br />
1;0;1;0;17;527<br />
1;0;1;0;17;439<br />
1;0;1;0;17;484<br />
1;0;1;0;17;406</p>
<p dir="auto">The first byte is the node ID, and I do not care about the second, third, fourth, or fifth bytes.  The sixth byte is the payload or data from an analog input.  I would like to, ideally, parse the 1st and 6th bytes from each line and store the data in an array, possibly in flash memory on a Mega board.  The problem is, I am so new to this, I am not sure how to begin to even present something to work on.  My hope is that someone who recognizes this as being similar to a question from an earlier time can direct me to a sample that might serve to illustrate how this process can be made to happen.   In the best of all possible worlds, someone may say "oh yeah, here's how you do it".  Hey . . . a newbie can dream.</p>
]]></description><link>https://forum.mysensors.org/post/14084</link><guid isPermaLink="true">https://forum.mysensors.org/post/14084</guid><dc:creator><![CDATA[Baran]]></dc:creator><pubDate>Wed, 13 May 2015 23:27:21 GMT</pubDate></item><item><title><![CDATA[Reply to Controller Code that Demonstrates Integer Parsing on Wed, 13 May 2015 10:55:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/baran" aria-label="Profile: Baran">@<bdi>Baran</bdi></a></p>
<p dir="auto">can you give an example of the message you are trying to parse.</p>
]]></description><link>https://forum.mysensors.org/post/14041</link><guid isPermaLink="true">https://forum.mysensors.org/post/14041</guid><dc:creator><![CDATA[BulldogLowell]]></dc:creator><pubDate>Wed, 13 May 2015 10:55:27 GMT</pubDate></item><item><title><![CDATA[Reply to Controller Code that Demonstrates Integer Parsing on Tue, 12 May 2015 13:05:17 GMT]]></title><description><![CDATA[<p dir="auto">I appreciate your suggestion but I know litte to nothing about coding.  I was hoping to view a working example of some sort of parsing that might serve as a template for this module.</p>
]]></description><link>https://forum.mysensors.org/post/13972</link><guid isPermaLink="true">https://forum.mysensors.org/post/13972</guid><dc:creator><![CDATA[Baran]]></dc:creator><pubDate>Tue, 12 May 2015 13:05:17 GMT</pubDate></item><item><title><![CDATA[Reply to Controller Code that Demonstrates Integer Parsing on Tue, 12 May 2015 06:49:00 GMT]]></title><description><![CDATA[<p dir="auto">Try <a href="http://www.cplusplus.com/reference/cstdio/sscanf/" rel="nofollow ugc">sscanf</a> for easy string parsing.</p>
]]></description><link>https://forum.mysensors.org/post/13947</link><guid isPermaLink="true">https://forum.mysensors.org/post/13947</guid><dc:creator><![CDATA[AWI]]></dc:creator><pubDate>Tue, 12 May 2015 06:49:00 GMT</pubDate></item></channel></rss>