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.

GETTING ERROR IN UDP

Other Parts Discussed in Thread: TM4C1294NCPDT, EK-TM4C1294XL

Description Resource Path Location Type
#20 identifier "portQUEUE_OVERHEAD_BYTES" is undefined .ccsproject /udptiva line 56, external location: C:\ti\TivaWare_C_Series-2.1.0.12573\third_party\lwip-1.4.1\ports\tiva-tm4c129\include\arch\sys_arch.h C/C++ Problem

  • #define DEBUGKLP = 10
    #include "stdint.h"
    #include "stdbool.h"
    #include <lwip/raw.h>
    #include "lwipopts.h"
    #include "utils/uartstdio.h"
    #include "stdio.h"
    #include "inc/hw_memmap.h"
    #include "lwip/opt.h"
    #include "lwip/debug.h"
    #include "lwip/stats.h"
    #include "utils/ustdlib.h"
    #include <string.h>
    #include <stdlib.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_gpio.h"
    #include "inc/hw_nvic.h"
    #include "inc/hw_types.h"
    #include "driverlib/emac.h"
    #include "driverlib/flash.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/rom_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/systick.h"
    #include "utils/locator.h"
    #include "utils/lwiplib.h"
    #include "utils/uartstdio.h"
    //#include "C:\ti\TivaWare_C_Series-2.1.0.12573\third_party\lwip-1.4.1\apps\httpserver_raw\httpd.h"
    #include "driverlib/ssi.h"
    #include "driverlib/debug.h"
    #include "driverlib/epi.h"
    #include "inc/hw_epi.h"
    #include "C:\ti\TivaWare_C_Series-2.1.0.12573\inc\tm4c1294ncpdt.h"
    #include "inc/hw_adc.h"
    #include "inc/hw_sysctl.h"
    #include "driverlib/adc.h"
    #include "lwip/udp.h"
    #include "io.h"

    unsigned char FillBuff[1024];

    struct ip_addr udpDestIpAddr;
    struct udp_pcb *udpSkt;
    struct udp_pcb *local_pcb;
    struct udp_pcb *remote_pcb;

    struct udp_pcb *udpSkt;

    struct pbuf* pbuf1;
    char buf [120];
    char SendFlg;
    int teller = 0;

    void udp_init_klp(void);
    void udp_recv_packet(void *arg, struct udp_pcb *pcb, struct pbuf *p,
    struct ip_addr *addr, u16_t port);

    void udp_echo_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p,
    struct ip_addr *addr, u16_t port) {
    if (p != NULL) {
    /* send received packet back to sender */
    udp_sendto(pcb, p, addr, 8760); //Port
    /* free the pbuf */
    pbuf_free(p);
    }
    }

    void udp_echo_init(void) {
    struct udp_pcb * pcb;
    /* get new pcb */
    pcb = udp_new();
    if (pcb == NULL) {
    LWIP_DEBUGF(UDP_DEBUG, ("udp_new failed!\n"));
    return;
    }

    /* bind to any IP address on port 7 */
    if (udp_bind(pcb, IP_ADDR_ANY, 8760) != ERR_OK) {
    LWIP_DEBUGF(UDP_DEBUG, ("udp_bind failed!\n"));
    return;
    }

    /* set udp_echo_recv() as callback function
    for received packets */
    // udp_recv(pcb, udp_echo_recv, NULL);
    udp_recv(pcb, udp_recv_packet, NULL);
    UARTprintf("\n UDP init");
    }

    void udp_recv_packet(void *arg, struct udp_pcb *pcb, struct pbuf *p,
    struct ip_addr *addr, u16_t port) {
    int n;

    char * cp;

    cp = p->payload;
    for (n= 0; n < p->len ; n++)
    buf [n]= *cp++;

    pbuf1->payload = (void*)buf;
    pbuf1->tot_len = 900;
    pbuf1->len = 900;

    udp_sendto(pcb, pbuf1, addr, 8760);
    pbuf_free(p);

    }

    /*-----------------------------------------------------------------------------------*/
    void udp_init_klp(void) {
    remote_pcb = udp_new();
    IP4_ADDR(&udpDestIpAddr, 192, 168, 2, 104);
    pbuf1 = pbuf_alloc(PBUF_TRANSPORT, 100, PBUF_RAM); //Get a pbuf struct.
    pbuf1->payload = (void*)buf;
    pbuf1->tot_len = 15;
    pbuf1->len = 15;
    buf[0] = 0x10; // = text
    buf[1] = 0;
    strcpy(&buf[4], "hallo");
    }

    void udpTX(void) {
    static int n = 0;
    pbuf1 = pbuf_alloc(PBUF_TRANSPORT, 100, PBUF_RAM); //Get a pbuf struct.
    pbuf1->payload = (void*)buf;
    pbuf1->tot_len = 15;
    pbuf1->len = 15;
    buf[0] = 0x10; // = text
    buf[1] = 0;
    usprintf(&buf[4], " test %d", n++);
    udp_send(remote_pcb, pbuf1);
    pbuf_free(pbuf1);

    }

  • Hello,

    I am using TIVAC1294NCPDT evaluation Board.

    Any example code  for UDP transmit and receive  to send data between tivac1294 board and my PC available?

    Any frum members familiar with UDP testing on TIVAC1294 Please help me?

    Regards,

    Krishnan

  • Hello,


    Now i was able to solve some errors and were the problem coming is [ Description Resource Path Location Type
    #37 the #if for this directive is missing .ccsproject /udptiva line 337, external location: C:\ti\TivaWare_C_Series-2.1.0.12573\third_party\lwip-1.4.1\src\include\lwip\sys.h C/C++ Problem].The lwip header is included in Properties-Include Options.

    Same error is coming on sys_arch.h..............


    Any Forum member using TIVAC1294 Please help me?
  • Hello Krishnan,

    We understand the seriousness of the issue but it takes time for us to replicate the issue. Can you please post in your CCS project so that we can check the same/

    Regards
    Amit
  • Hello Amit Ashara,

    Thank you for the message.I am attaching the ccs project .For any queries please replay.udptiva.zip

  • Hello Krishnan,

    In "<TivaWare_C_Series Install Directory>/utils/" folder a utility called "locator" (locator.c and locator.h) is included. This implements a UDP listening port on port 23 using lwIP.

    The "<TivaWare_C_Series Install Directory>/examples/boards/ek-tm4c1294xl/enet_lwip" application demonstrates how to use this locator utility.

    This should get you started.

    Regards,
    Sai
  • Stellaris Sai said:
    This should get you started.

     Hi Sai, happy see someone in help to our poor forum, did you read code on post?

     The one I appreciated is this line:

        IP4_ADDR(udpDestIpAddr,255,255,255,255);

     Our luck is this code probably doesn't work so don't perform his dangerous task....

     Welcome to our hell.

  • Sir,
    Thank you for finding out my mistake ,i removed the bugs which i mentioned previosly,i am able the build the code,but not able to perform communication

    my code is
    #include <stdio.h>
    #include <stdbool.h>
    #include <stdint.h>
    #include <string.h>
    #include <stdlib.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/flash.h"
    #include "driverlib/emac.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/gpio.h"
    #include "driverlib/rom_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/systick.h"
    #include "utils/locator.h"
    #include "utils/lwiplib.h"
    #include "utils/ustdlib.h"
    #include "utils/uartstdio.h"
    #include "lwip/inet.h"
    //#include "httpserver_raw/httpd.h"
    #include "drivers/pinout.h"

    #define IP_ADDR_OCT1 192
    #define IP_ADDR_OCT2 168
    #define IP_ADDR_OCT3 0
    #define IP_ADDR_OCT4 3

    #define SUBNET_OCT1 0
    #define SUBNET_OCT2 0
    #define SUBNET_OCT3 0
    #define SUBNET_OCT4 0

    #define GATEWAY_IP_OCT1 255
    #define GATEWAY_IP_OCT2 255
    #define GATEWAY_IP_OCT3 255
    #define GATEWAY_IP_OCT4 255

    //*****************************************************************************
    //
    // Defines for setting up the system clock.
    //
    //*****************************************************************************
    #define SYSTICKHZ 100
    #define SYSTICKMS (1000 / SYSTICKHZ)

    //*****************************************************************************
    //
    // Interrupt priority definitions. The top 3 bits of these values are
    // significant with lower values indicating higher priority interrupts.
    //
    //*****************************************************************************
    #define SYSTICK_INT_PRIORITY 0x80
    //#define ETHERNET_INT_PRIORITY 0xC0

    //*****************************************************************************
    //
    // The current IP address.
    //
    //*****************************************************************************
    uint32_t g_ui32IPAddress;

    //*****************************************************************************
    //
    // The system clock frequency.
    //
    //*****************************************************************************
    uint32_t g_ui32SysClock;

    //*****************************************************************************
    //
    // The error routine that is called if the driver library encounters an error.
    //
    //*****************************************************************************
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
    }
    #endif
    struct ip_addr *udpDestIpAddr;
    struct udp_pcb *pcb;
    struct udp_pcb *g_upcb1,*g_upcb2;
    unsigned char *datasram;
    int i,j;

    unsigned long index;
    unsigned char buffer[1440];
    unsigned char *UDPData;
    unsigned char gain;

    unsigned char u8_EtherNodeId = 0;
    unsigned char pucMACArray[8];
    unsigned char u8_EthNode;
    unsigned char IP_AddrOct1;

    // UDP transmit ...........................................
    void my_udp_tx(u8_t *data, u16_t len)
    {
    if(g_upcb1->remote_port != (unsigned short)0)
    {
    struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT,len, PBUF_RAM);
    memcpy(p->payload, data, len);
    udp_send(g_upcb1, p);
    pbuf_free(p);
    }
    }

    void my_udp_rx(struct udp_pcb *upcb,struct ip_addr *addr, u16_t port,u8_t *buf)
    {
    /* process the payload in p->payload */
    udp_connect(upcb, addr, port); /* connect to the remote host */
    my_udp_tx(buf,1456);
    free(buf); /* don't leak the pbuf!*/
    }


    // UDP initialization ......................................
    void my_udp_init(void)
    {
    g_upcb1 = udp_new();
    udp_bind(g_upcb1, IP_ADDR_ANY,(16700 ));
    IP4_ADDR(udpDestIpAddr,172,17,0,3);
    udp_recv(g_upcb1, &my_udp_rx, NULL);
    }





    //*****************************************************************************
    //
    // Required by lwIP library to support any host-related timer functions.
    //
    //*****************************************************************************
    void
    lwIPHostTimerHandler(void)
    {

    }

    //*****************************************************************************
    //
    // The interrupt handler for the SysTick interrupt.
    //
    //*****************************************************************************
    void
    SysTickIntHandler(void)
    {
    //
    // Call the lwIP timer handler.
    //
    lwIPTimer(SYSTICKMS);
    }

    //*****************************************************************************
    //
    // This example demonstrates the use of the Ethernet Controller.
    //
    //*****************************************************************************
    int main(void)
    {
    uint32_t IP_addr,subnet_addr,gateway_addr;
    char p[100];
    char b[100];
    char c[100];

    sprintf(p,"%d.%d.%d.%d\n",IP_AddrOct1,IP_ADDR_OCT2,IP_ADDR_OCT3,IP_ADDR_OCT4);
    sprintf(b,"%d.%d.%d.%d\n",SUBNET_OCT1,SUBNET_OCT2,SUBNET_OCT3,SUBNET_OCT4);
    sprintf(c,"%d.%d.%d.%d\n",GATEWAY_IP_OCT1,GATEWAY_IP_OCT2,GATEWAY_IP_OCT3,GATEWAY_IP_OCT4);

    IP_addr = inet_addr(p);
    subnet_addr = inet_addr(b);
    gateway_addr = inet_addr(c);
    lwIPInit(100,pucMACArray, IP_addr, subnet_addr, gateway_addr, IPADDR_USE_STATIC);
    udpDestIpAddr = (struct ip_addr *)malloc(sizeof(struct ip_addr));


    my_udp_init();

    }

    Any forum member who are able to help please do.


    Regards,
    Krishnan
  • Hello Amit Ashara,
    I am now able to build the code,some bugs are there,ok.Thnaking you for offering help.

    Regards,
    Krishnan
  • Krishnan G Nair said:

    #define IP_ADDR_OCT1 192
    #define IP_ADDR_OCT2 168
    #define IP_ADDR_OCT3 0
    #define IP_ADDR_OCT4 3

    #define SUBNET_OCT1 0
    #define SUBNET_OCT2 0
    #define SUBNET_OCT3 0
    #define SUBNET_OCT4 0

    #define GATEWAY_IP_OCT1 255
    #define GATEWAY_IP_OCT2 255
    #define GATEWAY_IP_OCT3 255
    #define GATEWAY_IP_OCT4 255

     Hi, network require understanding before try to setup a controller or personal or whichever thing you wish connect to internet or private network too.

     Gateway has to be ONE precise address (one IP) of device help transmit on internet or subnet different from the one you are.

     255.255.255.255 is called "broadcast address" and signify all IP numbers in the world!!! This CANNOT WORK!!!!

     Subnet mask 0.0.0.0 on the other way signify all bit are on this network, your network (192.168.x.y) is a class C network, is on subnet X and can have 254 hosts on it. 0 is the network and 255 is reserved too but can be used too in some cases.

     To have something working you need in first grasp network theory then have programming experience with client server too.