Hello Here is my program
int main (void) { net_initialize(); socket = tcp_get_socket (TCP_TYPE_SERVER, 0, 20, tcp_callback); if (socket) { tcp_listen (socket, 4050); } if (tcp_check_send(socket) ){ sprintf(msg,"W%04d%04d%04d%04d%04d%04d%04d%04d%05dR\n",10,20,30,40,50,60,70,80,90); len=sizeof(msg); sendbuf = tcp_get_buf (len); memcpy (sendbuf, msg, len); tcp_send (socket, sendbuf,len); } osDelay (1000); } }
when I remove this par
if (tcp_check_send(socket) ){ sprintf(msg,"W%04d%04d%04d%04d%04d%04d%04d%04d%05dR\n",10,20,30,40,50,60,70,80,90); len=sizeof(msg); sendbuf = tcp_get_buf (len); memcpy (sendbuf, msg, len); tcp_send (socket, sendbuf,len); }
I can't connect to chip via TCP/IP protocol but it shows only
W0010002000300040005000600070008000090R
and the do nothing but connection is alive.and when I add
I can't open the port and I fail to connect to my chip.
what is my mistake?
No while(1)...?
Sorry I pasted badly
int main (void) { net_initialize(); socket = tcp_get_socket (TCP_TYPE_SERVER, 0, 20, tcp_callback); if (socket) { tcp_listen (socket, 4050); } while (1) { net_main(); if (tcp_check_send(socket) ){ sprintf(msg,"W%04d%04d%04d%04d%04d%04d%04d%04d%05dR\n",10,20,30,40,50,60,70,80,90); len=sizeof(msg); sendbuf = tcp_get_buf (len); memcpy (sendbuf, msg, len); tcp_send (socket, sendbuf,len); } osDelay (1000); } }
Try calling tcp_get_state() before tcp_check_send(). Maybe socket is in state TCP_STATE_LISTEN, instead of TCP_STATE_CONNECT(ed). This may also help you with the other issue posted: http://www.keil.com/forum/61112/
You are using network component v5/v6. Using the network's debug may help resolve issue: www.keil.com/.../network_create_app.html
In the newest version (v7), netTCP_Send returns netStatus, which is more informative than tcp_send's boolean.
Dear Zack Thank you for your explanation I change my network component to V7 beta but in this states with this new code and other settings(Such as SPI and IP) I can't ping device's IP
#include "cmsis_os.h" #include "rl_net.h" uint32_t sock; uint32_t Tcp_Stat(int32_t socket, netTCP_Event event, const NET_ADDR *addr, const uint8_t *buf, uint32_t len) ; ###########################################*/ int main (void) { netInitialize (); sock = netTCP_GetSocket (Tcp_Stat); netTCP_SetOption (sock, netTCP_OptionTOS, 30); if (sock >=0) { netTCP_Listen (sock, 2000); } while (1) { } } ###########################################*/ uint32_t Tcp_Stat(int32_t socket, netTCP_Event event, const NET_ADDR *addr, const uint8_t *buf, uint32_t len) { switch (event) { case netTCP_EventConnect:return (1); case netTCP_EventEstablished:break; case netTCP_EventClosed :break; case netTCP_EventAborted:break; case netTCP_EventACK :break; case netTCP_EventData:break; } return (0); }
What version of the Networking middleware are you using?
V7 beta
Please download the active version "Keil.MDK-Middleware.7.0.0.pack". The beta version is actually older (I know that it is listed above).
Dear Reinhard Keil Thank you now I'm downloading MDK V7. But I find my problem but it is too strange. when I use sprintf without any variables with any size of string it works fine.
sprintf(msg,"HHHHHHHHHHellllooooooooooooooooo");
but as I add a little size variable to this command it doesn't work properly and I lose my connectivity or even it doesn't bind any port to my IP.
sprintf(msg,"W%04dR",10);
sprintf(msg,"W%04dR",var);
what do you think about this problem?
Hello I download the MDK v7.0 but ping command (in my pc) can't detect my board IP.My all configs are the same as the old ones ( with MDK v6.5) but it doesn't do anything.
uint32_t Tcp_Stat(int32_t socket, netTCP_Event event, const NET_ADDR *addr, const uint8_t *buf, uint32_t len) ; int main (void) { netInitialize (); sock = netTCP_GetSocket (Tcp_Stat); netTCP_SetOption (sock,netTCP_OptionTimeout, 120); if (sock >=0) { netTCP_Listen (sock, 4050); } while(1){} } uint32_t Tcp_Stat(int32_t socket, netTCP_Event event, const NET_ADDR *addr, const uint8_t *buf, uint32_t len) { switch (event) { case netTCP_EventConnect:return (1); case netTCP_EventEstablished:break; case netTCP_EventClosed :break; case netTCP_EventAborted:break; case netTCP_EventACK :break; case netTCP_EventData:break; } return (0); }
should I do anything else?