Go Down

Topic: Why would WiFiUDP::endPacket return error? (Read 113 times) previous topic - next topic

olegst90

Oct 12, 2018, 09:02 am Last Edit: Oct 12, 2018, 09:11 am by olegst90
Hi everybody!

I have a sketch which contains a function called from loop() that does the following:


Code: [Select]

    memset(&pkg, 0, sizeof(pkg));
    pkg.cmd = REQ_ID_STREAM_INFO;
    pkg.payload.stream_info.width = camera.width();
    pkg.payload.stream_info.height = camera.height();
    Udp.beginPacket(ctx->ip, ctx->port);
    Udp.write((uint8_t *)&pkg, sizeof(pkg));
    Udp.endPacket();
     
             
    // frame proper
    memset(&pkg, 0, sizeof(pkg));
    pkg.cmd = REQ_ID_STREAM_FRAME;
    pkg.payload.frame_size = camera.frameSize();
    Udp.beginPacket(ctx->ip, ctx->port);
    Udp.write((uint8_t *)&pkg, sizeof(pkg));
    Udp.write(camera.raw(), 30);//camera.frameSize());
    Udp.endPacket(); // OCCASIONAL FAILURE HERE


The last line occasionally fails.

I've noticed it doesn't fail when I reduce the number of bytes written to the second frame or when I introduce a delay between two packets.

Should it be like that or is it just a coincidence?

Can I check somehow that the packet has been sent and I can feed Udp more data? Should I do it?

I'm using WEMOS D1 Mini Lite based on ESP8285, WiFi client mode.


PaulS

Quote
The last line occasionally fails.
Your proof seems to be non-existent.

Quote
I've noticed it doesn't fail when I reduce the number of bytes written to the second frame
What do you mean by "second frame"? Reduce the number from what to what?

Quote
or when I introduce a delay between two packets.
What two packets? That code sends ONE packet.

Quote
Can I check somehow that the packet has been sent
The endPacket() method returns a value, so, yes, you can.

The art of getting good answers lies in asking good questions.

olegst90

Your proof seems to be non-existent.
What do you mean by "second frame"? Reduce the number from what to what?
What two packets? That code sends ONE packet.
The endPacket() method returns a value, so, yes, you can.


The proof seems to be true as when I reduce packet length to 30 bytes (you can see the commented-out fragment there) the number of packets dropped reduces.

How do you mean ONE packet? I call beginPacket/endPacket two times. Is it going to be one packet?

PaulS

Quote
I call beginPacket/endPacket two times.
I must have missed the scrollbars.

The art of getting good answers lies in asking good questions.

Go Up