<?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[Troubleshooting HDLC SNRM Handshake Timeout and 4-Byte Address Extension Bit]]></title><description><![CDATA[<h3>Problem Description</h3>
<p dir="auto">When connecting to 3-phase smart meters over RS-485 using DLMS/COSEM HDLC profile (IEC 62056-46), the client sends an SNRM (Set Normal Response Mode) frame, but the meter fails to return an unnumbered acknowledgment (UA) frame, resulting in communication timeout.</p>
<h4>Raw Hex Frame Trace</h4>
<pre><code class="language-hex">7E A0 0A 00 02 00 23 03 93 D4 71 7E
</code></pre>
<h4>HDLC Frame Breakdown</h4>
<ul>
<li><strong>Opening/Closing Flag</strong>: <code>7E</code></li>
<li><strong>Frame Format</strong>: <code>A0 0A</code> (Type 3, length 10 bytes)</li>
<li><strong>Server Address</strong>: <code>00 02 00 23</code> (4-byte logical + physical address)</li>
<li><strong>Client Address</strong>: <code>03</code> (Management client 0x01 shifted: <code>0x01 &lt;&lt; 1 | 1</code> = <code>0x03</code>)</li>
<li><strong>Control Field</strong>: <code>93</code> (SNRM command, P/F bit set)</li>
<li><strong>Header Check Sequence (HCS)</strong>: <code>D4 71</code> (CRC-16 CCITT)</li>
</ul>
<h4>Observed Behavior</h4>
<p dir="auto">Looking closely at the 4-byte server address field <code>00 02 00 23</code>:</p>
<ul>
<li>Byte 1: <code>00</code> (Logical address upper bits, bit 0 is 0 - extension bit)</li>
<li>Byte 2: <code>02</code> (Logical address lower bits, bit 0 is 0 - extension bit)</li>
<li>Byte 3: <code>00</code> (Physical address upper bits, bit 0 is 0 - extension bit)</li>
<li>Byte 4: <code>23</code> (Physical address lower bits, hex 0x23 = 00100011b)</li>
</ul>
<p dir="auto">In our custom gateway driver, the address generation logic forgot to mask the least significant bit (LSB) as the final address delimiter (bit 0 = 1) across the upper bytes, causing the meter's HDLC state machine to wait endlessly for additional address octets.</p>
]]></description><link>https://dlms.sharur.org/topic/11/troubleshooting-hdlc-snrm-handshake-timeout-and-4-byte-address-extension-bit</link><generator>RSS for Node</generator><lastBuildDate>Fri, 16 Oct 2026 19:26:30 GMT</lastBuildDate><atom:link href="https://dlms.sharur.org/topic/11.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 22 Aug 2026 12:32:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Troubleshooting HDLC SNRM Handshake Timeout and 4-Byte Address Extension Bit on Sat, 22 Aug 2026 12:35:10 GMT]]></title><description><![CDATA[<p dir="auto">Field testing confirms this resolution on 120+ meters in the regional substation gateway deployment. After patching the gateway firmware with Elena's bit-extension mask, all optical probe and RS-485 connection timeouts dropped to zero.</p>
]]></description><link>https://dlms.sharur.org/post/52</link><guid isPermaLink="true">https://dlms.sharur.org/post/52</guid><dc:creator><![CDATA[carlos_mendez]]></dc:creator><pubDate>Sat, 22 Aug 2026 12:35:10 GMT</pubDate></item><item><title><![CDATA[Reply to Troubleshooting HDLC SNRM Handshake Timeout and 4-Byte Address Extension Bit on Sat, 22 Aug 2026 12:32:48 GMT]]></title><description><![CDATA[<p dir="auto">We ran into this exact issue when integrating with Landis+Gyr and Itron meters in our Head-End System. Some meter models strictly validate the HDLC address length and will discard frames immediately if the CRC passes but the address field delimiter doesn't match the configured addressing mode.</p>
<p dir="auto">Also remember to ensure your client address uses the shifted format (<code>client_id &lt;&lt; 1 | 0x01</code>), so Client 16 (0x10) becomes <code>0x21</code>.</p>
]]></description><link>https://dlms.sharur.org/post/26</link><guid isPermaLink="true">https://dlms.sharur.org/post/26</guid><dc:creator><![CDATA[marcus_vance]]></dc:creator><pubDate>Sat, 22 Aug 2026 12:32:48 GMT</pubDate></item><item><title><![CDATA[Reply to Troubleshooting HDLC SNRM Handshake Timeout and 4-Byte Address Extension Bit on Sat, 22 Aug 2026 12:32:47 GMT]]></title><description><![CDATA[<p dir="auto">Great catch <a class="plugin-mentions-user plugin-mentions-a" href="/user/david_miller" aria-label="Profile: david_miller">@<bdi>david_miller</bdi></a>! According to <strong>ISO/IEC 13239 / IEC 62056-46 Clause 6.2.2</strong>, the HDLC address field is extended using the low-order bit (bit 0):</p>
<ul>
<li>In all octets except the last, bit 0 MUST be <code>0</code>.</li>
<li>In the last octet of the address, bit 0 MUST be <code>1</code>.</li>
</ul>
<p dir="auto">Here is a clean C implementation for serializing multi-byte HDLC server addresses properly:</p>
<pre><code class="language-c">void encode_hdlc_address(uint16_t logical, uint16_t physical, uint8_t *buf, int *len) {
    // Logical Device Address (2 bytes)
    buf[0] = (uint8_t)((logical &gt;&gt; 7) &amp; 0xFE);        // bit 0 = 0
    buf[1] = (uint8_t)((logical &lt;&lt; 1) &amp; 0xFE);        // bit 0 = 0
    // Physical Device Address (2 bytes)
    buf[2] = (uint8_t)((physical &gt;&gt; 7) &amp; 0xFE);       // bit 0 = 0
    buf[3] = (uint8_t)(((physical &lt;&lt; 1) &amp; 0xFE) | 0x01); // bit 0 = 1 (TERMINATOR)
    *len = 4;
}
</code></pre>
<p dir="auto">Once bit 0 is set only on the terminal octet, the meter instantly processes the SNRM frame and replies with UA (<code>7E A0 ... 73 ... 7E</code>).</p>
]]></description><link>https://dlms.sharur.org/post/25</link><guid isPermaLink="true">https://dlms.sharur.org/post/25</guid><dc:creator><![CDATA[elena_rostova]]></dc:creator><pubDate>Sat, 22 Aug 2026 12:32:47 GMT</pubDate></item></channel></rss>