<?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[nochmal Packed ASCII]]></title><description><![CDATA[<blockquote>
<p>HART makes limited use of data compression in the form of Packed ASCII. Normally, there are 256 possible ASCII characters, so that a full byte is needed to represent a character. Packed ASCII is a subset of full ASCII and uses only 64 of the 256 possible characters. These 64 characters are the capitalized alphabet, numbers 0 through 9, and a few punctuation marks. Many HART parameters need only this limited ASCII set, which means that data can be compressed to 3/4 of normal. This improves transmission speed, especially if the textual parameter being communicated is a large one.</p>
<p>Since only full bytes can be transmitted, the 3/4 compression is fully realized only when the number of uncompressed bytes is a multiple of 4. Any fractional part requires a whole byte. Thus, if U is the number of uncompressed bytes, and T the number of transmitted bytes; find T = (3*U)/4 and increase any fractional part to 1. As examples, U = 3, 7, 8, and 9 result in T = 3, 6, 6, and 7.</p>
<p>The rule for converting from ASCII to Packed ASCII is just to remove bits 6 and 7 (two most significant). An example is the character &quot;M&quot;. The full binary code to represent this is 0100,1101. The packed binary code is 00,1101. The rules for conversion from packed ASCII back to ASCII are (1) set bit 7 = 0 and (2) set bit 6 = complement of packed ASCII bit 5.</p>
<p>Note that, with some exceptions, HART Slaves don't need to do the compression or know anything about the compression. They simply store and re-transmit the already compressed data. Again, this is an instance where the more difficult software is placed in the device (Master) that is more capable of dealing with it.</p>
</blockquote>
<p>um nun den String ABCD darzustellen, sendet mir ein Messgerät:<br />
0x04 0x20 0xC4.</p>
<p>Diese Hexdezimalen Werte stelle ich nun binär dar:<br />
00000100 00100000 11000100</p>
<p>Nun teile ich sie in 4 Segment zu je 6Bit auf:<br />
000001 000010 000011 000100</p>
<p>Nun wieder auf 8Bit-Länge bringen mit der Regel(set bit 7 = 0 and (2) set bit 6 = complement of packed ASCII bit 5.):<br />
01000001 01000010 01000011 01000100</p>
<p>Nun in der ASCII-Tabelle nachschauen und das Ergebnis ist: ABCD</p>
<p>Mir fehlt jetzt noch eine Methode, in VC++, die genau das für mich macht.<br />
Hat jemand eine Idee wie man sowas elegant lösen kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/175001/nochmal-packed-ascii</link><generator>RSS for Node</generator><lastBuildDate>Sun, 05 Jul 2026 19:27:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/175001.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Mar 2007 09:16:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to nochmal Packed ASCII on Tue, 06 Mar 2007 09:16:01 GMT]]></title><description><![CDATA[<blockquote>
<p>HART makes limited use of data compression in the form of Packed ASCII. Normally, there are 256 possible ASCII characters, so that a full byte is needed to represent a character. Packed ASCII is a subset of full ASCII and uses only 64 of the 256 possible characters. These 64 characters are the capitalized alphabet, numbers 0 through 9, and a few punctuation marks. Many HART parameters need only this limited ASCII set, which means that data can be compressed to 3/4 of normal. This improves transmission speed, especially if the textual parameter being communicated is a large one.</p>
<p>Since only full bytes can be transmitted, the 3/4 compression is fully realized only when the number of uncompressed bytes is a multiple of 4. Any fractional part requires a whole byte. Thus, if U is the number of uncompressed bytes, and T the number of transmitted bytes; find T = (3*U)/4 and increase any fractional part to 1. As examples, U = 3, 7, 8, and 9 result in T = 3, 6, 6, and 7.</p>
<p>The rule for converting from ASCII to Packed ASCII is just to remove bits 6 and 7 (two most significant). An example is the character &quot;M&quot;. The full binary code to represent this is 0100,1101. The packed binary code is 00,1101. The rules for conversion from packed ASCII back to ASCII are (1) set bit 7 = 0 and (2) set bit 6 = complement of packed ASCII bit 5.</p>
<p>Note that, with some exceptions, HART Slaves don't need to do the compression or know anything about the compression. They simply store and re-transmit the already compressed data. Again, this is an instance where the more difficult software is placed in the device (Master) that is more capable of dealing with it.</p>
</blockquote>
<p>um nun den String ABCD darzustellen, sendet mir ein Messgerät:<br />
0x04 0x20 0xC4.</p>
<p>Diese Hexdezimalen Werte stelle ich nun binär dar:<br />
00000100 00100000 11000100</p>
<p>Nun teile ich sie in 4 Segment zu je 6Bit auf:<br />
000001 000010 000011 000100</p>
<p>Nun wieder auf 8Bit-Länge bringen mit der Regel(set bit 7 = 0 and (2) set bit 6 = complement of packed ASCII bit 5.):<br />
01000001 01000010 01000011 01000100</p>
<p>Nun in der ASCII-Tabelle nachschauen und das Ergebnis ist: ABCD</p>
<p>Mir fehlt jetzt noch eine Methode, in VC++, die genau das für mich macht.<br />
Hat jemand eine Idee wie man sowas elegant lösen kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1240052</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1240052</guid><dc:creator><![CDATA[maRKus23]]></dc:creator><pubDate>Tue, 06 Mar 2007 09:16:01 GMT</pubDate></item><item><title><![CDATA[Reply to nochmal Packed ASCII on Tue, 06 Mar 2007 10:06:40 GMT]]></title><description><![CDATA[<p>Du kannst die vier Bytes in eine 'unsigned long' Variable einlesen und mit Bit-Operatoren (&amp;,|,&gt;&gt;) auseinandernehmen:</p>
<pre><code class="language-cpp">//Achtung: ungetestet
unsigned long packed;
read(device,&amp;packed,3);
char unpacked[5]={0};
for(int i=0;i&lt;4;++i)
{
  unpacked[i]=packed&gt;&gt;(6*(3-i)) &amp; 0x3F;
  char bit6 = (~unpacked[i] &amp; 0x10) &lt;&lt; 1;
  unpacked[i]|=bit6;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1240070</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1240070</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 06 Mar 2007 10:06:40 GMT</pubDate></item><item><title><![CDATA[Reply to nochmal Packed ASCII on Tue, 06 Mar 2007 09:48:42 GMT]]></title><description><![CDATA[<p>Hmm? So ganz kapiere ich ja nicht was du da machst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1240084</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1240084</guid><dc:creator><![CDATA[maRKus23]]></dc:creator><pubDate>Tue, 06 Mar 2007 09:48:42 GMT</pubDate></item><item><title><![CDATA[Reply to nochmal Packed ASCII on Tue, 06 Mar 2007 10:08:10 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<pre><code class="language-cpp">for(int i=0;i&lt;4;++i)
{
  unpacked[i]=packed&gt;&gt;(6*(3-i)) &amp; 0x3F;   //aufteilen in 6er-Blöcke
  char bit6 = (~unpacked[i] &amp; 0x10) &lt;&lt; 1; //&quot;set bit 6 = complement of packed ASCII bit 5.)&quot;
  unpacked[i]|=bit6;                      //bit 6 wird gesetzt (bit 7 wurde von vornherein mit 0 belegt
}
</code></pre>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1240104</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1240104</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 06 Mar 2007 10:08:10 GMT</pubDate></item></channel></rss>