Hi ,
I am using TI-RTOS 2.14.10 and NDK 2.24.03.35 with CCS 6.1.1 and TM4C1294XL board.
I am having a problem while using the ethernet and the NDK stack.
What I want to do is launch a task and test (inside the task) if ethernet is having access to internet. According to this I want to do some action if the ethernet is online or not.
If I launch this task within the hook (netIPAddrHook) that triggers when the board gets an IP from DHCP, the HTTP functions (like the ones used in the HTTP get examples) works and do the job.
But when I create and launch the task from outside the hook (like in the main function, at the beginning of the program), the functions fail to connect (HTTPCli_connect) with error -101 and errno = 0 and other function like EMAC_IsLinkUp fail too.
I can't manage to find a way to create a task at the launch of the system, launch it and then do something like this inside :
if ethernet is online then
do http stuff (get, etc.)
else
do other stuff with uart
endif
My problem is that I want the network task to be launched even if the ethernet link is not online at the beginning of the system, because I want to be able to use it later.
What I understand is that a network task need to be the daughter of a netIpAddrHook function to be able to call network related functions.
Is there a way to do that ? All the post that I saw talk about launching network related task in the hook.
Thank you fr your help.
Regards,
Yannick
Please find attached simplified code that show what I want to do (Not working) and what is working but isn't best for me.
//WHAT I WANT TO DO int main(void) { InitStuff(); Task_Handle nettaskHandle; Task_Params nettaskParams; Error_Block neteb; //SPI Task Launching Task_Params_init(&nettaskParams); nettaskParams.stackSize = 2048; //define the stack size for the task nettaskParams.priority = 6; nettaskParams.instance->name = "Task_network_daemon"; Error_init(&neteb); nettaskHandle = Task_create((Task_FuncPtr)TASK_NETWORK_DAEMON, &nettaskParams, &neteb); if (nettaskHandle == NULL) { System_printf("Task_network_daemon() creation failed!\n"); BIOS_exit(0); } } // Hook called when ethernet link is on and have IP from dhcp server void netIPAddrHook(unsigned int IPAddr, unsigned int IfIdx, unsigned int fAdd) { // Create a Database task when the IP address is added if (fAdd) { System_printf("FIRST IP OK\n"); flagIPOK = true; } else { flagIPOK = false; } } void TASK_NETWORK_DAEMON() { if(EMAC_isLinkUp(0) && flagIPOK) { // Ethernet OK doHttpStuff(); // http get, etc -> HTTP FAIL HERE } else { // Access to internet via uart wifi module } }
// WHAT I HAVE AND IS WORKING
void netIPAddrHook(unsigned int IPAddr, unsigned int IfIdx, unsigned int fAdd)
{
static Task_Handle ethernetTaskHandle;
Task_Params ethernetTaskParams;
// Create a Database task when the IP address is added
if (fAdd && !ethernetTaskHandle)
{
System_printf("IP OK");
Error_Block ethernetTaskEb;
Error_init(ðernetTaskEb);
Task_Params_init(ðernetTaskParams);
ethernetTaskParams.instance->name = "ETH_Task";
// If there is errors, increase the size of the stack size
ethernetTaskParams.stackSize = HTTPTASKSTACKSIZE;
ethernetTaskParams.priority = 5;
ethernetTaskHandle = Task_create((Task_FuncPtr)TASK_NETWORK_DAEMON_ETH, ðernetTaskParams, ðernetTaskEb);
if (ethernetTaskHandle == NULL) {
System_printf("netIPAddrHook: Failed to create HTTP Task\n", -1);
// BIOS_exit(0);
}
}
}
void TASK_NETWORK_DAEMON_ETH()
{
if(EMAC_isLinkUp(0))
{
DoHttpStuff(); // htt get ,etc EVERYTHING IS OK HERE
}
}
Don't take in account the above code as running, it's just samples from my code to show my problem.