<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>zcbor map of empty string not returning what i expect.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/118615/zcbor-map-of-empty-string-not-returning-what-i-expect</link><description>This question relates to using zcbor . 
 Basically I have the following. 
 
 
 I got The contents of FRAME - 00, 00, 00, 02, 00, 01, 01, 00, b0, 06, But I was expecting 00, 00, 00, 01 , 00, 01, 01, 00, a0. I&amp;#39;ve played arround with -DZCBOR_CANONICAL, but</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 13 Feb 2025 10:07:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/118615/zcbor-map-of-empty-string-not-returning-what-i-expect" /><item><title>RE: zcbor map of empty string not returning what i expect.</title><link>https://devzone.nordicsemi.com/thread/522813?ContentTypeID=1</link><pubDate>Thu, 13 Feb 2025 10:07:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54e73f73-319e-4568-ad06-a01688115d76</guid><dc:creator>Menon</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;While checking the&lt;a href="https://github.com/NordicSemiconductor/zcbor/blob/main/src/zcbor_encode.c"&gt; ZCbor library,&lt;/a&gt; indefinite length encoding is triggered inside &lt;a href="https://github.com/NordicSemiconductor/zcbor/blob/main/src/zcbor_encode.c#L360"&gt;zcbor_map_start_encode()&lt;/a&gt;, which calls &lt;a href="https://github.com/NordicSemiconductor/zcbor/blob/main/src/zcbor_encode.c#L354"&gt;list_map_start_encode()&lt;/a&gt;, where the encoding behavior depends on the &lt;code&gt;max_num&lt;/code&gt; parameter. So, I guess if &lt;code&gt;max_num&lt;/code&gt; is not set to &lt;code&gt;0&lt;/code&gt;, the function inserts &lt;code&gt;BF&lt;/code&gt; and &lt;code&gt;FF&lt;/code&gt;. Can you try &lt;code&gt;zcbor_map_start_encode(encoding_state, 0);&lt;/code&gt; and see if this resolves the issue? See &lt;a href="https://github.com/NordicSemiconductor/zcbor/blob/main/src/zcbor_encode.c#L386"&gt;value encode()&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Kind Regards,&lt;/p&gt;
&lt;p&gt;Abhijith&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: zcbor map of empty string not returning what i expect.</title><link>https://devzone.nordicsemi.com/thread/522776?ContentTypeID=1</link><pubDate>Thu, 13 Feb 2025 07:20:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0eeaaa77-490b-4d6d-987a-857c28932989</guid><dc:creator>Spector</dc:creator><description>&lt;p&gt;This particular forum thread has been raised regarding the zcbor code provided by nordic semi. It has nothing to do with the smp_hdr part. The smp_hdr data length is 2 in my instance because the zcbor map of nothing is represented by BF FF. RATHER than A0&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;However I&amp;#39;ve seen other tools generating A0.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This corresponds to&amp;nbsp;ZCBOR_MAJOR_TYPE_MAP (5) existing on the top 3 bits and length 0 for the rest thus becoming 0xA0.&lt;br /&gt;&lt;br /&gt;However in my code&lt;br /&gt;r = r &amp;amp;&amp;amp; zcbor_map_start_encode(encoding_state, 1);&lt;br /&gt; r = r &amp;amp;&amp;amp; zcbor_map_end_encode(encoding_state, 1);&lt;br /&gt;&lt;br /&gt;Generates&amp;nbsp;&lt;span&gt;ZCBOR_MAJOR_TYPE_MAP (5) existing on the top 3 bits, with a length b&amp;#39;11111&amp;#39; thus becoming 0xBF. &lt;br /&gt;When the length is indefinite it needs a break which is the 0xFF&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;I guess in the simplest terms what I&amp;#39;m asking is can i control the length field?&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: zcbor map of empty string not returning what i expect.</title><link>https://devzone.nordicsemi.com/thread/522688?ContentTypeID=1</link><pubDate>Wed, 12 Feb 2025 15:19:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4cad8a09-fc09-4f36-bef0-0edb8ae82254</guid><dc:creator>Menon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am not sure about this, but the issue might be related to memory handling in the code. Could you verify whether &lt;code&gt;sizeof(smp_msg.hdr)&lt;/code&gt; is correct and does not overrun &lt;code&gt;smp_msg.data&lt;/code&gt;? Maybe try printing &lt;code&gt;sizeof(smp_msg.hdr)&lt;/code&gt; and check if it matches the expected size.&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Abhijith&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: zcbor map of empty string not returning what i expect.</title><link>https://devzone.nordicsemi.com/thread/521664?ContentTypeID=1</link><pubDate>Thu, 06 Feb 2025 08:15:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de5dac61-35b0-4b01-882c-e2e716856e1c</guid><dc:creator>Spector</dc:creator><description>&lt;p&gt;Yes the stack allocated dealt with the b0, 06 issue. HOWEVER i still have BF FF where i was expecting A0&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: zcbor map of empty string not returning what i expect.</title><link>https://devzone.nordicsemi.com/thread/521602?ContentTypeID=1</link><pubDate>Wed, 05 Feb 2025 15:50:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e888c3b-29a9-4075-adce-b914f22fa526</guid><dc:creator>Menon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Did the switch to a fixed stack-allocated data field resolve the discrepancy in the FRAME contents?&lt;/p&gt;
&lt;p&gt;Kind Regards,&lt;/p&gt;
&lt;p&gt;Abhijith&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: zcbor map of empty string not returning what i expect.</title><link>https://devzone.nordicsemi.com/thread/521540?ContentTypeID=1</link><pubDate>Wed, 05 Feb 2025 12:26:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2324b7f9-7fd6-48de-aecf-48306c425c7d</guid><dc:creator>Spector</dc:creator><description>&lt;p&gt;It&amp;#39;s worth noting that payload [0] is BF and payload[1] is FF.&amp;nbsp;The smp_msg.data was a pointer that meant i couldn&amp;#39;t increment the pointer like i was doing...Maybe if i used a tripple ref, but I&amp;#39;m just gonna create a fixed stack allocated data field.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>