Am 21.11.19 um 13:52 schrieb Brian:
On 11/21/19 7:12 AM, wkitt...@windstream.net wrote:
On 11/21/19 1:16 AM, Brian wrote:
My question: Is there a standard method for handling this situation,
i.e. making sure that a drive has not spun down, or is it just a case
of writing a wrapper round the write function and handling the 'No
such file' error with a wait and a retry?

why not just turn off or adjust your power management so that drive
doesn't spin down when it is connected? i do similar here but for my
monitors which sometimes don't want to wake back up after being put to
sleep...

Because on the *overwhelming* majority of occasions, I'm happy for the
drives to sleep if not being accessed. Most things that I do don't
need the USB drives. Bo's idea of a program which kept the drives spun
up had occurred to me if I couldn't find a setting somewhere, but I
was hoping for a solution which didn't require me to either disable
the drive's power management or do constant accesses.

Brian.


The old trick from DOS times with fileExists does not work anymore because the directory is cached.

What I do with "sleeping" USB disks is this:

{$I-}
repeat
application.processmessages;
assignFile(txt,'/mnt/test.txt');
rewrite (txt);
writeln (txt,'I''m so tired ...');
closeFile(txt);
io := ioResult;
// showMessage ('--> '+IntToStr(io));
until io=0;
{$I+}


If your disk is not corrupt or full then after this loop the drive is ready.

Tested with USB drives from Seagate and Toshiba.

This only tested with Linux!

Winni

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to