Replies: 3 comments 6 replies
-
|
Ah, I think the answer may have been given in #584: If tud_msc_test_unit_ready_cb() calls tud_msc_set_sense(lun, SCSI_SENSE_NOT_READY, 0x3a, 0x00); whenever it's about to return false, that seems to tell the host that the LUN is actually gone. In Windows, this makes the mounted drive disappear until tud_msc_test_unit_ready_cb() returns true, at which point the mounted drive reappears. This is exactly the behavior I wanted. Interestingly, it appears and disappears without playing the USB-attach/detach sounds, because I guess the USB device is there the whole time, reporting the same number of LUNs all the time, but just declaring some of them ready and some of them not. I didn't realize that was a thing. So now I can have the LUN say "I'm outta here" and then "Hey I'm back!". I'm still curious if there's a way in TinyUSB for the USB device itself to say "I'm outta here" and then "Hey, I'm back!" |
Beta Was this translation helpful? Give feedback.
-
|
No, tinyUSB doesn't have a way to trigger a disconnect. |
Beta Was this translation helpful? Give feedback.
-
|
@tlokovic I am not entirely sure what you want to achieve. Can you confirm which of following cases :
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I think I understand how an msc storage device can react when the host tells it "you're ejected", but how can the device itself say it's going away?
In this example:
https://github.com/hathach/tinyusb/blob/master/examples/device/msc_dual_lun/src/msc_disk_dual.c
I see
// Invoked when received Test Unit Ready command.
// return true allowing host to read/write this LUN e.g SD card inserted
bool tud_msc_test_unit_ready_cb(uint8_t lun)
{
if ( lun == 1 && board_button_read() ) return false;
return true; // RAM disk is always ready
}
But triggering this doesn't actually seem to tell Windows that the device has ejected. It just makes reads fail while the button is pressed. What I'd like is for the device to disappear when I push the button and then reappear when I release the button.
Is there a way for me to initiate the removal and re-addition of msc storage devices?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions