STR912 lwIP + Freertos demo

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

STR912 lwIP + Freertos demo

ajinkya
Hello All,
I have searched about this topic before posting it here, most of the threads are of 2007 and 2009 and I am not able to contact the people in the discussion.

i am working on STR912 platform (IAR embedded workbench). have worked on uip+FreeRTOS demo port available.
Now I have to switch to lwip+freeRTOS to receive a UDP packet and take a action corresponding to the code/command in the packet.
If somebody has a lwip+freeRTOS demo available for STR912, can please help me out.

--
Ajinkya
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

Noam weissman
Hi,

The platform or processor should not make a difference. It’s the same code.

First of all you need to define if you want to work in RAW or Sokets.

You need to set up the system first. Meaning setup your software and be able to ping to your device.
You have drivers at ST for the 912 so use it first to raise your setup.

Once you have a system running you have lost of examples.

I am working only in RAW mode but my code and drivers are dedicated. If you can define your system better I
Can help you to get started.

I suggest also getting the latest FreeRTOS and examples. You have examples for STM912 there.

After you download it go into the demo code:
    FreeRTOS\Demo\ARM9_STR91X_IAR

I have attached a  ZIP file with lots of examples. Take a look at the tcpecho and udpecho  examples.
This examples are very basic and simple to understand.

The rawapi.txt is part of LwIP but I added it as well to save you on searching.

Hope that helped.

BR,
Noam.








-----Original Message-----
From: lwip-users-bounces+noam=[hidden email] [mailto:lwip-users-bounces+noam=[hidden email]] On Behalf Of ajinkya
Sent: ד 03 אפריל 2013 14:39
To: [hidden email]
Subject: [lwip-users] STR912 lwIP + Freertos demo

Hello All,
I have searched about this topic before posting it here, most of the threads are of 2007 and 2009 and I am not able to contact the people in the discussion.

i am working on STR912 platform (IAR embedded workbench). have worked on
uip+FreeRTOS demo port available.
Now I have to switch to lwip+freeRTOS to receive a UDP packet and take a action corresponding to the code/command in the packet.
If somebody has a lwip+freeRTOS demo available for STR912, can please help me out.

--
Ajinkya



--
View this message in context: http://lwip.100.n7.nabble.com/STR912-lwIP-Freertos-demo-tp21277.html
Sent from the lwip-users mailing list archive at Nabble.com.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

 
 
************************************************************************************
This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************






************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

