Author Topic: TCP simple example problems.  (Read 8637 times)

Offline phomann

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Homann Designs
TCP simple example problems.
« on: September 19, 2008, 06:07:10 AM »
Hi Mark,

I'm using the LM3S6965 EK board with the Code Sourcery compiler (Or will be) and am trying to get the example shown in;
http://www.utasker.com/forum/index.php?topic=25.msg73#msg73

I've copied the uTasker project to a new project called TestIP and added the code in the above message to the application.c file. When I compile it, I get the fowwowing errors;

Code: [Select]
1>Compiling...
1>application.c
1>c:\utaskerv1.3_beta-lm3s\applications\testip\application.c(584) : error C2232: '->tTCP_Header' : left operand has 'struct' type, use '.'
1>c:\utaskerv1.3_beta-lm3s\applications\testip\application.c(584) : warning C4047: 'function' : 'unsigned char *' differs in levels of indirection from 'int'
1>c:\utaskerv1.3_beta-lm3s\applications\testip\application.c(584) : warning C4024: 'fnSendTCP' : different types for formal and actual parameter 2
1>c:\utaskerv1.3_beta-lm3s\applications\testip\application.c(584) : error C2198: 'fnSendTCP' : too few arguments for call

The code as inserted into application.c is identical as far as I can tell. and shown below. I presume that I am doing something wrong;

Code: [Select]
#define TEST_BUFFER_LENGTH 300
typedef struct stTCP_MESSAGE
{
    TCP_HEADER     tTCP_Header;     // reserve header space
    unsigned char   ucTCP_Message[TEST_BUFFER_LENGTH];
} TCP_MESSAGE;


static unsigned short usTestPort = 9999;


static int fnTestListener(USOCKET Socket, unsigned char ucEvent, unsigned char *ucIp_Data, unsigned short usPortLen)
{
   TCP_MESSAGE test_message;

    switch (ucEvent) {
    case TCP_EVENT_CONREQ:                                             
    case TCP_EVENT_CONNECTED:
    case TCP_EVENT_CLOSE:
    case TCP_EVENT_ACK:
    case TCP_EVENT_ARP_RESOLUTION_FAILED:
    case TCP_EVENT_PARTIAL_ACK:
        break;
    case TCP_EVENT_REGENERATE:
    case TCP_EVENT_DATA:
        if ((ucEvent == TCP_EVENT_REGENERATE) || (!uMemcmp((CHAR*)ucIp_Data, "TEST" , 4)))
{
            uStrcpy((CHAR*)test_message.ucTCP_Message, "Hi!!");
            if (fnSendTCP(Socket, (unsigned char *)&test_message->tTCP_Header, 4, TCP_FLAG_PUSH) > 0)
{
                return APP_SENT_DATA;
            }
        }
        break;
    case TCP_EVENT_ABORT:
    case TCP_EVENT_CLOSED:
{
        fnTCP_Listen(Socket, usTestPort, 0);                    // go back to listening state on next port number
        break;
        }
    }
    return APP_ACCEPT;
}


Cheers,

Peter






Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: TCP simple example problems.
« Reply #1 on: September 19, 2008, 12:46:19 PM »
Hi Peter

This looks to be a difference in the way that you are declaring test_message. The example assumes that this is a pointer to the memory eg.:
static TCP_MESSAGE *test_message = 0;
test_message = (TCP_MESSAGE*)uMalloc(sizeof(TCP_MESSAGE));            // get space for Tx message buffer

whereas I think that you are declaring it as a struct (as mentioned in the first error message)

static TCP_MESSAGE test_message;

Of course it is also possible as a struct by using it appropriately. In fact your uStrcpy() is using it as a struct, therefore change test_message->tTCP_Header to test_message.tTCP_Header and it should also work.

Regards

Mark



Offline phomann

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Homann Designs
Re: TCP simple example problems.
« Reply #2 on: September 25, 2008, 03:21:44 AM »
Hi Mark,

Thanks for that. I was just trying to implement the example verbatim as in your example in
http://www.utasker.com/forum/index.php?topic=25.0

I'll let you know how I go.

Cheers,

Peter.