Closed artofdestroy closed 3 years ago
Thanks, will correct soon..
try play:
int ERROR = 0; getsockopt (socket_fd, SOL_SOCKET, SO_ERROR, &ERROR, sizeof(ERROR)); to detect EWOULDBLOCK
got error when compile getsockopt
was not declared in this scope but use lwip_getsockopt
is ok.
Edit nbUDP::parsePacket()
to
int nbUDP::parsePacket()
{
int ERROR = 0;
socklen_t optlen = sizeof(ERROR);
if (rx_buffer)
return 0;
struct sockaddr_in si_other;
int slen = sizeof(si_other), len;
char *buf = new char[1460];
if (!buf)
return 0;
if ((len = lwip_recvfrom(udp_server, buf, 1460, MSG_DONTWAIT, (struct sockaddr *)&si_other, (socklen_t *)&slen)) == -1)
{
delete[] buf;
lwip_getsockopt (udp_server, SOL_SOCKET, SO_ERROR, &ERROR, &optlen);
if (ERROR == EWOULDBLOCK) // use lwip_getsockopt to detect instead of "errno" macro
{
return 0;
}
DEBUG_UDP("could not receive data: %d", errno);
return 0;
}
remote_ip = IPAddress(si_other.sin_addr.s_addr);
remote_port = ntohs(si_other.sin_port);
if (len > 0)
{
rx_buffer = new cbuf(len);
rx_buffer->write(buf, len);
}
delete[] buf;
return len;
}
confirmed can detect EWOULDBLOCK.
yep :) will correct soon
Hello
My application is using BC66 module to send UDP data and receive ack from sever, but when I use
nbUDP::parsePacket()
to check for an incoming packet, the module suddenly reset.After some printf debug, I suspect that program reset at line 194 in
nbUdp.cpp
when its try to callerrno
macro, so I end up comment that section fromto
and every thing work fine(till now). Am I do something wrong or not use
nbUDP
correct way.code
Board : Olimex-NB-IoT-DevKit with BC66NBR01A07 FW Platform version : 5dbec3f platformio.ini