cancel
Showing results for 
Search instead for 
Did you mean: 

DAVE™

User21593
New Contributor
Hello,

I have implemented a TCP connection between a XMC4800 and a server. The XMC is my client. I can see in Wireshark, that the Controller receives packages because an Ack-Flag is sent afterwards to the server. Sending TCP Packages works fine, but I need to save the response from the server in a buffer, in order to work with the data.
Unfortunately, I co not want to unable the poll opportunity because in my further project, I need to work with an ethercat bus. Does anybody have an idea, why my code doesn't work?


void recv_data()
{
tcp_recv(pcb_recv, client_recv); //ocb_recv is an empty pcb
}

err_t client_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
tcp_recved(pcb_recv, p->tot_len);
memcpy(recv_buffer, p->payload, p->tot_len);
pbuf_free(p);;
return ERR_OK;
}

/* @brief main() */
int main(void)
{
DAVE_STATUS_t status;
uint32_t timer_systimer_lwip, timer_systimer_counter;
uint8_t counter_old=0;
int buff_length = strlen(recv_buffer);
bool send = false;

status = DAVE_Init(); /* Initialization of DAVE APPs */

if(status != DAVE_STATUS_SUCCESS)
{
/* Placeholder for error handler code.
* The while loop below can be replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");
while(1U)
{
}
}

/* Initialize and start lwip system timer */
timer_systimer_lwip = SYSTIMER_CreateTimer(100000,
SYSTIMER_MODE_PERIODIC ,
tim_sys_check_timeouts_wrap,0);
SYSTIMER_StartTimer(timer_systimer_lwip);

/* Initialize and start client state counter timer */
timer_systimer_counter = SYSTIMER_CreateTimer (5000000,
SYSTIMER_MODE_PERIODIC ,
tim_counter_increment,0);
SYSTIMER_StartTimer(timer_systimer_counter);

while(1)
{
/* Check if client state counter was incremented */
if (counter!=counter_old)
{
/* Connection already/still active? */
if ((connection_ready==0)&&(pcb_valid==0))
{
client_init();
}
else
{
if(send==false)
{
send_data(data1);
send = true;
}
else
{
recv_data();
send = false;
}
}

counter_old=counter;
}
}



Thanks for your help 🙂
Maxi
0 Likes
2 Replies
ncbs
Moderator
Moderator
Hi Maxi,

Could you share your project here so that we can analyze the project better?

Regards,
Nikhil
0 Likes
ncbs
Moderator
Moderator

Hi Maxi,

The thread was locked due to inactivity for a long time, you can continue the discussion on the topic by opening a new thread with reference to the locked one. The continuous discussion in an inactive thread may mostly be unattended by community users.

Thanks and Regards,
Nikhil

0 Likes
Top labels