<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FreeMaster JSON-RPC methods in FreeMASTER</title>
    <link>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1355015#M764</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/100557"&gt;@iulian_stan&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Thanks for your suggestions, I moved the&amp;nbsp;&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;pcm.IsCommPortOpen()&lt;/STRONG&gt;&lt;/EM&gt; and the&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;pcm.IsBoardDetected()&lt;/EM&gt;&lt;/STRONG&gt; methods to the&lt;EM&gt;&lt;STRONG&gt; on_connected&lt;/STRONG&gt; &lt;/EM&gt;method. Now they work after the refresh.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;But moving the&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;pcm.ReadVariable&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;didn't solve the problem.&lt;BR /&gt;I include the JS and the HTML files so you can see that in the&amp;nbsp;&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;on_connected&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;method I check if the board is connected and if the comm port is open. And after that I call the&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;pcm.ReadVariable&lt;/EM&gt;&lt;/STRONG&gt;, but it returns an error, that says:&amp;nbsp;"ReadVariable: Could not read the variable 'FMSTR_u32FwVversion[0]'. &lt;BR /&gt;Error 0x8000fffb (Communication port is not opened.).".&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nxf63246_0-1634130328194.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/159001i38FC1282B07817C3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nxf63246_0-1634130328194.png" alt="nxf63246_0-1634130328194.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I can read variables, with an additional button like in the example.htm, but I need to read variables after the board is connected automatically.&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Kornel Lengl&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Oct 2021 13:19:53 GMT</pubDate>
    <dc:creator>nxf63246</dc:creator>
    <dc:date>2021-10-13T13:19:53Z</dc:date>
    <item>
      <title>FreeMaster JSON-RPC methods</title>
      <link>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1352811#M754</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;