contrib-1.4.1.zip (588K) Download Attachment
rawapi.txt (27K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

ajinkya
Thanks Noam ,
I have updated my version to current freeRTOS version.
And as you asked I am able to ping my STR912 comstick dongle.

but the demo code  -> FreeRTOS\Demo\ARM9_STR91X_IAR uses uip stack only.
since i changed the ip address,mask,gateway in uip_Task.c  and it is replying the ping.
Here is the part of void main() which is for uip and lwip.
---------------------------------------------------------------------------------------------
/* Start either the uIP TCP/IP stack or the lwIP TCP/IP stack. */
        #ifdef STACK_UIP
                /* Finally, create the WEB server task. */
                xTaskCreate( vuIP_Task, "uIP", configMINIMAL_STACK_SIZE * 3, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
        #endif

        #ifdef STACK_LWIP
                /* Create the lwIP task.  This uses the lwIP RTOS abstraction layer.*/
          vlwIPInit();
                sys_set_state( ( signed char * ) "httpd", lwipBASIC_SERVER_STACK_SIZE );
          sys_thread_new( vBasicWEBServer, ( void * ) NULL, basicwebWEBSERVER_PRIORITY );
                sys_set_default_state();
        #endif
---------------------------------------------------------------------------------------------------
So now the question remains. How to make lwip stack up?
I don't need a web server or something like that.
What i intend to do is:
1. Connect to Network: Module (str912) should be in network
2. Send a UDP packet: One remote server will send a udp packet destined to this module. (this part we are doing with "hping3" as of now and have tried with different strings between 2 PC's)
3. Receive and process udp packet: It should read the packet and on receiving particular string it should send a IR signal (generating IR and sending has been tested and is working but without any networking -uip/lwip involved)
4. Wait for next packet for processing.

Thnaks again for your reply,
Hope you can help on this .

Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

Noam weissman
Hi,

I just loaded the FreeRTOS demo in LwIP mode and I do not like the way they did it.

In general when you go to main you have:

        #ifdef STACK_LWIP
                /* Create the lwIP task.  This uses the lwIP RTOS abstraction layer.*/
          vlwIPInit();
                sys_set_state( ( signed char * ) "httpd", lwipBASIC_SERVER_STACK_SIZE );
          sys_thread_new( vBasicWEBServer, ( void * ) NULL, basicwebWEBSERVER_PRIORITY );
                sys_set_default_state();
        #endif

vlwIPInit calls all LwIP init functions wile vBasicWEBServer task sets IP, MAC etc and then dies.

If you do bnot need the HTTP server comment the httpd_init call in vBasicWEBServer task and add your
Own code there.


If you want to work in RAW mode you need to update  lwipopts.h   file and add
    #define LWIP_RAW                        1


Hope that gives you a head start.

If you have problems write to me and I will try to assist.

Have a nice weekend,
Noam.


-----Original Message-----
From: lwip-users-bounces+noam=[hidden email] [mailto:lwip-users-bounces+noam=[hidden email]] On Behalf Of ajinkya
Sent: ה 04 אפריל 2013 13:23
To: [hidden email]
Subject: Re: [lwip-users] STR912 lwIP + Freertos demo

Thanks Noam ,
I have updated my version to current freeRTOS version.
And as you asked I am able to ping my STR912 comstick dongle.

but the demo code  -> FreeRTOS\Demo\ARM9_STR91X_IAR uses *uip stack* only.
since i changed the ip address,mask,gateway in uip_Task.c  and it is replying the ping.
Here is the part of void main() which is for uip and lwip.
---------------------------------------------------------------------------------------------
/* Start either the uIP TCP/IP stack or the lwIP TCP/IP stack. */
        #ifdef STACK_UIP
                /* Finally, create the WEB server task. */
                xTaskCreate( vuIP_Task, "uIP", configMINIMAL_STACK_SIZE * 3, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
        #endif

        #ifdef STACK_LWIP
                /* Create the lwIP task.  This uses the lwIP RTOS abstraction layer.*/
          vlwIPInit();
                sys_set_state( ( signed char * ) "httpd", lwipBASIC_SERVER_STACK_SIZE );
          sys_thread_new( vBasicWEBServer, ( void * ) NULL, basicwebWEBSERVER_PRIORITY );
                sys_set_default_state();
        #endif
---------------------------------------------------------------------------------------------------
So now the question remains. How to make lwip stack up?
I don't need a web server or something like that.
What i intend to do is:
1. Connect to Network: Module (str912) should be in network 2. Send a UDP packet: One remote server will send a udp packet destined to this module. (this part we are doing with "hping3" as of now and have tried with different strings between 2 PC's) 3. *Receive and process udp packet:* It should read the packet and on receiving particular string it should send a IR signal (generating IR and sending has been tested and is working but without any networking -uip/lwip
involved)
4. Wait for next packet for processing.

Thnaks again for your reply,
Hope you can help on this .





--
View this message in context: http://lwip.100.n7.nabble.com/STR912-lwIP-Freertos-demo-tp21277p21286.html
Sent from the lwip-users mailing list archive at Nabble.com.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

 
 
************************************************************************************
This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




 
 
************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

Noam weissman
In reply to this post by ajinkya
Hi,

Were you able to work with the LwIP ??

BR,
Noam.

-----Original Message-----
From: lwip-users-bounces+noam=[hidden email] [mailto:lwip-users-bounces+noam=[hidden email]] On Behalf Of ajinkya
Sent: ה 04 אפריל 2013 13:23
To: [hidden email]
Subject: Re: [lwip-users] STR912 lwIP + Freertos demo

Thanks Noam ,
I have updated my version to current freeRTOS version.
And as you asked I am able to ping my STR912 comstick dongle.

but the demo code  -> FreeRTOS\Demo\ARM9_STR91X_IAR uses *uip stack* only.
since i changed the ip address,mask,gateway in uip_Task.c  and it is replying the ping.
Here is the part of void main() which is for uip and lwip.
---------------------------------------------------------------------------------------------
/* Start either the uIP TCP/IP stack or the lwIP TCP/IP stack. */
        #ifdef STACK_UIP
                /* Finally, create the WEB server task. */
                xTaskCreate( vuIP_Task, "uIP", configMINIMAL_STACK_SIZE * 3, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
        #endif

        #ifdef STACK_LWIP
                /* Create the lwIP task.  This uses the lwIP RTOS abstraction layer.*/
          vlwIPInit();
                sys_set_state( ( signed char * ) "httpd", lwipBASIC_SERVER_STACK_SIZE );
          sys_thread_new( vBasicWEBServer, ( void * ) NULL, basicwebWEBSERVER_PRIORITY );
                sys_set_default_state();
        #endif
---------------------------------------------------------------------------------------------------
So now the question remains. How to make lwip stack up?
I don't need a web server or something like that.
What i intend to do is:
1. Connect to Network: Module (str912) should be in network 2. Send a UDP packet: One remote server will send a udp packet destined to this module. (this part we are doing with "hping3" as of now and have tried with different strings between 2 PC's) 3. *Receive and process udp packet:* It should read the packet and on receiving particular string it should send a IR signal (generating IR and sending has been tested and is working but without any networking -uip/lwip
involved)
4. Wait for next packet for processing.

Thnaks again for your reply,
Hope you can help on this .





--
View this message in context: http://lwip.100.n7.nabble.com/STR912-lwIP-Freertos-demo-tp21277p21286.html
Sent from the lwip-users mailing list archive at Nabble.com.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

 
 
************************************************************************************
This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




 
 
************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

ajinkya
Hi Noam,
Sry was out for week end.
Yes your advise helped, I am able to work with lwip now. :-)
And I need some more help now.........
As I told you earlier I wanted to receive and process UDP packet.
Working on that now, your input will save time.
Thanks again :-)

--
Ajinkya
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

Noam weissman
Hi,

I have attached a simple UDP server working in RAW mode.

This code is based on a discovery server I made.

The code was stripped from my own data code. I left all the functional code.

Take a look. I hope this will help you. Take into consideration that this code will probably
not compile and you will have to make modifications and add your own data processing.

You will probably need to add some H files for types or even remove the one I placed in the H file

Happy to assist,
Noam.

-----Original Message-----
From: lwip-users-bounces+noam=[hidden email] [mailto:lwip-users-bounces+noam=[hidden email]] On Behalf Of ajinkya
Sent: ב 08 אפריל 2013 10:27
To: [hidden email]
Subject: Re: [lwip-users] STR912 lwIP + Freertos demo

Hi Noam,
Sry was out for week end.
Yes your advise helped, I am able to work with lwip now. :-) And I need some more help now.........
As I told you earlier I wanted to receive and process UDP packet.
Working on that now, your input will save time.
Thanks again :-)

--
Ajinkya



--
View this message in context: http://lwip.100.n7.nabble.com/STR912-lwIP-Freertos-demo-tp21277p21300.html
Sent from the lwip-users mailing list archive at Nabble.com.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

 
 
************************************************************************************
This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************






************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

gefenCore.rar (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

ajinkya
Hi Noam,

I have not tried the code you sent, I have gone through it though.
And it helped me.

As starters since we don't have any thing on that small module to
see whether it is receiving (like TCPdump/wireshark), I preferred to send a broadcast message first.

I referred your code + this link "http://www.ultimaserial.com/avr_lwip_udp.html"
for sending a broadcast UDP message on network.
It is working fine. Then Tried to send the same to a particular destination Host, that also works fine.

Now I am dealing with receiving UDP packet and processing the command in that packet.
I will tell you if I get stuck somewhere.

Thank you very much for help  :-)

--
Ajinkya
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

Noam weissman
Great, No problems

-----Original Message-----
From: lwip-users-bounces+noam=[hidden email] [mailto:lwip-users-bounces+noam=[hidden email]] On Behalf Of ajinkya
Sent: ד 10 אפריל 2013 09:45
To: [hidden email]
Subject: Re: [lwip-users] STR912 lwIP + Freertos demo

Hi Noam,

I have not tried the code you sent, I have gone through it though.
And it helped me.

As starters since we don't have any thing on that small module to see whether it is receiving (like TCPdump/wireshark), I preferred to send a broadcast message first.

I referred your code + this link
"http://www.ultimaserial.com/avr_lwip_udp.html"
for sending a broadcast UDP message on network.
It is working fine. Then Tried to send the same to a particular destination Host, that also works fine.

Now I am dealing with receiving UDP packet and processing the command in that packet.
I will tell you if I get stuck somewhere.

Thank you very much for help  :-)

