<?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[Stream direkt verarbeiten]]></title><description><![CDATA[<p>Hallo Zusammen,</p>
<p>ich habe vor kurzem angefangen mich mit C / C++ zu beschäftigen um ein GPS Projekt durchzuführen.</p>
<p>Leider habe ich ein Problem bei dem ich nicht weiterkomme.</p>
<p>Ich erhalte von meinem GPS Sensor die Daten in der Form :<br />
<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>G</mi><mi>P</mi><mi>G</mi><mi>S</mi><mi>V</mi><mo separator="true">,</mo><mn>3</mn><mo separator="true">,</mo><mn>1</mn><mo separator="true">,</mo><mn>1</mn><mn>0</mn><mo separator="true">,</mo><mn>2</mn><mn>9</mn><mo separator="true">,</mo><mn>7</mn><mn>3</mn><mo separator="true">,</mo><mn>2</mn><mn>4</mn><mn>2</mn><mo separator="true">,</mo><mn>3</mn><mn>4</mn><mo separator="true">,</mo><mn>2</mn><mn>8</mn><mo separator="true">,</mo><mn>7</mn><mn>0</mn><mo separator="true">,</mo><mn>1</mn><mn>0</mn><mn>3</mn><mo separator="true">,</mo><mn>1</mn><mn>7</mn><mo separator="true">,</mo><mn>2</mn><mn>6</mn><mo separator="true">,</mo><mn>6</mn><mn>7</mn><mo separator="true">,</mo><mn>2</mn><mn>7</mn><mn>6</mn><mo separator="true">,</mo><mn>4</mn><mn>0</mn><mo separator="true">,</mo><mn>0</mn><mn>8</mn><mo separator="true">,</mo><mn>4</mn><mn>1</mn><mo separator="true">,</mo><mn>0</mn><mn>8</mn><mn>6</mn><mo separator="true">,</mo><mn>2</mn><mn>3</mn><mo>∗</mo><mn>7</mn><mi>F</mi></mrow><annotation encoding="application/x-tex">GPGSV,3,1,10,29,73,242,34,28,70,103,17,26,67,276,40,08,41,086,23*7F  
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.8777699999999999em;vertical-align:-0.19444em;"></span><span class="base textstyle uncramped"><span class="mord mathit">G</span><span class="mord mathit" style="margin-right:0.13889em;">P</span><span class="mord mathit">G</span><span class="mord mathit" style="margin-right:0.05764em;">S</span><span class="mord mathit" style="margin-right:0.22222em;">V</span><span class="mpunct">,</span><span class="mord mathrm">3</span><span class="mpunct">,</span><span class="mord mathrm">1</span><span class="mpunct">,</span><span class="mord mathrm">1</span><span class="mord mathrm">0</span><span class="mpunct">,</span><span class="mord mathrm">2</span><span class="mord mathrm">9</span><span class="mpunct">,</span><span class="mord mathrm">7</span><span class="mord mathrm">3</span><span class="mpunct">,</span><span class="mord mathrm">2</span><span class="mord mathrm">4</span><span class="mord mathrm">2</span><span class="mpunct">,</span><span class="mord mathrm">3</span><span class="mord mathrm">4</span><span class="mpunct">,</span><span class="mord mathrm">2</span><span class="mord mathrm">8</span><span class="mpunct">,</span><span class="mord mathrm">7</span><span class="mord mathrm">0</span><span class="mpunct">,</span><span class="mord mathrm">1</span><span class="mord mathrm">0</span><span class="mord mathrm">3</span><span class="mpunct">,</span><span class="mord mathrm">1</span><span class="mord mathrm">7</span><span class="mpunct">,</span><span class="mord mathrm">2</span><span class="mord mathrm">6</span><span class="mpunct">,</span><span class="mord mathrm">6</span><span class="mord mathrm">7</span><span class="mpunct">,</span><span class="mord mathrm">2</span><span class="mord mathrm">7</span><span class="mord mathrm">6</span><span class="mpunct">,</span><span class="mord mathrm">4</span><span class="mord mathrm">0</span><span class="mpunct">,</span><span class="mord mathrm">0</span><span class="mord mathrm">8</span><span class="mpunct">,</span><span class="mord mathrm">4</span><span class="mord mathrm">1</span><span class="mpunct">,</span><span class="mord mathrm">0</span><span class="mord mathrm">8</span><span class="mord mathrm">6</span><span class="mpunct">,</span><span class="mord mathrm">2</span><span class="mord mathrm">3</span><span class="mbin">∗</span><span class="mord mathrm">7</span><span class="mord mathit" style="margin-right:0.13889em;">F</span></span></span></span>GPRMC,080917.000,A,42.8881,N,0218.1801,E,0.01,351.01,0907,,,A<em>62<br />
$GPGGA,080918.000,42.80,N,0218.1806,E,1,06,1.5,120.3,M,27.5,M,,0000</em>58</p>
<p>Im Augenblick speichere ich die Char-Daten in einem logfile und lese sie dann aus. Ich möche jedoch gerne ohne das Speichern auskommen und die Daten dirkt aus dem Buffer verwenden.</p>
<p>Ich möchte eigentlich das *.txt file duch einen Buffer, fester größe, ersetzen. Dieser soll in jedem schleifendurchlauf neue Daten erhalten. Leider bekomme ich das nicht richtig hin da ich ja in der Abfrage einen char benötige.</p>
<p>Eine zweite Frage hätte ich noch. Gibt es eine Möglichkeit das mit der verwendete Befehl &quot;strtok&quot; (Zeile 26) , für den fall z.B. &quot;A,B,,D&quot;, für das fehlende C eine 0 gesetzt wird?</p>
<p>Hier noch mein Code wie ich Ihn gerade verwende.</p>
<p>Ich würde mich freuen wenn Ihr ein paar Tipps für mich habt.</p>
<p>Vielen Dank</p>
<p>Gruß<br />
Bernd</p>
<pre><code>void serial::ReadPort() {

    int numBuff = 255;
    char szBuff[255];

    int numtemp;

    ofstream myfile; 
    myfile.open(&quot;/home/GPSTemp.txt&quot;);

    int i;
   while (1) {         

        numtemp = read(hndlserial, &amp;szBuff, sizeof (szBuff));
        if (szBuff != 0) {         

          FILE *file = fopen(&quot;/home/GPSTemp.txt&quot;, &quot;r&quot;); 

            char Buffer[255] = {0};                     

           while (fgets(Buffer, 255, file) != NULL) {  
             if (Buffer[0] == '$') {

                if (memcmp(Buffer + 1, &quot;GPGGA&quot;, 5) == 0) {
                    char *token = strtok(Buffer + 6, &quot;,&quot;);
                       Auswertung der Daten
                }
             }

          myfile &lt;&lt; szBuff&lt;&lt; &lt;&lt; endl; 
          szBuff[0] = 0;
          }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/316226/stream-direkt-verarbeiten</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 11:14:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/316226.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 26 Apr 2013 07:54:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Stream direkt verarbeiten on Fri, 26 Apr 2013 08:06:49 GMT]]></title><description><![CDATA[<p>Hallo Zusammen,</p>
<p>ich habe vor kurzem angefangen mich mit C / C++ zu beschäftigen um ein GPS Projekt durchzuführen.</p>
<p>Leider habe ich ein Problem bei dem ich nicht weiterkomme.</p>
<p>Ich erhalte von meinem GPS Sensor die Daten in der Form :<br />
<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>G</mi><mi>P</mi><mi>G</mi><mi>S</mi><mi>V</mi><mo separator="true">,</mo><mn>3</mn><mo separator="true">,</mo><mn>1</mn><mo separator="true">,</mo><mn>1</mn><mn>0</mn><mo separator="true">,</mo><mn>2</mn><mn>9</mn><mo separator="true">,</mo><mn>7</mn><mn>3</mn><mo separator="true">,</mo><mn>2</mn><mn>4</mn><mn>2</mn><mo separator="true">,</mo><mn>3</mn><mn>4</mn><mo separator="true">,</mo><mn>2</mn><mn>8</mn><mo separator="true">,</mo><mn>7</mn><mn>0</mn><mo separator="true">,</mo><mn>1</mn><mn>0</mn><mn>3</mn><mo separator="true">,</mo><mn>1</mn><mn>7</mn><mo separator="true">,</mo><mn>2</mn><mn>6</mn><mo separator="true">,</mo><mn>6</mn><mn>7</mn><mo separator="true">,</mo><mn>2</mn><mn>7</mn><mn>6</mn><mo separator="true">,</mo><mn>4</mn><mn>0</mn><mo separator="true">,</mo><mn>0</mn><mn>8</mn><mo separator="true">,</mo><mn>4</mn><mn>1</mn><mo separator="true">,</mo><mn>0</mn><mn>8</mn><mn>6</mn><mo separator="true">,</mo><mn>2</mn><mn>3</mn><mo>∗</mo><mn>7</mn><mi>F</mi></mrow><annotation encoding="application/x-tex">GPGSV,3,1,10,29,73,242,34,28,70,103,17,26,67,276,40,08,41,086,23*7F  
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.8777699999999999em;vertical-align:-0.19444em;"></span><span class="base textstyle uncramped"><span class="mord mathit">G</span><span class="mord mathit" style="margin-right:0.13889em;">P</span><span class="mord mathit">G</span><span class="mord mathit" style="margin-right:0.05764em;">S</span><span class="mord mathit" style="margin-right:0.22222em;">V</span><span class="mpunct">,</span><span class="mord mathrm">3</span><span class="mpunct">,</span><span class="mord mathrm">1</span><span class="mpunct">,</span><span class="mord mathrm">1</span><span class="mord mathrm">0</span><span class="mpunct">,</span><span class="mord mathrm">2</span><span class="mord mathrm">9</span><span class="mpunct">,</span><span class="mord mathrm">7</span><span class="mord mathrm">3</span><span class="mpunct">,</span><span class="mord mathrm">2</span><span class="mord mathrm">4</span><span class="mord mathrm">2</span><span class="mpunct">,</span><span class="mord mathrm">3</span><span class="mord mathrm">4</span><span class="mpunct">,</span><span class="mord mathrm">2</span><span class="mord mathrm">8</span><span class="mpunct">,</span><span class="mord mathrm">7</span><span class="mord mathrm">0</span><span class="mpunct">,</span><span class="mord mathrm">1</span><span class="mord mathrm">0</span><span class="mord mathrm">3</span><span class="mpunct">,</span><span class="mord mathrm">1</span><span class="mord mathrm">7</span><span class="mpunct">,</span><span class="mord mathrm">2</span><span class="mord mathrm">6</span><span class="mpunct">,</span><span class="mord mathrm">6</span><span class="mord mathrm">7</span><span class="mpunct">,</span><span class="mord mathrm">2</span><span class="mord mathrm">7</span><span class="mord mathrm">6</span><span class="mpunct">,</span><span class="mord mathrm">4</span><span class="mord mathrm">0</span><span class="mpunct">,</span><span class="mord mathrm">0</span><span class="mord mathrm">8</span><span class="mpunct">,</span><span class="mord mathrm">4</span><span class="mord mathrm">1</span><span class="mpunct">,</span><span class="mord mathrm">0</span><span class="mord mathrm">8</span><span class="mord mathrm">6</span><span class="mpunct">,</span><span class="mord mathrm">2</span><span class="mord mathrm">3</span><span class="mbin">∗</span><span class="mord mathrm">7</span><span class="mord mathit" style="margin-right:0.13889em;">F</span></span></span></span>GPRMC,080917.000,A,42.8881,N,0218.1801,E,0.01,351.01,0907,,,A<em>62<br />
$GPGGA,080918.000,42.80,N,0218.1806,E,1,06,1.5,120.3,M,27.5,M,,0000</em>58</p>
<p>Im Augenblick speichere ich die Char-Daten in einem logfile und lese sie dann aus. Ich möche jedoch gerne ohne das Speichern auskommen und die Daten dirkt aus dem Buffer verwenden.</p>
<p>Ich möchte eigentlich das *.txt file duch einen Buffer, fester größe, ersetzen. Dieser soll in jedem schleifendurchlauf neue Daten erhalten. Leider bekomme ich das nicht richtig hin da ich ja in der Abfrage einen char benötige.</p>
<p>Eine zweite Frage hätte ich noch. Gibt es eine Möglichkeit das mit der verwendete Befehl &quot;strtok&quot; (Zeile 26) , für den fall z.B. &quot;A,B,,D&quot;, für das fehlende C eine 0 gesetzt wird?</p>
<p>Hier noch mein Code wie ich Ihn gerade verwende.</p>
<p>Ich würde mich freuen wenn Ihr ein paar Tipps für mich habt.</p>
<p>Vielen Dank</p>
<p>Gruß<br />
Bernd</p>
<pre><code>void serial::ReadPort() {

    int numBuff = 255;
    char szBuff[255];

    int numtemp;

    ofstream myfile; 
    myfile.open(&quot;/home/GPSTemp.txt&quot;);

    int i;
   while (1) {         

        numtemp = read(hndlserial, &amp;szBuff, sizeof (szBuff));
        if (szBuff != 0) {         

          FILE *file = fopen(&quot;/home/GPSTemp.txt&quot;, &quot;r&quot;); 

            char Buffer[255] = {0};                     

           while (fgets(Buffer, 255, file) != NULL) {  
             if (Buffer[0] == '$') {

                if (memcmp(Buffer + 1, &quot;GPGGA&quot;, 5) == 0) {
                    char *token = strtok(Buffer + 6, &quot;,&quot;);
                       Auswertung der Daten
                }
             }

          myfile &lt;&lt; szBuff&lt;&lt; &lt;&lt; endl; 
          szBuff[0] = 0;
          }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2318568</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2318568</guid><dc:creator><![CDATA[proesel]]></dc:creator><pubDate>Fri, 26 Apr 2013 08:06:49 GMT</pubDate></item><item><title><![CDATA[Reply to Stream direkt verarbeiten on Fri, 26 Apr 2013 09:25:46 GMT]]></title><description><![CDATA[<p>Hallo und guten Tag</p>
<p>Dein Post leider etwas verwirrend weil er im C++/CLI Forum ist und du etwas von C und C++ schreibst.</p>
<p>Ich nehme nicht an, dass du wirklich C++/CLI Programmieren möchtest - das würde ziemlich sicher auch keinen Sinn machen, da diese Sprache einen sehr klaren Einsatzbereich hat.</p>
<p>Deshalb bleibt noch die Frage ob C oder C++ - ich persönlich würde das nicht mischen ausser du musst. Wenn du dich dann entschieden hast, verschiebt dich bestimmt ein netter Moderator. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Nur so als Hinweis - ev. wäre C# etwas für dich, da dort die Einstiegsschwelle niedriger ist als bei C++.</p>
<p>Gruss Simon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2318598</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2318598</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Fri, 26 Apr 2013 09:25:46 GMT</pubDate></item><item><title><![CDATA[Reply to Stream direkt verarbeiten on Fri, 26 Apr 2013 11:41:23 GMT]]></title><description><![CDATA[<p>Hallo Simon,</p>
<p>danke für die Info. Das hab ich völlig übersehen das hinter dem C++ noch CLI stand, das ist mein Fehler, da sollte der Beitrag auch nicht hin.</p>
<p>Da ich mit C schon etwas erfahrung habe wollte ich eben bei C und C++ bleiben. Zu C# kann ich nichts sagen, da ich mich damit noch nicht beschäftigt habe.</p>
<p>Ich würde mich freuen wenn ein Moderator diesen Beitrag in das C++ Forum schieben könnte.</p>
<p>Danke schon mal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2318605</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2318605</guid><dc:creator><![CDATA[proesel]]></dc:creator><pubDate>Fri, 26 Apr 2013 11:41:23 GMT</pubDate></item><item><title><![CDATA[Reply to Stream direkt verarbeiten on Fri, 26 Apr 2013 09:38:42 GMT]]></title><description><![CDATA[<p>Ok, dann ist mir nicht ganz klar, ob du ein File mit den Daten parsen möchtest oder direkt von der seriellen Schnittstelle lesen und parsen möchtest. Also wie?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2318607</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2318607</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Fri, 26 Apr 2013 09:38:42 GMT</pubDate></item><item><title><![CDATA[Reply to Stream direkt verarbeiten on Fri, 26 Apr 2013 11:41:12 GMT]]></title><description><![CDATA[<p>Ich möchte die die Daten direkt von der seriellen Schnittstelle lesen und parsen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2318637</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2318637</guid><dc:creator><![CDATA[proesel]]></dc:creator><pubDate>Fri, 26 Apr 2013 11:41:12 GMT</pubDate></item><item><title><![CDATA[Reply to Stream direkt verarbeiten on Fri, 26 Apr 2013 12:47:33 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/u18363" rel="nofollow">Jochen Kalmbach</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/f58" rel="nofollow">C++/CLI mit .NET</a> in das Forum <a href="http://www.c-plusplus.net/forum/f15" rel="nofollow">C++ (auch C++0x und C++11)</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2318678</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2318678</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Fri, 26 Apr 2013 12:47:33 GMT</pubDate></item><item><title><![CDATA[Reply to Stream direkt verarbeiten on Fri, 26 Apr 2013 12:59:34 GMT]]></title><description><![CDATA[<p>proesel schrieb:</p>
<blockquote>
<p>Da ich mit C schon etwas erfahrung habe wollte ich eben bei C und C++ bleiben.</p>
</blockquote>
<p>Was denn nun? C und C++ gleichzeitig geht nicht. Dein Code versucht das zwar zu mischen, aber das wird schiefgehen. C und C++ sind verschiedene Sprachen mit jeweils unterschiedlichen Herangehensweisen und inkompatiblen Standardbibliotheken.</p>
<p>proesel schrieb:</p>
<blockquote>
<p>Ich möchte die die Daten direkt von der seriellen Schnittstelle lesen und parsen.</p>
</blockquote>
<p>Die entscheidende Frage ist: Wie liest du die Daten von der seriellen Schnittstelle? Dazu nutzt du ja sicherlich irgendeine Bibliothek. Falls diese Bibliothek ein C++ Interface benutzt, dann hast du schon was du möchtest (sofern du C++ machen willst). Wenn sie ein C-Interface hast und du C++ möchtest, dann kapselst du die Schnittstelle in einen streambuf und koppelst diesen an einen istream. Wenn du C machen möchtest und die Bibliothek hat eine C-Schnittstelle, dann bist du ebenfalls schon direkt fertig. Wenn du C machen möchtest und die Bibliothek bietet nur eine C++-Schnittstelle: Oh, das, äh, das geht...irgendwie. Wird aber nicht so ganz einfach :p .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2318691</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2318691</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 26 Apr 2013 12:59:34 GMT</pubDate></item><item><title><![CDATA[Reply to Stream direkt verarbeiten on Fri, 26 Apr 2013 13:04:11 GMT]]></title><description><![CDATA[<blockquote>
<p>Stream direkt verarbeiten</p>
</blockquote>
<p>Vermische bitte nicht C und C++!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2318697</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2318697</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Fri, 26 Apr 2013 13:04:11 GMT</pubDate></item><item><title><![CDATA[Reply to Stream direkt verarbeiten on Fri, 26 Apr 2013 14:12:45 GMT]]></title><description><![CDATA[<p>Hallo Bernd,</p>
<p>Willkommen im C++-Forum.</p>
<p>proesel schrieb:</p>
<blockquote>
<p>Im Augenblick speichere ich die Char-Daten in einem logfile und lese sie dann aus. Ich möche jedoch gerne ohne das Speichern auskommen und die Daten dirkt aus dem Buffer verwenden.</p>
</blockquote>
<p>Da hast Du Dir gleich am Anfang eine anspruchsvolle Aufgabe vorgenommen. Gehe den Weg, den Dir SeppJ grob beschrieben hat. Er deutete ja bereits an</p>
<p>SeppJ schrieb:</p>
<blockquote>
<p>Wird aber nicht so ganz einfach :p .</p>
</blockquote>
<p>Wenn Du mit C++-Mitteln direkt von der seriellen Schnittstelle lesen möchtest, so benötigst Du einen konkreten <a href="http://www.cplusplus.com/reference/streambuf/streambuf" rel="nofollow">Streambuf</a>.<br />
So weit ich das aus Deinem Code-Schnipsel schließen kann, werden die Daten mit einer Funktion <code>read( hndlserial, ..</code> von der Schnittstelle gelesen.</p>
<p>Probiere mal folgenden Code aus - bitte die kommentierten Stellen vorher natürlich noch ausfüllen:</p>
<pre><code>#include &lt;streambuf&gt;
// #include &quot;&lt;serieller Schnittstellen Kram&gt;&quot;
class SerialIn : public std::streambuf
{
public:
    typedef void* handle_type;  // hier 'void*' ggf. gegen den Typ von 'hndlserial' ersetzen
    SerialIn( /* hier notwendige Parameter zum Öffnen der seriellen Schnittstelle einfügen */ )
        : hndlserial()
    {
        // hier Code einfügen, um hndlserial zu setzen
    }
    ~SerialIn()
    {
        // hier Code einfügen, um die serielle Schnittstelle zu schließen
        // close( hndlserial )
    }

protected:
    virtual int_type underflow()
    {
        int len = read( hndlserial, Buff, sizeof(Buff) ); // blockiert, wenn keine Daten anstehen - oder?!
        if( len &lt;= 0 )
            return traits_type::eof(); // Ende des Input -&gt; Fehler
        setp( Buff, Buff, Buff + len );
        return traits_type::to_int_type( *Buff ); // Ok; mit erstem Zeichen aus dem Buffer zurück
    }

private:
    handle_type hndlserial;
    char Buff[255];

    // --   Kopieren Verhindern
    SerialIn( const SerialIn&amp; );
    SerialIn&amp; operator=( const SerialIn&amp; );
};
</code></pre>
<p>Damit ausgerüstet kannst Du jetzt Deine Funktion <code>readPort()</code> neu schreiben:</p>
<pre><code>#include &lt;string&gt;
#include &lt;iostream&gt; // cout
#include &lt;limits&gt; // numeric_limits&lt;&gt;

// hier noch den obigen Code oder entsprechendes include einfügen

void readPort()
{
    using namespace std;
    SerialIn device( /* hier notwendige Parameter zum Öffnen der seriellen Schnittstelle einfügen */ );
    istream in( &amp;device ); // istream 'in' mit streambuf 'device' verbinden

    // --   folgendes ist nur zur Demo der Funktionsweise, parsen des Inputs sieht anders aus!
    in.ignore( std::numeric_limits&lt; streamsize &gt;::max(), '$' ); // Überlese alles bis zum '$'
    for( string token; getline( in, token, ',' ); ) // liest das erste Wort bis zum ','
    {
        string rest;
        getline( in, rest, '$' );
        cout &lt;&lt; &quot;Datensatz: &quot; &lt;&lt; token &lt;&lt; &quot; Rest: &quot; &lt;&lt; rest &lt;&lt; endl;
    }
}
</code></pre>
<p>Versuche zunächst das so zum Laufen zu bringen, und meld' Dich dann noch mal.</p>
<p>proesel schrieb:</p>
<blockquote>
<p>Eine zweite Frage hätte ich noch. Gibt es eine Möglichkeit das mit der verwendete Befehl &quot;strtok&quot; (Zeile 26) , für den fall z.B. &quot;A,B,,D&quot;, für das fehlende C eine 0 gesetzt wird?</p>
</blockquote>
<p>' <code>strtok</code> ' vergiss mal am besten, wie das geht machen wir später.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2318739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2318739</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Fri, 26 Apr 2013 14:12:45 GMT</pubDate></item><item><title><![CDATA[Reply to Stream direkt verarbeiten on Fri, 26 Apr 2013 16:38:59 GMT]]></title><description><![CDATA[<p>Super vielen Dank für die nette Hilfe.</p>
<p>Ich werd mir den Code nächste Woche genau anschauen. Eure Tipps haben mir aber jetzt schon soweit geholfen das es läuft <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":-)"
      alt="🙂"
    /><br />
Somit hoffe ich, das ich mir mein wochenende verdient hab <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";-)"
      alt="😉"
    /></p>
<p>Ich sag bescheid sobald ich den Code richtig und vollständig umgesetzt hab.</p>
<p>Danke nochma und ein schönes Wochen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2318791</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2318791</guid><dc:creator><![CDATA[proesel]]></dc:creator><pubDate>Fri, 26 Apr 2013 16:38:59 GMT</pubDate></item><item><title><![CDATA[Reply to Stream direkt verarbeiten on Sun, 28 Apr 2013 19:12:49 GMT]]></title><description><![CDATA[<p>Hallo Bernd,</p>
<p>Bei dem Input Deines Programms handelt es sich um ein <a href="http://de.wikipedia.org/wiki/NMEA_0183" rel="nofollow">NMEA 0183-Protokoll</a>. Da gibt es eine Menge Dinge, die 'input-technisch' ein wenig knifflig sind.<br />
Und es exisitert bereits eine in <a href="http://nmea.sourceforge.net/" rel="nofollow">C geschrieben Lib</a>, die Dir die einzelnen Pakete parsen kann. Ich habe mir das mal kurz angeschaut und finde sie recht ordentlich gemacht.</p>
<p>Entscheide Du Dich, ob das Programm in C oder C++ erstellt werden soll. Ich habe ein wenig experimentiert - hier ein (noch unvollendeter) Ausschnitt aus meinem Programmversuch, ein GGA-Paket zu parsen:</p>
<pre><code>std::istream&amp; operator&gt;&gt;( std::istream&amp; in, GGA&amp; gga )
{
    char g;
    return in &gt;&gt; gga.time &gt;&gt; comma &gt;&gt; geo_coordinate&lt;'N','S'&gt;(gga.latitude) &gt;&gt; comma &gt;&gt; geo_coordinate&lt;'E','W'&gt;(gga.longitude)
        &gt;&gt; comma &gt;&gt; gga.qualifier_indicator &gt;&gt; comma &gt;&gt; gga.n_sats 
        &gt;&gt; comma &gt;&gt; gga.horizontal_dilution_of_precision &gt;&gt; comma &gt;&gt; gga.antenna_altitude &gt;&gt; comma &gt;&gt; g
        &gt;&gt; comma &gt;&gt; gga.geoidal_separation &gt;&gt; comma &gt;&gt; g 
        &gt;&gt; comma &gt;&gt; opt(gga.age_of_differential_GPS_data=0) &gt;&gt; comma &gt;&gt; opt(gga.station_ID=0);
}
</code></pre>
<p>und das Pendat dazu aus der nmea-lib (Datei parse.c):</p>
<pre><code>int nmea_parse_GPGGA(const char *buff, int buff_sz, nmeaGPGGA *pack)
{
    char time_buff[NMEA_TIMEPARSE_BUF];
    NMEA_ASSERT(buff &amp;&amp; pack);
    memset(pack, 0, sizeof(nmeaGPGGA));
    nmea_trace_buff(buff, buff_sz);
    if(14 != nmea_scanf(buff, buff_sz,
        &quot;$GPGGA,%s,%f,%C,%f,%C,%d,%d,%f,%f,%C,%f,%C,%f,%d*&quot;,
        &amp;(time_buff[0]),
        &amp;(pack-&gt;lat), &amp;(pack-&gt;ns), &amp;(pack-&gt;lon), &amp;(pack-&gt;ew),
        &amp;(pack-&gt;sig), &amp;(pack-&gt;satinuse), &amp;(pack-&gt;HDOP), &amp;(pack-&gt;elv), &amp;(pack-&gt;elv_units),
        &amp;(pack-&gt;diff), &amp;(pack-&gt;diff_units), &amp;(pack-&gt;dgps_age), &amp;(pack-&gt;dgps_sid)))
    {
        nmea_error(&quot;GPGGA parse error!&quot;);
        return 0;
    }
    if(0 != _nmea_parse_time(&amp;time_buff[0], (int)strlen(&amp;time_buff[0]), &amp;(pack-&gt;utc)))
    {
        nmea_error(&quot;GPGGA time parse error!&quot;);
        return 0;
    }
    return 1;
}
</code></pre>
<p>Der Autor der nmea-lib hat sich ein eigens <code>scanf</code> (' <code>nmea_scanf</code> ' s.o.) geschrieben. In C++ habe ich das mit einigen Manipulatoren wie z.B.: <code>comma</code> , <code>geo_coordinate</code> und <code>opt</code> gelöst.</p>
<p>Falls Du Dich für C++ entscheidest, werde ich versuchen Dir zu erklären, wie das geht.</p>
<p>Bis dann &amp; Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2319473</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2319473</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Sun, 28 Apr 2013 19:12:49 GMT</pubDate></item></channel></rss>