Skip to content

Conversation

@gogogoghost
Copy link

Describe the PR
When CFG_TUD_VENDOR_TX_BUFSIZE set to 0. User should write ZLP by themselves. But there is no way to write ZLP. This check point not supports ZLP. I think expose tu_edpt_stream_write_zlp_if_needed is a good way.

Additional context
If applicable, add any other context about the PR and/or screenshots here.

@gogogoghost
Copy link
Author

The users can write ZLP like this:

void tud_vendor_tx_cb(uint8_t itf, uint32_t sent_bytes) { 
    // other logic...
	if(sendFinished){
		tud_vendor_write_zlp_if_needed(sent_bytes);
	}
}

@HiFiPhile HiFiPhile requested a review from Copilot December 10, 2025 13:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// Write to TX FIFO. This can be buffered and not sent immediately unless buffered bytes >= USB endpoint size
uint32_t tud_vendor_n_write(uint8_t idx, const void *buffer, uint32_t bufsize);


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, could you remove extra spaces ?

@hathach
Copy link
Owner

hathach commented Dec 10, 2025

maybe we should update the write() to allow zlp instead, let me check that option first.

@gogogoghost
Copy link
Author

Remove this line should be OK?

TU_VERIFY(bufsize > 0);

Will this affect other logic?

I tried this method. It works fine.

void tud_vendor_tx_cb(uint8_t itf, uint32_t sent_bytes) { 
    // other logic...
	if(sendFinished){
        if(sent_bytes&&(sent_bytes%MAX_PACKET_SIZE)==0){
            tud_vendor_write(NULL,0);
        }
	}
}

@gogogoghost
Copy link
Author

Or we can only check buffer length when FIFO enabled.

@HiFiPhile
Copy link
Collaborator

Could you check https://github.com/hathach/tinyusb/tree/stream_write

@gogogoghost
Copy link
Author

Thank you! I will test it on my board on Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants