This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/RM57L843: Sending whole structure via tcpip

Part Number: RM57L843

Tool/software: Code Composer Studio

Hi,

We have created a project in which we have to continuously receive measurement data into PC from controller(RM57L843).

I am using LwIP stack  to establish tcpip communication between PC and controller(RM57L843).

I want to send whole structure via tcp but when I pass structure to tcp_write() function it won't work, there are no bytes available in PC for receiving from board.

/* main.c */

struct myStruct
{
int a;
int b;
int c;
};

struct myStruct *testData;

void sendData()
{
testData->a = 50;
testData->b = 60;
testData->c = 70;

tcp_write(stPcb->pcb,(struct myStruct*)testData,sizeof(struct myStruct),TCP_WRITE_FLAG_COPY);

}

tcp_write() is working for string char buffer data but not working for structure data

Will anyone please help me in this?

Please tell me the way what changes to do in main.c file for sending whole structure?

Thanks 

Pratik

  • Where is the structure defined? You created a pointer to it, but never initialize the pointer.

    I have no idea where you are actually storing your data.

    To send the whole structure, you have to reference the area of memory it lives in, not the pointer:

    tcp_write(stPcb->pcb,(struct myStruct)*testData,sizeof(struct myStruct),TCP_WRITE_FLAG_COPY);

    But since you have not specified a memory location, this might not work anyway.

    The easiest way to fix it is to use:

    struct myStruct testData;