Sending ethernet messages to 2 destinations faults code...

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sending ethernet messages to 2 destinations faults code...

673 Views
rickstuart
Contributor V

Hi,

When I am sending Ethernet messages to 2 destinations, I am fairly sure that I am un-allocating (freeing up) the memory containing the Ethernet message twice.  And this is causing the code to stop working.  Unfortunately, the code that frees up the memory is buried deep into the MQX code.  Not in my application.  I would rather not touch the MQX code if possible.  Is there a known way to prevent the (I think) "RTCSPCB_free_internal(PCB_PTR)" function from freeing up the memory on the first go-around and not on the second? 


Reading the code hints that I might make use of a "duplication" concept.  But I am not familiar with this feature and do not understand the real purpose of this feature.  So I am hesitant on using it.


-thanks


Tags (4)
0 Kudos
5 Replies

403 Views
rickstuart
Contributor V

I haven't figured it out yet - but there does appears to be a well known "programming pattern" for what I want to do.  For instance, broadcasting involves sending Ethernet messages to multiple locations.  There is a function called RTCS_alloc_dup() that appears to help with this.  However, this function appears to only work on Ethernet messages of the "PCB send structure" (type RTCSPCB_PTR).  I believe I am working with the Ethernet messages of the "PCB receive structure" (type PCB_PTR).  And I do not see a RTCS_alloc_dup() function that can work on the receive structures.

So, what are my best options?  I'm thinking of copying the RTCSPCB_alloc_dup() function, putting it in my application and re-writing it to work with the type PCB_PTR.  Thoughts?

-thanks

0 Kudos

403 Views
rickstuart
Contributor V

It looks like the RTCSPCB type structure is for transmission out of the board and PCB is fore receiving into the board.  That somewhat explains why there is no support for duplicating the PCB structure as broadcasting is usually done on the way out of the board.  But using the already existing PCB structures is the easiest path in my case.  So I settled on allocating memory for the PCB and for the FRAGMENT it was pointing to.and copying the Ethernet message so each destination had its own copy.

If any here see this differently please speak up.

-thanks

0 Kudos

403 Views
RadekS
NXP Employee
NXP Employee

Unfortunately I am a little bit confused.

If I understood correctly, you wants send the same message (probably UDP) to two different IPs.

For some reason (why?) you want to do that somewhere in middle of RTCS stack (at PCB).

I am right?

If you have allocated just one message, why you want freeing up twice?

Could you please describe your task more widely, that we can understand what you really want to do?

Unfortunately I do not see difference between RTCSPCB and PCB like you (RTCSPCB type structure is for transmission out of the board and PCB is fore receiving into the board).

PCB structure belongs to RTCSPCB structure, see rtcspcb.h and pcb.h files.


Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

403 Views
rickstuart
Contributor V

Hi RadekS,

I want to combine the RTCS example with the USB/CDC example.  I want to make a hub between the stack and both ports.  Copying the message looked like the easiest way to do this.

It works in all directions except USB to RTCS.  The RTCS stack needs a structure of type IP_IF_PTR.  This is provided for messages from the Ethernet port.  But I can not find a similar structure for messages from the USB/CDC port!

The reason why the code faulted is because I had set the IP_IF_PTR pointer to NULL for messages from the USB port to the RTCS stack.  I did this because the pointer was used for messages from the Ethernet port to the RTCS stack.  And I did not want the RTCS stack confusing the Ethernet port with the USB/CDC port.

Since I am changing my question from faulting to connecting the USB/CDC port to the RTCS stack I will start a new thread here: How to connect USB/CDC port with RTCS stack?.

-thanks

0 Kudos

403 Views
RadekS
NXP Employee
NXP Employee

Thank you for additional information.

For now I suppose that you received concatenated Ethernet frame from USB.

Yes, there isn’t any structure type IP_IF_PTR directly for USB-CDC. You will need creating new one.

I suppose that best way will be creating new interface on ENET driver level:

  1. functions like MACNET_initialize, MACNET_shutdown, MACNET_send, … but for USB. These functions will be adaptation layer between USB and RTCS.
  2. structure with pointers to these function like MACNET_IF.
  3. configuration in init_enet.c file (BSP code).
  4. an application at some of RTCS layers (IP/IP-E) which will handle messages between interfaces.

As second inspiration for new interface you can use for example AR4100 WIFI patch (it uses communication trough SPI).

0 Kudos