--
Ajinkya



--
View this message in context: http://lwip.100.n7.nabble.com/STR912-lwIP-Freertos-demo-tp21277p21304.html
Sent from the lwip-users mailing list archive at Nabble.com.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

 
 
************************************************************************************
This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




 
 
************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

ajinkya
Hi Noam,
I have tried the code, and have made some changes, but I have some issues.

Here is the part of code.

"BuildReply" function compares the received payload with the string, and sets  "RetVal" flag,
which we use "Discovery_recv" function to send different replies depending on the returned "RetVal" flag value.
This is just for trials and testing i tried this code, and I am getting the expected reply.
But I wanted to ask, am I doing it correct??
I guess I am missing something.

Because when I introduce the "vAC_ON_OFF_Function" it happens only once (I get a reply saying "AC Switched ON" and the signal is also sent) but then it is gone.........doesn't even reply ping.

I have attached 2 screen shots of Wireshark for reference (With_vAC_ON_OFF_Function_1.png,  With_vAC_ON_OFF_Function_2.png)

And 2 more screen shots with plain request-reply (plain-request-reply1.png, plain-request-reply2.png) which was working fine (without the addon function - "vAC_ON_OFF_Function" ).

Source addr-10.114.12.50
Dest Addr - 10.114.12.58 --(STR9 device address)

void vBasicWEBServer( void *pvParameters )
{
struct ip_addr xIpAddr, xNetMast, xGateway;
extern err_t ethernetif_init( struct netif *netif );
err_t err;

struct udp_pcb *my_pcb;
struct pbuf *p;

    /* Parameters are not used - suppress compiler error. */
    ( void ) pvParameters;

    /* Create and configure the EMAC interface. */
    IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );
    IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );
    IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );
    netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );

    /* make it the default interface */
    netif_set_default( &EMAC_if );
   
    /* bring it up */
    netif_set_up(&EMAC_if);

