After loading tray wait for unit to become ready or to report some clear error

This commit is contained in:
Thomas Schmitt 2007-03-15 19:50:57 +00:00
parent 413c3455b3
commit 6b825d7360
4 changed files with 44 additions and 3 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2007.03.15.194531"
#define Cdrskin_timestamP "2007.03.15.195005"

View File

@ -3,9 +3,11 @@
/* scsi block commands */
#include <string.h>
#include <unistd.h>
#include "transport.h"
#include "sbc.h"
#include "spc.h"
#include "options.h"
/* spc command set */
@ -23,6 +25,7 @@ void sbc_load(struct burn_drive *d)
c.dir = NO_TRANSFER;
c.page = NULL;
d->issue_command(d, &c);
spc_wait_unit_attention(d, 60);
}
void sbc_eject(struct burn_drive *d)

View File

@ -40,7 +40,7 @@ static unsigned char SPC_MODE_SELECT[] =
static unsigned char SPC_REQUEST_SENSE[] = { 0x03, 0, 0, 0, 18, 0 };
static unsigned char SPC_TEST_UNIT_READY[] = { 0x00, 0, 0, 0, 0, 0 };
int spc_test_unit_ready(struct burn_drive *d)
int spc_test_unit_ready_r(struct burn_drive *d, int *key, int *asc, int *ascq)
{
struct command c;
@ -50,11 +50,41 @@ int spc_test_unit_ready(struct burn_drive *d)
c.page = NULL;
c.dir = NO_TRANSFER;
d->issue_command(d, &c);
if (c.error)
if (c.error) {
*key= c.sense[2];
*asc= c.sense[12];
*ascq= c.sense[13];
return (c.sense[2] & 0xF) == 0;
}
return 1;
}
int spc_test_unit_ready(struct burn_drive *d)
{
int key,asc,ascq;
return spc_test_unit_ready_r(d, &key, &asc, &ascq);
}
/* ts A70315 */
/** Wait until the drive state becomes clear in or until max_usec elapsed */
int spc_wait_unit_attention(struct burn_drive *d, int max_sec)
{
int i, ret, key, asc, ascq;
for(i=0; i < max_sec; i++) {
ret = spc_test_unit_ready_r(d, &key, &asc, &ascq);
if(ret > 0 || key!=0x2 || asc!=0x4) /* ready or error */
break;
usleep(1000000);
}
if (i < max_sec)
return (ret > 0);
return 0;
}
void spc_request_sense(struct burn_drive *d, struct buffer *buf)
{
struct command c;

View File

@ -20,8 +20,16 @@ void spc_probe_write_modes(struct burn_drive *);
void spc_request_sense(struct burn_drive *d, struct buffer *buf);
int spc_block_type(enum burn_block_types b);
int spc_get_erase_progress(struct burn_drive *d);
/* ts A70315 : test_unit_ready with result parameters */
int spc_test_unit_ready_r(struct burn_drive *d, int *key, int *asc, int *ascq);
int spc_test_unit_ready(struct burn_drive *d);
/* ts A70315 */
/** Wait until the drive state becomes clear in or until max_sec elapsed */
int spc_wait_unit_attention(struct burn_drive *d, int max_sec);
/* ts A61021 : the spc specific part of sg.c:enumerate_common()
*/
int spc_setup_drive(struct burn_drive *d);