2
$Id: scsi-mmc1.c,v 1.2 2004/11/13 20:38:41 rocky Exp $
4
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
/* Simple program to show use of SCSI MMC interface. Is basically the
22
the libdio scsi_mmc_get_hwinfo() routine.
28
#include <sys/types.h>
29
#include <cdio/cdio.h>
30
#include <cdio/scsi_mmc.h>
33
/* Set how long do wto wait for SCSI-MMC commands to complete */
34
#define DEFAULT_TIMEOUT_MS 10000
37
main(int argc, const char *argv[])
41
p_cdio = cdio_open (NULL, DRIVER_UNKNOWN);
44
printf("Couldn't find CD\n");
47
int i_status; /* Result of SCSI MMC command */
48
char buf[36] = { 0, }; /* Place to hold returned data */
49
scsi_mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Block */
51
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_INQUIRY);
52
cdb.field[4] = sizeof(buf);
54
i_status = scsi_mmc_run_cmd(p_cdio, DEFAULT_TIMEOUT_MS,
55
&cdb, SCSI_MMC_DATA_READ,
58
char psz_vendor[CDIO_MMC_HW_VENDOR_LEN+1];
59
char psz_model[CDIO_MMC_HW_MODEL_LEN+1];
60
char psz_rev[CDIO_MMC_HW_REVISION_LEN+1];
62
memcpy(psz_vendor, buf + 8, sizeof(psz_vendor)-1);
63
psz_vendor[sizeof(psz_vendor)-1] = '\0';
65
buf + 8 + CDIO_MMC_HW_VENDOR_LEN,
67
psz_model[sizeof(psz_model)-1] = '\0';
69
buf + 8 + CDIO_MMC_HW_VENDOR_LEN +CDIO_MMC_HW_MODEL_LEN,
71
psz_rev[sizeof(psz_rev)-1] = '\0';
73
printf("Vendor: %s\nModel: %s\nRevision: %s\n",
74
psz_vendor, psz_model, psz_rev);
76
printf("Couldn't get INQUIRY data (vendor, model, and revision).\n");