/*----------------------------Modify here---------------------------------------*/

    /* Initialize UDP */
    my_pcb = udp_new();

    if(my_pcb != NULL)
      err = udp_bind(my_pcb, IP_ADDR_ANY, 1235);

    if(err == ERR_OK)
    {
      while (1)
        {
         udp_recv(my_pcb, Discovery_recv, my_pcb);
        }
    }

    /* Nothing else to do.  No point hanging around. */

    //vTaskDelete( NULL );
}

/*----------------------------------------------------------------------------*/
/******************************************************************************/
/*----------------------------------------------------------------------------*/

static void Discovery_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
{
        struct pbuf *pLocal_ON, *pLocal_OFF, *pLocal_Miss ;
        char *Payload_extract;
        char reply_msg1[]="AC Switched ON";
        char reply_msg2[]="AC Switched OFF";
        char reply_msg3[]="Ohh noo";


  // p == NULL when client has terminated the udp connection. We will acknowledge the request and close conn.
  if(p == NULL)
  {
    return;
  }    

  Payload_extract = (char*) p->payload;  // take the pointer to the data or even better to copy it to a buffer
       
  pbuf_free(p);  

      // Allocate a new pbuf for sending the response.
    pLocal_ON = pbuf_alloc(PBUF_TRANSPORT, sizeof(reply_msg1), PBUF_RAM);
    pLocal_OFF = pbuf_alloc(PBUF_TRANSPORT, sizeof(reply_msg2), PBUF_RAM);
    pLocal_Miss = pbuf_alloc(PBUF_TRANSPORT, sizeof(reply_msg3), PBUF_RAM);


    memcpy (pLocal_ON->payload, reply_msg1, sizeof(reply_msg1));
    memcpy (pLocal_OFF->payload, reply_msg2, sizeof(reply_msg2));
    memcpy (pLocal_Miss->payload, reply_msg3, sizeof(reply_msg3));
   
   
    //   create the response
    RetVal = BuildReply(Payload_extract);

    //   Send the response.
    //  pLocal->len = pLocal->tot_len = PayloadLength;

       if(RetVal == 1)
         {
           //PassArray = 1;
           //vAC_ON_OFF_Function();  //Send signal to switch ON AC-
          udp_sendto(upcb, pLocal_ON, addr, port);  
         }
       else if(RetVal == 2)
         {
          //PassArray = 0;
          //vAC_ON_OFF_Function(); //Send signal to switch OFF AC
          udp_sendto(upcb, pLocal_OFF, addr, port);
         }

       else if(RetVal ==0)
          udp_sendto(upcb, pLocal_Miss, addr, port);
   
    pbuf_free(pLocal_ON);
    pbuf_free(pLocal_OFF);
    pbuf_free(pLocal_Miss);

  return;
}

/*----------------------------------------------------------------------------*/

static int BuildReply(char *Payload)
{
  char AC_Sig_ON[] = "Switch ON AC";
  char AC_Sig_OFF[] = "Switch OFF AC";
 
        // add your own code here
  if(strcmp (Payload, AC_Sig_ON) == 0)    //compare received payload with string
     RetVal = 1;
  else if(strcmp(Payload, AC_Sig_OFF) == 0) //compare received payload with string
     RetVal = 2;
  else
     RetVal = 0;
 
  return RetVal;
}

/*----------------------------------------------------------------------------*/
/*---------Add on code to send a signal on receiving perticular payload---------*/
/*------------------------------------------------------------------------*/
static int vAC_ON_OFF_Function()
{
      PWMBusy = 1;
      ConfigurePWMfor_AC_ON();
      if(PulseCount >= 31)
       {
         PulseCount =0;
         TIM_DeInit(TIM1);
         TIM_DeInit(TIM2);
       }
      PWMBusy = 0;
  return PWMBusy;
}

/*------------------------------------------------------------------------*/
void ConfigurePWMfor_AC_ON(void)
{
    VIC_DeInit();
    TIM_DeInit(TIM1);
    TIM_DeInit(TIM2);
   
    TIM2->OC1R = 0x0023;
    TIM2->OC2R = 0x0046;
    TIM2->CR2 = 0x0010;
    TIM2->CR1 = 0x8250;  //carrier 38 khz
   
    TIM_ClearFlag(TIM1,TIM_FLAG_OC2);
    portENTER_CRITICAL();
    {
          VIC_Config(TIM1_ITLine,VIC_IRQ, 0);
          VIC_ITCmd(TIM1_ITLine,ENABLE);
          //VIC_InitDefaultVectors();
          TIM1->SR &= 0x0000;
          VIC0->ISR = 0x0000;
    }
    portEXIT_CRITICAL();
   
    TIM1->OC1R = 0x00FF;
    TIM1->OC2R = 0x0FFF;
    TIM1->CR2 = 0x0810;
    TIM1->CR1 = 0x8250;  // Signal of AC remote
    while(PulseCount < 31);
}

/*------------------------------------------------------------------------*/
void PWM_TIM1_IRQHandler(void)    // Interrupt handler
{
     /* Clear the interrupt. */
    TIM1->SR = 0x0000;
    VIC0->ISR = 0x0000;
   
    if(PassArray != 1)
      TIM1->OC2R = OFFArrayOC2R[PulseCount];

    else
    TIM1->OC2R = ONArrayOC2R[PulseCount];
   
    TIM1->OC1R = ArrayOC1R[PulseCount];
   
    if(PulseCount < 31)
      PulseCount++;
    else
      TIM1->CR1 &= 0x7FFF;          //STOP timer counter so next interrupt will not occur

   VIC0->VAR = 0xFF;
}
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

Noam weissman
RE: [lwip-users] STR912 lwIP + Freertos demo

Hi,

The example code I sent you works in RAW mode.

That means you do not create any task or threads. Your functions are being called
by the TCP stack.

Please check again your code. In function vBasicWEBServer you need to call a function
that creates the UDP server and assigns your own call back functions to the new PCB

After that you call vTaskDelete( NULL ); and terminate the temporary task.

The UDP server will not die after that as it is running as part of the LwIP code.

You do not loop or call udp_recv yourself.

If this is not understood let me know.

BR,
Noam.



-----Original Message-----
From: lwip-users-bounces+noam=[hidden email] on behalf of ajinkya
Sent: Tue 4/16/2013 11:53 AM
To: [hidden email]
Subject: Re: [lwip-users] STR912 lwIP + Freertos demo

Hi Noam,
I have tried the code, and have made some changes, but I have some issues.

Here is the part of code.

"BuildReply" function compares the received payload with the string, and
sets  "RetVal" flag,
which we use "Discovery_recv" function to send different replies depending
on the returned "RetVal" flag value.
This is just for trials and testing i tried this code, and I am getting the
expected reply.
But I wanted to ask, *am I doing it correct??*
I guess I am missing something.

Because when I introduce the "vAC_ON_OFF_Function" it happens only once (I
get a reply saying "AC Switched ON" and the signal is also sent) but then it
is gone.........doesn't even reply ping.

I have attached 2 screen shots of Wireshark for reference (
With_vAC_ON_OFF_Function_1.png
<http://lwip.100.n7.nabble.com/file/n21320/With_vAC_ON_OFF_Function_1.png>
,   With_vAC_ON_OFF_Function_2.png
<http://lwip.100.n7.nabble.com/file/n21320/With_vAC_ON_OFF_Function_2.png>
)

And 2 more screen shots with plain request-reply ( plain-request-reply1.png
<http://lwip.100.n7.nabble.com/file/n21320/plain-request-reply1.png>  ,
plain-request-reply2.png
<http://lwip.100.n7.nabble.com/file/n21320/plain-request-reply2.png>  )
which was working fine (without the addon function - "vAC_ON_OFF_Function"
).

Source addr-10.114.12.50
Dest Addr - 10.114.12.58 --(STR9 device address)

void vBasicWEBServer( void *pvParameters )
{
struct ip_addr xIpAddr, xNetMast, xGateway;
extern err_t ethernetif_init( struct netif *netif );
err_t err;

struct udp_pcb *my_pcb;
struct pbuf *p;

    /* Parameters are not used - suppress compiler error. */
    ( void ) pvParameters;

    /* Create and configure the EMAC interface. */
    IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3
);
    IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2,
emacNET_MASK3 );
    IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1,
emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );
    netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL,
ethernetif_init, tcpip_input );

    /* make it the default interface */
    netif_set_default( &EMAC_if );
   
    /* bring it up */
    netif_set_up(&EMAC_if);

/*----------------------------Modify
here---------------------------------------*/

    /* Initialize UDP */
    my_pcb = udp_new();

    if(my_pcb != NULL)
      err = udp_bind(my_pcb, IP_ADDR_ANY, 1235);

    if(err == ERR_OK)
    {
      while (1)
        {
         udp_recv(my_pcb, Discovery_recv, my_pcb);
        }
    }

    /* Nothing else to do.  No point hanging around. */

    //vTaskDelete( NULL );
}

/*----------------------------------------------------------------------------*/
/******************************************************************************/
/*----------------------------------------------------------------------------*/

static void Discovery_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p,
struct ip_addr *addr, u16_t port)
{
        struct pbuf *pLocal_ON, *pLocal_OFF, *pLocal_Miss ;
        char *Payload_extract;
        char reply_msg1[]="AC Switched ON";
        char reply_msg2[]="AC Switched OFF";
        char reply_msg3[]="Ohh noo";


  // p == NULL when client has terminated the udp connection. We will
acknowledge the request and close conn.
  if(p == NULL)
  {
    return;
  }   

  Payload_extract = (char*) p->payload;  // take the pointer to the data or
even better to copy it to a buffer
       
  pbuf_free(p); 

      // Allocate a new pbuf for sending the response.
    pLocal_ON = pbuf_alloc(PBUF_TRANSPORT, sizeof(reply_msg1), PBUF_RAM);
    pLocal_OFF = pbuf_alloc(PBUF_TRANSPORT, sizeof(reply_msg2), PBUF_RAM);
    pLocal_Miss = pbuf_alloc(PBUF_TRANSPORT, sizeof(reply_msg3), PBUF_RAM);


