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.

[参考译文] TM4C1294NCPDT:重新连接 LAN 电缆时未建立 TCP 连接

Guru**** 2524550 points
Other Parts Discussed in Thread: TM4C1294NCPDT

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1052606/tm4c1294ncpdt-tcp-connection-not-established-when-lan-cable-reconnected

器件型号:TM4C1294NCPDT
Thread 中讨论的其他器件: SYSBIOS

您好!

我们使用的是 TM4C1294NCPDT TCP 使用 RTOS、请查找随附的源代码以供您参考。

连接 LAN 电缆后、系统将根据要求运行。

当 LAN 电缆 断开并重新连接时、系统在电源重新启动设备之前无法连接到服务器。

我们使用两个不同的任务来连接不同的端口(5000和5001)。

除此问题外、系统工作正常。

您能指导我们如何优先解决此问题。

Void tcpHandler(UArg arg0, UArg arg1)
{
    SOCKET lSocket;
    int    status;
    struct sockaddr_in sLocalAddr;
    int    clientfd;

    int temp,temp1;

    int txbytes;
    int txlen;
    int optval;
    int optlen = sizeof(optval);

    int reuse = 1;

    WD_Flag ^= true;

    fdOpenSession(TaskSelf());


    lSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

    if (lSocket < 0) {
        System_printf("tcpHandler: socket failed\n");
        Task_exit();
        return;
    }

    memset((char *)&sLocalAddr, 0, sizeof(sLocalAddr));
    sLocalAddr.sin_family = AF_INET;//
    sLocalAddr.sin_addr.s_addr = inet_addr(Server_IP_Address);//inet_addr("10.7.55.2");////inet_addr("192.168.0.125");//htonl(INADDR_ANY);
    sLocalAddr.sin_port = htons(arg0);

    sprintf (TCP_Send_Buffer, "%c", '$');
    sprintf (TCP_Send_Buffer+1, "%c", ',');
    usprintf(TCP_Send_Buffer+2, "%d.%d.%d.%d", Ip_Address_Static & 0xff, (Ip_Address_Static >> 8) & 0xff,
                (Ip_Address_Static >> 16) & 0xff, (Ip_Address_Static >> 24) & 0xff);

    sprintf (TCP_Send_Buffer+strlen(TCP_Send_Buffer), "%c", ',');

    temp = (char)(sLocalAddr.sin_port >> 8) & 0xff;
    temp1 = (char)(sLocalAddr.sin_port & 0xff);
    temp = (int)(temp1 << 8) | temp;
    usprintf(TCP_Send_Buffer+strlen(TCP_Send_Buffer), "%d",  temp);//,

    sprintf (TCP_Send_Buffer+strlen(TCP_Send_Buffer), "%c", ',');
    Frame_len = strlen(TCP_Send_Buffer);

    while(clientfd = (connect(lSocket, (struct sockaddr *)&sLocalAddr, sizeof(sLocalAddr)) < 0)){
        SysCtlDelay(g_ui32SysClock/100/3);
        System_printf("Connection failed.\n%d", errno);
    }

    System_flush();

    if (setsockopt(lSocket, SOL_SOCKET, SO_REUSEPORT, (const char*)&reuse, sizeof(reuse)) < 0)
        perror("setsockopt(SO_REUSEPORT) failed");


    status = bind(lSocket, (struct sockaddr *)&sLocalAddr, sizeof(sLocalAddr));
    if (status == -1) {
        System_printf("Error: bind failed.\n");
    }

    optval = 2;
    if (setsockopt(lSocket, SOL_SOCKET, SO_RCVTIMEO, &optval, optlen) < 0) {
        System_printf("Error: setsockopt failed\n");
    }

    while (true) {

      MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5,
                            (MAP_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_5) ^
                                            GPIO_PIN_5));
        if (Semaphore_getCount(semHandle) == 0) {
            System_printf("Sem blocked in TCP Sender \n");
        }
        Semaphore_pend(semHandle, BIOS_NO_WAIT);

        WD_Flag ^= true;

		if((recv_comp == 0)&&(send_rns_details == 0)&&(send_bss_details == 0)&&(send_rs_details == 0)&&
                (send_bs_details == 0)&&(send_fs_details == 0)&&(send_sp_details == 0)&&(send_config_details == 0)&&
                (send_device_ip == 0)&&(send_server_ip == 0)){
            if(Power_Reset == 0){
                memset(TCP_Config_transmit_buf,0x00,150);
                usprintf (TCP_Config_transmit_buf, "%c%c%s%c%s%c%c%c%c",
                         '$',',',Device_IP_Address, ',',"Connection_Check_with_Server",',','\r',',','\n');

                txbytes = send(lSocket, (char *)TCP_Config_transmit_buf,strlen(TCP_Config_transmit_buf),0);
                if(txbytes == strlen(TCP_Config_transmit_buf)){
                    send_server_ip = 0;
                }
                else;
                close(clientfd);
                Task_sleep(1000);
            }
            else;
        }

        resource = 0;
        Semaphore_post(semHandle);
        Task_sleep(1);
    }
}