&lt;P&gt;I've created GUIs for S32K boards with FreeMaster several times, but until now I only used the ActiveX interface and methods.&lt;BR /&gt;This time I tried to create GUI that uses JSON-RPC methods, by modifying an existing ActiveX GUI.&lt;BR /&gt;Help me to see what I miss.&lt;/P&gt;
&lt;P&gt;First problem,&lt;/P&gt;
&lt;P&gt;I started with simple variable reading. I use the following fields for feedback.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nxf63246_1-1633683040170.png" style="width: 316px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/158605iE39307CBB7BCE7B2/image-dimensions/316x246?v=v2" width="316" height="246" role="button" title="nxf63246_1-1633683040170.png" alt="nxf63246_1-1633683040170.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here we can see, that I received a positive feedback from the&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;pcm.OnBoardDetected &lt;/EM&gt;&lt;/STRONG&gt;and from the&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;pcm.IsCommPortOpen() &lt;/EM&gt;&lt;/STRONG&gt;methods. Only after that I tried to read a variable, but I received the following error message: "&lt;EM&gt;ReadVariable: Could not read the variable 'FMSTR_u32FwVversion[0]'. Error 0x8000fffb (&lt;STRONG&gt;Communication port is not opened&lt;/STRONG&gt;.)."&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Interesting is, that when I call the same ReadVariable method manually with a button, it works.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nxf63246_2-1633683489731.png" style="width: 80px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/158607i99299A75A3E293ED/image-dimensions/80x52?v=v2" width="80" height="52" role="button" title="nxf63246_2-1633683489731.png" alt="nxf63246_2-1633683489731.png" /&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nxf63246_3-1633683512235.png" style="width: 234px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/158608i9A57E59CE8993531/image-dimensions/234x52?v=v2" width="234" height="52" role="button" title="nxf63246_3-1633683512235.png" alt="nxf63246_3-1633683512235.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;code sniplet:&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;pcm.ReadVariable(name)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;.then((response) =&amp;gt; {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;$("#mcu_ic_text").val("Variable value: " + response.data);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;})&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;.catch((err) =&amp;gt; { &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;on_error(err.msg);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;});&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;But I need to read variables automatically when the board connects.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Second,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;When I click refresh (F5), it seems like nothing works that worked until that point. I have in the main() function, which is called after the refresh, a&amp;nbsp;&lt;EM&gt;pcm.IsCommPortOpen()&amp;nbsp;&lt;/EM&gt;and a&amp;nbsp;&lt;EM&gt;pcm.IsBoardDetected()&lt;/EM&gt; methods, but they don't deliver any response after the refresh.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;function main() {&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;pcm = new PCM("localhost:41000", on_connected, on_error, on_error);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;pcm.OnServerError = on_error;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;pcm.OnSocketError = on_error;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;pcm.IsCommPortOpen().then(response =&amp;gt; {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;$("#pcb_version_text").val("Port status: " + response.data);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;});&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;pcm.IsBoardDetected()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;.then((response) =&amp;gt; {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;$("#nfc_ic_text").val("board:");&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;})&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;.catch((err) =&amp;gt; { &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;on_error(err.msg);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;});&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;PS:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I removed the "&lt;EM&gt;&amp;lt;object id="pcm" height="0" width="0" classid="clsid:48A185F1-FFDB-11D3-80E3-00C04F176153"&amp;gt;&amp;lt;/object&amp;gt;&lt;/EM&gt;" line&lt;/LI&gt;
&lt;LI&gt;I included the&amp;nbsp;&lt;EM&gt;simple-jsonrpc-js.js&lt;/EM&gt; and the&lt;EM&gt;&amp;nbsp;freemaster-client.js&lt;/EM&gt; files&lt;/LI&gt;
&lt;LI&gt;I created the PCM object:&amp;nbsp;pcm = new PCM("localhost:41000", on_connected, on_error, on_error);&lt;/LI&gt;
&lt;LI&gt;I use the example.htm file from the FreeMaster installation folder to avoid syntax errors in the basic methods&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I'm looking forward to an answer and thanks for any suggestions.&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Kornel Lengl&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 05:06:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1352811#M754</guid>
      <dc:creator>nxf63246</dc:creator>
      <dc:date>2021-10-11T05:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: FreeMaster JSON-RPC methods</title>
      <link>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1353311#M757</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/145489"&gt;@nxf63246&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;My guess is that it may be related to the JS reactive pattern - the Variable read function should be called inside a successful connection or board detected callback function ex:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;pcm.OnBoardDetected = function() {
  pcm.ReadVariable(name)
   .then((response) =&amp;gt; {
   $("#mcu_ic_text").val("Variable value: " + response.data);
   })
   .catch((err) =&amp;gt; {
   on_error(err.msg);
   });
}&lt;/LI-CODE&gt;
&lt;P&gt;Regarding the second part - there's a similar issue in your code snippet - you do not wait for the connection to be established:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;function main() {

   pcm = new PCM("localhost:41000", on_connected, on_error, on_error);
   pcm.OnServerError = on_error;
   pcm.OnSocketError = on_error;

   pcm.IsCommPortOpen().then(response =&amp;gt; { // there is no guarantee that pcm is connected to localhost at this point
   $("#pcb_version_text").val("Port status: " + response.data);
   });

   pcm.IsBoardDetected() // there is no guarantee that pcm is connected to localhost at this point
   .then((response) =&amp;gt; {
   $("#nfc_ic_text").val("board:");
   })
   .catch((err) =&amp;gt; {
   on_error(err.msg);
   });

   }&lt;/LI-CODE&gt;
&lt;P&gt;All pcm functions calls (ex: IsCommPortOpen, IsBoardDetected ...) should be made inside or after&amp;nbsp; "on_connected" function is executed - that's when pcm is actually connected to FreeMASTER server.&lt;/P&gt;
&lt;P&gt;If moving those calls does not solve your issues please share your HTML/JS code with us.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 07:25:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1353311#M757</guid>
      <dc:creator>iulian_stan</dc:creator>
      <dc:date>2021-10-11T07:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: FreeMaster JSON-RPC methods</title>
      <link>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1355015#M764</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/100557"&gt;@iulian_stan&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Thanks for your suggestions, I moved the&amp;nbsp;&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;pcm.IsCommPortOpen()&lt;/STRONG&gt;&lt;/EM&gt; and the&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;pcm.IsBoardDetected()&lt;/EM&gt;&lt;/STRONG&gt; methods to the&lt;EM&gt;&lt;STRONG&gt; on_connected&lt;/STRONG&gt; &lt;/EM&gt;method. Now they work after the refresh.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;But moving the&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;pcm.ReadVariable&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;didn't solve the problem.&lt;BR /&gt;I include the JS and the HTML files so you can see that in the&amp;nbsp;&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;on_connected&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;method I check if the board is connected and if the comm port is open. And after that I call the&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;pcm.ReadVariable&lt;/EM&gt;&lt;/STRONG&gt;, but it returns an error, that says:&amp;nbsp;"ReadVariable: Could not read the variable 'FMSTR_u32FwVversion[0]'. &lt;BR /&gt;Error 0x8000fffb (Communication port is not opened.).".&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nxf63246_0-1634130328194.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/159001i38FC1282B07817C3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nxf63246_0-1634130328194.png" alt="nxf63246_0-1634130328194.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I can read variables, with an additional button like in the example.htm, but I need to read variables after the board is connected automatically.&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Kornel Lengl&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 13:19:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1355015#M764</guid>
      <dc:creator>nxf63246</dc:creator>
      <dc:date>2021-10-13T13:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: FreeMaster JSON-RPC methods</title>
      <link>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1355075#M765</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/145489"&gt;@nxf63246&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I did not see any issues in your example nor I was able to reproduce your issue. The only "abnormal" case when I was able to get the error was when I disconnected the board before the JS code executed. My steps :&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Open the page in a web browser&lt;/LI&gt;
&lt;LI&gt;Connect / disconnect FreeMASTER to / from the board to trigger the &lt;EM&gt;&lt;STRONG&gt;OnBoardDetected&lt;/STRONG&gt;&lt;/EM&gt; event (multiple times)&lt;/LI&gt;
&lt;LI&gt;Refresh the page and repeat step 2&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Actually, I could say &lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;IsCommPortOpen&lt;/STRONG&gt;&lt;/EM&gt; call is redundant because&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;OnBoardDetected &lt;/STRONG&gt;&lt;/EM&gt;implies the communication port is already open. To add an extra check could you move&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;read_variable &lt;/STRONG&gt;&lt;/EM&gt;into &lt;EM&gt;&lt;STRONG&gt;.then&lt;/STRONG&gt;&lt;/EM&gt; method of the &lt;EM&gt;&lt;STRONG&gt;pcm.&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;IsCommPortOpen&lt;/STRONG&gt;&lt;/EM&gt; promise to make sure that the port is open before the variable is read:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;function boardDetected()
{
  //These feedbacks get printed succesfully
  $("#board_detected_text").val("Board connected +");
  pcm.IsCommPortOpen().then(response =&amp;gt; {
    $("#port_status_text").val("Port status: " + response.data);
    read_variable("FMSTR_u32FwVversion[0]");
  });
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 15:02:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1355075#M765</guid>
      <dc:creator>iulian_stan</dc:creator>
      <dc:date>2021-10-13T15:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: FreeMaster JSON-RPC methods</title>
      <link>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1358477#M769</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/100557"&gt;@iulian_stan&lt;/a&gt; for you time and suggestions, but I still get the same error message for the immediate variable reading, even if I move the read_variable() function&amp;nbsp;&lt;SPAN&gt;into&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;.then&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;method of the&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;pcm.&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;IsCommPortOpen, &lt;/STRONG&gt;&lt;/EM&gt;just like this:&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;pcm.IsCommPortOpen().then(response =&amp;gt; {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; $("#port_status_text").val("Port status: " + response.data); &lt;BR /&gt;&amp;nbsp; //response.data = true&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; read_variable("FMSTR_u32FwVversion[0]");// the same error message as before&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;});&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;I can make the FMSTR to wait for the variable like this, but this is very poor:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;setInterval(function(){ pcm.ReadVariable("FMSTR_PcbVersionLength")&lt;BR /&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;nbsp; .then((response) =&amp;gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; pcb_version_length = response.data; //this works&lt;BR /&gt;}) }, 100);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;PS: also an interesting thing that the &lt;STRONG&gt;&lt;EM&gt;variable watch&lt;/EM&gt;&lt;/STRONG&gt; sees all the variable values immediately, the problem is only with the displaying&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 08:25:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1358477#M769</guid>
      <dc:creator>nxf63246</dc:creator>
      <dc:date>2021-10-20T08:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: FreeMaster JSON-RPC methods</title>
      <link>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1360086#M771</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/145489"&gt;@nxf63246&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Apologies for the delayed reply.&lt;/P&gt;
&lt;P&gt;Could you please attach your communication log. You can access the logger on the top menu bar: &lt;BR /&gt;Tools&amp;nbsp;&lt;SPAN&gt;→ Communication Debug Log...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Just make sure you open it before you connect to the board (press the "Go!" button) so it can catches all the messages from the start.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 11:51:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1360086#M771</guid>
      <dc:creator>iulian_stan</dc:creator>
      <dc:date>2021-10-22T11:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: FreeMaster JSON-RPC methods</title>
      <link>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1362415#M786</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/100557"&gt;@iulian_stan&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;On this communication log you can see the error for the pcm.ReadVariable() function. And after that the successful variable reads for the variable watch.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nxf63246_0-1635335794219.png" style="width: 623px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/160398i70C03F101DA0823B/image-dimensions/623x327?v=v2" width="623" height="327" role="button" title="nxf63246_0-1635335794219.png" alt="nxf63246_0-1635335794219.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On this one, you can see the same failed variable read and the successful one with the button, mentioned earlier.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nxf63246_1-1635335933537.png" style="width: 630px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/160399iB73ACFC3EAE16D4D/image-dimensions/630x214?v=v2" width="630" height="214" role="button" title="nxf63246_1-1635335933537.png" alt="nxf63246_1-1635335933537.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 12:16:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1362415#M786</guid>
      <dc:creator>nxf63246</dc:creator>
      <dc:date>2021-10-27T12:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: FreeMaster JSON-RPC methods</title>
      <link>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1363203#M790</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/145489"&gt;@nxf63246&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I was able to reproduce your issue - it happens only when the variable info is loaded from an ELF file (I was using TSA in my tests, but from your logs I noticed that in your case TSA call fails meaning it is not used).&lt;/P&gt;
&lt;P&gt;Unfortunately I don't have a solution, we will further investigate this issue. As a workaround I could suggest:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Define your embedded variables in a TSA table (in your embedded project)&lt;/LI&gt;
&lt;LI&gt;Implement a workaround in JS - either with an initial delay as you mentioned before or a retry mechanism&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var retry = 3;

function read_variable(name)
{
  /* ReadVariable uses FreeMASTER variable object from current project. Use 
   * ReadUIntVariable to access the memory directly using a symbol name. */
  pcm.ReadVariable(name)
    .then((response) =&amp;gt; {
      $("#var_read_text").val("Variable value: " + response.data);
    })
    .catch((err) =&amp;gt; {
      if (retry--) {
        setTimeout(() =&amp;gt; read_variable(name), 100);
      } else {
        retry = 3;
        on_error(err.msg);
      }
    });
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will post updates on this thread once we find the root cause of this issue.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 11:20:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1363203#M790</guid>
      <dc:creator>iulian_stan</dc:creator>
      <dc:date>2021-10-28T11:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: FreeMaster JSON-RPC methods</title>
      <link>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1363847#M791</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;A href="https://community.nxp.com/t5/user/viewprofilepage/user-id/145489" target="_blank" rel="noopener"&gt;nxf63246,&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I confirm the issue in the FreeMASTER desktop application. The OnCommPortStateChanged(true)&amp;nbsp; and OnBoardDetected() events are triggered prematurely. Variables which are accessed within approximately 100ms after these events may return the 'port not open' error.&lt;/P&gt;
&lt;P&gt;The reason why the issue appears only when using an ELF file but not with TSA is just a question of processing speed. The ELF file is read much faster than TSA.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The simplest fix is to delay the event handler execution:&lt;/P&gt;
&lt;PRE&gt;pcm.OnBoardDetected = ()=&amp;gt;setTimeout(MyOnBoardDetectedHandler, 100);&lt;BR /&gt;pcm.OnCommPortStateChanged = (x)=&amp;gt;setTimeout(()=&amp;gt;MyOnCommPortStateChangedHandler(x), 100);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As the FreeMASTER 3.1.3 version is just being published, this issue will be fixed later, in a next version planned for Q1/2022. I can provide a hotfix version if you need it.&lt;/P&gt;
&lt;P&gt;Thank you for your report &amp;amp; to Iulian for support,&lt;BR /&gt;Michal&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 10:43:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/FreeMaster-JSON-RPC-methods/m-p/1363847#M791</guid>
      <dc:creator>MichalH</dc:creator>
      <dc:date>2021-10-29T10:43:07Z</dc:date>
    </item>
  </channel>
</rss>

