<?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>Support code python librairie nrfutil</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34760/support-code-python-librairie-nrfutil</link><description>Hi, 
 
 I am working on the port of the nrfutil library of python -&amp;gt; C and I am looking for a support to understand the python code of the nrfutil library please. 
 Can you help me please. 
 
 Best Regards.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 25 May 2018 12:56:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34760/support-code-python-librairie-nrfutil" /><item><title>RE: Support code python librairie nrfutil</title><link>https://devzone.nordicsemi.com/thread/133433?ContentTypeID=1</link><pubDate>Fri, 25 May 2018 12:56:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fba2ef7-991b-4d3c-9622-4be992e435ee</guid><dc:creator>Lora</dc:creator><description>&lt;p&gt;I am working on a communication project ble, is among the objectives of the project is the portage of the function ble in the main.py C is a project a little critical that requires less space of the memory c is why I am carrying a C or assembler&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;that&amp;#39;s the function I need&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/NordicSemiconductor/pc-nrfutil/blob/master/nordicsemi/dfu/dfu_transport_ble.py"&gt;github.com/.../dfu_transport_ble.py&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;def send_init_packet(self, init_packet):&lt;br /&gt; def try_to_recover():&lt;br /&gt; if response['offset'] == 0 or response['offset'] &amp;gt; len(init_packet):&lt;br /&gt; # There is no init packet or present init packet is too long.&lt;br /&gt; return False&lt;/p&gt;
&lt;p&gt;expected_crc = (binascii.crc32(init_packet[:response['offset']]) &amp;amp; 0xFFFFFFFF)&lt;/p&gt;
&lt;p&gt;if expected_crc != response['crc']:&lt;br /&gt; # Present init packet is invalid.&lt;br /&gt; return False&lt;/p&gt;
&lt;p&gt;if len(init_packet) &amp;gt; response['offset']:&lt;br /&gt; # Send missing part.&lt;br /&gt; try:&lt;br /&gt; self.__stream_data(data = init_packet[response['offset']:],&lt;br /&gt; crc = expected_crc,&lt;br /&gt; offset = response['offset'])&lt;br /&gt; except ValidationException:&lt;br /&gt; return False&lt;/p&gt;
&lt;p&gt;self.__execute()&lt;br /&gt; return True&lt;/p&gt;
&lt;p&gt;response = self.__select_command()&lt;br /&gt; assert len(init_packet) &amp;lt;= response['max_size'], &amp;#39;Init command is too long&amp;#39;&lt;/p&gt;
&lt;p&gt;if try_to_recover():&lt;br /&gt; return&lt;/p&gt;
&lt;p&gt;for r in range(DfuTransportBle.RETRIES_NUMBER):&lt;br /&gt; try:&lt;br /&gt; self.__create_command(len(init_packet))&lt;br /&gt; self.__stream_data(data=init_packet)&lt;br /&gt; self.__execute()&lt;br /&gt; except ValidationException:&lt;br /&gt; pass&lt;br /&gt; break&lt;br /&gt; else:&lt;br /&gt; raise NordicSemiException(&amp;quot;Failed to send init packet&amp;quot;)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Support code python librairie nrfutil</title><link>https://devzone.nordicsemi.com/thread/133402?ContentTypeID=1</link><pubDate>Fri, 25 May 2018 11:25:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f34e20e-2228-4520-9eb9-5007a7b74c7e</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Why would you do that, what is the use case? You should be able to use the python version programmatically using the command line interface. I am trying to understand what you need in case there are better options that may save you for a lot of work. What is your end goal, what problem are you trying to solve?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>