<?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[Patch for UDP 7 segments bug]]></title><description><![CDATA[<p dir="auto">Hi Matthew,</p>
<p dir="auto">We found a bug where com.serotonin.bacnet4j.npdu.ip.IpMessageControl.sendResponse(InetSocketAddress, Network, ConfirmedRequest, AcknowledgementService) was limiting the number of UDP packets to 7 segments instead of more than 64.  We need to have at least 2000 BACnet Objects on a local device and it was complaining about too many segments.</p>
<p dir="auto">I have created a patch for this, how should I give this to you?</p>
<p dir="auto">For my own convenience I have converted your CVS repository to GIT, so if you like I could put the repository up on Github, then I could fork your repository and create pull request. Otherwise I can just upload a patch in the [url=<a href="http://sourceforge.net/tracker/?group_id=224576&amp;atid=1062318" rel="nofollow ugc">http://sourceforge.net/tracker/?group_id=224576&amp;atid=1062318</a>]Patches section of sourceforge</p>
<p dir="auto">Let me know what you prefer.</p>
<p dir="auto">Cheers,</p>
<p dir="auto">-Joel</p>
]]></description><link>https://forum.mango-os.com/topic/1108/patch-for-udp-7-segments-bug</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 15:19:26 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/1108.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 29 Aug 2012 03:51:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Patch for UDP 7 segments bug on Tue, 04 Sep 2012 17:39:56 GMT]]></title><description><![CDATA[<p dir="auto">Indeed. A fix has been checked in.</p>
]]></description><link>https://forum.mango-os.com/post/6794</link><guid isPermaLink="true">https://forum.mango-os.com/post/6794</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Tue, 04 Sep 2012 17:39:56 GMT</pubDate></item><item><title><![CDATA[Reply to Patch for UDP 7 segments bug on Tue, 04 Sep 2012 07:31:37 GMT]]></title><description><![CDATA[<p dir="auto">Hi Matthew,</p>
<p dir="auto">You missed the MORE_THAN_64 segments in the valueOf function, which makes bacnet4j pretty unusable</p>
<p dir="auto">This is the diff of what's missing:</p>
<pre><code>diff --git a/src/com/serotonin/bacnet4j/enums/MaxSegments.java b/src/com/serotonin/bacnet4j/enums/MaxSegments.java
index 0845c74..362e210 100644
--- a/src/com/serotonin/bacnet4j/enums/MaxSegments.java
+++ b/src/com/serotonin/bacnet4j/enums/MaxSegments.java
@@ -67,6 +67,8 @@ public enum MaxSegments {
             return UP_TO_32;
         if (id == UP_TO_64.id)
             return UP_TO_64;
+        if (id == MORE_THAN_64.id)
+            return MORE_THAN_64;
 
         throw new IllegalArgumentException("Unknown id: " + id);
     }
</code></pre>
<p dir="auto">Cheers,</p>
<p dir="auto">-Joel</p>
]]></description><link>https://forum.mango-os.com/post/6792</link><guid isPermaLink="true">https://forum.mango-os.com/post/6792</guid><dc:creator><![CDATA[japearson]]></dc:creator><pubDate>Tue, 04 Sep 2012 07:31:37 GMT</pubDate></item><item><title><![CDATA[Reply to Patch for UDP 7 segments bug on Thu, 30 Aug 2012 03:17:23 GMT]]></title><description><![CDATA[<p dir="auto">Patch has been applied. Thanks.</p>
]]></description><link>https://forum.mango-os.com/post/6775</link><guid isPermaLink="true">https://forum.mango-os.com/post/6775</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Thu, 30 Aug 2012 03:17:23 GMT</pubDate></item><item><title><![CDATA[Reply to Patch for UDP 7 segments bug on Wed, 29 Aug 2012 06:34:42 GMT]]></title><description><![CDATA[<p dir="auto">Ok done: <a href="https://sourceforge.net/tracker/?func=detail&amp;aid=3562579&amp;group_id=224576&amp;atid=1062318" rel="nofollow ugc">https://sourceforge.net/tracker/?func=detail&amp;aid=3562579&amp;group_id=224576&amp;atid=1062318</a></p>
]]></description><link>https://forum.mango-os.com/post/6766</link><guid isPermaLink="true">https://forum.mango-os.com/post/6766</guid><dc:creator><![CDATA[japearson]]></dc:creator><pubDate>Wed, 29 Aug 2012 06:34:42 GMT</pubDate></item><item><title><![CDATA[Reply to Patch for UDP 7 segments bug on Wed, 29 Aug 2012 06:20:40 GMT]]></title><description><![CDATA[<p dir="auto">Re test, sure, send it along.</p>
]]></description><link>https://forum.mango-os.com/post/6765</link><guid isPermaLink="true">https://forum.mango-os.com/post/6765</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Wed, 29 Aug 2012 06:20:40 GMT</pubDate></item><item><title><![CDATA[Reply to Patch for UDP 7 segments bug on Wed, 29 Aug 2012 06:20:18 GMT]]></title><description><![CDATA[<p dir="auto">I noticed that too and committed a fix just after.</p>
]]></description><link>https://forum.mango-os.com/post/6764</link><guid isPermaLink="true">https://forum.mango-os.com/post/6764</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Wed, 29 Aug 2012 06:20:18 GMT</pubDate></item><item><title><![CDATA[Reply to Patch for UDP 7 segments bug on Wed, 29 Aug 2012 06:15:45 GMT]]></title><description><![CDATA[<p dir="auto">Thanks that now breaks the AnnexFEncodingTest though, I also wrote a test that tries to use 4000 objects as well, should I submit that as a patch for you?</p>
]]></description><link>https://forum.mango-os.com/post/6763</link><guid isPermaLink="true">https://forum.mango-os.com/post/6763</guid><dc:creator><![CDATA[japearson]]></dc:creator><pubDate>Wed, 29 Aug 2012 06:15:45 GMT</pubDate></item><item><title><![CDATA[Reply to Patch for UDP 7 segments bug on Wed, 29 Aug 2012 06:02:20 GMT]]></title><description><![CDATA[<p dir="auto">Ah, i see what you mean. The code is using the encoded value as the actual max segments. I've checked in a fix for this into the SF repo. I created an enum for the max segments like there is for the max APDU length. Thanks for pointing this out.</p>
]]></description><link>https://forum.mango-os.com/post/6762</link><guid isPermaLink="true">https://forum.mango-os.com/post/6762</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Wed, 29 Aug 2012 06:02:20 GMT</pubDate></item><item><title><![CDATA[Reply to Patch for UDP 7 segments bug on Wed, 29 Aug 2012 05:26:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mlohbihler" aria-label="Profile: mlohbihler">@<bdi>mlohbihler</bdi></a> said:</p>
<blockquote>
<p dir="auto">Not sure what you mean. This is the code that i have (lines 274 and 275):</p>
<pre><code>           if (segmentsRequired &amp;gt; request.getMaxSegmentsAccepted() || segmentsRequired &amp;gt; 128)
               throw new BACnetException(&amp;quot;Response too big to send to device; too many segments required&amp;quot;);