Void tcpHandler2(UArg arg0, UArg arg1)
{
    SOCKET socketl;
    int status;
    struct sockaddr_in sLocalAddr;
    int clientfd;
    int nbytes;
    int optval;
    int optlen = sizeof(optval);
    char ip_len=0;
    char trecvbuffer[20];

    int c = 0;
    int c1 = 0;
    char B_Rate[10];
    char dlen,Receive_Fram_Len;
    char *eptr;
    uint32_t e2size,e2block,returnCode;

    int reuse = 1;

    int counter = 0;

    WD_Flag ^= true;

    fdOpenSession(TaskSelf());

    socketl = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

    if (socketl < 0) {
        System_printf("tcpHandler: socket failed\n");
        Task_exit();
        return;
    }


    memset((char *)&sLocalAddr, 0, sizeof(sLocalAddr));
    sLocalAddr.sin_family = AF_INET;
    sLocalAddr.sin_addr.s_addr = inet_addr(Server_IP_Address);//inet_addr("10.7.55.2");//inet_addr("10.7.55.85");////inet_addr("192.168.0.125");//inet_addr(Server_IP_Recv_Buf);////inet_addr("192.168.0.125");//htonl(INADDR_ANY);
    sLocalAddr.sin_port = htons(arg0);

    while(clientfd = (connect(socketl, (struct sockaddr *)&sLocalAddr, sizeof(sLocalAddr)) < 0)){
        SysCtlDelay(g_ui32SysClock/100/3);
    }

    System_flush();

    if (setsockopt(socketl, SOL_SOCKET, SO_REUSEPORT, (const char*)&reuse, sizeof(reuse)) < 0)
            perror("setsockopt(SO_REUSEPORT) failed");


    status = bind(socketl, (struct sockaddr *)&sLocalAddr, sizeof(sLocalAddr));
        if (status == -1) {
            System_printf("Error: bind failed.\n");
        }

    optval = 2;
    if (setsockopt(socketl, SOL_SOCKET, SO_RCVTIMEO, &optval, optlen) < 0) {
        System_printf("Error: setsockopt failed\n");
    }

    optval = 1;
    if (setsockopt(socketl, SOL_SOCKET, SO_SNDTIMEO, &optval, optlen) < 0) {
        System_printf("Error: setsockopt failed\n");
    }

    while (true) {

        MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5,
                            (MAP_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_5) ^
                                            GPIO_PIN_5));
        WD_Flag ^= true;

        send(socketl, (char *)"$OK",3,0);

        if (Semaphore_getCount(semHandle) == 0) {
            System_printf("Sem blocked in TCP Receiver \n");
        }
        Semaphore_pend(semHandle, BIOS_NO_WAIT);


            nbytes = recv(socketl, (char *)recvbuffer, TCPPACKETSIZE, 0);

            if(nbytes > 1){
                ip_len = strlen(Device_IP_Address);
			}
                
            if (connect(socketl, (struct sockaddr *)&sLocalAddr, sizeof(sLocalAddr)) < 0){
              System_printf("DID NOT CONNECT \n");
              System_printf("%d\n", fdError());
              System_printf("Connection failed.\n%d", errno);
            }
            else {
              System_printf("CONNECTED \n");

            }

        resource = 0;

        Semaphore_post(semHandle);

        Task_sleep(3);

    }
}


