void out_char (CHAR ch) { UCHAR c = (UCHAR)ch; //block process!! if (c == '\n') xUARTPutChar(printf_handle, '\r', portMAX_DELAY) ; xUARTPutChar(printf_handle, ch, portMAX_DELAY) ; }
/** * Callback function called from lwIP when data is received from Ethernet * * @param bridge actual information * @param tcp connection descriptor * @param received network buffer * @param reception error flag * @return error type on callback to be processed by lwIP */ static err_t BRIDGE_UART_ETH_RX(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) { struct bridge_state *hs; CHAR *rq; uint16 length; struct pbuf *q; hs = arg; /* If we got a NULL pbuf in p, the remote end has closed the connection. */ if(p != NULL) { /*FSL:send as many pbuf availables*/ for(q = p; q != NULL; q = q->next) { /*payload pointer in the pbuf contains the data in the TCP segment*/ rq = q->payload; length = q->len; /*send to UART*/ while(length--) { /*FSL: blocking push to uart buffer*/ xUARTPutChar(UARThandle, *(rq++), portMAX_DELAY); } } /* Inform TCP that we have taken the data. */ tcp_recved(pcb, p->tot_len); /* Free the pbuf */ pbuf_free(p); } else { /*close session if CLIENT did it first*/ BRIDGE_UART_ETH_CLOSE(pcb, hs); } return ERR_OK; }