Hello Felipe García
Thank you for the reply.
The problem is not changing the argument . In tcpecho_raw_send function I given my own data and it is working fine only when I call the function tcpecho_raw_send() in tcpecho_raw_recv().
I want to call tcpecho_raw_send() in main file , but I am not understanding how to pass a arguments.
My transmit function should not depend on the receive function , I want to call this when my serial data is arrive.
I have a problem with the parameters like struct tcp_pcb *tpcb
tcpecho_raw_send(struct tcp_pcb *tpcb, struct tcpecho_raw_state *es)
static void
tcpecho_raw_send(struct tcp_pcb *tpcb, struct tcpecho_raw_state *es)
{
struct pbuf *ptr;
err_t wr_err = ERR_OK;
char mydata[1024] = "Hello everyone\n";
// tcpecho_raw_init();
while ((wr_err == ERR_OK) &&
(es->p != NULL) &&
(es->p->len <= tcp_sndbuf(tpcb))) {
ptr = es->p;
wr_err = tcp_write(tpcb, "FRDM K64-F",10, 1); // This is working fine
if (wr_err == ERR_OK) {
u16_t plen;
plen = ptr->len;
/* continue with next pbuf in chain (if any) */
es->p = ptr->next;
if(es->p != NULL) {
/* new reference! */
pbuf_ref(es->p);
}
/* chop first pbuf from chain */
pbuf_free(ptr);
/* we can read more data now */
tcp_recved(tpcb, plen);
} else if(wr_err == ERR_MEM) {
/* we are low on memory, try later / harder, defer to poll */
es->p = ptr;
} else {
/* other problem ?? */
}
}
}
I tried above function like this but invalid pcb error is generated.
static void
tcpecho_raw_send()
{
struct tcp_pcb *new_tpcb;
struct pbuf *ptr;
err_t wr_err = ERR_OK;
char mydata[1024] = "Hello everyone\n";
// tcpecho_raw_init();
while ((wr_err == ERR_OK) &&
(es->p != NULL) &&
(es->p->len <= tcp_sndbuf(tpcb))) {
ptr = es->p;
wr_err = tcp_write(new_tpcb, "FRDM K64-F",10, 1); // This is working fine
if (wr_err == ERR_OK) {
u16_t plen;
plen = ptr->len;
/* continue with next pbuf in chain (if any) */
es->p = ptr->next;
if(es->p != NULL) {
/* new reference! */
pbuf_ref(es->p);
}
/* chop first pbuf from chain */
pbuf_free(ptr);
/* we can read more data now */
tcp_recved(tpcb, plen);
} else if(wr_err == ERR_MEM) {
/* we are low on memory, try later / harder, defer to poll */
es->p = ptr;
} else {
/* other problem ?? */
}
}
}
Thank you
Kapil Patil