Void functionNetworkOpenHook(Void)
{
    char *HostName = "_csl_";

    CI_IPNET NA;

    CI_ROUTE RT;
    HANDLE hCfg;

    HANDLE hCfgIpAddr;

    /* Setup manual IP address */
    bzero(&NA, sizeof(NA));
    NA.IPAddr = Ip_Address_Static;//inet_addr("192.168.0.143");//
    strcpy(NA.Domain, "demo.net");
    NA.NetType = 0;

    Ip_Address = NA.IPAddr;

    /* get the current static IP entry */
    CfgGetEntry(0, CFGTAG_IPNET, 1, 1, &hCfgIpAddr);

    /* remove the current static IP entry */
    CfgRemoveEntry(0, hCfgIpAddr);

    /* add a new static IP entry */
    CfgAddEntry(0, CFGTAG_IPNET, 1, 0,
    sizeof(CI_IPNET), (UINT8 *)&NA, 0);


    bzero( &RT, sizeof(RT) );
    RT.IPDestAddr = 0;//Ip_Address_Static;
    RT.IPDestMask = subnetmaskaddress;
    RT.IPGateAddr = GateWayAddress;//inet_addr("10.7.55.254");

    hCfg = CfgNew();
    CfgAddEntry( hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,
    strlen(HostName), (UINT8 *)HostName, 0 );

    // Add the route
    CfgAddEntry( hCfg, CFGTAG_ROUTE, 0, 0, sizeof(CI_ROUTE), (UINT8 *)&RT, 0 );

    Error_Block eb;

    /* Make sure Error_Block is initialized */
    Error_init(&eb);


}

void main (void)
{
	bool bUpdate;

    uint32_t e2size,e2block,returnCode;

    Error_Block        eb;
    Task_Handle        taskHandle;
    Task_Params        taskParams;

    Watchdog_Params params;

    Semaphore_Params semParams;

    WD_Flag ^= true;
	
	Board_initGeneral();
    Board_initGPIO();
    Board_initEMAC();
    Board_initI2C();
    Board_initUART();

    Board_initWatchdog();


    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                            SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
                            SYSCTL_CFG_VCO_480), 120000000);

	
	Task_Params_init(&taskParams);
    Error_init(&eb);

    Semaphore_Params sem_params;
    Semaphore_Params_init(&sem_params);

    sem_params.mode = Semaphore_Mode_BINARY;

    Semaphore_Handle sem = Semaphore_create(0, &sem_params, &eb);

    if (sem == NULL) {
        System_printf("Semaphore_create() failed!");
    }
	
	
    taskParams.stackSize = 2048;
    taskParams.instance->name = "TCP";
    taskParams.priority = 3;
    taskParams.arg0 = TCPPORT;
    taskHandle = Task_create((Task_FuncPtr)tcpHandler, &taskParams, &eb);

    if (taskHandle == NULL) {
        System_printf("Error: Failed to create new TCP Task\n");
        System_flush();
    }
	
	taskParams.stackSize = 1536;
    taskParams.instance->name = "TCP";
    taskParams.priority = 1;
    taskParams.arg0 = TCPPORT1;
    taskHandle = Task_create((Task_FuncPtr)tcpHandler2, &taskParams, &eb);

    if (taskHandle == NULL) {
        System_printf("Error: Failed to create new TCP Task\n");
        System_flush();
    }
	
	/* Construct a Semaphore object to be use as a resource lock, inital count 1 */
	Semaphore_Params_init(&semParams);
	Semaphore_construct(&semStruct, 1, &semParams);

	/* Obtain instance handle */
	semHandle = Semaphore_handle(&semStruct);

	/* We want to sleep for 10000 microseconds */
	sleepTickCount = 10000 / Clock_tickPeriod;

	BIOS_start();

    return (0);
}

