/* create new UDP PCB structure */
upcb_tftp_data = udp_new();
if (!upcb_tftp_data)
{
/* Error creating PCB. Out of Memory */
printf("Can not create pcb 1\r\n");
__LTDC_drv->LTDC_DispStringAt(12, 180,
LCD_COLOR_RED,
LCD_COLOR_WHITE,
&FontAscii8x16,
(const uint8_t *)"Can not create pcb 1");
return;
}
/* bind to port 0 to receive next available free port */
/* NOTE: This is how TFTP works. There is a UDP PCB for the standard port
* 69 which al transactions begin communication on, however, _all_ subsequent
* transactions for a given "stream" occur on another port */
err = udp_bind(upcb_tftp_data, IP_ADDR_ANY, 0);
if (err != ERR_OK)
{
/* Unable to bind to port */
printf("Can not create pcb 2\r\n");
__LTDC_drv->LTDC_DispStringAt(12, 200,
LCD_COLOR_RED,
LCD_COLOR_WHITE,
&FontAscii8x16,
(const uint8_t *)"Can not create pcb 2");
return;
}
op = IAP_tftp_decode_op(pkt_buf->payload);
if (op != TFTP_WRQ) // op 实际返回的值为 1,而这个 TFTP_WRQ 定义的为2 ,
{
/* remove PCB */