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

problem with send_data () of TCPNet

I tried to convert the LEDClient example project to send data to my server. But the problem I have is that I can't send more than 4 bytes.

Here's my code

case TCP_STATE_CONNECT:
            if (tcp_check_send (socket_tcp) == __TRUE) { //normal
               //sendbuf = tcp_get_buf(SENDLEN);
               //sendbuf[0] = BLINKLED;
               //sendbuf[1] = p2;
               //tcp_send (socket_tcp, sendbuf, SENDLEN);
//changed code
                           sendbuf = tcp_get_buf(7);
                           sendbuf[0]=1;
                           sendbuf[1]=20;
                           sendbuf[2]=111;
                           sendbuf[3]=213;
                           sendbuf[4]=0;
                           sendbuf[5]=88;
                           sendbuf[6]=99;
                           tcp_send (socket_tcp, sendbuf, 7);

Don't know why it will not send more than 4 bytes. Anyone who does know???

If this works, then I can adopt this project to work with my RTX Kernel...

  • "it will not send more than 4 bytes"

    What do you mean by that?

    It sends only the 1st 4 bytes?

    It doesn't send anything if you attempt >4 bytes?

    Or what??

    Also, how do you know that it's not sending? MAybe the bug is in your receiver...?

  • The problem is that whatever I send, it will only send the first 4 bytes.

    The problem is not withh my receiver, this has been tested and works fine.

    Could it be that I don't have reserved enough resources for the ethernet module? If so, where can I change these?

  • "The problem is not withh my receiver, this has been tested and works fine."

    How did you test it?
    I don't know if it's likely, but it's possible that your test was flawed...

    It wouldn't be the first time that something has passed a flawed test, and then fails in "real life"...

    On the other hand, if the receiver really is fine, what diagnostics does it give you?

    Is it receiving a well-formed message containing only the 1st 4 bytes, or is it receiving a truncated message?

    That should st least give you a clue as to where to start looking...

  • Ok, this ploblem is solved. All my bytes are being seen (it was my receive program on pc who changed the data to a string, here something went wrong... but when we linked 2 pc's it worked)

    I still have the problem that I don't know what to do with the callback function and where to put my own code when I want to use TCPNet with RTX kernel. I started this thread here (with some sample code):

    http://www.keil.com/forum/docs/thread11111.asp

    can someone help me with this? i read the manual about 3 times, but couldn't find it.

    Thanks

  • "it was my receive program on pc..."

    How embarassing!
    Anyhow, do remember to update the tests for your receiver!

    "...changed the data to a string, here something went wrong..."

    Well, look at the data you were sending:

    sendbuf = tcp_get_buf(7);
    sendbuf[0]=1;
    sendbuf[1]=20;
    sendbuf[2]=111;
    sendbuf[3]=213;
    sendbuf[4]=0;     // <-- Look!!
    sendbuf[5]=88;
    sendbuf[6]=99;
    
    tcp_send (socket_tcp, sendbuf, 7);
    


    What does a character value of zero signify in a 'C' string...?

  • i know a '0' in a string means the end... But at first I didn't know that my receive program converted it to string, I got it from a collegue. And then I overlooked it...

    Would you perhaps know how to implement my callback function with rtx? Should this function be a process on it's own, or just a function. I tried both, buth didn't seem to work. It's never called. i know that my connection is being initiated, but it's never accepted because the callback function is never called.

    thanks

  • Hello,

    in case you wasn't able to get it running yet.

    Is the connecting working between PC and you embedded board?
    Check this with the ping command.

    Have you setup the tasks correctly, that are needed to run TCP stack with RTX Kernel?
    (see www.keil.com/.../rlarm_tn_using_withkernel.htm)

    Did you try the LED example? Is it working?

  • Hello,
    the connecting is ok. The LEDClient is working fine, when I change the remote IP adres for my board to the one of my pc. I can see everything coming in ok.

    The problem is that I don't know if my setup of processes is ok. I don't know if the callback function should be a process on it's own or not... Now my problem is that it is never being called. I even don't know if my socket is ok. I can work with my socket and try to make a connection trough it. Then the socket is in the TCP_STATE_SYN_SENT state. But the problem is that I can't see anything on my network coming from the IP address of my board when I snif it...

    How can this be?

    I use the Net_Config.c file from the LEDClient and the LPC2300_RTX.s startup file from the HTTP example. Also tried other startup files, but that didn't mather...

    Any ideas?

  • Hello,
    the connecting is ok. The LEDClient is working fine, when I change the remote IP adres for my board to the one of my pc. I can see everything coming in ok.

    The problem is that I don't know if my setup of processes is ok. I don't know if the callback function should be a process on it's own or not... Now my problem is that it is never being called. I even don't know if my socket is ok. I can work with my socket and try to make a connection trough it. Then the socket is in the TCP_STATE_SYN_SENT state. But the problem is that I can't see anything on my network coming from the IP address of my board when I snif it...

    How can this be?

    I use the Net_Config.c file from the LEDClient and the LPC2300_RTX.s startup file from the HTTP example. Also tried other startup files, but that didn't mather...

    Any ideas?

  • The callback function, you hand over with tcp_get_socket , is called by the tcp_poll task. If you want to handle the events in a different task you should hand it over in an appropriate way, e.g. mailbox.

    When the callback function isn't called, you have either a missconfigured stack or you didn't use it in the correct way.
    1. tcp_get_socket
    2. tcp_connect
    3. tcp_send
    Do you check the return codes of these functions?
    Maybe tcp_get_socket doesn't work due to a lag of available sockets?

    If the LED example is working, take this as a start and change it according your needs to learn how everything is working.

  • Ok, I'm a step closer now. I found out that with my own made program (which is composed out of LEDClient en HTTP RTX example) doesn't get connection with my network. My board is not recognised on the network, it gets no IP. When I load the LEDCLient and I search my network for PC's I can see my board with the IP address I gave it.

    But with my project this isn't the case. So I think something goes wrong with Init_TCPNet() or with Main_TcpNet(). Stack sizes and Net_config.c file is the same as the HTTP example.

    What can go wrong here? I'm just calling these functions as I should do, I think so?

  • It sounds like you want to assign a static IP address to your device. As far as I now, the HTTP example worked with enabled DHCP Client. Maybe that's the reason, you couldn't find it in the network.

    I think you should double check all the options in Net_config.c.

    Did you ever analysed the debug output from the debug version of RL Libary?

    Here the link to the manual: http://www.keil.com/support/man/docs/rlarm/rlarm_tn_debug.htm