    memcpy (pLocal_ON->payload, reply_msg1, sizeof(reply_msg1));
    memcpy (pLocal_OFF->payload, reply_msg2, sizeof(reply_msg2));
    memcpy (pLocal_Miss->payload, reply_msg3, sizeof(reply_msg3));
   
   
    //   create the response
    RetVal = BuildReply(Payload_extract);

    //   Send the response.
    //  pLocal->len = pLocal->tot_len = PayloadLength;

       if(RetVal == 1)
         {
           //PassArray = 1;
           //vAC_ON_OFF_Function();  //Send signal to switch ON AC-
          udp_sendto(upcb, pLocal_ON, addr, port); 
         }
       else if(RetVal == 2)
         {
          //PassArray = 0;
          //vAC_ON_OFF_Function(); //Send signal to switch OFF AC
          udp_sendto(upcb, pLocal_OFF, addr, port);
         }

       else if(RetVal ==0)
          udp_sendto(upcb, pLocal_Miss, addr, port);
   
    pbuf_free(pLocal_ON);
    pbuf_free(pLocal_OFF);
    pbuf_free(pLocal_Miss);

  return;
}

/*----------------------------------------------------------------------------*/

static int BuildReply(char *Payload)
{
  char AC_Sig_ON[] = "Switch ON AC";   
  char AC_Sig_OFF[] = "Switch OFF AC";

        // add your own code here
  if(strcmp (Payload, AC_Sig_ON) == 0)    //compare received payload with
string
     RetVal = 1;
  else if(strcmp(Payload, AC_Sig_OFF) == 0) //compare received payload with
string
     RetVal = 2;
  else
     RetVal = 0;
 
  return RetVal;
}

/*----------------------------------------------------------------------------*/
/*---------Add on code to send a signal on receiving perticular
payload---------*/
/*------------------------------------------------------------------------*/
static int vAC_ON_OFF_Function()
{
      PWMBusy = 1;
      ConfigurePWMfor_AC_ON();
      if(PulseCount >= 31)
       {
         PulseCount =0;
         TIM_DeInit(TIM1);
         TIM_DeInit(TIM2);
       }
      PWMBusy = 0;
  return PWMBusy;
}

/*------------------------------------------------------------------------*/
void ConfigurePWMfor_AC_ON(void)
{
    VIC_DeInit();
    TIM_DeInit(TIM1);
    TIM_DeInit(TIM2);
   
    TIM2->OC1R = 0x0023;
    TIM2->OC2R = 0x0046;
    TIM2->CR2 = 0x0010;
    TIM2->CR1 = 0x8250;  //carrier 38 khz
   
    TIM_ClearFlag(TIM1,TIM_FLAG_OC2);
    portENTER_CRITICAL();
    {
          VIC_Config(TIM1_ITLine,VIC_IRQ, 0);
          VIC_ITCmd(TIM1_ITLine,ENABLE);
          //VIC_InitDefaultVectors();
          TIM1->SR &= 0x0000;
          VIC0->ISR = 0x0000;
    }
    portEXIT_CRITICAL();
   
    TIM1->OC1R = 0x00FF;
    TIM1->OC2R = 0x0FFF;
    TIM1->CR2 = 0x0810;
    TIM1->CR1 = 0x8250;  // Signal of AC remote
    while(PulseCount < 31);
}

/*------------------------------------------------------------------------*/
void PWM_TIM1_IRQHandler(void)    // Interrupt handler
{
     /* Clear the interrupt. */
    TIM1->SR = 0x0000;
    VIC0->ISR = 0x0000;
   
    if(PassArray != 1)
      TIM1->OC2R = OFFArrayOC2R[PulseCount];

    else
    TIM1->OC2R = ONArrayOC2R[PulseCount];
   
    TIM1->OC1R = ArrayOC1R[PulseCount];
   
    if(PulseCount < 31)
      PulseCount++;
    else
      TIM1->CR1 &= 0x7FFF;          //STOP timer counter so next interrupt
will not occur

   VIC0->VAR = 0xFF;
}



--
View this message in context: http://lwip.100.n7.nabble.com/STR912-lwIP-Freertos-demo-tp21277p21320.html
Sent from the lwip-users mailing list archive at Nabble.com.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users



************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************








************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

ajinkya
Thanks Noam,
We did the changes ......
Without trying to send a IR signal (as a separate function/task).....
siply I am able to read the payload do some processing and send some reply.....
Tested rigorously for around 500 transmitted UDP packets.

But Still I have some problem after including my code (Transmitting IR code).
Here is the file I have attached. Because it sends the code(IR) ..... it replies back UDP packet......and it goes off......doesn't even reply ping......
can you please guide on this........What care should be taken..........

BasicWEB.c

Thanks........
Ajinkya
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

Noam weissman
Hi,

As far as I see in your code.

In line 240
   udp_recv(my_pcb, udp_echo_recv, NULL);