/*
 * Copyright (c) 2015-2016, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */



/* ================ Clock configuration ================ */
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var GIO = xdc.useModule('ti.sysbios.io.GIO');
/*
 * Default value is family dependent. For example, Linux systems often only
 * support a minimum period of 10000 us and multiples of 10000 us.
 * TI platforms have a default of 1000 us.
 */
Clock.tickPeriod = 1000;



/* ================ Defaults (module) configuration ================ */
var Defaults = xdc.useModule('xdc.runtime.Defaults');
/*
 * A flag to allow module names to be loaded on the target. Module name
 * strings are placed in the .const section for debugging purposes.
 *
 * Pick one:
 *  - true (default)
 *      Setting this parameter to true will include name strings in the .const
 *      section so that Errors and Asserts are easier to debug.
 *  - false
 *      Setting this parameter to false will reduce footprint in the .const
 *      section. As a result, Error and Assert messages will contain an
 *      "unknown module" prefix instead of the actual module name.
 */
Defaults.common$.namedModule = true;
//Defaults.common$.namedModule = false;



/* ================ Error configuration ================ */
var Error = xdc.useModule('xdc.runtime.Error');
/*
 * This function is called to handle all raised errors, but unlike
 * Error.raiseHook, this function is responsible for completely handling the
 * error with an appropriately initialized Error_Block.
 *
 * Pick one:
 *  - Error.policyDefault (default)
 *      Calls Error.raiseHook with an initialized Error_Block structure and logs
 *      the error using the module's logger.
 *  - Error.policySpin
 *      Simple alternative that traps on a while(1) loop for minimized target
 *      footprint.
 *      Using Error.policySpin, the Error.raiseHook will NOT called.
 */
Error.policyFxn = Error.policyDefault;
//Error.policyFxn = Error.policySpin;

/*
 * If Error.policyFxn is set to Error.policyDefault, this function is called
 * whenever an error is raised by the Error module.
 *
 * Pick one:
 *  - Error.print (default)
 *      Errors are formatted and output via System_printf() for easier
 *      debugging.
 *  - null
 *      Errors are not formatted or logged. This option reduces code footprint.
 *  - non-null function
 *      Errors invoke custom user function. See the Error module documentation
 *      for more details.
 */
Error.raiseHook = Error.print;
//Error.raiseHook = null;
//Error.raiseHook = "&myErrorFxn";

/*
 * If Error.policyFxn is set to Error.policyDefault, this option applies to the
 * maximum number of times the Error.raiseHook function can be recursively
 * invoked. This option limits the possibility of an infinite recursion that
 * could lead to a stack overflow.
 * The default value is 16.
 */
Error.maxDepth = 2;



/* ================ Hwi configuration ================ */
var halHwi = xdc.useModule('ti.sysbios.hal.Hwi');
var m3Hwi = xdc.useModule('ti.sysbios.family.arm.m3.Hwi');
/*
 * Checks for Hwi (system) stack overruns while in the Idle loop.
 *
 * Pick one:
 *  - true (default)
 *      Checks the top word for system stack overflows during the idle loop and
 *      raises an Error if one is detected.
 *  - false
 *      Disabling the runtime check improves runtime performance and yields a
 *      reduced flash footprint.
 */
halHwi.checkStackFlag = true;
//halHwi.checkStackFlag = false;

