<?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: How to ENET driver under MQX? in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-ENET-driver-under-MQX/m-p/487222#M15920</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assume you wanted to send and receive a given packet type(say profinet type 0x8892) on Ethernet. This can be done with the Ethernet driver in MQX as follows:&lt;/P&gt;&lt;PRE style="background: white;"&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri',sans-serif;"&gt;Initialize the Ethernet driver as you would for use with RTCS. Obtain the Ethernet driver handle by calling ENET_get_device_handle(devno). &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="background: white;"&gt; &lt;/PRE&gt;&lt;P&gt;Open the Ethernet driver for Profinet packets as follows:&amp;nbsp; ENET_open(device_handle, 0x8892, profinetRxCallback, callbackDataPtr); ); callbackDataPtr points to some memory where you can store data needed for the callback function. If your callback function does not need data, callbackDataPtr can be NULL.&lt;/P&gt;&lt;P&gt;Now, when a packet of type 0x8892is received by the Ethernet driver, the driver will call your callback as follows:&amp;nbsp; profinetRxCallback(pcb_ptr, callbackDataPtr)&lt;/P&gt;&lt;PRE style="background: white;"&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri',sans-serif;"&gt;The callback runs from within the ethernet ISR, so it should enqueue the pcb on a queue and wake up a task to service the pcb. 
The pcb contains a pointer to the message (pcb-&amp;gt;FRAG[0].FRAGMENT) and the message length (pcb-&amp;gt;FRAG[0].LENGTH). 
When done processing the message, call PCB_free(pcb) to return the PCB. &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="background: white;"&gt; &lt;/PRE&gt;&lt;P&gt;To send a packet, you have to create a pcb_alloc function and a pcb_free function. A sample alloc function:&lt;/P&gt;&lt;P&gt;The pcb_alloc function might look like:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;PCB_PTR myPcbAlloc(void)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; PCB_PTR pcb;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; uint8_t * frame;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; pcb = _mem_alloc_system(sizeof(*pcb));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; frame = _mem_alloc_system(MAX_PROFINET_PACKET_SIZE);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; pcb-&amp;gt;FREE = myPcbFree;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; pcb-&amp;gt;FRAG[0].LENGTH =&amp;nbsp; MAX_PROFINET_PACKET_SIZE;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; pcb-&amp;gt;FRAG[0].FRAGMENT = frame;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; pcb-&amp;gt;FRAG[1].LENGTH&amp;nbsp;&amp;nbsp; = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; pcb-&amp;gt;FRAG[1].FRAGMENT = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; return pcb;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the free function would be:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;void myPcbFree(PCB_PTR pcb)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; _mem_free(pcb-&amp;gt;FRAG[0].FRAGMENT);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; _mem_free(pcb);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would want to add error checking to these functions.&lt;/P&gt;&lt;P&gt;To send a packet, allocate a pcb, fill in the packet data, and call either ENET_send or ENET_send_raw. If you call ENET_send_raw, you are responsible for constructing the Ethernet header in the packet buffer. If you call ENET_send, the header will be constructed for you – but you still need to leave space in the packet buffer for the header.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Mar 2016 20:58:09 GMT</pubDate>
    <dc:creator>EAI</dc:creator>
    <dc:date>2016-03-04T20:58:09Z</dc:date>
    <item>
      <title>How to ENET driver under MQX?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-ENET-driver-under-MQX/m-p/487220#M15918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used MQX4.2 for our product. And I need to transmit/receive raw Ethernet frame(start from MAC address), I read the ENET driver under /io/enet&amp;nbsp; and get so confused and don't know how to use the API, eg, ENET_send, ENET_find_receiver.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I can't find a document explaining these API on website, is it possible that someone can help me with this issue?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Feb 2016 11:12:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-ENET-driver-under-MQX/m-p/487220#M15918</guid>
      <dc:creator>cencongsu</dc:creator>
      <dc:date>2016-02-25T11:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to ENET driver under MQX?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-ENET-driver-under-MQX/m-p/487221#M15919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately MQX APIs does not support &lt;SPAN class="quothighlight"&gt;raw&lt;/SPAN&gt; sockets. However you can modify the library according your needs. You should look inside &lt;SPAN class="quothighlight"&gt;RTCS&lt;/SPAN&gt; stack the way it works with network interfaces, or to inside ENET driver.&lt;/P&gt;&lt;P&gt;I would like to recommend look at MACNET_RX_ISR interrupt routine in macnet_receive.c file.&lt;/P&gt;&lt;P&gt;This is place where we receive interrupt from ENET module and we can start with processing of such data (like check of MAC address and verification of CRC)&lt;/P&gt;&lt;P&gt;Unfortunately, any change on the MQX or any library as &lt;SPAN class="quothighlight"&gt;RTCS&lt;/SPAN&gt; is out of the free support scope.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check the below thread this may helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/thread/307442"&gt;Sending data using "Raw Ethernet"&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt; Sol &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2016 21:32:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-ENET-driver-under-MQX/m-p/487221#M15919</guid>
      <dc:creator>soledad</dc:creator>
      <dc:date>2016-03-03T21:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to ENET driver under MQX?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-ENET-driver-under-MQX/m-p/487222#M15920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assume you wanted to send and receive a given packet type(say profinet type 0x8892) on Ethernet. This can be done with the Ethernet driver in MQX as follows:&lt;/P&gt;&lt;PRE style="background: white;"&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri',sans-serif;"&gt;Initialize the Ethernet driver as you would for use with RTCS. Obtain the Ethernet driver handle by calling ENET_get_device_handle(devno). &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="background: white;"&gt; &lt;/PRE&gt;&lt;P&gt;Open the Ethernet driver for Profinet packets as follows:&amp;nbsp; ENET_open(device_handle, 0x8892, profinetRxCallback, callbackDataPtr); ); callbackDataPtr points to some memory where you can store data needed for the callback function. If your callback function does not need data, callbackDataPtr can be NULL.&lt;/P&gt;&lt;P&gt;Now, when a packet of type 0x8892is received by the Ethernet driver, the driver will call your callback as follows:&amp;nbsp; profinetRxCallback(pcb_ptr, callbackDataPtr)&lt;/P&gt;&lt;PRE style="background: white;"&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri',sans-serif;"&gt;The callback runs from within the ethernet ISR, so it should enqueue the pcb on a queue and wake up a task to service the pcb. 