change it to:
   udp_recv(my_pcb, udp_echo_recv, my_pcb);


This is what I am doing in my code.

Hope that helped.

BR,
Noam.


-----Original Message-----
From: lwip-users-bounces+noam=[hidden email] [mailto:lwip-users-bounces+noam=[hidden email]] On Behalf Of ajinkya
Sent: ה 18 אפריל 2013 15:41
To: [hidden email]
Subject: Re: [lwip-users] STR912 lwIP + Freertos demo

Thanks Noam,
We did the changes ......
Without trying to send a IR signal (as a separate function/task).....
siply I am able to read the payload do some processing and send some reply.....
Tested rigorously for around 500 transmitted UDP packets.

But Still I have some problem after including my code (Transmitting IR code).
Here is the file I have attached. Because it sends the code(IR) ..... it replies back UDP packet......and it goes off......doesn't even reply ping......
can you please guide on this........What care should be taken..........

BasicWEB.c <http://lwip.100.n7.nabble.com/file/n21325/BasicWEB.c>  

Thanks........
Ajinkya



--
View this message in context: http://lwip.100.n7.nabble.com/STR912-lwIP-Freertos-demo-tp21277p21325.html
Sent from the lwip-users mailing list archive at Nabble.com.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

 
 
************************************************************************************
This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




 
 
************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

ajinkya
Hi Noam,
I wish this to be a last doubt........:-)

Which timer does LWIP uses......??

Because I am using 2 timers to generate my required IR signal (Timer1 and Timer2)  
(Kit has 4 timers in total From TIM0, TIM1, TIM2, TIM3)

I have one timer interrupt routine too (for timer1), which is used to get variable PWM o/p.

Is this causing problem? --->> That I am using the same timer that LWIP uses or something like that.

Because I found one link ----->>>   http://forums.xilinx.com/t5/Embedded-Development-Tools/xps-timer-interrupt-clashing-with-lwip-socket/td-p/91164

Which discusses same kind of problem reported.

Waiting for your input, meanwhile I am trying the same code with combination of different timers,

--
Thanks,
Ajinkya

Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

Noam weissman
Hi,

Were you able to run the UDP eventually ?

I have just checked a project I have that uses TIM2 for FreeRTOS

The rest are not used by LwIP.

As far as I know LwIP does not uses any hardware timers in this application

Hope that helped.

Noam.


-----Original Message-----
From: lwip-users-bounces+noam=[hidden email] [mailto:lwip-users-bounces+noam=[hidden email]] On Behalf Of ajinkya
Sent: ב 22 אפריל 2013 09:14
To: [hidden email]
Subject: Re: [lwip-users] STR912 lwIP + Freertos demo

Hi Noam,
I wish this to be a last doubt........:-)

Which timer does LWIP uses......??

Because I am using 2 timers to generate my required IR signal (Timer1 and
Timer2)
(Kit has 4 timers in total From TIM0, TIM1, TIM2, TIM3)

I have one timer interrupt routine too (for timer1), which is used to get variable PWM o/p.

Is this causing problem? --->> That I am using the same timer that LWIP uses or something like that.

Because I found one link ----->>>
http://forums.xilinx.com/t5/Embedded-Development-Tools/xps-timer-interrupt-clashing-with-lwip-socket/td-p/91164

Which discusses same kind of problem reported.

Waiting for your input, meanwhile I am trying the same code with combination of different timers,

--
Thanks,
Ajinkya





--
View this message in context: http://lwip.100.n7.nabble.com/STR912-lwIP-Freertos-demo-tp21277p21328.html
Sent from the lwip-users mailing list archive at Nabble.com.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

 
 
************************************************************************************
This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




 
 
************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

ajinkya
Hi Noam,
I am done with the trials of different combinations of Timers available.

But I guess , something is wrong. As udp works fine without the use of timers.

And as the timer related function gets called it stops (Ethernet leds continue to blink but doesn't reply ping ).

Yes, I do agree that LWIP cannot use hardware timers, as its a platform independent thing.

I am still checking whats going wrong here........and will also post a new thread, in case, somebody has faced same kind of problem.

--
Thanks,
Ajinkya
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

Noam weissman
Hi,

Ethernet LED's blink because it is hardware related (PHY).

This sounds strange as we work we with timers all the time. Check your code and see.
 
there something else that happens.

I can suggest commenting all the code and just leave the timer interrupt function.
See if the TCP hangs. If not than something in your code causes the problem.

Noam.

-----Original Message-----
From: lwip-users-bounces+noam=[hidden email] [mailto:lwip-users-bounces+noam=[hidden email]] On Behalf Of ajinkya
Sent: ב 22 אפריל 2013 12:27
To: [hidden email]
Subject: Re: [lwip-users] STR912 lwIP + Freertos demo

Hi Noam,
I am done with the trials of different combinations of Timers available.

But I guess , something is wrong. As udp works fine without the use of timers.

And as the timer related function gets called it stops (Ethernet leds continue to blink but doesn't reply ping ).

Yes, I do agree that LWIP cannot use hardware timers, as its a platform independent thing.

I am still checking whats going wrong here........and will also post a new thread, in case, somebody has faced same kind of problem.

--
Thanks,
Ajinkya



--
View this message in context: http://lwip.100.n7.nabble.com/STR912-lwIP-Freertos-demo-tp21277p21330.html
Sent from the lwip-users mailing list archive at Nabble.com.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

 
 
************************************************************************************
This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




 
 
************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

ajinkya
Hi Noam,
I just rectified the problem, :-)
Actually I wrote the IR generation first, got it working.
Then I started with LWIP, also got it working, with your help of course.

But while integrating both the codes, I did not comment

---->>         VIC_DeInit();  //(actually did that purposefully while writing IR generation)

function call, which was a part of IR generation code, and was getting called after
UDP server comes online.

So everything related to interrupts was deinitialized (as ethernet requires them, it was not working)

Finally it is working.........
I am able to control AC over Ethernet now...........

Still I have some reliability issues, as it goes offline after certain time/ packets of transmission and reception.
Is there something/some function to keep it refreshing/resetting?


---
Thanks a lot,
Ajinkya


----(Will be available on this mailing list if somebody finds some problem, and I am able to solve it :-) )
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