/*
 * The following options alter the system's behavior when a hardware exception
 * is detected.
 *
 * Pick one:
 *  - Hwi.enableException = true
 *      This option causes the default m3Hwi.excHandlerFunc function to fully
 *      decode an exception and dump the registers to the system console.
 *      This option raises errors in the Error module and displays the
 *      exception in ROV.
 *  - Hwi.enableException = false
 *      This option reduces code footprint by not decoding or printing the
 *      exception to the system console.
 *      It however still raises errors in the Error module and displays the
 *      exception in ROV.
 *  - Hwi.excHandlerFunc = null
 *      This is the most aggressive option for code footprint savings; but it
 *      can difficult to debug exceptions. It reduces flash footprint by
 *      plugging in a default while(1) trap when exception occur. This option
 *      does not raise an error with the Error module.
 */
m3Hwi.enableException = true;
//m3Hwi.enableException = false;
//m3Hwi.excHandlerFunc = null;

/*
 * Enable hardware exception generation when dividing by zero.
 *
 * Pick one:
 *  - 0 (default)
 *      Disables hardware exceptions when dividing by zero
 *  - 1
 *      Enables hardware exceptions when dividing by zero
 */
m3Hwi.nvicCCR.DIV_0_TRP = 0;
//m3Hwi.nvicCCR.DIV_0_TRP = 1;

/*
 * Enable hardware exception generation for invalid data alignment.
 *
 * Pick one:
 *  - 0 (default)
 *      Disables hardware exceptions for data alignment
 *  - 1
 *      Enables hardware exceptions for data alignment
 */
m3Hwi.nvicCCR.UNALIGN_TRP = 0;
//m3Hwi.nvicCCR.UNALIGN_TRP = 1;



/* ================ Idle configuration ================ */
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
/*
 * The Idle module is used to specify a list of functions to be called when no
 * other tasks are running in the system.
 *
 * Functions added here will be run continuously within the idle task.
 *
 * Function signature:
 *     Void func(Void);
 */
//Idle.addFunc("&myIdleFunc");



/* ================ Kernel (SYS/BIOS) configuration ================ */
var BIOS = xdc.useModule('ti.sysbios.BIOS');
/*
 * Enable asserts in the BIOS library.
 *
 * Pick one:
 *  - true (default)
 *      Enables asserts for debugging purposes.
 *  - false
 *      Disables asserts for a reduced code footprint and better performance.
 */
//BIOS.assertsEnabled = true;
BIOS.assertsEnabled = false;

/*
 * Specify default heap size for BIOS.
 */
BIOS.heapSize = 20480;

/*
 * A flag to determine if xdc.runtime sources are to be included in a custom
 * built BIOS library.
 *
 * Pick one:
 *  - false (default)
 *      The pre-built xdc.runtime library is provided by the respective target
 *      used to build the application.
 *  - true
 *      xdc.runtime library souces are to be included in the custom BIOS
 *      library. This option yields the most efficient library in both code
 *      footprint and runtime performance.
 */
BIOS.includeXdcRuntime = false;
//BIOS.includeXdcRuntime = true;

/*
 * The SYS/BIOS runtime is provided in the form of a library that is linked
 * with the application. Several forms of this library are provided with the
 * SYS/BIOS product.
 *
 * Pick one:
 *   - BIOS.LibType_Custom
 *      Custom built library that is highly optimized for code footprint and
 *      runtime performance.
 *   - BIOS.LibType_Debug
 *      Custom built library that is non-optimized that can be used to
 *      single-step through APIs with a debugger.
 *
 */
BIOS.libType = BIOS.LibType_Custom;
//BIOS.libType = BIOS.LibType_Debug;

/*
 * Runtime instance creation enable flag.
 *
 * Pick one:
 *   - true (default)
 *      Allows Mod_create() and Mod_delete() to be called at runtime which
 *      requires a default heap for dynamic memory allocation.
 *   - false
 *      Reduces code footprint by disallowing Mod_create() and Mod_delete() to
 *      be called at runtime. Object instances are constructed via
 *      Mod_construct() and destructed via Mod_destruct().
 */
BIOS.runtimeCreatesEnabled = true;
//BIOS.runtimeCreatesEnabled = false;

