<?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[String in hex umwandeln?]]></title><description><![CDATA[<p>Moin!<br />
Mein Problem sieht wie folgt aus:<br />
ich habe ein prog zu Com-Kommunikation und will damit daten mit einem Chipkartenleser austauschen. Ich muß die Daten als hex-bytes schicken. Wie kann ich z.B. &quot;<strong>60 05 22 05 3F E0 10 8D</strong>&quot; diese 8 Hex-bytes senden. Bis jetzt kann mein prog nur strings senden:</p>
<pre><code class="language-cpp">void CTest::OnTest() 
{

    DCB PortConfig; 
    hCom = CreateFile(&quot;COM1&quot;, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); 
    if(GetCommState(hCom,&amp;PortConfig) == 0) 
    { 
        //hier fehlerbehandlung
		MessageBox(&quot;1.Senden nicht möglich!&quot;);
        return; 
    } 
    PortConfig.BaudRate = CBR_9600; 
    PortConfig.StopBits = ONESTOPBIT; 
    PortConfig.Parity = NOPARITY; 
    PortConfig.ByteSize = 8; 
    if(SetCommState(hCom,&amp;PortConfig) == 0) 
    { 
        //hier error;
		MessageBox(&quot;2.Senden nicht möglich!&quot;);
    } 

    //SENDEN 
    unsigned long length = 0; 
    CString sDaten = &quot;60 05 22 05 3F E0 10 8D&quot;; 
	if(WriteFile(hCom, sDaten, sDaten.GetLength(), &amp;length,NULL) == 0) 
    { 
        //hier fehlerbehandlung
		MessageBox(&quot;3.Senden nicht möglich!&quot;);
        return; 
    }
	CloseHandle(hCom);
}
</code></pre>
<p><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>
]]></description><link>https://www.c-plusplus.net/forum/topic/84420/string-in-hex-umwandeln</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 02:16:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/84420.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 30 Aug 2004 07:56:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to String in hex umwandeln? on Mon, 30 Aug 2004 07:56:04 GMT]]></title><description><![CDATA[<p>Moin!<br />
Mein Problem sieht wie folgt aus:<br />
ich habe ein prog zu Com-Kommunikation und will damit daten mit einem Chipkartenleser austauschen. Ich muß die Daten als hex-bytes schicken. Wie kann ich z.B. &quot;<strong>60 05 22 05 3F E0 10 8D</strong>&quot; diese 8 Hex-bytes senden. Bis jetzt kann mein prog nur strings senden:</p>
<pre><code class="language-cpp">void CTest::OnTest() 
{

    DCB PortConfig; 
    hCom = CreateFile(&quot;COM1&quot;, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); 
    if(GetCommState(hCom,&amp;PortConfig) == 0) 
    { 
        //hier fehlerbehandlung
		MessageBox(&quot;1.Senden nicht möglich!&quot;);
        return; 
    } 
    PortConfig.BaudRate = CBR_9600; 
    PortConfig.StopBits = ONESTOPBIT; 
    PortConfig.Parity = NOPARITY; 
    PortConfig.ByteSize = 8; 
    if(SetCommState(hCom,&amp;PortConfig) == 0) 
    { 
        //hier error;
		MessageBox(&quot;2.Senden nicht möglich!&quot;);
    } 

    //SENDEN 
    unsigned long length = 0; 
    CString sDaten = &quot;60 05 22 05 3F E0 10 8D&quot;; 
	if(WriteFile(hCom, sDaten, sDaten.GetLength(), &amp;length,NULL) == 0) 
    { 
        //hier fehlerbehandlung
		MessageBox(&quot;3.Senden nicht möglich!&quot;);
        return; 
    }
	CloseHandle(hCom);
}
</code></pre>
<p><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>
]]></description><link>https://www.c-plusplus.net/forum/post/594943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/594943</guid><dc:creator><![CDATA[Bullach]]></dc:creator><pubDate>Mon, 30 Aug 2004 07:56:04 GMT</pubDate></item><item><title><![CDATA[Reply to String in hex umwandeln? on Mon, 30 Aug 2004 12:20:56 GMT]]></title><description><![CDATA[<p>tach auch,<br />
mittels strtol(..) müsstest du arbeitem können ..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/595225</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/595225</guid><dc:creator><![CDATA[wuTangl]]></dc:creator><pubDate>Mon, 30 Aug 2004 12:20:56 GMT</pubDate></item><item><title><![CDATA[Reply to String in hex umwandeln? on Mon, 30 Aug 2004 12:22:22 GMT]]></title><description><![CDATA[<p>Guck dir das mal an: <a href="http://www.c-plusplus.net/forum/viewtopic.php?t=71870&amp;postdays=0&amp;postorder=asc&amp;highlight=string+hex&amp;start=10" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic.php?t=71870&amp;postdays=0&amp;postorder=asc&amp;highlight=string+hex&amp;start=10</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/595227</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/595227</guid><dc:creator><![CDATA[Max M.]]></dc:creator><pubDate>Mon, 30 Aug 2004 12:22:22 GMT</pubDate></item><item><title><![CDATA[Reply to String in hex umwandeln? on Mon, 06 Sep 2004 09:07:06 GMT]]></title><description><![CDATA[<p>Bullach schrieb:</p>
<blockquote>
<p>Moin!<br />
Mein Problem sieht wie folgt aus:<br />
ich habe ein prog zu Com-Kommunikation und will damit daten mit einem Chipkartenleser austauschen. Ich muß die Daten als hex-bytes schicken. Wie kann ich z.B. &quot;<strong>60 05 22 05 3F E0 10 8D</strong>&quot; diese 8 Hex-bytes senden. Bis jetzt kann mein prog nur strings senden:</p>
<p>[cpp]<br />
void CTest::OnTest()<br />
{</p>
<p>DCB PortConfig;<br />
hCom = CreateFile(&quot;COM1&quot;, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);<br />
if(GetCommState(hCom,&amp;PortConfig) == 0)<br />
{<br />
//hier fehlerbehandlung<br />
MessageBox(&quot;1.Senden nicht möglich!&quot;);<br />
return;<br />
}<br />
PortConfig.BaudRate = CBR_9600;<br />
PortConfig.StopBits = ONESTOPBIT;<br />
PortConfig.Parity = NOPARITY;<br />
PortConfig.ByteSize = 8;<br />
if(SetCommState(hCom,&amp;PortConfig) == 0)<br />
{<br />
//hier error;<br />
MessageBox(&quot;2.Senden nicht möglich!&quot;);<br />
}</p>
<p>//SENDEN<br />
unsigned long length = 0;<br />
CString sDaten = &quot;600522053FE0108D&quot;;<br />
if(WriteFile(hCom, sDaten, sDaten.GetLength(), &amp;length,NULL) == 0)<br />
{<br />
//hier fehlerbehandlung<br />
MessageBox(&quot;3.Senden nicht möglich!&quot;);<br />
return;<br />
}<br />
<strong>CString sDaten = 0x03<br />
if(WriteFile(hCom, sDaten, sDaten.GetLength(), &amp;length,NULL) == 0)<br />
{<br />
//hier fehlerbehandlung<br />
MessageBox(&quot;3.Senden nicht möglich!&quot;);<br />
return;<br />
}</strong><br />
CloseHandle(hCom);<br />
}[/cpp]<br />
<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>
</blockquote>
<p>Hat jetzt fnktioniert!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
End of Text hat gefehlt. Die hex-bytes kann man wie oben schicken. COOL</p>
]]></description><link>https://www.c-plusplus.net/forum/post/600496</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/600496</guid><dc:creator><![CDATA[Bullach]]></dc:creator><pubDate>Mon, 06 Sep 2004 09:07:06 GMT</pubDate></item></channel></rss>