<?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[OBIS 1.0.32.7.0.255 Phase A Voltage Scaler-Unit 0xFF Parsing Bug (-1 vs 255 Exponent)]]></title><description><![CDATA[<h3>Overview</h3>
<p dir="auto">When querying Class 3 (Register) object <code>1.0.32.7.0.255</code> (Phase A Instantaneous Voltage), our data collector parsed a raw voltage value of <code>2200</code> with scaler <code>0xFF</code> and produced a catastrophic measurement reading: <code>2200000000000000000000 V</code> (2.2 x 10^27 V).</p>
<h4>DLMS APDU Response Trace</h4>
<pre><code class="language-hex">C4 01 C1 00 00 02 02 12 08 98 02 02 0F FF 16 23
</code></pre>
<h4>ASN.1 Type Dissection</h4>
<ul>
<li><code>C4 01 C1</code>: <code>GET-Response-Normal</code> (Invoke-Id-And-Priority <code>C1</code>)</li>
<li><code>00 00</code>: Data-Access-Result <code>success</code> (0)</li>
<li><code>02 02</code>: Structure of 2 elements
<ul>
<li><code>12 08 98</code>: Element 1 -&gt; <code>double-long-unsigned</code> (Value = 2200 / <code>0x0898</code>)</li>
<li><code>02 02</code>: Element 2 -&gt; Structure of 2 elements (Scaler_Unit_Type)
<ul>
<li><code>0F FF</code>: Scaler -&gt; <strong><code>Integer8</code></strong> (<code>0xFF</code>)</li>
<li><code>16 23</code>: Unit -&gt; <code>enum</code> (35 = <code>0x23</code> = Volts <code>V</code>)</li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Root Cause</h4>
<p dir="auto">Per <strong>DLMS Blue Book Section 4.3.3</strong>, the <code>scaler</code> field is of type <strong><code>Integer8</code> (signed 8-bit integer)</strong> in two's complement representation.</p>
<ul>
<li><code>0xFF</code> = <code>-1</code> (Scaling factor is $10^{-1} = 0.1$)</li>
<li>Correct calculation: $2200 \times 10^{-1} = 220.0\text{ V}$</li>
<li>The bug: The parsing library treated <code>0xFF</code> as <code>uint8_t</code> (255), evaluating $2200 \times 10^{255}$ and overflowing database decimal columns!</li>
</ul>
]]></description><link>https://dlms.sharur.org/topic/12/obis-1.0.32.7.0.255-phase-a-voltage-scaler-unit-0xff-parsing-bug-1-vs-255-exponent</link><generator>RSS for Node</generator><lastBuildDate>Fri, 16 Oct 2026 19:50:08 GMT</lastBuildDate><atom:link href="https://dlms.sharur.org/topic/12.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 22 Aug 2026 12:32:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to OBIS 1.0.32.7.0.255 Phase A Voltage Scaler-Unit 0xFF Parsing Bug (-1 vs 255 Exponent) on Sat, 22 Aug 2026 12:35:12 GMT]]></title><description><![CDATA[<p dir="auto">Thanks Elena! We applied the signed <code>int8</code> cast in the collection pipeline parser. All phase voltages (A/B/C: <code>1.0.32.7.0.255</code>, <code>1.0.52.7.0.255</code>, <code>1.0.72.7.0.255</code>) now correctly read 220.4V, 219.8V, and 220.1V.</p>
]]></description><link>https://dlms.sharur.org/post/55</link><guid isPermaLink="true">https://dlms.sharur.org/post/55</guid><dc:creator><![CDATA[sarah_jenkins]]></dc:creator><pubDate>Sat, 22 Aug 2026 12:35:12 GMT</pubDate></item><item><title><![CDATA[Reply to OBIS 1.0.32.7.0.255 Phase A Voltage Scaler-Unit 0xFF Parsing Bug (-1 vs 255 Exponent) on Sat, 22 Aug 2026 12:35:12 GMT]]></title><description><![CDATA[<p dir="auto">Note that for <strong>Class 4 (Extended Register)</strong> and <strong>Class 5 (Demand Register)</strong>, the scaler-unit structure is identical, but is followed by a <code>status</code> octet-string or bit-string and an optional <code>capture_time</code> (Octet-String, 12 bytes). If you don't enforce signed <code>int8</code> decoding across all register classes, power factor and reactive energy registers with negative scalers will corrupt downstream analytics.</p>
]]></description><link>https://dlms.sharur.org/post/54</link><guid isPermaLink="true">https://dlms.sharur.org/post/54</guid><dc:creator><![CDATA[david_miller]]></dc:creator><pubDate>Sat, 22 Aug 2026 12:35:12 GMT</pubDate></item><item><title><![CDATA[Reply to OBIS 1.0.32.7.0.255 Phase A Voltage Scaler-Unit 0xFF Parsing Bug (-1 vs 255 Exponent) on Sat, 22 Aug 2026 12:35:11 GMT]]></title><description><![CDATA[<p dir="auto">This is one of the classic pitfalls in DLMS COSEM client implementations!</p>
<p dir="auto">Here is the safe deserialization snippet in Python:</p>
<pre><code class="language-python">import struct

def decode_scaler_unit(scaler_byte, unit_enum):
    # 'b' ensures signed 8-bit integer interpretation (-128 to 127)
    signed_scaler = struct.unpack('b', bytes([scaler_byte]))[0]
    multiplier = 10 ** signed_scaler
    return signed_scaler, multiplier

scaler, mult = decode_scaler_unit(0xFF, 35)
print(f"Scaler: {scaler}, Multiplier: {mult}, Voltage: {2200 * mult} V")
# Output: Scaler: -1, Multiplier: 0.1, Voltage: 220.0 V
</code></pre>
]]></description><link>https://dlms.sharur.org/post/53</link><guid isPermaLink="true">https://dlms.sharur.org/post/53</guid><dc:creator><![CDATA[elena_rostova]]></dc:creator><pubDate>Sat, 22 Aug 2026 12:35:11 GMT</pubDate></item></channel></rss>