/*
 * Enable logs in the BIOS library.
 *
 * Pick one:
 *  - true (default)
 *      Enables logs for debugging purposes.
 *  - false
 *      Disables logging for reduced code footprint and improved runtime
 *      performance.
 */
//BIOS.logsEnabled = true;
BIOS.logsEnabled = false;



/* ================ Memory configuration ================ */
var Memory = xdc.useModule('xdc.runtime.Memory');
/*
 * The Memory module itself simply provides a common interface for any
 * variety of system and application specific memory management policies
 * implemented by the IHeap modules(Ex. HeapMem, HeapBuf).
 */



/* ================ Program configuration ================ */
/*
 *  Program.stack is ignored with IAR. Use the project options in
 *  IAR Embedded Workbench to alter the system stack size.
 */
if (!Program.build.target.$name.match(/iar/)) {
    /*
     *  Reducing the system stack size (used by ISRs and Swis) to reduce
     *  RAM usage.
     */
    Program.stack = 1024;
}



/*
 * Enable Semihosting for GNU targets to print to CCS console
 */
if (Program.build.target.$name.match(/gnu/)) {
    var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');
}
/* ================ Semaphore configuration ================ */
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
/*
 * Enables global support for Task priority pend queuing.
 *
 * Pick one:
 *  - true (default)
 *      This allows pending tasks to be serviced based on their task priority.
 *  - false
 *      Pending tasks are services based on first in, first out basis.
 *
 *  When using BIOS in ROM:
 *      This option must be set to false.
 */
//Semaphore.supportsPriority = true;
Semaphore.supportsPriority = false;

/*
 * Allows for the implicit posting of events through the semaphore,
 * disable for additional code saving.
 *
 * Pick one:
 *  - true
 *      This allows the Semaphore module to post semaphores and events
 *      simultaneously.
 *  - false (default)
 *      Events must be explicitly posted to unblock tasks.
 *
 */
//Semaphore.supportsEvents = true;
Semaphore.supportsEvents = false;



/* ================ Swi configuration ================ */
var Swi = xdc.useModule('ti.sysbios.knl.Swi');
/*
 * A software interrupt is an object that encapsulates a function to be
 * executed and a priority. Software interrupts are prioritized, preempt tasks
 * and are preempted by hardware interrupt service routines.
 *
 * This module is included to allow Swi's in a users' application.
 */



/* ================ System configuration ================ */
var System = xdc.useModule('xdc.runtime.System');
/*
 * The Abort handler is called when the system exits abnormally.
 *
 * Pick one:
 *  - System.abortStd (default)
 *      Call the ANSI C Standard 'abort()' to terminate the application.
 *  - System.abortSpin
 *      A lightweight abort function that loops indefinitely in a while(1) trap
 *      function.
 *  - A custom abort handler
 *      A user-defined function. See the System module documentation for
 *      details.
 */
System.abortFxn = System.abortStd;
//System.abortFxn = System.abortSpin;
//System.abortFxn = "&myAbortSystem";

/*
 * The Exit handler is called when the system exits normally.
 *
 * Pick one:
 *  - System.exitStd (default)
 *      Call the ANSI C Standard 'exit()' to terminate the application.
 *  - System.exitSpin
 *      A lightweight exit function that loops indefinitely in a while(1) trap
 *      function.
 *  - A custom exit function
 *      A user-defined function. See the System module documentation for
 *      details.
 */
System.exitFxn = System.exitStd;
//System.exitFxn = System.exitSpin;
//System.exitFxn = "&myExitSystem";

/*
 * Minimize exit handler array in the System module. The System module includes
 * an array of functions that are registered with System_atexit() which is
 * called by System_exit(). The default value is 8.
 */
System.maxAtexitHandlers = 2;

/*
 * The System.SupportProxy defines a low-level implementation of System
 * functions such as System_printf(), System_flush(), etc.
 *
 * Pick one pair:
 *  - SysMin
 *      This module maintains an internal configurable circular buffer that
 *      stores the output until System_flush() is called.
 *      The size of the circular buffer is set via SysMin.bufSize.
 *  - SysCallback
 *      SysCallback allows for user-defined implementations for System APIs.
 *      The SysCallback support proxy has a smaller code footprint and can be
 *      used to supply custom System_printf services.
 *      The default SysCallback functions point to stub functions. See the
 *      SysCallback module's documentation.
 */
