Hello,
Having trouble getting this code snippet to work. I keep getting a "Cortex_M3_0: Can't Run Target CPU: (Error -1268 @ 0x90001) Device is locked up in Hard Fault or in NMI". I correctly get the DHCP address but when I execute the DNSGetHostbyName the program blows up. I am running TI-RTOS 1_21_00_09 along with NDK_2_23_01. Here is the code,
/*
* ======== tcpEcho.c ========
*/
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/Memory.h>
#include <xdc/runtime/System.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Task.h>
/* NDK Header files */
#include <ti/ndk/inc/netmain.h>
#include <ti/ndk/inc/_stack.h>
/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
/* Example/Board Header files */
#include "Board.h"
#define TCPPACKETSIZE 1024
#define TCPPORT 1000
#define NUMTCPWORKERS 3
/*
* ======== tcpHandler ========
* Creates new Task to handle new TCP connections.
*/
Void tcpHandler(UArg arg0, UArg arg1)
{
// Setup TCP/IP file structure
fdOpenSession(TaskSelf());
// Wait a little bit for DHCP to get an address
int i;
int j;
int k = 0;
for (i = 0; i < 3000; ++i)
{
for (j = 0; j < 1000; ++j)
{
++k;
}
k = 0;
}
// Ok, get ip address
System_printf("Requesting DNS to get IP Address\n");
System_flush();
// Set up DNS Scrap Buffer
char myDNSbuffer[512];
HOSTENT *DNSdata;
int result;
// Set up heap structure
DNSdata = (HOSTENT *)&myDNSbuffer[0];
// Go get powercloud ip address
result = DNSGetHostByName("www.google.com", myDNSbuffer, sizeof(myDNSbuffer));
// Check to see if result was ok
if (result == 0)
{
System_printf("Good DNS Capture\n");
System_printf("Hostname = %s\n", DNSdata->h_name);
}
else
{
System_printf("Bad DNS Capture\n");
}
System_flush();
// Loop forever
while (TRUE) {
}
}
/*
* ======== main ========
*/
Int main(Void)
{
Task_Handle taskHandle;
Task_Params taskParams;
Error_Block eb;
/* Call board init functions */
Board_initGeneral();
Board_initGPIO();
Board_initEMAC();
System_printf("Starting the TCP Echo example\nSystem provider is set to "
"SysMin. Halt the target and use ROV to view output.\n");
/* SysMin will only print to the console when you call flush or exit */
System_flush();
/*
* Create the Task that farms out incoming TCP connections.
* arg0 will be the port that this task listens to.
*/
Task_Params_init(&taskParams);
Error_init(&eb);
taskParams.stackSize = 1024;
taskParams.priority = 1;
taskParams.arg0 = TCPPORT;
taskHandle = Task_create((Task_FuncPtr)tcpHandler, &taskParams, &eb);
if (taskHandle == NULL) {
System_printf("main: Failed to create tcpWait Task\n");
}
/* Start BIOS */
BIOS_start();
return (0);
}