Hi Marti, ok, I will add another variable then. But there will never be a partial flush of the USB buffer, the interrupt is only generated after the ACK has been received from the host for the complete packet.

Regards, Manuel

On Jan 17, 2013, at 8:31 PM, Marti Bolivar <notifications@github.com> wrote:

> In wirish/usb_serial.cpp:
> 
> >          if (old_txed != txed) {
> >              start = millis();
> >          }
> >          old_txed = txed;
> >      }
> > +
> > +
> > +    if (sent == USB_CDCACM_TX_EPSIZE) {
> > +      while (usb_cdcacm_get_pending() != 0) {
> Yes, I set it to zero in vcomDataTxCb(), but its meaning is the number of unsent bytes waiting in the TX buffer. Empirically, it looks like after the TX callback, the host has actually pulled all of the bytes sitting in the TX buffer, so setting n_unsent_bytes to 0 is correct. But if you notice in that routine, there's a commented-out line that reads n_unsent_bytes = usb_get_ep_tx_count(USB_CDCACM_TX_ENDP); -- I had to comment it out because it didn't work, but I didn't understand why and didn't have time to investigate further.
> 
> I don't mean to change the name of n_unsent_bytes, I mean having a separate variable like "sending_packet".
> 
> —
> Reply to this email directly or view it on GitHub.
> 
>