The pcb contains a pointer to the message (pcb-&amp;gt;FRAG[0].FRAGMENT) and the message length (pcb-&amp;gt;FRAG[0].LENGTH). 
When done processing the message, call PCB_free(pcb) to return the PCB. &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="background: white;"&gt; &lt;/PRE&gt;&lt;P&gt;To send a packet, you have to create a pcb_alloc function and a pcb_free function. A sample alloc function:&lt;/P&gt;&lt;P&gt;The pcb_alloc function might look like:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;PCB_PTR myPcbAlloc(void)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; PCB_PTR pcb;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; uint8_t * frame;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; pcb = _mem_alloc_system(sizeof(*pcb));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; frame = _mem_alloc_system(MAX_PROFINET_PACKET_SIZE);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; pcb-&amp;gt;FREE = myPcbFree;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; pcb-&amp;gt;FRAG[0].LENGTH =&amp;nbsp; MAX_PROFINET_PACKET_SIZE;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; pcb-&amp;gt;FRAG[0].FRAGMENT = frame;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; pcb-&amp;gt;FRAG[1].LENGTH&amp;nbsp;&amp;nbsp; = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; pcb-&amp;gt;FRAG[1].FRAGMENT = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; return pcb;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the free function would be:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;void myPcbFree(PCB_PTR pcb)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; _mem_free(pcb-&amp;gt;FRAG[0].FRAGMENT);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; _mem_free(pcb);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would want to add error checking to these functions.&lt;/P&gt;&lt;P&gt;To send a packet, allocate a pcb, fill in the packet data, and call either ENET_send or ENET_send_raw. If you call ENET_send_raw, you are responsible for constructing the Ethernet header in the packet buffer. If you call ENET_send, the header will be constructed for you – but you still need to leave space in the packet buffer for the header.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2016 20:58:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-ENET-driver-under-MQX/m-p/487222#M15920</guid>
      <dc:creator>EAI</dc:creator>
      <dc:date>2016-03-04T20:58:09Z</dc:date>
    </item>
  </channel>
</rss>