Noam weissman
Hi,

Under UDP there should be a time out as there is no connection.

When you work with TCP it is normal to have some kind of timeout and that is
to avoid unused connections.

Noam.

-----Original Message-----
From: lwip-users-bounces+noam=[hidden email] [mailto:lwip-users-bounces+noam=[hidden email]] On Behalf Of ajinkya
Sent: ב 22 אפריל 2013 15:26
To: [hidden email]
Subject: Re: [lwip-users] STR912 lwIP + Freertos demo

Hi Noam,
I just rectified the problem, :-)
Actually I wrote the IR generation first, got it working.
Then I started with LWIP, also got it working, with your help of course.

But while integrating both the codes, I did not comment

---->>         VIC_DeInit();  //(actually did that purposefully while
writing IR generation)

function call, which was a part of IR generation code, and was getting called after UDP server comes online.

So everything related to interrupts was deinitialized (as ethernet requires them, it was not working)

Finally it is working.........
I am able to control AC over Ethernet now...........

Still I have some reliability issues, as it goes offline after certain time/ packets of transmission and reception.
Is there something/some function to keep it refreshing/resetting?


---
Thanks a lot,
Ajinkya


----(Will be available on this mailing list if somebody finds some problem, and I am able to solve it :-) )



--
View this message in context: http://lwip.100.n7.nabble.com/STR912-lwIP-Freertos-demo-tp21277p21332.html
Sent from the lwip-users mailing list archive at Nabble.com.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

 
 
************************************************************************************
This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




 
 
************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************




_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: STR912 lwIP + Freertos demo

Bill Auerbach
Noam,

Didn’t you mean to say "... there should NOT be a timeout as ..."?

Bill

-----Original Message-----
From: lwip-users-bounces+bauerbach=[hidden email]
[mailto:lwip-users-bounces+bauerbach=[hidden email]] On Behalf
Of Noam weissman
Sent: Monday, April 22, 2013 9:05 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] STR912 lwIP + Freertos demo

Hi,

Under UDP there should be a time out as there is no connection.

When you work with TCP it is normal to have some kind of timeout and that is
to avoid unused connections.

Noam.

-----Original Message-----
From: lwip-users-bounces+noam=[hidden email]
[mailto:lwip-users-bounces+noam=[hidden email]] On Behalf Of ajinkya
Sent: ב 22 אפריל 2013 15:26
To: [hidden email]
Subject: Re: [lwip-users] STR912 lwIP + Freertos demo

Hi Noam,
I just rectified the problem, :-)
Actually I wrote the IR generation first, got it working.
Then I started with LWIP, also got it working, with your help of course.

But while integrating both the codes, I did not comment

---->>         VIC_DeInit();  //(actually did that purposefully while
writing IR generation)

function call, which was a part of IR generation code, and was getting
called after UDP server comes online.

So everything related to interrupts was deinitialized (as ethernet requires
them, it was not working)

Finally it is working.........
I am able to control AC over Ethernet now...........

Still I have some reliability issues, as it goes offline after certain time/
packets of transmission and reception.
Is there something/some function to keep it refreshing/resetting?


---
Thanks a lot,
Ajinkya


----(Will be available on this mailing list if somebody finds some problem,
and I am able to solve it :-) )



--
View this message in context:
http://lwip.100.n7.nabble.com/STR912-lwIP-Freertos-demo-tp21277p21332.html
Sent from the lwip-users mailing list archive at Nabble.com.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

 
 
****************************************************************************
********
This footnote confirms that this email message has been scanned by PineApp
Mail-SeCure for the presence of malicious code, vandals & computer viruses.
****************************************************************************
********




 
 
****************************************************************************
********
This footnote confirms that this email message has been scanned by PineApp
Mail-SeCure for the presence of malicious code, vandals & computer viruses.
****************************************************************************
********




_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
12