var SysMin = xdc.useModule('xdc.runtime.SysMin');
SysMin.bufSize = 128;
System.SupportProxy = SysMin;



/* ================ Text configuration ================ */
var Text = xdc.useModule('xdc.runtime.Text');
/*
 * These strings are placed in the .const section. Setting this parameter to
 * false will save space in the .const section. Error, Assert and Log messages
 * will print raw ids and args instead of a formatted message.
 *
 * Pick one:
 *  - true (default)
 *      This option loads test string into the .const for easier debugging.
 *  - false
 *      This option reduces the .const footprint.
 */
Text.isLoaded = true;
//Text.isLoaded = false;



/* ================ Types configuration ================ */
var Types = xdc.useModule('xdc.runtime.Types');
/*
 * This module defines basic constants and types used throughout the
 * xdc.runtime package.
 */



/* ================ TI-RTOS middleware configuration ================ */
var mwConfig = xdc.useModule('ti.mw.Config');
/*
 * Include TI-RTOS middleware libraries
 */



/* ================ TI-RTOS drivers' configuration ================ */
var driversConfig = xdc.useModule('ti.drivers.Config');
/*
 * Include TI-RTOS drivers
 *
 * Pick one:
 *  - driversConfig.LibType_NonInstrumented (default)
 *      Use TI-RTOS drivers library optimized for footprint and performance
 *      without asserts or logs.
 *  - driversConfig.LibType_Instrumented
 *      Use TI-RTOS drivers library for debugging with asserts and logs enabled.
 */
driversConfig.libType = driversConfig.LibType_NonInstrumented;
//driversConfig.libType = driversConfig.LibType_Instrumented;



/* ================ Application Specific Instances ================ */
/* ================ NDK configuration ================ */
var Ndk       = xdc.loadPackage('ti.ndk.config');
var Global    = xdc.useModule('ti.ndk.config.Global');
var Ip        = xdc.useModule('ti.ndk.config.Ip');
var Udp       = xdc.useModule('ti.ndk.config.Udp');
var Tcp       = xdc.useModule('ti.ndk.config.Tcp');


Global.IPv6 = false;
Global.stackLibType = Global.MIN;
Global.networkOpenHook = "&functionNetworkOpenHook"//"&netOpenHook";

/* automatically call fdOpen/CloseSession for our sockets Task */
Global.autoOpenCloseFD = true;

Global.pktNumFrameBufs = 10;
Global.memRawPageCount = 6;
Global.ndkThreadStackSize = 1536;
Global.lowTaskStackSize = 1024;
Global.normTaskStackSize = 1024;
Global.highTaskStackSize = 1024;
Tcp.transmitBufSize = 1024;
Tcp.receiveBufSize = 1024;
Defaults.common$.diags_ENTRY = xdc.module("xdc.runtime.Diags").RUNTIME_ON;
Ip.ResolveIP = false;
Ip.dhcpClientMode = 1;
Ip.autoIp = false;
Ip.address = "10.7.55.86";
Ip.enableForwarding = false;
Defaults.common$.diags_ENTRY = xdc.module("xdc.runtime.Diags").RUNTIME_ON;

Ip.mask = "255.255.255.0";
Ip.socketIoTimeout = 1;
Ip.domainName = "dcu.net";
Ip.socketConnectTimeout = 5;
Defaults.common$.diags_EXIT = xdc.module("xdc.runtime.Diags").RUNTIME_OFF;
Defaults.common$.diags_STATUS = xdc.module("xdc.runtime.Diags").ALWAYS_OFF;
Ip.routeKeepAliveTime = 1200;
Ip.routeCloneTimeout = 5;
Global.ndkTickPeriod = 1;