<?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>Manipulate data receive from serial NRF52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78836/manipulate-data-receive-from-serial-nrf52840</link><description>I have succeed transferred data from PC to NRF52840 dongle and managed to receive it back on the PC. 
 But i want to be available to manipulate the data in NRF52840 dongle before send it back. 
 My data types is float and i use Python.serial to send and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Aug 2021 19:04:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78836/manipulate-data-receive-from-serial-nrf52840" /><item><title>RE: Manipulate data receive from serial NRF52840</title><link>https://devzone.nordicsemi.com/thread/326422?ContentTypeID=1</link><pubDate>Tue, 24 Aug 2021 19:04:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39e5ef9b-392d-4ed6-964f-891e532102cd</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If each float is converted to 4 bytes it should be relatively easy to convert it on the dongle side.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you confirm that the encoded string is 39*4 = 156 bytes long?&lt;/p&gt;
&lt;p&gt;In order to convert a uint8_t array to float in this case it should be sufficient to create a union type, like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;union 
{
    float values_fl[39];
    uint8_t values_char[39*4];
} char_to_float_t;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Write the char values from the cdc_acm class into the values_char field, and read them out as float from the values_fl field.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please note that it is important to make sure that you get a full sequence before you do the conversion, in case some bytes still haven&amp;#39;t been received.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In order to test if everything works OK you can apply some simple calculation to all the float values and send them back.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Manipulate data receive from serial NRF52840</title><link>https://devzone.nordicsemi.com/thread/326236?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 16:01:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f11bfd33-080c-44df-a7f2-314d20db969e</guid><dc:creator>ImanIkhwan</dc:creator><description>&lt;p&gt;Hi.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1) I cannot check how the data in the dongle look, but i believe it is saves as char in the dongle&lt;/p&gt;
&lt;p&gt;2) the float are encode in bytes type before sending it to the serial by python, so the dongle receive the bytes in char format. And the char are send back through serial to python and python reads the char as bytes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;my input is an array of float with 39 rows and one column&lt;/p&gt;
&lt;p&gt;I attached snippet of the input and output file below.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Input after encode to bytes:&lt;/p&gt;
&lt;p&gt;b&amp;#39;\xd4\x82Z@\xd4\x82Z@\x8c\x0c\x84@\x8c\x0c\x84@n&amp;lt;\xa2@n&amp;lt;\xa2@.\xc4\xca@.\xc4\xca@\x9e\xba\xdd@\x9e\xba\xdd@\xacW\xc1@\xacW\xc1@\x16\x89\xb7@\x16\x89\xb7@\x1a\xe8\xba@\x1a\xe8\xba@\x06\xa8\xdc@\x06\xa8\xdc@\x8e\xd2\xec@\x8e\xd2\xec@\xb5\x00\x06A\xb5\x00\x06A\x94\xb8\xdf@\x94\xb8\xdf@x@\xeb@x@\xeb@\xc2O\xdc@\xc2O\xdc@4+\xe3@4+\xe3@J\xbd\xe4@J\xbd\xe4@^j\xf2@^j\xf2@f!\xe3@f!\xe3@ZN\xe7@ZN\xe7@\x921\xf0@&amp;#39;&lt;/p&gt;
&lt;p&gt;Ouput file:&lt;/p&gt;
&lt;p&gt;[b'\x00\x82Z@\xd4\x82Z@\x8c\x0c\x84@\x8c\x0c\x84@n&amp;lt;\xa2@n&amp;lt;\xa2@.\xc4\xca@.\xc4\xca@\x9e\xba\xdd@\x9e\xba\xdd@\xacW\xc1@\xacW\xc1@\x16\x89\xb7@\x16\x89\xb7@\x1a\xe8\xba@\x1a\xe8\xba@\x06\xa8\xdc@\x06\xa8\xdc@\x8e\xd2\xec@\x8e\xd2\xec@\xb5\x00\x06A\xb5\x00\x06A\x94\xb8\xdf@\x94\xb8\xdf@x@\xeb@x@\xeb@\xc2O\xdc@\xc2O\xdc@4+\xe3@4+\xe3@J\xbd\xe4@J\xbd\xe4@^j\xf2@^j\xf2@f!\xe3@f!\xe3@ZN\xe7@ZN\xe7@\x921\xf0@\x00\x82Z@\xd4\x82Z@\x8c\x0c\x84@\x8c\x0c\x84@n&amp;lt;\xa2@n&amp;lt;\xa2@.\xc4\xca@.\xc4\xca@\x9e\xba\xdd@\x9e\xba\xdd@\xacW\xc1@\xacW\xc1@\x16\x89\xb7@\x16\x89\xb7@\x1a\xe8\xba@\x1a\xe8\xba@\x06\xa8\xdc@\x06\xa8\xdc@\x8e\xd2\xec@\x8e\xd2\xec@\xb5\x00\x06A\xb5\x00\x06A\x94\xb8\xdf@\x94\xb8\xdf@x@\xeb']&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Manipulate data receive from serial NRF52840</title><link>https://devzone.nordicsemi.com/thread/326214?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 13:42:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0958a041-7d2e-4660-8099-9c723d09ed68</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How does the data that you send to the dongle look?&lt;/p&gt;
&lt;p&gt;Are the float values encoded in binary format, or as strings?&lt;/p&gt;
&lt;p&gt;Maybe you can send me an example of such an update, then it is easier to know how best to do the conversion.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>