USB PVND Check for ZLP while writing

Hello,

I'm hoping someone can help me with a use case regarding the r_usb_pvnd stack:

When sending a large amount of data (long transfer) from RA4 to PC over USB, we want to periodically check the other pipe for a ZLP, which indicates the PC client is no longer receiving and wants to end the transfer early.

I've tried periodically reading, waiting a bit for the callback, when nothing happens, stop the read by calling R_USB_PipeStop() and continue sending. But when I'm done sending, and go to read the next request from the PC, there are bytes missing from the beginning of that next read. The amount of bytes missing match the amount attempted to be read during the send. All this is in the same thread.

Any idea what would cause that? Is there any other way other than reading to see if there are any bytes waiting, specifically a ZLP?

Another related question:

What is the proper way to detect a ZLP sent from PC to RA4 using a pipe read? For example:

fsp_err_t err = R_USB_PipeRead ( g_basic0_ctrl, buffer,  64, usbReadPipe  );

Is there a usb_event_info_t status, event, and data_size combination that would indicate a ZLP in this case? Would it be USB_STATUS_WRITE_COMPLETE, FSP_SUCCESS, 0 ?

Thank you!!

Matt