This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM437x RTOS TCP packets handling without daemon

Hi,

I use idkam437x with ccs 6.1.2, sysbios 6.45.1.29, sdk 2.1.1.2 and ndk 2.24.3.35.

I have an application in which some tcp frames should be obtained trough ethernet connection. The first one should be handled in high priority and the rest could be received in normal mode with appropriate transmission timeout.

So far, I succesfully configured the emac instance on my idkam437x as it can be pinged. The first packet with high priority number in vlan tag is going to be received by callback function. But I don't know how to handle the rest them. In every ndk example the only way presented is daemon creation which I don't like due to its complication and workload. Instead of that, I would like to establish an ordinary socket. I saw some examples of socket creation on E2E but they do not answer some questions:

- Is it sufficient to create a socket without  opening a session by fdOpenSession?

- If I need to open a session I should probably create a separate task (provided as fdOpenSession() argument) for handling a socket? I don't want to create a task for that as it is similar to daemon action...

- Is there ANY example found somewhere in sdk or ndk (or elswhere) about handling packets that are not in the category of 'Protocol specific callback' but not by Daemon?? I don't mean NDK Guide or Reference Guide with plain information, just a piece of code?

Thanks,

JJ

  • I have notified the RTOS team. They will respond here.
  • Hi JJ

    >>- Is it sufficient to create a socket without opening a session by fdOpenSession?

    Please see spru524i.pdf –
    3.1.2.2 Auto-Initializing the File Descriptor Environment

    The calls to fdOpenSession and fdCloseSession can be configured to be called automatically.
    This is achieved by setting the following configuration parameter in XGCONF:
    var Global = xdc.useModule('ti.ndk.config.Global.xdc');
    Global.autoOpenCloseFD = true;

    Setting this parameter to true causes calls to fdOpenSession and fdCloseSession to be made automatically in the SYS/BIOS Task module's create hook function and exit hook function, respectively.

    >>- If I need to open a session I should probably create a separate task (provided as fdOpenSession() argument) for handling a socket? I don't want to create a task for that as it is similar to daemon action...

    There is not a disadvantage to create a task for handling the packets. Just use a semaphore to synchronize with high priority packet callback function.

    >>- Is there ANY example found somewhere in sdk or ndk (or elswhere) about handling packets that are not in the category of 'Protocol specific callback' but not by Daemon?? I don't mean NDK Guide or Reference Guide with plain information, just a piece of code?

    There is some relevant example code in C:\ti\ndk_2_24_03_35\packages\ti\ndk\tools\console\contest.c.

    David
  • Hi David,
    Thanks for your answer.
    I included your advices from this and the previous topic: e2e.ti.com/.../531324
    My projects works pretty fine but I wonder if I really need synchronizing packet to be sent every time that deteriorates app's efficiency.
    The idea was to receive synchronizing packet with high priority to launch 'communication' task and read the rest of data by ethernet socket.
    Is there any way of generating the interrupt from the stack (or emac) informing that I received low-priority packet? The emac rx line is occupied by the ICSS_EmacRxInterruptHandler so that cannot be used by me for Hwi_create action. I do not want to check constantly if there is something on the stack so this kind of indication would be useful...
    Thank you in advance!
    JJ
  • Hi JJ
     Let me check with out experts.

     David

  • Hi JJ

    The interrupt from PRU/ICSS_EMAC Rx is hooked to ICSS_EmacRxInterruptHandler() you understand. No additional interrupt is generated from the stack (or emac) to inform low-priority packet received.

    An alternative to a synchronization packet may be to take advantage of the fact that ICSS_EMacOsRxTaskFn() internally has a semaphore for sync with incoming packets. In this case you could set the packet receive task priority and synchronization so that it can be preempted when low-priority packets are received and other task of his application is running.


       void ICSS_EMacOsRxTaskFnc(uint32_t a0, uint32_t a1)

    {

      while(1)

        {

    ICSS_EMAC_osalPendLock(((ICSS_EmacObject*)icssEmacHandle->object)->rxSemaphoreHandle, SemaphoreP_WAIT_FOREVER);

    …

    David

  • Hi David,

    Thanks for your hint. This actually might be the solution of my problem. 

    To be absolutely sure about its effciency, I would like to ask about one trivial thing - supposing that two packets come one after another  and the gap between them is ultimately small. The semaphore will be posted twice during awaiting for it in the above while(1) loop - would it launch the code below it twice one after another or the code needs to be latched in 'osalPendLock' to be reactivated (and the code will be launched only once)?

    Thank you in advance!

    JJ