</code></pre>
<p dir="auto">BACnet4J will respond with up to 128 segments unless limited further by the max accepted by the client.</p>
</blockquote>
<p dir="auto">That is true, however request.getMaxSegmentsAccepted() is a maximum of number 7 and not 128.</p>
<p dir="auto">Look at lines 240 - 258 of ConfirmedRequest, maxSegmentsAccepted is set directly from the byte queue, which works for everything except the one use of getMaxSegmentsAccepted.  It needs to work exactly like maxApduLengthAccepted, which is the solution I came up with.  I created an enum that maps between the integer/byte value and the actual meaning of that value.</p>
<pre><code>    ConfirmedRequest(ServicesSupported servicesSupported, ByteQueue queue) throws BACnetException {
        byte b = queue.pop();
        segmentedMessage = (b &amp; 8) != 0;
        moreFollows = (b &amp; 4) != 0;
        segmentedResponseAccepted = (b &amp; 2) != 0;

        b = queue.pop();
        maxSegmentsAccepted = (b &amp; 0x70) &amp;gt;&amp;gt; 4;
        maxApduLengthAccepted = MaxApduLength.valueOf((byte) (b &amp; 0xf));
        invokeId = queue.pop();
        if (segmentedMessage) {
            sequenceNumber = queue.popU1B();
            proposedWindowSize = queue.popU1B();
        }
        serviceChoice = queue.pop();
        serviceData = new ByteQueue(queue.popAll());

        ConfirmedRequestService.checkConfirmedRequestService(servicesSupported, serviceChoice);
    }

</code></pre>
<p dir="auto">Lines 191-193 show that no conversion is taking place, it's still the original byte/integer value.</p>
<pre><code>    public int getMaxSegmentsAccepted() {
        return maxSegmentsAccepted;
    }

</code></pre>
]]></description><link>https://forum.mango-os.com/post/6761</link><guid isPermaLink="true">https://forum.mango-os.com/post/6761</guid><dc:creator><![CDATA[japearson]]></dc:creator><pubDate>Wed, 29 Aug 2012 05:26:10 GMT</pubDate></item><item><title><![CDATA[Reply to Patch for UDP 7 segments bug on Wed, 29 Aug 2012 04:49:36 GMT]]></title><description><![CDATA[<p dir="auto">Not sure what you mean. This is the code that i have (lines 274 and 275):</p>
<pre><code>            if (segmentsRequired &amp;gt; request.getMaxSegmentsAccepted() || segmentsRequired &amp;gt; 128)
                throw new BACnetException(&amp;quot;Response too big to send to device; too many segments required&amp;quot;);

</code></pre>
<p dir="auto">BACnet4J will respond with up to 128 segments unless limited further by the max accepted by the client.</p>
]]></description><link>https://forum.mango-os.com/post/6760</link><guid isPermaLink="true">https://forum.mango-os.com/post/6760</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Wed, 29 Aug 2012 04:49:36 GMT</pubDate></item></channel></rss>