2018-08-31 03:31 PM
Im trying to send udp packets back and forth using a Nucleo F429zi board. As I debug the program, I get 0 for all the other errors, but for udp_sendto() I get a -4. I found that this error code corresponds to ERR_RTE, operation in progress error, but I'm not sure what exactly that is or why it's happening. Below is the program I'm using to get familiar with these functions. Any suggestions? Thanks.
while (1)
{
printf("hello");
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_14);
HAL_Delay(100);
struct udp_pcb *upcb;
upcb = udp_new();
ip_addr_t recvIPaddress;
IP4_ADDR(&recvIPaddress, 192 , 168, 1, 128);
uint16_t recvPort = 4446;
err_t bindErr;
printf("bindErr: %u \n", bindErr);
bindErr = udp_bind(upcb, recvIPaddress, recvPort);
ip_addr_t sendIPaddress;
IP4_ADDR(&sendIPaddress, 192 , 168, 1, 255);
uint16_t sendPort = 4448;
err_t connectErr;
connectErr = udp_connect(upcb, sendIPaddress, sendPort);
uint8_t sbuffer[1000];
sbuffer[0] = "3";
struct pbuf *p;
p = pbuf_alloc(PBUF_TRANSPORT,strlen((char*)sbuffer), PBUF_POOL);
err_t takeErr;
takeErr = pbuf_take(p, (char)sbuffer, strlen((char)sbuffer));
err_t scount;
scount = udp_sendto(upcb, p, sendIPaddress, sendPort);
}