This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

TCPNET with RTX not working

hi
i am implementing tcpnet tcp/ip stack with rtx and i have read the keil instructions. but this code doesnt work and no tcp packet is sent to the pc. i am confused and dont know what to do to eliminate the fault.
here is my code

init task :

__task void tcp_init1 (void) { init (); init_TcpNet (); debug_frmwrk_init(); tcp_tick_tsk=os_tsk_create (tcp_tick, 3); tcp_main_tsk=os_tsk_create (tcp_main, 1); tcp_send_rec_tsk=os_tsk_create (tcp_send_rec,2); os_mut_init(mutex_TcpNet); /* Init done, terminate this task. */ os_tsk_delete_self ();
}
task 1 :

__task void tcp_tick (void) { os_itv_set (100); while (1) { os_itv_wait (); /* Timer tick every 100 ms */ timer_tick (); os_evt_set(0x0001, tcp_main_tsk); }
}
task 2 :

__task void tcp_main (void) { while (1) { os_mut_wait (mutex_TcpNet, 0xffff); os_evt_wait_and(0x0001, 0xFFFF); main_TcpNet (); os_mut_release (mutex_TcpNet); os_tsk_pass (); }
}
task 3 :

__task void tcp_send_rec (void){ uint8_t *sendbuf; U16 k; tcp_soc = tcp_get_socket (TCP_TYPE_CLIENT_SERVER | TCP_TYPE_KEEP_ALIVE, 0,30,tcp_callback); tcp_listen (tcp_soc, 1001); for(;;) { os_mut_wait (mutex_TcpNet, 0xffff); switch (tcp_get_state (tcp_soc)) { case TCP_STATE_FREE: case TCP_STATE_CLOSED; case TCP_STATE_LISTEN: tcp_connect (tcp_soc, Rem_IP, 1001, 0); break;

case TCP_STATE_CONNECT: if (tcp_check_send (tcp_soc) == __TRUE) { sendbuf = tcp_get_buf(10); //Fill buffer in here for(k=0;k<10;k++) sendbuf[k] = 0x41 + k%10; tcp_send (tcp_soc, sendbuf, 10); } break;

} os_mut_release (mutex_TcpNet); } }

  • Maybe the code would be clearer if you put it in a post so we could view it in a more traditional manner?

    Look at using the <pre> tag.

  • Just curious to ask: why do you want to implement your own TCP stack with RTX? MDK v5.x comes with Middleware Network Component, which has TCP/IP stack well implemented enough for most of applications. For MDK v4.x it has RL-TCPNet module as well.