Description
Discussed in #2034
Originally posted by Jubatian April 19, 2023
Hi,
Would like to ask about the behaviour of tud_msc_read10_cb() in a scenario which seems to not work like I was expecting.
I have a relatively slow data source (an SPI Flash chip).
The existing architecture (with a different USB library I am migrating from), when a read request arrives from USB, calls a callback to notify the Data Source module that it needs to prepare "lba" sector.
The Data Source module later called from the main loop manages the read working through a state machine in a couple of main loop iterations until the data is ready. When so, it calls the USB library, which then begins sending the response.
Just to emphasize: There is no RTOS or interrupts in play, it is all sequential program flow.
Reading tud_msc_read10_cb(), it appeared like it should be easy, return 0 to it until the data is ready. However what I get is that seemingly it never returns! (The main loop freezes up for several seconds, with no return data observable by Wireshark).
Digging into TinyUSB's code I have a suspicion that it might not work the way I anticipated here (tud_task() doesn't return until tud_msc_read10_cb() is served a nonzero return, so there is no chance for other things called from the main loop to do their jobs, including preparing the data to be sent back).
Mainly would like to ask, whether I see this right? (To avoid spending more time on finding out why it doesn't work if this is it)
If it indeed works this way, any possible suggestions would be nice of course (maybe a way to tell data not yet ready to the host with an SCSI sense code? Not sure).
Metadata
Metadata
Assignees
Projects
Status