<?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 Sending UDP data from my Simulink model to some IP without passing by my MIMXRT1024 board in Model-Based Design Toolbox (MBDT)</title>
    <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Sending-UDP-data-from-my-Simulink-model-to-some-IP-without/m-p/1675193#M8309</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi. My Simulink model needs to run on my NXP MIMXRT1024 board. I am running in External Mode, so that I can log some sensor measurements I receive using ADC block of MBDT toolbox.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Everything runs well, until I try to add a &lt;STRONG&gt;UDP communication&lt;/STRONG&gt; block to transmit data from my ADC to a Unity game that listens on port 8000 of my localhost (&lt;EM&gt;i.e. same PC machine running the simulation&lt;/EM&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;None of the UDP methods I tried worked: I tried all Simulink library "&lt;EM&gt;UDP send&lt;/EM&gt;" blocks, and writing custom &lt;FONT face="courier new,courier"&gt;MyUDP.m&lt;/FONT&gt; code inside &lt;EM&gt;MATLAB functions&lt;/EM&gt;, &lt;EM&gt;MATLAB Systems&lt;/EM&gt;, and &lt;EM&gt;Level-1 S Function&lt;/EM&gt; using &lt;FONT face="courier new,courier"&gt;udpport&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;dsp.UDPSender&lt;/FONT&gt; objects, as well as trying NXP's own &lt;EM&gt;TCP/UDP block&lt;/EM&gt; (&lt;EM&gt;which I believe will only work if we physically connect the board with Ethernet cable to my PC&lt;/EM&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;All of these methods mentioned, caused error when Simulink's Embedded Coder tries to code generate. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My question I guess is, &lt;STRONG&gt;in External Mode simulation, how can I force the UDP part of my model to not code generate itself&lt;/STRONG&gt; (&lt;EM&gt;i.e. runs from the board&lt;/EM&gt;), &lt;STRONG&gt;and instead make it run using the MATLAB engine from my PC without compiling&lt;/STRONG&gt; (&lt;EM&gt;as if I was executing a "UDP send" command from MATLAB shell, which works btw&lt;/EM&gt;)&lt;STRONG&gt;?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;U&gt;PS&lt;/U&gt;: In trying to create a &lt;EM&gt;MATLAB System&lt;/EM&gt; block, the block generated (&lt;FONT size="2"&gt;&lt;EM&gt;see figure below&lt;/EM&gt;&lt;/FONT&gt;) proposes the choices: &lt;EM&gt;Code Generation&lt;/EM&gt; and &lt;EM&gt;Interpreted Execution&lt;/EM&gt;, but no matter what I choose, it throws the same error, as I believe it always tries to code generate. So I wonder if there is any actual effect of&amp;nbsp;&lt;EM&gt;Interpreted Execution&lt;/EM&gt; choice.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ylahdili_0-1687572835599.png" style="width: 952px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/229078i02BD22A06FB3F710/image-dimensions/952x641?v=v2" width="952" height="641" role="button" title="ylahdili_0-1687572835599.png" alt="ylahdili_0-1687572835599.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Code inside the &lt;EM&gt;MATLAB System&lt;/EM&gt; block:&lt;/P&gt;&lt;PRE&gt;classdef MyUDPSender &amp;lt; matlab.System&lt;BR /&gt;   properties (Nontunable)&lt;BR /&gt;      ipAddress = '127.0.0.1';&lt;BR /&gt;      port = 8000;&lt;BR /&gt;   end&lt;BR /&gt;&lt;BR /&gt;   properties (Access = private)&lt;BR /&gt;      udpObject&lt;BR /&gt;   end&lt;BR /&gt;&lt;BR /&gt;   methods (Access = protected)&lt;BR /&gt;      function setupImpl(obj)&lt;BR /&gt;         obj.udpObject = dsp.UDPSender('RemoteIPAddress', obj.ipAddress, 'RemoteIPPort', obj.port);&lt;BR /&gt;      end&lt;BR /&gt;&lt;BR /&gt;      function stepImpl(obj, data)&lt;BR /&gt;         data = uint8(data);&lt;BR /&gt;         step(obj.udpObject, data);&lt;BR /&gt;      end&lt;BR /&gt;&lt;BR /&gt;      function releaseImpl(obj)&lt;BR /&gt;         release(obj.udpObject);&lt;BR /&gt;      end&lt;BR /&gt;&lt;BR /&gt;      function resetImpl(obj)&lt;BR /&gt;         obj.releaseImpl();&lt;BR /&gt;         obj.setupImpl();&lt;BR /&gt;      end&lt;BR /&gt;&lt;BR /&gt;      function numInputs = getNumInputsImpl(obj)&lt;BR /&gt;         numInputs = 1;&lt;BR /&gt;      end&lt;BR /&gt;&lt;BR /&gt;      function numOutputs = getNumOutputsImpl(obj)&lt;BR /&gt;         numOutputs = 0;&lt;BR /&gt;      end&lt;BR /&gt;   end&lt;BR /&gt;end&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Am I missing something? thanks a lot for helping me.&lt;/P&gt;</description>
    <pubDate>Sat, 24 Jun 2023 02:42:20 GMT</pubDate>
    <dc:creator>ylahdili</dc:creator>
    <dc:date>2023-06-24T02:42:20Z</dc:date>
    <item>
      <title>Sending UDP data from my Simulink model to some IP without passing by my MIMXRT1024 board</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Sending-UDP-data-from-my-Simulink-model-to-some-IP-without/m-p/1675193#M8309</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi. My Simulink model needs to run on my NXP MIMXRT1024 board. I am running in External Mode, so that I can log some sensor measurements I receive using ADC block of MBDT toolbox.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Everything runs well, until I try to add a &lt;STRONG&gt;UDP communication&lt;/STRONG&gt; block to transmit data from my ADC to a Unity game that listens on port 8000 of my localhost (&lt;EM&gt;i.e. same PC machine running the simulation&lt;/EM&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;None of the UDP methods I tried worked: I tried all Simulink library "&lt;EM&gt;UDP send&lt;/EM&gt;" blocks, and writing custom &lt;FONT face="courier new,courier"&gt;MyUDP.m&lt;/FONT&gt; code inside &lt;EM&gt;MATLAB functions&lt;/EM&gt;, &lt;EM&gt;MATLAB Systems&lt;/EM&gt;, and &lt;EM&gt;Level-1 S Function&lt;/EM&gt; using &lt;FONT face="courier new,courier"&gt;udpport&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;dsp.UDPSender&lt;/FONT&gt; objects, as well as trying NXP's own &lt;EM&gt;TCP/UDP block&lt;/EM&gt; (&lt;EM&gt;which I believe will only work if we physically connect the board with Ethernet cable to my PC&lt;/EM&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;All of these methods mentioned, caused error when Simulink's Embedded Coder tries to code generate. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My question I guess is, &lt;STRONG&gt;in External Mode simulation, how can I force the UDP part of my model to not code generate itself&lt;/STRONG&gt; (&lt;EM&gt;i.e. runs from the board&lt;/EM&gt;), &lt;STRONG&gt;and instead make it run using the MATLAB engine from my PC without compiling&lt;/STRONG&gt; (&lt;EM&gt;as if I was executing a "UDP send" command from MATLAB shell, which works btw&lt;/EM&gt;)&lt;STRONG&gt;?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;U&gt;PS&lt;/U&gt;: In trying to create a &lt;EM&gt;MATLAB System&lt;/EM&gt; block, the block generated (&lt;FONT size="2"&gt;&lt;EM&gt;see figure below&lt;/EM&gt;&lt;/FONT&gt;) proposes the choices: &lt;EM&gt;Code Generation&lt;/EM&gt; and &lt;EM&gt;Interpreted Execution&lt;/EM&gt;, but no matter what I choose, it throws the same error, as I believe it always tries to code generate. So I wonder if there is any actual effect of&amp;nbsp;&lt;EM&gt;Interpreted Execution&lt;/EM&gt; choice.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ylahdili_0-1687572835599.png" style="width: 952px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/229078i02BD22A06FB3F710/image-dimensions/952x641?v=v2" width="952" height="641" role="button" title="ylahdili_0-1687572835599.png" alt="ylahdili_0-1687572835599.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Code inside the &lt;EM&gt;MATLAB System&lt;/EM&gt; block:&lt;/P&gt;&lt;PRE&gt;classdef MyUDPSender &amp;lt; matlab.System&lt;BR /&gt;   properties (Nontunable)&lt;BR /&gt;      ipAddress = '127.0.0.1';&lt;BR /&gt;      port = 8000;&lt;BR /&gt;   end&lt;BR /&gt;&lt;BR /&gt;   properties (Access = private)&lt;BR /&gt;      udpObject&lt;BR /&gt;   end&lt;BR /&gt;&lt;BR /&gt;   methods (Access = protected)&lt;BR /&gt;      function setupImpl(obj)&lt;BR /&gt;         obj.udpObject = dsp.UDPSender('RemoteIPAddress', obj.ipAddress, 'RemoteIPPort', obj.port);&lt;BR /&gt;      end&lt;BR /&gt;&lt;BR /&gt;      function stepImpl(obj, data)&lt;BR /&gt;         data = uint8(data);&lt;BR /&gt;         step(obj.udpObject, data);&lt;BR /&gt;      end&lt;BR /&gt;&lt;BR /&gt;      function releaseImpl(obj)&lt;BR /&gt;         release(obj.udpObject);&lt;BR /&gt;      end&lt;BR /&gt;&lt;BR /&gt;      function resetImpl(obj)&lt;BR /&gt;         obj.releaseImpl();&lt;BR /&gt;         obj.setupImpl();&lt;BR /&gt;      end&lt;BR /&gt;&lt;BR /&gt;      function numInputs = getNumInputsImpl(obj)&lt;BR /&gt;         numInputs = 1;&lt;BR /&gt;      end&lt;BR /&gt;&lt;BR /&gt;      function numOutputs = getNumOutputsImpl(obj)&lt;BR /&gt;         numOutputs = 0;&lt;BR /&gt;      end&lt;BR /&gt;   end&lt;BR /&gt;end&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Am I missing something? thanks a lot for helping me.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Jun 2023 02:42:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Sending-UDP-data-from-my-Simulink-model-to-some-IP-without/m-p/1675193#M8309</guid>
      <dc:creator>ylahdili</dc:creator>
      <dc:date>2023-06-24T02:42:20Z</dc:date>
    </item>
  </channel>
</rss>

