Hello folks,
I have made a connection between a PC and the LPC2294 with the TCP/IP Port. I am able to send some data but if I want to receive something from the PC I get nothing.
The PC send me a string with only the number "1" in it. Then the PC encodes this number into bytes and sends it over and over again...about 100 times.
My problem now is, how can i receive this bytes from the PC. I catch this bytes and check if it is a "1".
Here is my code. The LED switch and client server example code. But only the parts which I have changed. Hope there is someone who can help me! :-)
/*--------------------------- Process received data ------------------------*/ void procrec (U8 *buf) { if (buf[0] == 1) { IOCLR0 = 0x00000100; /* Turn LED On (P0.8 = 0) */ } else { IOSET0 = 0x00000100; /* Turn LED Off (P0.8 = 1) */ } } /*--------------------------- TCP send --------------------------------------*/ void send_data (){ U8 *sendbuf; U8 p2; U32 max; int i; static char array2[26] = {"5566.77.555.4.1.23.43.90."}; /* TCP */ if (socket_tcp != 0) { /* Start Connection */ switch (tcp_get_state(socket_tcp)) { case TCP_STATE_FREE: case TCP_STATE_CLOSED: tcp_connect (socket_tcp, Rem_IP, PORT_NUM, 0); break; case TCP_STATE_CONNECT: if (tcp_check_send (socket_tcp) == __TRUE) { sendbuf = tcp_get_buf(SENDLEN); for (i = 0; i<max; i++) { sendbuf[i] = array2[i]; } tcp_send (socket_tcp, sendbuf, SENDLEN); } break; } } } int main (void) { /* Main Thread of the TcpNet */ U8 p2val, cnt, lshf; U8 protocol; init (); init_TcpNet (); protocol = PROTOCOL; switch (protocol) { case TCP: socket_tcp = tcp_get_socket (TCP_TYPE_CLIENT, 0, 5005, tcp_callback); break; } p2val = 1; cnt = 0; lshf = 1; /* left shift */ while (1) { timer_poll (); main_TcpNet (); if (tick == __TRUE) { if (++cnt == SPEED) { if (p2val & 1) { IOCLR0 = 0x00000100; } else { IOSET0 = 0x00000100; } send_data (); p2val = lshf ? (p2val << 1) : (p2val >> 1); if (p2val == 0x80) lshf = 0; if (p2val == 0x01) lshf = 1; cnt = 0; } tick = __FALSE; } if (socket_tcp != 0) { tcp_listen (socket_tcp, PORT_NUM); } } }
PS: Sorry about my bad english!